MT2523 API Reference  LinkIt SDK v4
MPU

This section describes the programming interfaces of MPU HAL driver. More...

Overview

This section describes the programming interfaces of MPU HAL driver.

The MPU is an optional component in ARMv7-M architecture, that provides control of access rights on physical addresses. The processor supports a standard ARMv7 Protected Memory System Architecture model. The MPU divides the memory map into a number of regions, and defines the location, size, access permissions and memory attributes of each region. The Cortex-M4 MPU defines eight separate memory regions as well as a background region. The Cortex-M4 MPU memory map is unified. This means instruction accesses and data accesses have the same region settings. The MPU provides full support for:

MPU mismatches and permission violations invoke the programmable-priority MemManage fault handler.
You can use the MPU to:

Terms and acronyms

The following provides descriptions to the terms commonly used in the MPU driver and how to use its various functions.

Terms Details
MPU Memory Protection Unit. For more information, please refer to ARMv7-M Architecture Reference Manual.

Supported features

The MPU HAL driver enables configuration of location, size and access permissions for each region. The configuration of memory attributes (TEX, C, B bits field of the Region Attribute and Size Register) is not supported. Call the MPU APIs to configure the MPU, as shown below:

How to use this driver

The MPU HAL driver APIs enable the user to perform the following.

Functions

hal_mpu_status_t hal_mpu_init (const hal_mpu_config_t *mpu_config)
 MPU initialization function. More...
 
hal_mpu_status_t hal_mpu_deinit (void)
 MPU deinitialization function. More...
 
hal_mpu_status_t hal_mpu_enable (void)
 MPU enable function. More...
 
hal_mpu_status_t hal_mpu_disable (void)
 MPU disable function. More...
 
hal_mpu_status_t hal_mpu_region_enable (hal_mpu_region_t region)
 MPU region enable function. More...
 
hal_mpu_status_t hal_mpu_region_disable (hal_mpu_region_t region)
 MPU region disable function. More...
 
hal_mpu_status_t hal_mpu_region_configure (hal_mpu_region_t region, const hal_mpu_region_config_t *region_config)
 MPU region configuration function. More...
 

Modules

 Enum
 
 Struct
 

Function Documentation

hal_mpu_status_t hal_mpu_deinit ( void  )

MPU deinitialization function.

This function resets the MPU registers to their default values.

Returns
HAL_MPU_STATUS_OK, MPU is successfully deinitialized.
hal_mpu_status_t hal_mpu_disable ( void  )

MPU disable function.

Disables the MPU settings.

See also
hal_mpu_enable().
Returns
HAL_MPU_STATUS_OK, MPU is successfully disabled.
hal_mpu_status_t hal_mpu_enable ( void  )

MPU enable function.

Enables the MPU settings during a memory access.

See also
hal_mpu_disable().
Returns
HAL_MPU_STATUS_OK, MPU is successfully enabled .
hal_mpu_status_t hal_mpu_init ( const hal_mpu_config_t mpu_config)

MPU initialization function.

Parameters
[in]mpu_configis the configuration information for MPU.
Returns
HAL_MPU_STATUS_OK, MPU is successfully initialized.
HAL_MPU_STATUS_INVALID_PARAMETER, mpu_config is NULL.
HAL_MPU_STATUS_ERROR_BUSY, MPU is busy.
hal_mpu_status_t hal_mpu_region_configure ( hal_mpu_region_t  region,
const hal_mpu_region_config_t region_config 
)

MPU region configuration function.

Parameters
[in]regionis the region that is configured.
[in]region_configis the configuration information of the region.
Returns
HAL_MPU_STATUS_OK, MPU region is successfully configured.
HAL_MPU_STATUS_INVALID_PARAMETER, region_config is NULL.
HAL_MPU_STATUS_ERROR_REGION, the region is invalid.
HAL_MPU_STATUS_ERROR_REGION_SIZE, the region size is invalid.
HAL_MPU_STATUS_ERROR_REGION_ADDRESS, the region address is invalid.
hal_mpu_status_t hal_mpu_region_disable ( hal_mpu_region_t  region)

MPU region disable function.

Disables the specified region, when this function is called, the settings of corresponding region are disabled even if the hal_mpu_enable() function is called.

See also
hal_mpu_disable().
Parameters
[in]regionis the region that is disabled, this parameter can only be a value of type hal_mpu_region_t.
Returns
HAL_MPU_STATUS_OK, MPU region is successfully disabled.
HAL_MPU_STATUS_ERROR_REGION, the region is invalid.
hal_mpu_status_t hal_mpu_region_enable ( hal_mpu_region_t  region)

MPU region enable function.

Enables the specified region, when the hal_mpu_enable() is called, the settings of the corresponding region take effect.

See also
hal_mpu_enable().
Parameters
[in]regionis the region that is enabled, this parameter can only be a value of type hal_mpu_region_t.
Returns
HAL_MPU_STATUS_OK, MPU region is successfully enabled.
HAL_MPU_STATUS_ERROR_REGION, the region is invalid.