MPUEMLIB
Detailed Description
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:
- Executable attribute.
- Cachable, bufferable and shareable attributes.
- Cache policy.
- Access permissions: Priviliged or User state, read or write access, and combinations of all these.
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.
Data Structures |
|
struct | MPU_RegionInit_TypeDef |
Macros |
|
#define | MPU_CTRL_HFNMIENA MPU_CTRL_HFNMIENA_Msk |
#define | MPU_CTRL_PRIVDEFENA MPU_CTRL_PRIVDEFENA_Msk |
#define | MPU_INIT_FLASH_DEFAULT |
#define | MPU_INIT_PERIPHERAL_DEFAULT |
#define | MPU_INIT_SRAM_DEFAULT |
Enumerations |
|
enum |
MPU_RegionAp_TypeDef
{
mpuRegionNoAccess = 0, mpuRegionApPRw = 1, mpuRegionApPRwURo = 2, mpuRegionApFullAccess = 3, mpuRegionApPRo = 5, mpuRegionApPRo_URo = 6 } |
enum |
MPU_RegionSize_TypeDef
{
mpuRegionSize32b = 4, mpuRegionSize64b = 5, mpuRegionSize128b = 6, mpuRegionSize256b = 7, mpuRegionSize512b = 8, mpuRegionSize1Kb = 9, mpuRegionSize2Kb = 10, mpuRegionSize4Kb = 11, mpuRegionSize8Kb = 12, mpuRegionSize16Kb = 13, mpuRegionSize32Kb = 14, mpuRegionSize64Kb = 15, mpuRegionSize128Kb = 16, mpuRegionSize256Kb = 17, mpuRegionSize512Kb = 18, mpuRegionSize1Mb = 19, mpuRegionSize2Mb = 20, mpuRegionSize4Mb = 21, mpuRegionSize8Mb = 22, mpuRegionSize16Mb = 23, mpuRegionSize32Mb = 24, mpuRegionSize64Mb = 25, mpuRegionSize128Mb = 26, mpuRegionSize256Mb = 27, mpuRegionSize512Mb = 28, mpuRegionSize1Gb = 29, mpuRegionSize2Gb = 30, mpuRegionSize4Gb = 31 } |
Functions |
|
void | MPU_ConfigureRegion (const MPU_RegionInit_TypeDef *init) |
Configure an MPU region.
|
|
__STATIC_INLINE void | MPU_Disable (void) |
Disable the MPU.
|
|
__STATIC_INLINE void | MPU_Enable (uint32_t flags) |
Enable the MPU.
|
|
Macro Definition Documentation
#define MPU_CTRL_HFNMIENA MPU_CTRL_HFNMIENA_Msk |
#define MPU_CTRL_PRIVDEFENA MPU_CTRL_PRIVDEFENA_Msk |
#define MPU_INIT_FLASH_DEFAULT |
Default configuration of MPU region init structure for flash memory.
Definition at line
137
of file
em_mpu.h
.
#define MPU_INIT_PERIPHERAL_DEFAULT |
Default configuration of MPU region init structure for onchip peripherals.
Definition at line
169
of file
em_mpu.h
.
#define MPU_INIT_SRAM_DEFAULT |
Default configuration of MPU region init structure for sram memory.
Definition at line
153
of file
em_mpu.h
.
Enumeration Type Documentation
enum MPU_RegionAp_TypeDef |
MPU region access permission attributes.
Definition at line
108
of file
em_mpu.h
.
Size of an MPU region.
Definition at line
74
of file
em_mpu.h
.
Function Documentation
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.
- Parameters
-
[in] init
Pointer to a structure containing MPU region init information.
Definition at line
87
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 |
|
) |
Disable the MPU.
Disable MPU and MPU fault exceptions.
Definition at line
196
of file
em_mpu.h
.
__STATIC_INLINE void MPU_Enable | ( | uint32_t |
flags
|
) |
Enable the MPU.
Enable MPU and MPU fault exceptions.
- Parameters
-
[in] flags
Use a logical OR of MPU_CTRL_PRIVDEFENA and MPU_CTRL_HFNMIENA as needed.
Definition at line
213
of file
em_mpu.h
.