You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
607 B
18 lines
607 B
2 months ago
|
#pragma once
|
||
|
|
||
|
// ********************* Critical section helpers *********************
|
||
|
void enable_interrupts(void);
|
||
|
void disable_interrupts(void);
|
||
|
|
||
|
extern uint8_t global_critical_depth;
|
||
|
|
||
|
#define ENTER_CRITICAL() \
|
||
|
__disable_irq(); \
|
||
|
global_critical_depth += 1U;
|
||
|
|
||
|
#define EXIT_CRITICAL() \
|
||
|
global_critical_depth -= 1U; \
|
||
|
if ((global_critical_depth == 0U) && interrupts_enabled) { \
|
||
|
__enable_irq(); \
|
||
|
}
|