BSPACM  20150113
Board Support Package for ARM Cortex-M Microcontrollers
Macros | Functions
device.h File Reference

Common device header for all nRF51 series devices. More...

#include "nrf51.h"

Go to the source code of this file.

Macros

#define BSPACM_NRF_USE_SD   0
 
#define NOSD_BODY()
 
#define NOSD_BODY()
 
#define NOSD_BODY()
 
#define NOSD_BODY()
 
#define NOSD_BODY()
 
#define NOSD_BODY()
 
#define NOSD_FN()   NVIC_GetPriority(irqn)
 
#define NOSD_BODY()
 
#define NOSD_BODY()
 
#define NOSD_BODY()
 
#define NOSD_BODY()
 
#define NOSD_FN()   NRF_PPI->CHEN
 
#define NOSD_BODY()
 

Functions

__STATIC_INLINE void vBSPACMnrf51NVICsetApplicationPriority (IRQn_Type irqn, bool high)
 
__STATIC_INLINE void vBSPACMnrf51_NVIC_EnableIRQ (IRQn_Type irqn)
 
__STATIC_INLINE void vBSPACMnrf51_NVIC_DisableIRQ (IRQn_Type irqn)
 
__STATIC_INLINE uint32_t uiBSPACMnrf51_NVIC_GetPendingIRQ (IRQn_Type irqn)
 
__STATIC_INLINE void vBSPACMnrf51_NVIC_SetPendingIRQ (IRQn_Type irqn)
 
__STATIC_INLINE void vBSPACMnrf51_NVIC_ClearPendingIRQ (IRQn_Type irqn)
 
__STATIC_INLINE void vBSPACMnrf51_NVIC_SetPriority (IRQn_Type irqn, uint32_t priority)
 
__STATIC_INLINE uint32_t uiBSPACMnrf51_NVIC_GetPriority (IRQn_Type irqn)
 
__STATIC_INLINE void vBSPACMnrf51_NVIC_SystemReset (void)
 
__STATIC_INLINE void vBSPACMnrf51_PPI_CH (uint8_t channel_num, const volatile void *evt_endpoint, const volatile void *task_endpoint)
 
__STATIC_INLINE void vBSPACMnrf51_PPI_CHENCLR (uint32_t mask)
 
__STATIC_INLINE void vBSPACMnrf51_PPI_CHENSET (uint32_t mask)
 
__STATIC_INLINE uint32_t uiBSPACMnrf51_PPI_CHEN ()
 
__STATIC_INLINE void vBSPACMnrf51_HFCLKSTART ()
 

Detailed Description

Common device header for all nRF51 series devices.

Primarily this contains wrappers that allow code to be generically capable of running with or without a soft device.

First, the soft-device wrapper functions should not be used for peripherals that are not restricted by the soft-device: doing so can result in hard faults.

Second, the soft-device wrapper functions are unnecessary if soft device support is disabled (BSPACM_NRF_USE_SD).

Third, even when compiled-in support is present the softdevice might not enabled at the time the operation is invoked. In that situation we need to fall back to the non-SD implementation.

Because non-SD functionality generally does not indicate errors, any errors evoked by the soft-device wrappers that can't be processed immediately causes the application to block. The expectation is that these errors are due to mis-use of a restricted peripheral, and will be discovered during application testing.

Homepage
http://github.com/pabigot/bspacm

Macro Definition Documentation

#define BSPACM_NRF_USE_SD   0

Define to a true value to use the nRF soft-device wrapper functions.

