From 877e88fcd079b0feb4e018709dfffb3abae06d86 Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Fri, 15 May 2026 22:23:00 +0000 Subject: [PATCH] Use ATOMIC_BLOCK instead of manual cli/sei --- src/avclandrv.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/avclandrv.c b/src/avclandrv.c index a0a6137..636cc1b 100644 --- a/src/avclandrv.c +++ b/src/avclandrv.c @@ -92,6 +92,7 @@ #include #include #include +#include #include #include #include @@ -233,11 +234,11 @@ void AVCLAN_muteDevice(uint8_t mute) { // 1 sec) void AVCLAN_startPlaying() { CD_Mode = stPlay; - cli(); - loop_until_bit_is_clear(RTC_PITSTATUS, RTC_CNTBUSY_bp); - RTC.CNT = 0; - sbi(RTC.PITINTCTRL, RTC_PI_bp); - sei(); + ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { + loop_until_bit_is_clear(RTC_PITSTATUS, RTC_CNTBUSY_bp); + RTC.CNT = 0; + sbi(RTC.PITINTCTRL, RTC_PI_bp); + } } // Sets CD_mode to play and resets timer count (so that the next interrupt is in