Firmware SDK
twr_irq.c
1 #include <twr_irq.h>
2 #include <stm32l0xx.h>
3 
4 static volatile uint32_t _twr_irq_primask = 0;
5 static volatile uint32_t _twr_irq_disable = 0;
6 
7 void twr_irq_disable(void)
8 {
9  uint32_t primask = __get_PRIMASK();
10 
11  __disable_irq();
12 
13  if (_twr_irq_disable == 0)
14  {
15  _twr_irq_primask = primask & 1;
16  }
17 
18  _twr_irq_disable++;
19 }
20 
21 void twr_irq_enable(void)
22 {
23  if (_twr_irq_disable != 0)
24  {
25  _twr_irq_disable--;
26 
27  if (_twr_irq_disable == 0 && _twr_irq_primask == 0)
28  {
29  __enable_irq();
30  }
31  }
32 }
void twr_irq_disable(void)
Disable interrupt requests globally (call can be nested)
Definition: twr_irq.c:7
void twr_irq_enable(void)
Enable interrupt requests globally (call can be nested)
Definition: twr_irq.c:21