-
Notifications
You must be signed in to change notification settings - Fork 0
/
mbed_isr.cpp
44 lines (31 loc) · 1009 Bytes
/
mbed_isr.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
* mbed_isr.cpp
*
* Created on: Dic 2017
* Author: raulMrello
*
* Implementa un sencillo control de ISR nesting
*
*/
#include "mbed_api.h"
#include "Callback.h"
//------------------------------------------------------------------------------------
//--- PRIVATE TYPES ------------------------------------------------------------------
//------------------------------------------------------------------------------------
static volatile int isr_nesting = 0; /// Variable global de control del isr nesting
//------------------------------------------------------------------------------------
//-- PUBLIC METHODS IMPLEMENTATION ---------------------------------------------------
//------------------------------------------------------------------------------------
bool IS_ISR(){
return ((isr_nesting > 0)? true : false);
}
int GET_ISR_NESTING(){
return (isr_nesting);
}
void ENTER_ISR(){
++isr_nesting;
}
void EXIT_ISR(){
--isr_nesting;
MBED_ASSERT(isr_nesting >= 0);
}