]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/SilLabs_Code/emlib/inc/em_int.h
Add Pearl Gecko demo.
[freertos] / FreeRTOS / Demo / CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio / Source / SilLabs_Code / emlib / inc / em_int.h
1 /***************************************************************************//**\r
2  * @file em_int.h\r
3  * @brief Interrupt enable/disable unit API\r
4  * @version 4.2.1\r
5  *******************************************************************************\r
6  * @section License\r
7  * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>\r
8  *******************************************************************************\r
9  *\r
10  * Permission is granted to anyone to use this software for any purpose,\r
11  * including commercial applications, and to alter it and redistribute it\r
12  * freely, subject to the following restrictions:\r
13  *\r
14  * 1. The origin of this software must not be misrepresented; you must not\r
15  *    claim that you wrote the original software.\r
16  * 2. Altered source versions must be plainly marked as such, and must not be\r
17  *    misrepresented as being the original software.\r
18  * 3. This notice may not be removed or altered from any source distribution.\r
19  *\r
20  * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no\r
21  * obligation to support this Software. Silicon Labs is providing the\r
22  * Software "AS IS", with no express or implied warranties of any kind,\r
23  * including, but not limited to, any implied warranties of merchantability\r
24  * or fitness for any particular purpose or warranties against infringement\r
25  * of any proprietary rights of a third party.\r
26  *\r
27  * Silicon Labs will not be liable for any consequential, incidental, or\r
28  * special damages, or any other relief, or for any claim by any third party,\r
29  * arising from your use of this Software.\r
30  *\r
31  ******************************************************************************/\r
32 \r
33 #ifndef __SILICON_LABS_EM_INT_H__\r
34 #define __SILICON_LABS_EM_INT_H__\r
35 \r
36 #include "em_device.h"\r
37 \r
38 extern uint32_t INT_LockCnt;\r
39 \r
40 #ifdef __cplusplus\r
41 extern "C" {\r
42 #endif\r
43 \r
44 /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */\r
45 #ifndef UINT32_MAX\r
46 #define UINT32_MAX ((uint32_t)(0xFFFFFFFF))\r
47 #endif\r
48 /** @endcond */\r
49 \r
50 /***************************************************************************//**\r
51  * @addtogroup EM_Library\r
52  * @{\r
53  ******************************************************************************/\r
54 \r
55 /***************************************************************************//**\r
56  * @addtogroup INT\r
57  * @{\r
58  ******************************************************************************/\r
59 \r
60 /***************************************************************************//**\r
61  * @brief\r
62  *   Disable interrupts.\r
63  *\r
64  * @details\r
65  *   Disable interrupts and increment lock level counter.\r
66  *\r
67  * @return\r
68  *   The resulting interrupt disable nesting level.\r
69  *\r
70  ******************************************************************************/\r
71 __STATIC_INLINE uint32_t INT_Disable(void)\r
72 {\r
73   __disable_irq();\r
74   if (INT_LockCnt < UINT32_MAX)\r
75   {\r
76     INT_LockCnt++;\r
77   }\r
78 \r
79   return INT_LockCnt;\r
80 }\r
81 \r
82 /***************************************************************************//**\r
83  * @brief\r
84  *   Enable interrupts.\r
85  *\r
86  * @return\r
87  *   The resulting interrupt disable nesting level.\r
88  *\r
89  * @details\r
90  *   Decrement interrupt lock level counter and enable interrupts if counter\r
91  *   reached zero.\r
92  *\r
93  ******************************************************************************/\r
94 __STATIC_INLINE uint32_t INT_Enable(void)\r
95 {\r
96   uint32_t retVal;\r
97 \r
98   if (INT_LockCnt > 0)\r
99   {\r
100     INT_LockCnt--;\r
101     retVal = INT_LockCnt;\r
102     if (retVal == 0)\r
103     {\r
104       __enable_irq();\r
105     }\r
106     return retVal;\r
107   }\r
108   else\r
109   {\r
110     return 0;\r
111   }\r
112 }\r
113 \r
114 /** @} (end addtogroup INT) */\r
115 /** @} (end addtogroup EM_Library) */\r
116 \r
117 #ifdef __cplusplus\r
118 }\r
119 #endif\r
120 \r
121 #endif /* __SILICON_LABS_EM_INT_H__ */\r