Use ATOMIC_BLOCK instead of manual cli/sei

This commit is contained in:
Allen Hill
2026-05-15 22:23:00 +00:00
parent 194c3928f9
commit 877e88fcd0
+3 -2
View File
@@ -92,6 +92,7 @@
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <avr/io.h> #include <avr/io.h>
#include <avr/sfr_defs.h> #include <avr/sfr_defs.h>
#include <util/atomic.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@@ -233,11 +234,11 @@ void AVCLAN_muteDevice(uint8_t mute) {
// 1 sec) // 1 sec)
void AVCLAN_startPlaying() { void AVCLAN_startPlaying() {
CD_Mode = stPlay; CD_Mode = stPlay;
cli(); ATOMIC_BLOCK(ATOMIC_RESTORESTATE) {
loop_until_bit_is_clear(RTC_PITSTATUS, RTC_CNTBUSY_bp); loop_until_bit_is_clear(RTC_PITSTATUS, RTC_CNTBUSY_bp);
RTC.CNT = 0; RTC.CNT = 0;
sbi(RTC.PITINTCTRL, RTC_PI_bp); sbi(RTC.PITINTCTRL, RTC_PI_bp);
sei(); }
} }
// Sets CD_mode to play and resets timer count (so that the next interrupt is in // Sets CD_mode to play and resets timer count (so that the next interrupt is in