Detailed Description

Memory Protection Unit Peripheral Abstraction Layer.

Data Structures

struct  mpu_error_info_t
 MPU detail error access info Implements : mpu_error_info_t_Class. More...
 
struct  mpu_master_access_permission_t
 MPU master access permission. Implements : mpu_master_access_permission_t_Class. More...
 
struct  mpu_region_config_t
 MPU region configuration structure. Implements : mpu_region_config_t_Class. More...
 

Enumerations

enum  mpu_error_access_type_t { MPU_ERROR_TYPE_READ = 0U, MPU_ERROR_TYPE_WRITE = 1U }
 MPU access error Implements : mpu_error_access_type_t_Class. More...
 
enum  mpu_error_attributes_t { MPU_ERROR_USER_MODE_INSTRUCTION_ACCESS = 0U, MPU_ERROR_USER_MODE_DATA_ACCESS = 1U, MPU_ERROR_SUPERVISOR_MODE_INSTRUCTION_ACCESS = 2U, MPU_ERROR_SUPERVISOR_MODE_DATA_ACCESS = 3U }
 MPU access error attributes Implements : mpu_error_attributes_t_Class. More...
 

MPU PAL API

status_t MPU_Init (const mpu_instance_t *const instance, uint8_t regionCnt, const mpu_region_config_t *configPtr)
 Initializes memory protection unit by allocating regions and granting access rights for masters. More...
 
status_t MPU_Deinit (const mpu_instance_t *const instance)
 De-initializes memory protection unit by reseting all regions and masters to default and disable module. More...
 
status_t MPU_GetDefautRegionConfig (const mpu_instance_t *const instance, mpu_master_access_permission_t *masterAccRight, mpu_region_config_t *regionConfig)
 Gets default region configuration. Grants all access rights for masters; disable PID and cache; unlock region descriptor. More...
 
status_t MPU_UpdateRegion (const mpu_instance_t *const instance, uint8_t regionNum, const mpu_region_config_t *configPtr)
 Updates region configuration. More...
 
status_t MPU_EnableRegion (const mpu_instance_t *const instance, uint8_t regionNum, bool enable)
 Enables or disables an exist region configuration. More...
 
bool MPU_GetError (const mpu_instance_t *const instance, uint8_t channel, mpu_error_info_t *errPtr)
 Checks and gets the access error detail information then clear error flag if the error caused by a master. More...
 
enum  mpu_inst_type_t { MPU_INST_TYPE_MPU = 0U }
 Enumeration with the types of peripherals supported by MPU PAL. More...
 

Enumeration Type Documentation

MPU access error Implements : mpu_error_access_type_t_Class.

Enumerator
MPU_ERROR_TYPE_READ 

Error type: read

MPU_ERROR_TYPE_WRITE 

Error type: write

Definition at line 48 of file mpu_pal.h.

MPU access error attributes Implements : mpu_error_attributes_t_Class.

Enumerator
MPU_ERROR_USER_MODE_INSTRUCTION_ACCESS 

Instruction access error in user mode

MPU_ERROR_USER_MODE_DATA_ACCESS 

Data access error in user mode

MPU_ERROR_SUPERVISOR_MODE_INSTRUCTION_ACCESS 

Instruction access error in supervisor mode

MPU_ERROR_SUPERVISOR_MODE_DATA_ACCESS 

Data access error in supervisor mode

Definition at line 58 of file mpu_pal.h.

Enumeration with the types of peripherals supported by MPU PAL.

This enumeration contains the types of peripherals supported by MPU PAL. Implements : mpu_inst_type_t_Class

Enumerator
MPU_INST_TYPE_MPU 

Definition at line 54 of file mpu_pal_mapping.h.

Function Documentation

status_t MPU_Deinit ( const mpu_instance_t *const  instance)

De-initializes memory protection unit by reseting all regions and masters to default and disable module.

Parameters
[in]instanceThe pointer to MPU instance number.
Returns
operation status
  • STATUS_SUCCESS : Operation was successful.
  • STATUS_ERROR : Operation failed due to the region was locked by another master or all masters are locked.
  • STATUS_UNSUPPORTED : Operation was unsupported.

Definition at line 279 of file mpu_pal.c.

status_t MPU_EnableRegion ( const mpu_instance_t *const  instance,
uint8_t  regionNum,
bool  enable 
)

Enables or disables an exist region configuration.

Parameters
[in]instanceThe pointer to MPU instance number.
[in]regionNumThe region number.
[in]enableValid state
  • true : Enable region.
  • false : Disable region.
Returns
operation status
  • STATUS_SUCCESS : Operation was successful.
  • STATUS_ERROR : Operation failed due to the region was locked by another master or all masters are locked.
  • STATUS_UNSUPPORTED : Operation was unsupported.

Definition at line 428 of file mpu_pal.c.

status_t MPU_GetDefautRegionConfig ( const mpu_instance_t *const  instance,
mpu_master_access_permission_t masterAccRight,
mpu_region_config_t regionConfig 
)

Gets default region configuration. Grants all access rights for masters; disable PID and cache; unlock region descriptor.

Parameters
[in]instanceThe pointer to MPU instance number.
[out]masterAccRightThe pointer to master configuration structure, see mpu_master_access_permission_t. The length of array should be defined by number of masters supported by hardware.
[out]regionConfigThe pointer to default region configuration structure, see mpu_region_config_t.
Returns
operation status
  • STATUS_SUCCESS : Operation was successful.
  • STATUS_UNSUPPORTED : Operation was unsupported.

Definition at line 314 of file mpu_pal.c.

bool MPU_GetError ( const mpu_instance_t *const  instance,
uint8_t  channel,
mpu_error_info_t errPtr 
)

Checks and gets the access error detail information then clear error flag if the error caused by a master.

Parameters
[in]instanceThe pointer to MPU instance number.
[in]channelThe error capture channel For MPU: corresponding with the slave port number For SMPU: corresponding with the the master number
[out]errPtrThe pointer to access error info structure, see mpu_error_info_t.
Returns
operation status
  • true : An error has occurred.
  • false : No error has occurred or the operation was unsupported.

Definition at line 465 of file mpu_pal.c.

status_t MPU_Init ( const mpu_instance_t *const  instance,
uint8_t  regionCnt,
const mpu_region_config_t configPtr 
)

Initializes memory protection unit by allocating regions and granting access rights for masters.

Parameters
[in]instanceThe pointer to MPU instance number.
[in]regionCntThe number of regions configured.
[in]configPtrThe pointer to regions configuration structure, see mpu_region_config_t.
Returns
operation status
  • STATUS_SUCCESS : Operation was successful.
  • STATUS_ERROR : Operation failed due to invalid master number or the region was locked by another master or all masters are locked.
  • STATUS_UNSUPPORTED : Operation was unsupported.

Definition at line 216 of file mpu_pal.c.

status_t MPU_UpdateRegion ( const mpu_instance_t *const  instance,
uint8_t  regionNum,
const mpu_region_config_t configPtr 
)

Updates region configuration.

Parameters
[in]instanceThe pointer to MPU instance number.
[in]regionNumThe region number.
[in]configPtrThe pointer to region configuration structure, see mpu_region_config_t.
Returns
operation status
  • STATUS_SUCCESS : Operation was successful.
  • STATUS_ERROR : Operation failed due to invalid master number or the region was locked by another master or all masters are locked.
  • STATUS_UNSUPPORTED : Operation was unsupported.

Definition at line 383 of file mpu_pal.c.