11 #ifndef APP_UTIL_PLATFORM_H__
12 #define APP_UTIL_PLATFORM_H__
15 #include "compiler_abstraction.h"
17 #ifdef SOFTDEVICE_PRESENT
21 #include "nrf_assert.h"
22 #include "app_error.h"
28 #if __CORTEX_M == (0x00U)
29 #define _PRIO_SD_HIGH 0
30 #define _PRIO_APP_HIGH 1
31 #define _PRIO_APP_MID 1
32 #define _PRIO_SD_LOW 2
33 #define _PRIO_APP_LOW 3
34 #define _PRIO_APP_LOWEST 3
35 #define _PRIO_THREAD 4
36 #elif __CORTEX_M == (0x04U) && !defined(S1XX)
37 #define _PRIO_SD_HIGH 0
38 #define _PRIO_SD_MID 1
39 #define _PRIO_APP_HIGH 2
40 #define _PRIO_APP_MID 3
41 #define _PRIO_SD_LOW 4
42 #define _PRIO_SD_LOWEST 5
43 #define _PRIO_APP_LOW 6
44 #define _PRIO_APP_LOWEST 7
45 #define _PRIO_THREAD 15
47 #define _PRIO_SD_HIGH 0
48 #define _PRIO_APP_HIGH 1
49 #define _PRIO_APP_MID 1
50 #define _PRIO_SD_LOW 2
51 #define _PRIO_APP_LOW 3
52 #define _PRIO_APP_LOWEST 3
53 #define _PRIO_THREAD 4
55 #error "No platform defined"
63 #ifndef SOFTDEVICE_PRESENT
64 APP_IRQ_PRIORITY_HIGHEST = _PRIO_SD_HIGH,
66 APP_IRQ_PRIORITY_HIGHEST = _PRIO_APP_HIGH,
68 APP_IRQ_PRIORITY_HIGH = _PRIO_APP_HIGH,
69 #ifndef SOFTDEVICE_PRESENT
70 APP_IRQ_PRIORITY_MID = _PRIO_SD_LOW,
72 APP_IRQ_PRIORITY_MID = _PRIO_APP_MID,
74 APP_IRQ_PRIORITY_LOW = _PRIO_APP_LOW,
75 APP_IRQ_PRIORITY_LOWEST = _PRIO_APP_LOWEST,
84 APP_LEVEL_UNPRIVILEGED,
89 #define EXTERNAL_INT_VECTOR_OFFSET 16
95 #define NRF_BREAKPOINT __builtin_trap()
97 #define NRF_BREAKPOINT __BKPT(0)
105 #if __CORTEX_M == 0x04
106 #define NRF_BREAKPOINT_COND do { \
108 if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) \
115 #define NRF_BREAKPOINT_COND NRF_BREAKPOINT
116 #endif // __CORTEX_M == 0x04
118 #if defined ( __CC_ARM )
119 #define PACKED(TYPE) __packed TYPE
120 #define PACKED_STRUCT PACKED(struct)
121 #elif defined ( __GNUC__ )
122 #define PACKED __attribute__((packed))
123 #define PACKED_STRUCT struct PACKED
124 #elif defined (__ICCARM__)
125 #define PACKED_STRUCT __packed struct
128 void app_util_critical_region_enter (uint8_t *p_nested);
129 void app_util_critical_region_exit (uint8_t nested);
137 #ifdef SOFTDEVICE_PRESENT
138 #define CRITICAL_REGION_ENTER() \
140 uint8_t __CR_NESTED = 0; \
141 app_util_critical_region_enter(&__CR_NESTED);
143 #define CRITICAL_REGION_ENTER() app_util_critical_region_enter(NULL)
152 #ifdef SOFTDEVICE_PRESENT
153 #define CRITICAL_REGION_EXIT() \
154 app_util_critical_region_exit(__CR_NESTED); \
157 #define CRITICAL_REGION_EXIT() app_util_critical_region_exit(0)
162 #define IPSR_ISR_Msk (0x1FFUL )
169 #if defined(__CC_ARM)
170 #define ANON_UNIONS_ENABLE _Pragma("push") \
171 _Pragma("anon_unions")
172 #elif defined(__ICCARM__)
173 #define ANON_UNIONS_ENABLE _Pragma("language=extended")
175 #define ANON_UNIONS_ENABLE
183 #if defined(__CC_ARM)
184 #define ANON_UNIONS_DISABLE _Pragma("pop")
185 #elif defined(__ICCARM__)
186 #define ANON_UNIONS_DISABLE
189 #define ANON_UNIONS_DISABLE
197 #define GCC_PRAGMA(v) _Pragma(v)
199 #define GCC_PRAGMA(v)
203 #ifndef CONTROL_nPRIV_Msk
204 #define CONTROL_nPRIV_Msk (1UL )
230 #endif // APP_UTIL_PLATFORM_H__