39 #define ARM_MODE_USR 0x10 41 #define PRIVILEGE_MODE 0 44 #define MPU_DEFAULT_ITCM_REGION (1) 45 #define MPU_DEFAULT_IFLASH_REGION (2) 46 #define MPU_DEFAULT_DTCM_REGION (3) 47 #define MPU_DEFAULT_SRAM_REGION_1 (4) 48 #define MPU_DEFAULT_SRAM_REGION_2 (5) 49 #define MPU_PERIPHERALS_REGION (6) 50 #define MPU_EXT_EBI_REGION (7) 51 #define MPU_DEFAULT_SDRAM_REGION (8) 52 #define MPU_QSPIMEM_REGION (9) 53 #define MPU_USBHSRAM_REGION (10) 54 #if defined MPU_HAS_NOCACHE_REGION 55 #define MPU_NOCACHE_SRAM_REGION (11) 57 #define MPU_SYSTEM_REGION (12) 60 #define MPU_USER_DEFINED_REGION (15) 63 #define MPU_REGION_VALID (0x10) 64 #define MPU_REGION_ENABLE (0x01) 65 #define MPU_REGION_DISABLE (0x0) 67 #define MPU_ENABLE (0x1 << MPU_CTRL_ENABLE_Pos) 68 #define MPU_HFNMIENA (0x1 << MPU_CTRL_HFNMIENA_Pos) 69 #define MPU_PRIVDEFENA (0x1 << MPU_CTRL_PRIVDEFENA_Pos) 72 #define MPU_REGION_BUFFERABLE (0x01 << MPU_RASR_B_Pos) 73 #define MPU_REGION_CACHEABLE (0x01 << MPU_RASR_C_Pos) 74 #define MPU_REGION_SHAREABLE (0x01 << MPU_RASR_S_Pos) 76 #define MPU_REGION_EXECUTE_NEVER (0x01 << MPU_RASR_XN_Pos) 78 #define MPU_AP_NO_ACCESS (0x00 << MPU_RASR_AP_Pos) 79 #define MPU_AP_PRIVILEGED_READ_WRITE (0x01 << MPU_RASR_AP_Pos) 80 #define MPU_AP_UNPRIVILEGED_READONLY (0x02 << MPU_RASR_AP_Pos) 81 #define MPU_AP_FULL_ACCESS (0x03 << MPU_RASR_AP_Pos) 82 #define MPU_AP_RES (0x04 << MPU_RASR_AP_Pos) 83 #define MPU_AP_PRIVILEGED_READONLY (0x05 << MPU_RASR_AP_Pos) 84 #define MPU_AP_READONLY (0x06 << MPU_RASR_AP_Pos) 85 #define MPU_AP_READONLY2 (0x07 << MPU_RASR_AP_Pos) 87 #define MPU_TEX_B000 (0x01 << MPU_RASR_TEX_Pos) 88 #define MPU_TEX_B001 (0x01 << MPU_RASR_TEX_Pos) 89 #define MPU_TEX_B010 (0x01 << MPU_RASR_TEX_Pos) 90 #define MPU_TEX_B011 (0x01 << MPU_RASR_TEX_Pos) 91 #define MPU_TEX_B100 (0x01 << MPU_RASR_TEX_Pos) 92 #define MPU_TEX_B101 (0x01 << MPU_RASR_TEX_Pos) 93 #define MPU_TEX_B110 (0x01 << MPU_RASR_TEX_Pos) 94 #define MPU_TEX_B111 (0x01 << MPU_RASR_TEX_Pos) 110 #define ITCM_START_ADDRESS ((uintptr_t) atsam_memory_itcm_begin) 111 #define ITCM_END_ADDRESS ((uintptr_t) atsam_memory_itcm_end - 1) 112 #define IFLASH_START_ADDRESS ((uintptr_t) atsam_memory_intflash_begin) 113 #define IFLASH_END_ADDRESS ((uintptr_t) atsam_memory_intflash_end - 1) 115 #define ITCM_START_ADDRESS 0x00000000UL 116 #define ITCM_END_ADDRESS 0x003FFFFFUL 117 #define IFLASH_START_ADDRESS 0x00400000UL 118 #define IFLASH_END_ADDRESS 0x005FFFFFUL 122 #define IFLASH_PRIVILEGE_START_ADDRESS (IFLASH_START_ADDRESS) 123 #define IFLASH_PRIVILEGE_END_ADDRESS (IFLASH_START_ADDRESS + 0xFFF) 125 #define IFLASH_UNPRIVILEGE_START_ADDRESS (IFLASH_PRIVILEGE_END_ADDRESS + 1) 126 #define IFLASH_UNPRIVILEGE_END_ADDRESS (IFLASH_END_ADDRESS) 130 #define DTCM_START_ADDRESS ((uintptr_t) atsam_memory_dtcm_begin) 131 #define DTCM_END_ADDRESS ((uintptr_t) atsam_memory_dtcm_end - 1) 133 #define DTCM_START_ADDRESS 0x20000000UL 134 #define DTCM_END_ADDRESS 0x203FFFFFUL 141 #define SRAM_START_ADDRESS ((uintptr_t) atsam_memory_intsram_begin) 142 #define SRAM_END_ADDRESS ((uintptr_t) atsam_memory_intsram_end - 1) 144 #define SRAM_START_ADDRESS 0x20400000UL 145 #define SRAM_END_ADDRESS 0x2045FFFFUL 149 #if defined MPU_HAS_NOCACHE_REGION 150 #define NOCACHE_SRAM_REGION_SIZE 0x1000 156 #define SRAM_FIRST_START_ADDRESS ((uintptr_t) atsam_memory_intsram_begin) 157 #define SRAM_FIRST_END_ADDRESS ((uintptr_t) atsam_memory_intsram_end - 1) 159 #define SRAM_FIRST_START_ADDRESS (SRAM_START_ADDRESS) 160 #define SRAM_FIRST_END_ADDRESS (SRAM_FIRST_START_ADDRESS + 0x3FFFF) // (2^18) 256 KB 163 #if defined MPU_HAS_NOCACHE_REGION 165 #define SRAM_NOCACHE_START_ADDRESS ((uintptr_t) atsam_memory_nocache_begin) 166 #define SRAM_NOCACHE_END_ADDRESS ((uintptr_t) atsam_memory_nocache_end - 1) 167 #define NOCACHE_SRAM_REGION_SIZE (SRAM_NOCACHE_END_ADDRESS - SRAM_NOCACHE_START_ADDRESS) 169 #define SRAM_SECOND_START_ADDRESS (SRAM_FIRST_END_ADDRESS+1) 170 #define SRAM_SECOND_END_ADDRESS (SRAM_END_ADDRESS - NOCACHE_SRAM_REGION_SIZE) // (2^17) 128 - 0x1000 KB 171 #define SRAM_NOCACHE_START_ADDRESS (SRAM_SECOND_END_ADDRESS + 1) 172 #define SRAM_NOCACHE_END_ADDRESS (SRAM_END_ADDRESS) 176 #define SRAM_SECOND_START_ADDRESS (SRAM_FIRST_END_ADDRESS + 1) 177 #define SRAM_SECOND_END_ADDRESS (SRAM_END_ADDRESS) // (2^17) 128 KB 181 #define PERIPHERALS_START_ADDRESS 0x40000000UL 182 #define PERIPHERALS_END_ADDRESS 0x5FFFFFFFUL 184 #define SYSTEM_START_ADDRESS 0xE0000000UL 185 #define SYSTEM_END_ADDRESS 0xFFFFFFFFUL 189 #define EXT_EBI_START_ADDRESS 0x60000000UL 190 #define EXT_EBI_END_ADDRESS 0x6FFFFFFFUL 194 #define SDRAM_START_ADDRESS ((uintptr_t) atsam_memory_sdram_begin) 195 #define SDRAM_END_ADDRESS ((uintptr_t) atsam_memory_sdram_end - 1) 197 #define SDRAM_START_ADDRESS 0x70000000UL 198 #define SDRAM_END_ADDRESS 0x7FFFFFFFUL 203 #define QSPI_START_ADDRESS ((uintptr_t) atsam_memory_qspiflash_begin) 204 #define QSPI_END_ADDRESS ((uintptr_t) atsam_memory_qspiflash_end - 1) 206 #define QSPI_START_ADDRESS 0x80000000UL 207 #define QSPI_END_ADDRESS 0x9FFFFFFFUL 211 #define USBHSRAM_START_ADDRESS 0xA0100000UL 212 #define USBHSRAM_END_ADDRESS 0xA01FFFFFUL 218 void MPU_SetRegion(uint32_t dwRegionBaseAddr, uint32_t dwRegionAttr);
223 uint32_t dwRegionAttr);
void MPU_SetRegionNum(uint32_t dwRegionNum)
Set active memory region.
Definition: mpu.c:88
void MPU_DisableRegion(void)
Disable the current active region.
Definition: mpu.c:96
uint32_t MPU_CalMPURegionSize(uint32_t dwActualSizeInBytes)
Calculate region size for the RASR.
Definition: mpu.c:117
void MPU_UpdateRegions(uint32_t dwRegionNum, uint32_t dwRegionBaseAddr, uint32_t dwRegionAttr)
Update MPU regions.
Definition: mpu.c:140
void MPU_SetRegion(uint32_t dwRegionBaseAddr, uint32_t dwRegionAttr)
Setup a memory region.
Definition: mpu.c:107
void MPU_Enable(uint32_t dwMPUEnable)
Enables the MPU module.
Definition: mpu.c:78