MPU HAL

group nrf_mpu_hal

Hardware access layer for managing the Memory Protection Unit (MPU) peripheral.

Defines

NRF_MPU_PERIPHERAL_MASK_GET(base_addr)

Macro for getting MPU region configuration mask for the specified peripheral.

Parameters
  • base_addr[in] Peripheral base address.

Returns

MPU configuration mask for the specified peripheral.

Functions

NRF_STATIC_INLINE void nrf_mpu_region0_ram_size_set(NRF_MPU_Type *p_reg, uint32_t size)

Function for setting the size of the RAM region 0.

When memory protection is enabled, the Memory Protection Unit enforces runtime protection and readback protection of resources classified as region 0. See the product specification for more information.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • size[in] Size of the RAM region 0, in bytes. Must be word-aligned.

NRF_STATIC_INLINE void nrf_mpu_region0_peripherals_set(NRF_MPU_Type *p_reg, uint32_t peripheral_mask)

Function for configuring specified peripherals in the memory region 0.

When the memory protection is enabled, the Memory Protection Unit enforces runtime protection and readback protection of resources classified as region 0. See the product specification for more information.

After reset, all peripherals are configured as not assigned to region 0.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • peripheral_mask[in] Mask that specifies peripherals to be configured in the memory region 0. Compose this mask using NRF_MPU_PERIPHERAL_MASK_GET macro.

NRF_STATIC_INLINE uint32_t nrf_mpu_region0_peripherals_get(NRF_MPU_Type const *p_reg)

Function for getting the bitmask that specifies peripherals configured in the memory region 0.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

Returns

Bitmask representing peripherals configured in region 0.

NRF_STATIC_INLINE void nrf_mpu_nvm_blocks_protection_enable(NRF_MPU_Type *p_reg, uint8_t group_idx, uint32_t block_mask)

Function for enabling protection for specified non-volatile memory blocks.

Blocks are arranged into groups of 32 blocks each. Each block size is 4 kB. Any attempt to write or erase a protected block will result in hard fault. The memory block protection can be disabled only by resetting the device.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • group_idx[in] Non-volatile memory group containing memory blocks to protect.

  • block_mask[in] Non-volatile memory blocks to protect. Each bit in bitmask represents one memory block in the specified group.

NRF_STATIC_INLINE void nrf_mpu_nvm_protection_in_debug_set(NRF_MPU_Type *p_reg, bool enable)

Function for setting the non-volatile memory (NVM) protection during debug.

NVM protection during debug is disabled by default.

Parameters
  • p_reg[in] Pointer to the structure of registers of the peripheral.

  • enable[in] True if NVM protection during debug is to be enabled, false otherwise.