Annex Critical Section Macros¶
The user needs to create macros that enable the same behavior in the BSP interface lib module.
CRITICAL_SECTION_ENTER¶
This function is used to disable all interrupts. It is required to either protect resources from concurrent access or guarantee execution timings.
In the SDK, this is implemented by this interface lib specifically written for the STM32G4 MCU:
/** @brief Macro for entering a critical region.
*
* @note This needs to handle nested interrupts.
*/
#define CRITICAL_SECTION_ENTER() { \
__disable_irq(); \
++m_in_critical_region; \
}
sdk_spark_vx.y.z/bsp/interface/lib/queue/evk/circular_queue_critical_section.h
CRITICAL_SECTION_EXIT¶
This function is used to enable all interrupts.
In the SDK, this is implemented by this interface lib specifically written for the STM32G4 MCU:
/** @brief Macro for leaving a critical region.
*
* @note This needs to handle nested interrupts.
*/
#define CRITICAL_SECTION_EXIT() { \
if (--m_in_critical_region == 0) { \
__enable_irq();\
} \
}
sdk_spark_vx.y.z/bsp/interface/lib/queue/evk/circular_queue_critical_section.h