EFR32 Mighty Gecko 1 Software Documentation  efr32mg1-doc-5.1.2

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:

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. More...
 
__STATIC_INLINE void MPU_Disable (void)
 Disable the MPU. More...
 
__STATIC_INLINE void MPU_Enable (uint32_t flags)
 Enable the MPU. More...
 

Macro Definition Documentation

#define MPU_CTRL_HFNMIENA   MPU_CTRL_HFNMIENA_Msk

Argument to MPU_enable(). Enables MPU during hard fault, NMI, and FAULTMASK handlers.

Definition at line 65 of file em_mpu.h.

#define MPU_CTRL_PRIVDEFENA   MPU_CTRL_PRIVDEFENA_Msk

Argument to MPU_enable(). Enables priviledged access to default memory map.

Definition at line 60 of file em_mpu.h.

#define MPU_INIT_FLASH_DEFAULT
Value:
{ \
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. */ \
}
#define FLASH_MEM_BASE

Default configuration of MPU region init structure for flash memory.

Definition at line 141 of file em_mpu.h.

#define MPU_INIT_PERIPHERAL_DEFAULT
Value:
{ \
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.

Definition at line 175 of file em_mpu.h.

#define MPU_INIT_SRAM_DEFAULT
Value:
{ \
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. */ \
}
#define RAM_MEM_BASE

Default configuration of MPU region init structure for sram memory.

Definition at line 158 of file em_mpu.h.

Enumeration Type Documentation

MPU region access permission attributes.

Enumerator
mpuRegionNoAccess 

No access what so ever.

mpuRegionApPRw 

Priviledged state R/W only.

mpuRegionApPRwURo 

Priviledged state R/W, User state R only.

mpuRegionApFullAccess 

R/W in Priviledged and User state.

mpuRegionApPRo 

Priviledged R only.

mpuRegionApPRo_URo 

R only in Priviledged and User state.

Definition at line 109 of file em_mpu.h.

Size of an MPU region.

Enumerator
mpuRegionSize32b 

32 byte region size.

mpuRegionSize64b 

64 byte region size.

mpuRegionSize128b 

128 byte region size.

mpuRegionSize256b 

256 byte region size.

mpuRegionSize512b 

512 byte region size.

mpuRegionSize1Kb 

1K byte region size.

mpuRegionSize2Kb 

2K byte region size.

mpuRegionSize4Kb 

4K byte region size.

mpuRegionSize8Kb 

8K byte region size.

mpuRegionSize16Kb 

16K byte region size.

mpuRegionSize32Kb 

32K byte region size.

mpuRegionSize64Kb 

64K byte region size.

mpuRegionSize128Kb 

128K byte region size.

mpuRegionSize256Kb 

256K byte region size.

mpuRegionSize512Kb 

512K byte region size.

mpuRegionSize1Mb 

1M byte region size.

mpuRegionSize2Mb 

2M byte region size.

mpuRegionSize4Mb 

4M byte region size.

mpuRegionSize8Mb 

8M byte region size.

mpuRegionSize16Mb 

16M byte region size.

mpuRegionSize32Mb 

32M byte region size.

mpuRegionSize64Mb 

64M byte region size.

mpuRegionSize128Mb 

128M byte region size.

mpuRegionSize256Mb 

256M byte region size.

mpuRegionSize512Mb 

512M byte region size.

mpuRegionSize1Gb 

1G byte region size.

mpuRegionSize2Gb 

2G byte region size.

mpuRegionSize4Gb 

4G byte region size.

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]initPointer to a structure containing MPU region init information.

Definition at line 91 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 205 of file em_mpu.h.

__STATIC_INLINE void MPU_Enable ( uint32_t  flags)

Enable the MPU.

Enable MPU and MPU fault exceptions.

Parameters
[in]flagsUse a logical OR of MPU_CTRL_PRIVDEFENA and MPU_CTRL_HFNMIENA as needed.

Definition at line 221 of file em_mpu.h.