123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- #ifndef NRF_MPU_H__
- #define NRF_MPU_H__
- #include <nrfx.h>
- #ifdef __cplusplus
- extern "C" {
- #endif
- #define NRF_MPU_PERIPHERAL_MASK_GET(base_addr) (1UL << NRFX_PERIPHERAL_ID_GET(base_addr))
- __STATIC_INLINE void nrf_mpu_region0_ram_size_set(NRF_MPU_Type * p_reg, uint32_t size);
- __STATIC_INLINE void nrf_mpu_region0_peripherals_set(NRF_MPU_Type * p_reg,
- uint32_t peripheral_mask);
- __STATIC_INLINE uint32_t nrf_mpu_region0_peripherals_get(NRF_MPU_Type const * p_reg);
- __STATIC_INLINE void nrf_mpu_nvm_blocks_protection_enable(NRF_MPU_Type * p_reg,
- uint8_t group_idx,
- uint32_t block_mask);
- __STATIC_INLINE void nrf_mpu_nvm_protection_in_debug_set(NRF_MPU_Type * p_reg,
- bool enable);
- #ifndef SUPPRESS_INLINE_IMPLEMENTATION
- __STATIC_INLINE void nrf_mpu_region0_ram_size_set(NRF_MPU_Type * p_reg, uint32_t size)
- {
- NRFX_ASSERT(nrfx_is_word_aligned((const void *)size));
- p_reg->RLENR0 = size;
- }
- __STATIC_INLINE void nrf_mpu_region0_peripherals_set(NRF_MPU_Type * p_reg,
- uint32_t peripheral_mask)
- {
- p_reg->PERR0 = peripheral_mask;
- }
- __STATIC_INLINE uint32_t nrf_mpu_region0_peripherals_get(NRF_MPU_Type const * p_reg)
- {
- return p_reg->PERR0;
- }
- __STATIC_INLINE void nrf_mpu_nvm_blocks_protection_enable(NRF_MPU_Type * p_reg,
- uint8_t group_idx,
- uint32_t block_mask)
- {
- switch (group_idx)
- {
- case 0:
- p_reg->PROTENSET0 = block_mask;
- break;
- case 1:
- p_reg->PROTENSET1 = block_mask;
- break;
- default:
- NRFX_ASSERT(false);
- break;
- }
- }
- __STATIC_INLINE void nrf_mpu_nvm_protection_in_debug_set(NRF_MPU_Type * p_reg,
- bool enable)
- {
- p_reg->DISABLEINDEBUG =
- (enable ? 0 : MPU_DISABLEINDEBUG_DISABLEINDEBUG_Msk);
- }
- #endif
- #ifdef __cplusplus
- }
- #endif
- #endif
|