STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches
mpu_reg.h File Reference

MPU registers: the Armv7-M memory protection unit (PM0214, MPU chapter). More...

#include <stdint.h>
Include dependency graph for mpu_reg.h:

Go to the source code of this file.

Data Structures

struct  MpuRegisters_t
 MPU register block. More...

Macros

#define MPU_BASE   (0xE000ED90UL)
 MPU base address (System Control Space).
#define MPU   ((MpuRegisters_t *)MPU_BASE)
 The MPU instance.
TYPE - MPU type (0x00)
#define MPU_TYPE_SEPARATE_Pos   (0U)
 Bit 0.
#define MPU_TYPE_SEPARATE   ((uint32_t)1U << MPU_TYPE_SEPARATE_Pos)
  ro Separate instruction and data maps (0 on the Cortex-M4).
#define MPU_TYPE_DREGION_Pos   (8U)
 Bits 15:8.
#define MPU_TYPE_DREGION_Msk   ((uint32_t)0xFFU << MPU_TYPE_DREGION_Pos)
  ro Number of regions.
CTRL - control (0x04)
#define MPU_CTRL_ENABLE_Pos   (0U)
 Bit 0.
#define MPU_CTRL_ENABLE   ((uint32_t)1U << MPU_CTRL_ENABLE_Pos)
  rw Enable the MPU.
#define MPU_CTRL_HFNMIENA_Pos   (1U)
 Bit 1.
#define MPU_CTRL_HFNMIENA   ((uint32_t)1U << MPU_CTRL_HFNMIENA_Pos)
  rw Keep the MPU on in HardFault, NMI and FAULTMASK handlers.
#define MPU_CTRL_PRIVDEFENA_Pos   (2U)
 Bit 2.
#define MPU_CTRL_PRIVDEFENA   ((uint32_t)1U << MPU_CTRL_PRIVDEFENA_Pos)
  rw Privileged code may use the default memory map as a background region.
RNR - region number (0x08)
#define MPU_RNR_REGION_Pos   (0U)
 Bits 7:0.
#define MPU_RNR_REGION_Msk   ((uint32_t)0xFFU << MPU_RNR_REGION_Pos)
  rw Region that RBAR and RASR access.
RBAR - region base address (0x0C)
#define MPU_RBAR_REGION_Pos   (0U)
 Bits 3:0.
#define MPU_RBAR_REGION_Msk   ((uint32_t)0xFU << MPU_RBAR_REGION_Pos)
  rw Region number, used when VALID is set.
#define MPU_RBAR_VALID_Pos   (4U)
 Bit 4.
#define MPU_RBAR_VALID   ((uint32_t)1U << MPU_RBAR_VALID_Pos)
  wo Write REGION into RNR as part of this write.
#define MPU_RBAR_ADDR_Pos   (5U)
 Bits 31:5.
#define MPU_RBAR_ADDR_Msk   ((uint32_t)0x7FFFFFFU << MPU_RBAR_ADDR_Pos)
  rw Region base address, aligned to the region size.
RASR - region attribute and size (0x10)

Every field is rw.

#define MPU_RASR_ENABLE_Pos   (0U)
 Bit 0.
#define MPU_RASR_ENABLE   ((uint32_t)1U << MPU_RASR_ENABLE_Pos)
 Enable this region.
#define MPU_RASR_SIZE_Pos   (1U)
 Bits 5:1.
#define MPU_RASR_SIZE_Msk   ((uint32_t)0x1FU << MPU_RASR_SIZE_Pos)
 Region size: 2^(SIZE + 1) bytes, minimum 32.
#define MPU_RASR_SRD_Pos   (8U)
 Bits 15:8.
#define MPU_RASR_SRD_Msk   ((uint32_t)0xFFU << MPU_RASR_SRD_Pos)
 Subregion disable: one bit per eighth of the region.
#define MPU_RASR_B_Pos   (16U)
 Bit 16.
#define MPU_RASR_B   ((uint32_t)1U << MPU_RASR_B_Pos)
 Bufferable.
#define MPU_RASR_C_Pos   (17U)
 Bit 17.
#define MPU_RASR_C   ((uint32_t)1U << MPU_RASR_C_Pos)
 Cacheable.
#define MPU_RASR_S_Pos   (18U)
 Bit 18.
#define MPU_RASR_S   ((uint32_t)1U << MPU_RASR_S_Pos)
 Shareable.
#define MPU_RASR_TEX_Pos   (19U)
 Bits 21:19.
#define MPU_RASR_TEX_Msk   ((uint32_t)0x7U << MPU_RASR_TEX_Pos)
 Type extension.
#define MPU_RASR_AP_Pos   (24U)
 Bits 26:24.
#define MPU_RASR_AP_Msk   ((uint32_t)0x7U << MPU_RASR_AP_Pos)
 Access permission; values below.
#define MPU_RASR_XN_Pos   (28U)
 Bit 28.
#define MPU_RASR_XN   ((uint32_t)1U << MPU_RASR_XN_Pos)
 Execute never.
RASR.AP values
#define MPU_RASR_AP_NONE   (0x0U)
 No access.
#define MPU_RASR_AP_PRIV_RW   (0x1U)
 Privileged read/write only.
#define MPU_RASR_AP_PRIV_RW_UNPRIV_RO   (0x2U)
 Privileged read/write, unprivileged read.
#define MPU_RASR_AP_FULL_RW   (0x3U)
 Full read/write.
#define MPU_RASR_AP_PRIV_RO   (0x5U)
 Privileged read only.
#define MPU_RASR_AP_FULL_RO   (0x6U)
 Read only.

Typedefs

typedef struct MpuRegisters_t MpuRegisters_t
 MPU register block.

Detailed Description

MPU registers: the Armv7-M memory protection unit (PM0214, MPU chapter).

The F446's Cortex-M4 has 8 regions (TYPE.DREGION). A region is selected through RNR, or through RBAR with VALID set. The RBAR/RASR aliases let up to four regions be written back to back without rewriting RNR.

Definition in file mpu_reg.h.