31static volatile bool wasGlobalInterruptsEnabled =
false;
32static volatile bool isAtomicSectionOngoing =
false;
37 if (isAtomicSectionOngoing)
43 const uint8_t gieMask = (uint8_t)CPU_I_bm;
45 wasGlobalInterruptsEnabled = ((cpuStatusRegVal & gieMask) == gieMask);
49 isAtomicSectionOngoing =
true;
55 if (!isAtomicSectionOngoing)
61 isAtomicSectionOngoing =
false;
63 if (wasGlobalInterruptsEnabled)
72 const uint8_t stateMask = (uint8_t)ERRCTRL_STATE_gm;
73 const uint8_t normalStateConfig = (uint8_t)ERRCTRL_STATE_NORMAL_gc;
75 const bool isStateNormal = ((regVal & stateMask) == normalStateConfig);
79 const bool isErrorChSet = ((chStatus & channelMask) != 0UL);
81 return (!isErrorChSet && isStateNormal);
uint8_t CPUCTRL_ReadStatusRegister(void)
Reads the SREG register value.
void CPUCTRL_ClearStatusRegister(uint8_t bitmask)
Clears specific bits in the SREG register.
void CPUCTRL_SetStatusRegister(uint8_t bitmask)
Sets specific bits in the SREG register.
uint8_t ERRCTRL_ReadControlA(void)
Reads the CTRLA register value.
uint32_t ERRCTRL_ReadChannelStatus(void)
Reads the ESF register value.
void AtomicSectionStart(void)
Backup and disable global interrupts.
void AtomicSectionEnd(void)
Restore global interrupts if previously enabled.
bool IsErrChConfigurable(uint32_t channelMask)
Check Error Controller state and error channels indicated by the channel mask input.