This section describes the programming interface of the MPU Peripheral driver. The MPU driver configures MPU.
MPU Initialization
To initialize the MPU module, call the MPU_DRV_Init() function and provide the user configuration data structure. This function sets the configuration of the MPU module automatically and enables the MPU module.
Note that the configuration start address, end address, the region valid value and the debugger's access permission for the MPU region 0 cannot be changed.
This is example code to configure the MPU driver:
struct mpu_access_rights_t mpuAccessRights{
.m0Process_identifier = kMPUIdentifierDisable;
.m1Process_identifier = kMPUIdentifierDisable;
.m2Process_identifier = kMPUIdentifierDisable;
.m3Process_identifier = kMPUIdentifierDisable;
.m4WriteControl = kMPUAccessDisable;
.m4ReadControl = kMPUAccessDisable;
.m5WriteControl = kMPUAccessDisable;
.m5ReadControl = kMPUAccessDisable;
.m6WriteControl = kMPUAccessDisable;
.m6ReadControl = kMPUAccessDisable;
.m7WriteControl = kMPUAccessDisable;
.m7ReadControl = kMPUAccessDisable;
};
.startAddr = 0x0;
.endAddr = 0xffffffff;
.accessRights = mpuAccessRights;
};
.next = NULL;
MPU Interrupt
- The interrupt corresponding to BUSFAULT causes an error by accessing the core.
- Definition for the MPU IRQ function.
void MPU_DRV_IRQHandler(uint32_t instance)
{
assert(instance < HW_MPU_INSTANCE_COUNT);
if (mpu_state_ptrs[instance])
{
if (mpu_state_ptrs[instance]->userCallbackFunc)
{
(*(mpu_state_ptrs[instance]->userCallbackFunc))();
}
}
}
|
struct | mpu_user_config_t |
| Data The section describes the programming interface of the for MPU region initialization. More...
|
|
|
MPU_Type *const | g_mpuBase [] |
| Table of base addresses for MPU instances. More...
|
|
const IRQn_Type | g_mpuIrqId [MPU_INSTANCE_COUNT] |
| Table to save MPU IRQ enumeration numbers defined in the CMSIS header file. More...
|
|
|
MPU driver user callback function.
The contents of this structure provides a callback function.
|
mpu_status_t | MPU_DRV_Init (uint32_t instance, const mpu_user_config_t *userConfigPtr) |
| Initializes the MPU driver. More...
|
|
void | MPU_DRV_Deinit (uint32_t instance) |
| Deinitializes the MPU region. More...
|
|
mpu_status_t | MPU_DRV_SetRegionConfig (uint32_t instance, const mpu_region_config_t *regionConfigPtr) |
| Configures the MPU region. More...
|
|
void | MPU_DRV_SetRegionAddr (uint32_t instance, mpu_region_num_t regionNum, uint32_t startAddr, uint32_t endAddr) |
| Sets the region start address. More...
|
|
mpu_status_t | MPU_DRV_SetLowMasterAccessRights (uint32_t instance, mpu_region_num_t regionNum, mpu_master_t masterNum, const mpu_low_masters_access_rights_t *accessRightsPtr) |
| Configures the low master access permission. More...
|
|
mpu_status_t | MPU_DRV_SetHighMasterAccessRights (uint32_t instance, mpu_region_num_t regionNum, mpu_master_t masterNum, const mpu_high_masters_access_rights_t *accessRightsPtr) |
| Configures the high master access permission. More...
|
|
void | MPU_DRV_SetRegionValidCmd (uint32_t instance, mpu_region_num_t regionNum, bool enable) |
| Sets the MPU region valid. More...
|
|
mpu_status_t | MPU_DRV_GetDetailErrorAccessInfo (uint32_t instance, mpu_access_err_info_t *errInfoArrayPtr) |
| Gets the MPU access error detail information. More...
|
|
This structure is used when calling the MPU_DRV_Init function.
- Parameters
-
instance | The MPU peripheral instance number. |
userConfigPtr | The pointer to the MPU user configure structure, see mpu_user_config_t. |
userStatePtr | The pointer of run time structure. |
- Returns
- kStatus_MPU_Success means success. Otherwise, means failure.
void MPU_DRV_Deinit |
( |
uint32_t |
instance | ) |
|
- Parameters
-
instance | The MPU peripheral instance number. |
- Parameters
-
instance | The MPU peripheral instance number. |
regionConfigPtr | The pointer to the MPU user configure structure, see mpu_region_config_t. |
- Returns
- kStatus_MPU_Success means success. Otherwise, means failure.
void MPU_DRV_SetRegionAddr |
( |
uint32_t |
instance, |
|
|
mpu_region_num_t |
regionNum, |
|
|
uint32_t |
startAddr, |
|
|
uint32_t |
endAddr |
|
) |
| |
- Parameters
-
instance | The MPU peripheral instance number. |
regionNum | The region number. |
startAddr | Region start address. |
endAddr | Region end address. |
- Parameters
-
instance | The MPU peripheral instance number. |
regionNum | The MPU region number. |
masterNum | The MPU master number. |
accessRightsPtr | A pointer to access permission structure. |
- Returns
- kStatus_MPU_Success means success. Otherwise, means failure.
- Parameters
-
instance | The MPU peripheral instance number. |
regionNum | The MPU region number. |
masterNum | The MPU master number. |
accessRightsPtr | A pointer to access permission structure. |
- Returns
- kStatus_MPU_Success means success. Otherwise, means failure.
void MPU_DRV_SetRegionValidCmd |
( |
uint32_t |
instance, |
|
|
mpu_region_num_t |
regionNum, |
|
|
bool |
enable |
|
) |
| |
- Parameters
-
instance | The MPU peripheral instance number. |
regionNum | MPU region number. |
enable | Enables or disables region. |
- Parameters
-
instance | The MPU peripheral instance number. |
errInfoArrayPtr | A pointer to access error info structure. |
- Returns
- kStatus_MPU_Success means success. Otherwise, means failure.
MPU_Type* const g_mpuBase[] |
const IRQn_Type g_mpuIrqId[MPU_INSTANCE_COUNT] |