60 #ifndef BSPACM_DEVICE_NRF51_H
61 #define BSPACM_DEVICE_NRF51_H
63 #if ! (BSPACM_DEVICE_SERIES_NRF51 - 0)
64 #error NRF51 device header in non-NRF51 device
72 #ifndef BSPACM_NRF_USE_SD
75 #define BSPACM_NRF_USE_SD 0
78 #if (BSPACM_NRF_USE_SD - 0)
109 #if (BSPACM_NRF_USE_SD - 0)
111 NVIC_SetPriority(irqn, high ? 1 : 3);
119 #define NOSD_BODY() do { \
120 NVIC_EnableIRQ(irqn); \
123 #if (BSPACM_NRF_USE_SD - 0)
124 uint32_t ec = sd_nvic_EnableIRQ(irqn);
125 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
127 }
else if (NRF_SUCCESS != ec) {
143 #define NOSD_BODY() do { \
144 NVIC_DisableIRQ(irqn); \
147 #if (BSPACM_NRF_USE_SD - 0)
148 uint32_t ec = sd_nvic_DisableIRQ(irqn);
149 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
151 }
else if (NRF_SUCCESS != ec) {
164 __STATIC_INLINE uint32_t
167 uint32_t pending_irq;
169 #define NOSD_BODY() do { \
170 pending_irq = NVIC_GetPendingIRQ(irqn); \
173 #if (BSPACM_NRF_USE_SD - 0)
174 uint32_t ec = sd_nvic_GetPendingIRQ(irqn, &pending_irq);
175 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
177 }
else if (NRF_SUCCESS != ec) {
194 #define NOSD_BODY() do { \
195 NVIC_SetPendingIRQ(irqn); \
198 #if (BSPACM_NRF_USE_SD - 0)
199 uint32_t ec = sd_nvic_SetPendingIRQ(irqn);
200 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
202 }
else if (NRF_SUCCESS != ec) {
218 #define NOSD_BODY() do { \
219 NVIC_ClearPendingIRQ(irqn); \
222 #if (BSPACM_NRF_USE_SD - 0)
223 uint32_t ec = sd_nvic_ClearPendingIRQ(irqn);
224 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
226 }
else if (NRF_SUCCESS != ec) {
243 #define NOSD_BODY() do { \
244 NVIC_SetPriority(irqn, priority); \
247 #if (BSPACM_NRF_USE_SD - 0)
248 uint32_t ec = sd_nvic_SetPriority(irqn, priority);
249 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
251 }
else if (NRF_SUCCESS != ec) {
264 __STATIC_INLINE uint32_t
267 #define NOSD_FN() NVIC_GetPriority(irqn)
269 #if (BSPACM_NRF_USE_SD - 0)
270 nrf_app_irq_priority_t priority;
271 uint32_t ec = sd_nvic_GetPriority(irqn, &priority);
272 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
273 priority = NOSD_FN();
274 }
else if (NRF_SUCCESS != ec) {
291 #define NOSD_BODY() do { \
292 NVIC_SystemReset(); \
295 #if (BSPACM_NRF_USE_SD - 0)
296 uint32_t ec = sd_nvic_SystemReset();
297 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
314 const volatile void * evt_endpoint,
315 const volatile void * task_endpoint)
317 #define NOSD_BODY() do { \
318 NRF_PPI->CH[channel_num].EEP = (uintptr_t)evt_endpoint; \
319 NRF_PPI->CH[channel_num].TEP = (uintptr_t)task_endpoint; \
322 #if (BSPACM_NRF_USE_SD - 0)
323 uint32_t ec = sd_ppi_channel_assign(channel_num, evt_endpoint, task_endpoint);
324 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
326 }
else if (NRF_SUCCESS != ec) {
342 #define NOSD_BODY() do { \
343 NRF_PPI->CHENCLR = mask; \
346 #if (BSPACM_NRF_USE_SD - 0)
347 uint32_t ec = sd_ppi_channel_enable_clr(mask);
348 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
350 }
else if (NRF_SUCCESS != ec) {
366 #define NOSD_BODY() do { \
367 NRF_PPI->CHENSET = mask; \
370 #if (BSPACM_NRF_USE_SD - 0)
371 uint32_t ec = sd_ppi_channel_enable_set(mask);
372 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
374 }
else if (NRF_SUCCESS != ec) {
387 __STATIC_INLINE uint32_t
390 #define NOSD_FN() NRF_PPI->CHEN
392 #if (BSPACM_NRF_USE_SD - 0)
394 uint32_t ec = sd_ppi_channel_enable_get(&chen);
395 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
397 }
else if (NRF_SUCCESS != ec) {
414 #define NOSD_BODY() do { \
415 NRF_CLOCK->EVENTS_HFCLKSTARTED = 0; \
416 NRF_CLOCK->TASKS_HFCLKSTART = 1; \
417 while (! NRF_CLOCK->EVENTS_HFCLKSTARTED) { \
421 #if (BSPACM_NRF_USE_SD - 0)
422 uint32_t ec = sd_clock_hfclk_request();
424 if (NRF_ERROR_SOFTDEVICE_NOT_ENABLED == ec) {
426 }
else if (NRF_SUCCESS == ec) {
429 if (NRF_SUCCESS != sd_clock_hfclk_is_running(&is_running))
433 }
while (! is_running);
__STATIC_INLINE void vBSPACMnrf51_NVIC_EnableIRQ(IRQn_Type irqn)
Definition: device.h:117
__STATIC_INLINE void vBSPACMnrf51_NVIC_DisableIRQ(IRQn_Type irqn)
Definition: device.h:141
__STATIC_INLINE uint32_t uiBSPACMnrf51_NVIC_GetPriority(IRQn_Type irqn)
Definition: device.h:265
__STATIC_INLINE void vBSPACMnrf51_PPI_CH(uint8_t channel_num, const volatile void *evt_endpoint, const volatile void *task_endpoint)
Definition: device.h:313
__STATIC_INLINE void vBSPACMnrf51_NVIC_SystemReset(void)
Definition: device.h:289
__STATIC_INLINE uint32_t uiBSPACMnrf51_NVIC_GetPendingIRQ(IRQn_Type irqn)
Definition: device.h:165
__STATIC_INLINE void vBSPACMnrf51_HFCLKSTART()
Definition: device.h:412
__STATIC_INLINE void vBSPACMnrf51_NVIC_ClearPendingIRQ(IRQn_Type irqn)
Definition: device.h:216
__STATIC_INLINE void vBSPACMnrf51_NVIC_SetPriority(IRQn_Type irqn, uint32_t priority)
Definition: device.h:240
__STATIC_INLINE void vBSPACMnrf51_PPI_CHENSET(uint32_t mask)
Definition: device.h:364
__STATIC_INLINE void vBSPACMnrf51_NVIC_SetPendingIRQ(IRQn_Type irqn)
Definition: device.h:192
__STATIC_INLINE uint32_t uiBSPACMnrf51_PPI_CHEN()
Definition: device.h:388
__STATIC_INLINE void vBSPACMnrf51_PPI_CHENCLR(uint32_t mask)
Definition: device.h:340
__STATIC_INLINE void vBSPACMnrf51NVICsetApplicationPriority(IRQn_Type irqn, bool high)
Definition: device.h:106