EFM32 Happy Gecko Software Documentation  efm32hg-doc-5.1.2
em_mpu.c
Go to the documentation of this file.
1 /***************************************************************************/
33 #include "em_mpu.h"
34 #if defined(__MPU_PRESENT) && (__MPU_PRESENT == 1)
35 #include "em_assert.h"
36 
37 
38 /***************************************************************************/
44 /***************************************************************************/
73 /*******************************************************************************
74  ************************** GLOBAL FUNCTIONS *******************************
75  ******************************************************************************/
76 
77 
78 /***************************************************************************/
91 void MPU_ConfigureRegion(const MPU_RegionInit_TypeDef *init)
92 {
93  EFM_ASSERT(init->regionNo < ((MPU->TYPE & MPU_TYPE_DREGION_Msk) >>
94  MPU_TYPE_DREGION_Pos));
95 
96  MPU->RNR = init->regionNo;
97 
98  if (init->regionEnable)
99  {
100  EFM_ASSERT(!(init->baseAddress & ~MPU_RBAR_ADDR_Msk));
101  EFM_ASSERT(init->tex <= 0x7);
102 
103  MPU->RBAR = init->baseAddress;
104  MPU->RASR = ((init->disableExec ? 1 : 0) << MPU_RASR_XN_Pos)
105  | (init->accessPermission << MPU_RASR_AP_Pos)
106  | (init->tex << MPU_RASR_TEX_Pos)
107  | ((init->shareable ? 1 : 0) << MPU_RASR_S_Pos)
108  | ((init->cacheable ? 1 : 0) << MPU_RASR_C_Pos)
109  | ((init->bufferable ? 1 : 0) << MPU_RASR_B_Pos)
110  | (init->srd << MPU_RASR_SRD_Pos)
111  | (init->size << MPU_RASR_SIZE_Pos)
112  | (1 << MPU_RASR_ENABLE_Pos);
113  }
114  else
115  {
116  MPU->RBAR = 0;
117  MPU->RASR = 0;
118  }
119 }
120 
121 
124 #endif /* defined(__MPU_PRESENT) && (__MPU_PRESENT == 1) */
Memory protection unit (MPU) peripheral API.
Emlib peripheral API "assert" implementation.