diff --git a/Marlin/src/HAL/HC32/HAL.h b/Marlin/src/HAL/HC32/HAL.h index 4f5659355954..8111e1b57ee6 100644 --- a/Marlin/src/HAL/HC32/HAL.h +++ b/Marlin/src/HAL/HC32/HAL.h @@ -114,22 +114,19 @@ // Misc. Functions // #ifndef analogInputToDigitalPin -#define analogInputToDigitalPin(p) pin_t(p) + #define analogInputToDigitalPin(p) pin_t(p) #endif -#define CRITICAL_SECTION_START \ - uint32_t primask = __get_PRIMASK(); \ - (void)__iCliRetVal() +#define CRITICAL_SECTION_START() \ + const bool irqon = !__get_PRIMASK(); \ + __disable_irq(); \ + __DSB(); +#define CRITICAL_SECTION_END() \ + __DSB(); \ + if (irqon) __enable_irq(); -#define CRITICAL_SECTION_END \ - if (!primask) \ - (void)__iSeiRetVal() - -// Disable interrupts -#define cli() noInterrupts() - -// Enable interrupts -#define sei() interrupts() +#define cli() __disable_irq() +#define sei() __enable_irq() // bss_end alias #define __bss_end __bss_end__