123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- #ifndef NRF_CCM_H__
- #define NRF_CCM_H__
- #include <nrfx.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- typedef enum
- {
- NRF_CCM_TASK_KSGEN = offsetof(NRF_CCM_Type, TASKS_KSGEN),
- NRF_CCM_TASK_CRYPT = offsetof(NRF_CCM_Type, TASKS_CRYPT),
- NRF_CCM_TASK_STOP = offsetof(NRF_CCM_Type, TASKS_STOP),
- #if defined(CCM_RATEOVERRIDE_RATEOVERRIDE_Pos) || defined(__NRFX_DOXYGEN__)
- NRF_CCM_TASK_RATEOVERRIDE = offsetof(NRF_CCM_Type, TASKS_RATEOVERRIDE),
- #endif
- } nrf_ccm_task_t;
- typedef enum
- {
- NRF_CCM_EVENT_ENDKSGEN = offsetof(NRF_CCM_Type, EVENTS_ENDKSGEN),
- NRF_CCM_EVENT_ENDCRYPT = offsetof(NRF_CCM_Type, EVENTS_ENDCRYPT),
- NRF_CCM_EVENT_ERROR = offsetof(NRF_CCM_Type, EVENTS_ERROR),
- } nrf_ccm_event_t;
- typedef enum
- {
- NRF_CCM_INT_ENDKSGEN_MASK = CCM_INTENSET_ENDKSGEN_Msk,
- NRF_CCM_INT_ENDCRYPT_MASK = CCM_INTENSET_ENDCRYPT_Msk,
- NRF_CCM_INT_ERROR_MASK = CCM_INTENSET_ERROR_Msk,
- } nrf_ccm_int_mask_t;
- typedef enum
- {
- NRF_CCM_MODE_ENCRYPTION = CCM_MODE_MODE_Encryption,
- NRF_CCM_MODE_DECRYPTION = CCM_MODE_MODE_Decryption,
- } nrf_ccm_mode_t;
- #if defined(CCM_MODE_DATARATE_Pos) || defined(__NRFX_DOXYGEN__)
- typedef enum
- {
- NRF_CCM_DATARATE_1M = CCM_MODE_DATARATE_1Mbit,
- NRF_CCM_DATARATE_2M = CCM_MODE_DATARATE_2Mbit,
- #if defined(CCM_MODE_DATARATE_125Kbps) || defined(__NRFX_DOXYGEN__)
- NRF_CCM_DATARATE_125K = CCM_MODE_DATARATE_125Kbps,
- #endif
- #if defined(CCM_MODE_DATARATE_500Kbps) || defined(__NRFX_DOXYGEN__)
- NRF_CCM_DATARATE_500K = CCM_MODE_DATARATE_500Kbps,
- #endif
- } nrf_ccm_datarate_t;
- #endif
- #if defined(CCM_MODE_LENGTH_Pos) || defined(__NRFX_DOXYGEN__)
- typedef enum
- {
- NRF_CCM_LENGTH_DEFAULT = CCM_MODE_LENGTH_Default,
- NRF_CCM_LENGTH_EXTENDED = CCM_MODE_LENGTH_Extended,
- } nrf_ccm_length_t;
- #endif
- typedef struct {
- nrf_ccm_mode_t mode;
- #if defined(CCM_MODE_DATARATE_Pos) || defined(__NRFX_DOXYGEN__)
- nrf_ccm_datarate_t datarate;
- #endif
- #if defined(CCM_MODE_LENGTH_Pos) || defined(__NRFX_DOXYGEN__)
- nrf_ccm_length_t length;
- #endif
- } nrf_ccm_config_t;
- __STATIC_INLINE void nrf_ccm_task_trigger(NRF_CCM_Type * p_reg,
- nrf_ccm_task_t task);
- __STATIC_INLINE uint32_t nrf_ccm_task_address_get(NRF_CCM_Type const * p_reg,
- nrf_ccm_task_t task);
- __STATIC_INLINE void nrf_ccm_event_clear(NRF_CCM_Type * p_reg,
- nrf_ccm_event_t event);
- __STATIC_INLINE bool nrf_ccm_event_check(NRF_CCM_Type const * p_reg,
- nrf_ccm_event_t event);
- __STATIC_INLINE uint32_t nrf_ccm_event_address_get(NRF_CCM_Type const * p_reg,
- nrf_ccm_event_t event);
- __STATIC_INLINE void nrf_ccm_int_enable(NRF_CCM_Type * p_reg, uint32_t mask);
- __STATIC_INLINE void nrf_ccm_int_disable(NRF_CCM_Type * p_reg, uint32_t mask);
- __STATIC_INLINE bool nrf_ccm_int_enable_check(NRF_CCM_Type const * p_reg,
- nrf_ccm_int_mask_t ccm_int);
- __STATIC_INLINE void nrf_ccm_enable(NRF_CCM_Type * p_reg);
- __STATIC_INLINE void nrf_ccm_disable(NRF_CCM_Type * p_reg);
- __STATIC_INLINE void nrf_ccm_configure(NRF_CCM_Type * p_reg,
- nrf_ccm_config_t const * p_config);
- #if defined(CCM_MAXPACKETSIZE_MAXPACKETSIZE_Pos) || defined(__NRFX_DOXYGEN__)
- __STATIC_INLINE void nrf_ccm_maxpacketsize_set(NRF_CCM_Type * p_reg,
- uint8_t size);
- #endif
- __STATIC_INLINE bool nrf_ccm_micstatus_get(NRF_CCM_Type const * p_reg);
- __STATIC_INLINE void nrf_ccm_cnfptr_set(NRF_CCM_Type * p_reg,
- uint32_t const * p_data);
- __STATIC_INLINE uint32_t * nrf_ccm_cnfptr_get(NRF_CCM_Type const * p_reg);
- __STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type * p_reg,
- uint32_t const * p_data);
- __STATIC_INLINE uint32_t * nrf_ccm_inptr_get(NRF_CCM_Type const * p_reg);
- __STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type * p_reg,
- uint32_t const * p_data);
- __STATIC_INLINE uint32_t * nrf_ccm_outptr_get(NRF_CCM_Type const * p_reg);
- __STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type * p_reg,
- uint32_t const * p_area);
- __STATIC_INLINE uint32_t * nrf_ccm_stratchptr_get(NRF_CCM_Type const * p_reg);
- #if defined(CCM_RATEOVERRIDE_RATEOVERRIDE_Pos) || defined(__NRFX_DOXYGEN__)
- __STATIC_INLINE void nrf_ccm_datarate_override_set(NRF_CCM_Type * p_reg,
- nrf_ccm_datarate_t datarate);
- #endif
- #ifndef SUPPRESS_INLINE_IMPLEMENTATION
- __STATIC_INLINE void nrf_ccm_task_trigger(NRF_CCM_Type * p_reg,
- nrf_ccm_task_t task)
- {
- *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
- }
- __STATIC_INLINE uint32_t nrf_ccm_task_address_get(NRF_CCM_Type const * p_reg,
- nrf_ccm_task_t task)
- {
- return ((uint32_t)p_reg + (uint32_t)task);
- }
- __STATIC_INLINE void nrf_ccm_event_clear(NRF_CCM_Type * p_reg,
- nrf_ccm_event_t event)
- {
- *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
- #if __CORTEX_M == 0x04
- volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
- (void)dummy;
- #endif
- }
- __STATIC_INLINE bool nrf_ccm_event_check(NRF_CCM_Type const * p_reg,
- nrf_ccm_event_t event)
- {
- return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
- }
- __STATIC_INLINE uint32_t nrf_ccm_event_address_get(NRF_CCM_Type const * p_reg,
- nrf_ccm_event_t event)
- {
- return ((uint32_t)p_reg + (uint32_t)event);
- }
- __STATIC_INLINE void nrf_ccm_int_enable(NRF_CCM_Type * p_reg, uint32_t mask)
- {
- p_reg->INTENSET = mask;
- }
- __STATIC_INLINE void nrf_ccm_int_disable(NRF_CCM_Type * p_reg, uint32_t mask)
- {
- p_reg->INTENCLR = mask;
- }
- __STATIC_INLINE bool nrf_ccm_int_enable_check(NRF_CCM_Type const * p_reg,
- nrf_ccm_int_mask_t ccm_int)
- {
- return (bool)(p_reg->INTENSET & ccm_int);
- }
- __STATIC_INLINE void nrf_ccm_enable(NRF_CCM_Type * p_reg)
- {
- p_reg->ENABLE = (CCM_ENABLE_ENABLE_Enabled << CCM_ENABLE_ENABLE_Pos);
- }
- __STATIC_INLINE void nrf_ccm_disable(NRF_CCM_Type * p_reg)
- {
- p_reg->ENABLE = (CCM_ENABLE_ENABLE_Disabled << CCM_ENABLE_ENABLE_Pos);
- }
- __STATIC_INLINE void nrf_ccm_configure(NRF_CCM_Type * p_reg,
- nrf_ccm_config_t const * p_config)
- {
- p_reg->MODE = (((uint32_t)p_config->mode << CCM_MODE_MODE_Pos) |
- #if defined(CCM_MODE_DATARATE_Pos)
- ((uint32_t)p_config->datarate << CCM_MODE_DATARATE_Pos) |
- #endif
- #if defined(CCM_MODE_LENGTH_Pos)
- ((uint32_t)p_config->length << CCM_MODE_LENGTH_Pos) |
- #endif
- 0);
- }
- #if defined(CCM_MAXPACKETSIZE_MAXPACKETSIZE_Pos)
- __STATIC_INLINE void nrf_ccm_maxpacketsize_set(NRF_CCM_Type * p_reg,
- uint8_t size)
- {
- NRFX_ASSERT((size >= 0x1B) && (size <= 0xFB));
- p_reg->MAXPACKETSIZE = size;
- }
- #endif
- __STATIC_INLINE bool nrf_ccm_micstatus_get(NRF_CCM_Type const * p_reg)
- {
- return (bool)(p_reg->MICSTATUS);
- }
- __STATIC_INLINE void nrf_ccm_cnfptr_set(NRF_CCM_Type * p_reg,
- uint32_t const * p_data)
- {
- p_reg->CNFPTR = (uint32_t)p_data;
- }
- __STATIC_INLINE uint32_t * nrf_ccm_cnfptr_get(NRF_CCM_Type const * p_reg)
- {
- return (uint32_t *)(p_reg->CNFPTR);
- }
- __STATIC_INLINE void nrf_ccm_inptr_set(NRF_CCM_Type * p_reg,
- uint32_t const * p_data)
- {
- p_reg->INPTR = (uint32_t)p_data;
- }
- __STATIC_INLINE uint32_t * nrf_ccm_inptr_get(NRF_CCM_Type const * p_reg)
- {
- return (uint32_t *)(p_reg->INPTR);
- }
- __STATIC_INLINE void nrf_ccm_outptr_set(NRF_CCM_Type * p_reg,
- uint32_t const * p_data)
- {
- p_reg->OUTPTR = (uint32_t)p_data;
- }
- __STATIC_INLINE uint32_t * nrf_ccm_outptr_get(NRF_CCM_Type const * p_reg)
- {
- return (uint32_t *)(p_reg->OUTPTR);
- }
- __STATIC_INLINE void nrf_ccm_scratchptr_set(NRF_CCM_Type * p_reg,
- uint32_t const * p_area)
- {
- p_reg->SCRATCHPTR = (uint32_t)p_area;
- }
- __STATIC_INLINE uint32_t * nrf_ccm_stratchptr_get(NRF_CCM_Type const * p_reg)
- {
- return (uint32_t *)(p_reg->SCRATCHPTR);
- }
- #if defined(CCM_RATEOVERRIDE_RATEOVERRIDE_Pos)
- __STATIC_INLINE void nrf_ccm_datarate_override_set(NRF_CCM_Type * p_reg,
- nrf_ccm_datarate_t datarate)
- {
- p_reg->RATEOVERRIDE = ((uint32_t)datarate << CCM_RATEOVERRIDE_RATEOVERRIDE_Pos);
- }
- #endif
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|