123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- #ifndef NRFX_GLUE_H__
- #define NRFX_GLUE_H__
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <legacy/apply_old_config.h>
- #include <soc/nrfx_irqs.h>
- #include <nrf_assert.h>
- #define NRFX_ASSERT(expression) ASSERT(expression)
- #include <app_util.h>
- #define NRFX_STATIC_ASSERT(expression) STATIC_ASSERT(expression)
- #ifdef NRF51
- #ifdef SOFTDEVICE_PRESENT
- #define INTERRUPT_PRIORITY_IS_VALID(pri) (((pri) == 1) || ((pri) == 3))
- #else
- #define INTERRUPT_PRIORITY_IS_VALID(pri) ((pri) < 4)
- #endif
- #else
- #ifdef SOFTDEVICE_PRESENT
- #define INTERRUPT_PRIORITY_IS_VALID(pri) ((((pri) > 1) && ((pri) < 4)) || \
- (((pri) > 4) && ((pri) < 8)))
- #else
- #define INTERRUPT_PRIORITY_IS_VALID(pri) ((pri) < 8)
- #endif
- #endif
- #define NRFX_IRQ_PRIORITY_SET(irq_number, priority) \
- _NRFX_IRQ_PRIORITY_SET(irq_number, priority)
- static inline void _NRFX_IRQ_PRIORITY_SET(IRQn_Type irq_number,
- uint8_t priority)
- {
- ASSERT(INTERRUPT_PRIORITY_IS_VALID(priority));
- NVIC_SetPriority(irq_number, priority);
- }
- #define NRFX_IRQ_ENABLE(irq_number) _NRFX_IRQ_ENABLE(irq_number)
- static inline void _NRFX_IRQ_ENABLE(IRQn_Type irq_number)
- {
- NVIC_EnableIRQ(irq_number);
- }
- #define NRFX_IRQ_IS_ENABLED(irq_number) _NRFX_IRQ_IS_ENABLED(irq_number)
- static inline bool _NRFX_IRQ_IS_ENABLED(IRQn_Type irq_number)
- {
- return 0 != (NVIC->ISER[irq_number / 32] & (1UL << (irq_number % 32)));
- }
- #define NRFX_IRQ_DISABLE(irq_number) _NRFX_IRQ_DISABLE(irq_number)
- static inline void _NRFX_IRQ_DISABLE(IRQn_Type irq_number)
- {
- NVIC_DisableIRQ(irq_number);
- }
- #define NRFX_IRQ_PENDING_SET(irq_number) _NRFX_IRQ_PENDING_SET(irq_number)
- static inline void _NRFX_IRQ_PENDING_SET(IRQn_Type irq_number)
- {
- NVIC_SetPendingIRQ(irq_number);
- }
- #define NRFX_IRQ_PENDING_CLEAR(irq_number) _NRFX_IRQ_PENDING_CLEAR(irq_number)
- static inline void _NRFX_IRQ_PENDING_CLEAR(IRQn_Type irq_number)
- {
- NVIC_ClearPendingIRQ(irq_number);
- }
- #define NRFX_IRQ_IS_PENDING(irq_number) _NRFX_IRQ_IS_PENDING(irq_number)
- static inline bool _NRFX_IRQ_IS_PENDING(IRQn_Type irq_number)
- {
- return (NVIC_GetPendingIRQ(irq_number) == 1);
- }
- #include <nordic_common.h>
- #include <app_util_platform.h>
- #define NRFX_CRITICAL_SECTION_ENTER() CRITICAL_REGION_ENTER()
- #define NRFX_CRITICAL_SECTION_EXIT() CRITICAL_REGION_EXIT()
- #define NRFX_DELAY_DWT_BASED 0
- #include <soc/nrfx_coredep.h>
- #define NRFX_DELAY_US(us_time) nrfx_coredep_delay_us(us_time)
- #include <soc/nrfx_atomic.h>
- #define nrfx_atomic_t nrfx_atomic_u32_t
- #define NRFX_ATOMIC_FETCH_STORE(p_data, value) nrfx_atomic_u32_fetch_store(p_data, value)
- #define NRFX_ATOMIC_FETCH_OR(p_data, value) nrfx_atomic_u32_fetch_or(p_data, value)
- #define NRFX_ATOMIC_FETCH_AND(p_data, value) nrfx_atomic_u32_fetch_and(p_data, value)
- #define NRFX_ATOMIC_FETCH_XOR(p_data, value) nrfx_atomic_u32_fetch_xor(p_data, value)
- #define NRFX_ATOMIC_FETCH_ADD(p_data, value) nrfx_atomic_u32_fetch_add(p_data, value)
- #define NRFX_ATOMIC_FETCH_SUB(p_data, value) nrfx_atomic_u32_fetch_sub(p_data, value)
- #ifndef NRFX_CUSTOM_ERROR_CODES
- #include <sdk_errors.h>
- #define NRFX_CUSTOM_ERROR_CODES 1
- typedef ret_code_t nrfx_err_t;
- #define NRFX_SUCCESS NRF_SUCCESS
- #define NRFX_ERROR_INTERNAL NRF_ERROR_INTERNAL
- #define NRFX_ERROR_NO_MEM NRF_ERROR_NO_MEM
- #define NRFX_ERROR_NOT_SUPPORTED NRF_ERROR_NOT_SUPPORTED
- #define NRFX_ERROR_INVALID_PARAM NRF_ERROR_INVALID_PARAM
- #define NRFX_ERROR_INVALID_STATE NRF_ERROR_INVALID_STATE
- #define NRFX_ERROR_INVALID_LENGTH NRF_ERROR_INVALID_LENGTH
- #define NRFX_ERROR_TIMEOUT NRF_ERROR_TIMEOUT
- #define NRFX_ERROR_FORBIDDEN NRF_ERROR_FORBIDDEN
- #define NRFX_ERROR_NULL NRF_ERROR_NULL
- #define NRFX_ERROR_INVALID_ADDR NRF_ERROR_INVALID_ADDR
- #define NRFX_ERROR_BUSY NRF_ERROR_BUSY
- #define NRFX_ERROR_ALREADY_INITIALIZED NRF_ERROR_MODULE_ALREADY_INITIALIZED
- #define NRFX_ERROR_DRV_TWI_ERR_OVERRUN NRF_ERROR_DRV_TWI_ERR_OVERRUN
- #define NRFX_ERROR_DRV_TWI_ERR_ANACK NRF_ERROR_DRV_TWI_ERR_ANACK
- #define NRFX_ERROR_DRV_TWI_ERR_DNACK NRF_ERROR_DRV_TWI_ERR_DNACK
- #endif
- #include <sdk_resources.h>
- #define NRFX_PPI_CHANNELS_USED NRF_PPI_CHANNELS_USED
- #define NRFX_PPI_GROUPS_USED NRF_PPI_GROUPS_USED
- #define NRFX_SWI_USED NRF_SWI_USED
- #define NRFX_TIMERS_USED NRF_TIMERS_USED
- #ifdef __cplusplus
- }
- #endif
- #endif
|