123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- #ifndef NRF_AAR_H__
- #define NRF_AAR_H__
- #include <nrfx.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef enum
- {
- NRF_AAR_EVENT_END = offsetof(NRF_AAR_Type, EVENTS_END),
- NRF_AAR_EVENT_RESOLVED = offsetof(NRF_AAR_Type, EVENTS_RESOLVED),
- NRF_AAR_EVENT_NOTRESOLVED = offsetof(NRF_AAR_Type, EVENTS_NOTRESOLVED),
- } nrf_aar_event_t;
- typedef enum
- {
- NRF_AAR_INT_END_MASK = AAR_INTENSET_END_Msk,
- NRF_AAR_INT_RESOLVED_MASK = AAR_INTENSET_RESOLVED_Msk,
- NRF_AAR_INT_NOTRESOLVED_MASK = AAR_INTENSET_NOTRESOLVED_Msk,
- } nrf_aar_int_mask_t;
- typedef enum
- {
- NRF_AAR_TASK_START = offsetof(NRF_AAR_Type, TASKS_START),
- NRF_AAR_TASK_STOP = offsetof(NRF_AAR_Type, TASKS_STOP),
- } nrf_aar_task_t;
- __STATIC_INLINE bool nrf_aar_event_check(NRF_AAR_Type const * p_reg,
- nrf_aar_event_t event);
- __STATIC_INLINE void nrf_aar_event_clear(NRF_AAR_Type * p_reg,
- nrf_aar_event_t event);
- __STATIC_INLINE uint32_t nrf_aar_event_address_get(NRF_AAR_Type const * p_reg,
- nrf_aar_event_t event);
- __STATIC_INLINE void nrf_aar_int_enable(NRF_AAR_Type * p_reg, uint32_t mask);
- __STATIC_INLINE bool nrf_aar_int_enable_check(NRF_AAR_Type const * p_reg,
- nrf_aar_int_mask_t mask);
- __STATIC_INLINE void nrf_aar_int_disable(NRF_AAR_Type * p_reg, uint32_t mask);
- __STATIC_INLINE void nrf_aar_task_trigger(NRF_AAR_Type * p_reg, nrf_aar_task_t task);
- __STATIC_INLINE uint32_t nrf_aar_task_address_get(NRF_AAR_Type const * p_reg,
- nrf_aar_task_t task);
- __STATIC_INLINE void nrf_aar_enable(NRF_AAR_Type * p_reg);
- __STATIC_INLINE void nrf_aar_disable(NRF_AAR_Type * p_reg);
- __STATIC_INLINE void nrf_aar_irk_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * irk_ptr);
- __STATIC_INLINE uint8_t const * nrf_aar_irk_pointer_get(NRF_AAR_Type const * p_reg);
- __STATIC_INLINE void nrf_aar_irk_number_set(NRF_AAR_Type * p_reg, uint8_t irk_num);
- __STATIC_INLINE uint8_t nrf_aar_irk_number_get(NRF_AAR_Type const * p_reg);
- __STATIC_INLINE void nrf_aar_addr_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * addr_ptr);
- __STATIC_INLINE uint8_t const * nrf_aar_addr_pointer_get(NRF_AAR_Type const * p_reg);
- __STATIC_INLINE void nrf_aar_scratch_pointer_set(NRF_AAR_Type * p_reg, uint8_t * scratch_ptr);
- __STATIC_INLINE uint8_t * nrf_aar_scratch_pointer_get(NRF_AAR_Type const * p_reg);
- __STATIC_INLINE uint8_t nrf_aar_resolution_status_get(NRF_AAR_Type const * p_reg);
- #ifndef SUPPRESS_INLINE_IMPLEMENTATION
- __STATIC_INLINE bool nrf_aar_event_check(NRF_AAR_Type const * p_reg,
- nrf_aar_event_t aar_event)
- {
- return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)aar_event);
- }
- __STATIC_INLINE void nrf_aar_event_clear(NRF_AAR_Type * p_reg,
- nrf_aar_event_t aar_event)
- {
- *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)aar_event)) = 0;
- #if __CORTEX_M == 0x04
- volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)aar_event));
- (void)dummy;
- #endif
- }
- __STATIC_INLINE uint32_t nrf_aar_event_address_get(NRF_AAR_Type const * p_reg,
- nrf_aar_event_t aar_event)
- {
- return (uint32_t)((uint8_t *)p_reg + (uint32_t)aar_event);
- }
- __STATIC_INLINE void nrf_aar_int_enable(NRF_AAR_Type * p_reg, uint32_t mask)
- {
- p_reg->INTENSET = mask;
- }
- __STATIC_INLINE bool nrf_aar_int_enable_check(NRF_AAR_Type const * p_reg,
- nrf_aar_int_mask_t mask)
- {
- return (bool)(p_reg->INTENSET & mask);
- }
- __STATIC_INLINE void nrf_aar_int_disable(NRF_AAR_Type * p_reg, uint32_t mask)
- {
- p_reg->INTENCLR = mask;
- }
- __STATIC_INLINE void nrf_aar_task_trigger(NRF_AAR_Type * p_reg, nrf_aar_task_t task)
- {
- *(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task) = 1;
- }
- __STATIC_INLINE uint32_t nrf_aar_task_address_get(NRF_AAR_Type const * p_reg,
- nrf_aar_task_t task)
- {
- return (uint32_t)((uint8_t *)p_reg + (uint32_t)task);
- }
- __STATIC_INLINE void nrf_aar_enable(NRF_AAR_Type * p_reg)
- {
- p_reg->ENABLE = AAR_ENABLE_ENABLE_Enabled << AAR_ENABLE_ENABLE_Pos;
- }
- __STATIC_INLINE void nrf_aar_disable(NRF_AAR_Type * p_reg)
- {
- p_reg->ENABLE = AAR_ENABLE_ENABLE_Disabled << AAR_ENABLE_ENABLE_Pos;
- }
- __STATIC_INLINE void nrf_aar_irk_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * irk_ptr)
- {
- p_reg->IRKPTR = (uint32_t)irk_ptr;
- }
- __STATIC_INLINE uint8_t const * nrf_aar_irk_pointer_get(NRF_AAR_Type const * p_reg)
- {
- return (uint8_t const *)(p_reg->IRKPTR);
- }
- __STATIC_INLINE void nrf_aar_irk_number_set(NRF_AAR_Type * p_reg, uint8_t irk_num)
- {
- p_reg->NIRK = irk_num;
- }
- __STATIC_INLINE uint8_t nrf_aar_irk_number_get(NRF_AAR_Type const * p_reg)
- {
- return (uint8_t)(p_reg->NIRK);
- }
- __STATIC_INLINE void nrf_aar_addr_pointer_set(NRF_AAR_Type * p_reg, uint8_t const * addr_ptr)
- {
- p_reg->ADDRPTR = (uint32_t)addr_ptr;
- }
- __STATIC_INLINE uint8_t const * nrf_aar_addr_pointer_get(NRF_AAR_Type const * p_reg)
- {
- return (uint8_t const *)(p_reg->ADDRPTR);
- }
- __STATIC_INLINE void nrf_aar_scratch_pointer_set(NRF_AAR_Type * p_reg, uint8_t * scratch_ptr)
- {
- p_reg->SCRATCHPTR = (uint32_t)scratch_ptr;
- }
- __STATIC_INLINE uint8_t * nrf_aar_scratch_pointer_get(NRF_AAR_Type const * p_reg)
- {
- return (uint8_t *)(p_reg->SCRATCHPTR);
- }
- __STATIC_INLINE uint8_t nrf_aar_resolution_status_get(NRF_AAR_Type const * p_reg)
- {
- return (uint8_t)(p_reg->STATUS);
- }
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|