49 #ifndef APP_UTIL_PLATFORM_H__
50 #define APP_UTIL_PLATFORM_H__
53 #include "compiler_abstraction.h"
55 #ifdef SOFTDEVICE_PRESENT
67 #if __CORTEX_M == (0x00U)
68 #define _PRIO_SD_HIGH 0
69 #define _PRIO_APP_HIGH 1
70 #define _PRIO_APP_MID 1
71 #define _PRIO_SD_LOW 2
72 #define _PRIO_APP_LOW 3
73 #define _PRIO_APP_LOWEST 3
74 #define _PRIO_THREAD 4
75 #elif __CORTEX_M == (0x04U)
76 #define _PRIO_SD_HIGH 0
77 #define _PRIO_SD_MID 1
78 #define _PRIO_APP_HIGH 2
79 #define _PRIO_APP_MID 3
80 #define _PRIO_SD_LOW 4
81 #define _PRIO_SD_LOWEST 5
82 #define _PRIO_APP_LOW 6
83 #define _PRIO_APP_LOWEST 7
84 #define _PRIO_THREAD 15
86 #error "No platform defined"
93 #ifndef SOFTDEVICE_PRESENT
94 APP_IRQ_PRIORITY_HIGHEST = _PRIO_SD_HIGH,
96 APP_IRQ_PRIORITY_HIGHEST = _PRIO_APP_HIGH,
98 APP_IRQ_PRIORITY_HIGH = _PRIO_APP_HIGH,
99 #ifndef SOFTDEVICE_PRESENT
100 APP_IRQ_PRIORITY_MID = _PRIO_SD_LOW,
102 APP_IRQ_PRIORITY_MID = _PRIO_APP_MID,
104 APP_IRQ_PRIORITY_LOW = _PRIO_APP_LOW,
105 APP_IRQ_PRIORITY_LOWEST = _PRIO_APP_LOWEST,
106 APP_IRQ_PRIORITY_THREAD = _PRIO_THREAD
107 } app_irq_priority_t;
113 APP_LEVEL_UNPRIVILEGED,
118 #define EXTERNAL_INT_VECTOR_OFFSET 16
123 #if defined(__GNUC__)
124 #define NRF_BREAKPOINT __builtin_trap()
126 #define NRF_BREAKPOINT __BKPT(0)
134 #if __CORTEX_M == 0x04
135 #define NRF_BREAKPOINT_COND \
139 if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) \
146 #define NRF_BREAKPOINT_COND NRF_BREAKPOINT
147 #endif // __CORTEX_M == 0x04
149 #if defined(__CC_ARM)
150 #define PACKED(TYPE) __packed TYPE
151 #define PACKED_STRUCT PACKED(struct)
152 #elif defined(__GNUC__)
153 #define PACKED __attribute__((packed))
154 #define PACKED_STRUCT struct PACKED
155 #elif defined(__ICCARM__)
156 #define PACKED_STRUCT __packed struct
159 void app_util_critical_region_enter(uint8_t *p_nested);
160 void app_util_critical_region_exit(uint8_t nested);
168 #ifdef SOFTDEVICE_PRESENT
169 #define CRITICAL_REGION_ENTER() \
171 uint8_t __CR_NESTED = 0; \
172 app_util_critical_region_enter(&__CR_NESTED);
174 #define CRITICAL_REGION_ENTER() app_util_critical_region_enter(NULL)
183 #ifdef SOFTDEVICE_PRESENT
184 #define CRITICAL_REGION_EXIT() \
185 app_util_critical_region_exit(__CR_NESTED); \
188 #define CRITICAL_REGION_EXIT() app_util_critical_region_exit(0)
193 #define IPSR_ISR_Msk (0x1FFUL )
198 #if defined(__CC_ARM)
199 #define ANON_UNIONS_ENABLE _Pragma("push") \
200 _Pragma("anon_unions")
201 #elif defined(__ICCARM__)
202 #define ANON_UNIONS_ENABLE _Pragma("language=extended")
204 #define ANON_UNIONS_ENABLE
212 #if defined(__CC_ARM)
213 #define ANON_UNIONS_DISABLE _Pragma("pop")
214 #elif defined(__ICCARM__)
215 #define ANON_UNIONS_DISABLE
218 #define ANON_UNIONS_DISABLE
226 #define GCC_PRAGMA(v) _Pragma(v)
228 #define GCC_PRAGMA(v)
232 #ifndef CONTROL_nPRIV_Msk
233 #define CONTROL_nPRIV_Msk (1UL )
243 uint8_t current_int_priority_get(
void);
251 uint8_t privilege_level_get(
void);
257 #endif // APP_UTIL_PLATFORM_H__