Memory Protection Unit (MPU) Peripheral API. More...
![]() |
Memory Protection Unit (MPU) Peripheral API.
This module contains functions to enable, disable and setup the MPU. The MPU is used to control access attributes and permissions in the memory map. The settings that can be controlled are:
The MPU can be activated and deactivated with functions:
* MPU_Enable(..); * MPU_Disable();
The MPU can control 8 memory regions with individual access control settings. Section attributes and permissions are set with:
* MPU_ConfigureRegion(..);
It is advisable to disable the MPU when altering region settings.
#define MPU_CTRL_HFNMIENA MPU_CTRL_HFNMIENA_Msk |
#define MPU_CTRL_PRIVDEFENA MPU_CTRL_PRIVDEFENA_Msk |
#define MPU_INIT_FLASH_DEFAULT |
{ \ true, /* Enable MPU region. */ \ 0, /* MPU Region number. */ \ FLASH_MEM_BASE, /* Flash base address. */ \ mpuRegionSize1Mb, /* Size - Set to max. */ \ mpuRegionApFullAccess, /* Access permissions. */ \ false, /* Execution allowed. */ \ false, /* Not shareable. */ \ true, /* Cacheable. */ \ false, /* Not bufferable. */ \ 0, /* No subregions. */ \ 0 /* No TEX attributes. */ \ }
Default configuration of MPU region init structure for flash memory.
#define MPU_INIT_PERIPHERAL_DEFAULT |
{ \ true, /* Enable MPU region. */ \ 0, /* MPU Region number. */ \ 0, /* Region base address. */ \ mpuRegionSize32b, /* Size - Set to minimum */ \ mpuRegionApFullAccess, /* Access permissions. */ \ true, /* Execution not allowed. */ \ true, /* Shareable. */ \ false, /* Not cacheable. */ \ true, /* Bufferable. */ \ 0, /* No subregions. */ \ 0 /* No TEX attributes. */ \ }
Default configuration of MPU region init structure for onchip peripherals.
#define MPU_INIT_SRAM_DEFAULT |
{ \ true, /* Enable MPU region. */ \ 1, /* MPU Region number. */ \ RAM_MEM_BASE, /* SRAM base address. */ \ mpuRegionSize128Kb, /* Size - Set to max. */ \ mpuRegionApFullAccess, /* Access permissions. */ \ false, /* Execution allowed. */ \ true, /* Shareable. */ \ true, /* Cacheable. */ \ false, /* Not bufferable. */ \ 0, /* No subregions. */ \ 0 /* No TEX attributes. */ \ }
Default configuration of MPU region init structure for sram memory.
enum MPU_RegionAp_TypeDef |
MPU region access permission attributes.
Size of an MPU region.
void MPU_ConfigureRegion | ( | const MPU_RegionInit_TypeDef * | init | ) |
Configure an MPU region.
Writes to MPU RBAR and RASR registers. Refer to Cortex-M3 Reference Manual, MPU chapter for further details. To disable a region it is only required to set init->regionNo to the desired value and init->regionEnable = false.
[in] | init | Pointer to a structure containing MPU region init information. |
Definition at line 92 of file em_mpu.c.
References MPU_RegionInit_TypeDef::accessPermission, MPU_RegionInit_TypeDef::baseAddress, MPU_RegionInit_TypeDef::bufferable, MPU_RegionInit_TypeDef::cacheable, MPU_RegionInit_TypeDef::disableExec, MPU_RegionInit_TypeDef::regionEnable, MPU_RegionInit_TypeDef::regionNo, MPU_RegionInit_TypeDef::shareable, MPU_RegionInit_TypeDef::size, MPU_RegionInit_TypeDef::srd, and MPU_RegionInit_TypeDef::tex.
__STATIC_INLINE void MPU_Disable | ( | void | ) |
__STATIC_INLINE void MPU_Enable | ( | uint32_t | flags | ) |
Enable the MPU.
Enable MPU and MPU fault exceptions.
[in] | flags | Use a logical OR of MPU_CTRL_PRIVDEFENA and MPU_CTRL_HFNMIENA as needed. |