#define NOSD_BODY ( )
Value:
do { \
NVIC_EnableIRQ(irqn); \
} while (0)
#define NOSD_BODY ( )
Value:
do { \
NVIC_DisableIRQ(irqn); \
} while (0)
#define NOSD_BODY ( )
Value:
do { \
pending_irq = NVIC_GetPendingIRQ(irqn); \
} while (0)
#define NOSD_BODY ( )
Value:
do { \
NVIC_SetPendingIRQ(irqn); \
} while (0)
#define NOSD_BODY ( )
Value:
do { \
NVIC_ClearPendingIRQ(irqn); \
} while (0)
#define NOSD_BODY ( )
Value:
do { \
NVIC_SetPriority(irqn, priority); \
} while (0)
#define NOSD_BODY ( )
Value:
do { \
NVIC_SystemReset(); \
} while (0)
#define NOSD_BODY ( )
Value:
do { \
NRF_PPI->CH[channel_num].EEP = (uintptr_t)evt_endpoint; \
NRF_PPI->CH[channel_num].TEP = (uintptr_t)task_endpoint; \
} while (0)
#define NOSD_BODY ( )
Value:
do { \
NRF_PPI->CHENCLR = mask; \
} while (0)
#define NOSD_BODY ( )
Value:
do { \
NRF_PPI->CHENSET = mask; \
} while (0)
#define NOSD_BODY ( )
Value:
do { \
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0; \
NRF_CLOCK->TASKS_HFCLKSTART = 1; \
while (! NRF_CLOCK->EVENTS_HFCLKSTARTED) { \
} \
} while (0)

Function Documentation

__STATIC_INLINE uint32_t uiBSPACMnrf51_NVIC_GetPendingIRQ ( IRQn_Type  irqn)

Soft-device–aware version of NVIC_GetPendingIRQ

__STATIC_INLINE uint32_t uiBSPACMnrf51_NVIC_GetPriority ( IRQn_Type  irqn)

Soft-device–aware version of NVIC_GetPriority

__STATIC_INLINE uint32_t uiBSPACMnrf51_PPI_CHEN ( )

Soft-device–aware read of to NRF_PPI->CHEN

__STATIC_INLINE void vBSPACMnrf51_HFCLKSTART ( )

Soft-device–aware start of HFCLK

__STATIC_INLINE void vBSPACMnrf51_NVIC_ClearPendingIRQ ( IRQn_Type  irqn)

Soft-device–aware version of NVIC_ClearPendingIRQ

__STATIC_INLINE void vBSPACMnrf51_NVIC_DisableIRQ ( IRQn_Type  irqn)

Soft-device–aware version of NVIC_DisableIRQ

__STATIC_INLINE void vBSPACMnrf51_NVIC_EnableIRQ ( IRQn_Type  irqn)

Soft-device–aware version of NVIC_EnableIRQ

__STATIC_INLINE void vBSPACMnrf51_NVIC_SetPendingIRQ ( IRQn_Type  irqn)

Soft-device–aware version of NVIC_SetPendingIRQ

__STATIC_INLINE void vBSPACMnrf51_NVIC_SetPriority ( IRQn_Type  irqn,
uint32_t  priority 
)

Soft-device–aware version of NVIC_SetPriority

__STATIC_INLINE void vBSPACMnrf51_NVIC_SystemReset ( void  )

Soft-device–aware version of NVIC_SystemReset

__STATIC_INLINE void vBSPACMnrf51_PPI_CH ( uint8_t  channel_num,
const volatile void *  evt_endpoint,
const volatile void *  task_endpoint 
)

Soft-device–aware configuration of NRF_PPI->CH

__STATIC_INLINE void vBSPACMnrf51_PPI_CHENCLR ( uint32_t  mask)

Soft-device–aware assignment to NRF_PPI->CHENCLR

__STATIC_INLINE void vBSPACMnrf51_PPI_CHENSET ( uint32_t  mask)

Soft-device–aware assignment to NRF_PPI->CHENSET

__STATIC_INLINE void vBSPACMnrf51NVICsetApplicationPriority ( IRQn_Type  irqn,
bool  high 
)

Conditionally set priority for non-soft-device interrupts.

The ARM Cortex-M0 supports four interrupt levels from 0 (highest) through 3 (lowest), with 0 being the power-up default.

The Nordic soft device architecture allows applications to use interrupt levels 1 (high-priority application) and 3 (low-priority application). Attempts to enable the soft-device if interrupts at other priorities are already enabled result in an error NRF_ERROR_SDM_INCORRECT_INTERRUPT_CONFIGURATION.

This function can be used wherever interrupts are configured for peripherals that are not restricted by the soft-device. It has no effect when BSPACM_NRF_USE_SD is false, but assigns a SD-acceptable priority when BSPACM_NRF_USE_SD is true.

Parameters
irqnthe IRQ number.
Note
irqn should reflect a peripheral that is not restricted by the soft device. For restricted peripherals you should use vBSPACMnrf_NVIC_SetPriority().
Parameters
highif true use high priority; if false use low priority.