46 #define ARM_MODE_USR 0x10 48 #define PRIVILEGE_MODE 0 51 #define MPU_DEFAULT_ITCM_REGION ( 1 ) 52 #define MPU_DEFAULT_IFLASH_REGION ( 2 ) 53 #define MPU_DEFAULT_DTCM_REGION ( 3 ) 54 #define MPU_DEFAULT_SRAM_REGION_1 ( 4 ) 55 #define MPU_DEFAULT_SRAM_REGION_2 ( 5 ) 56 #define MPU_PERIPHERALS_REGION ( 6 ) 57 #define MPU_EXT_EBI_REGION ( 7 ) 58 #define MPU_DEFAULT_SDRAM_REGION ( 8 ) 59 #define MPU_QSPIMEM_REGION ( 9 ) 60 #define MPU_USBHSRAM_REGION ( 10 ) 61 #if defined MPU_HAS_NOCACHE_REGION 62 #define MPU_NOCACHE_SRAM_REGION ( 11 ) 65 #define MPU_REGION_VALID ( 0x10 ) 66 #define MPU_REGION_ENABLE ( 0x01 ) 67 #define MPU_REGION_DISABLE ( 0x0 ) 69 #define MPU_ENABLE ( 0x1 << MPU_CTRL_ENABLE_Pos) 70 #define MPU_HFNMIENA ( 0x1 << MPU_CTRL_HFNMIENA_Pos ) 71 #define MPU_PRIVDEFENA ( 0x1 << MPU_CTRL_PRIVDEFENA_Pos ) 74 #define MPU_REGION_BUFFERABLE ( 0x01 << MPU_RASR_B_Pos ) 75 #define MPU_REGION_CACHEABLE ( 0x01 << MPU_RASR_C_Pos ) 76 #define MPU_REGION_SHAREABLE ( 0x01 << MPU_RASR_S_Pos ) 78 #define MPU_REGION_EXECUTE_NEVER ( 0x01 << MPU_RASR_XN_Pos ) 80 #define MPU_AP_NO_ACCESS ( 0x00 << MPU_RASR_AP_Pos ) 81 #define MPU_AP_PRIVILEGED_READ_WRITE ( 0x01 << MPU_RASR_AP_Pos ) 82 #define MPU_AP_UNPRIVILEGED_READONLY ( 0x02 << MPU_RASR_AP_Pos ) 83 #define MPU_AP_FULL_ACCESS ( 0x03 << MPU_RASR_AP_Pos ) 84 #define MPU_AP_RES ( 0x04 << MPU_RASR_AP_Pos ) 85 #define MPU_AP_PRIVILEGED_READONLY ( 0x05 << MPU_RASR_AP_Pos ) 86 #define MPU_AP_READONLY ( 0x06 << MPU_RASR_AP_Pos ) 87 #define MPU_AP_READONLY2 ( 0x07 << MPU_RASR_AP_Pos ) 89 #define MPU_TEX_B000 ( 0x01 << MPU_RASR_TEX_Pos ) 90 #define MPU_TEX_B001 ( 0x01 << MPU_RASR_TEX_Pos ) 91 #define MPU_TEX_B010 ( 0x01 << MPU_RASR_TEX_Pos ) 92 #define MPU_TEX_B011 ( 0x01 << MPU_RASR_TEX_Pos ) 93 #define MPU_TEX_B100 ( 0x01 << MPU_RASR_TEX_Pos ) 94 #define MPU_TEX_B101 ( 0x01 << MPU_RASR_TEX_Pos ) 95 #define MPU_TEX_B110 ( 0x01 << MPU_RASR_TEX_Pos ) 96 #define MPU_TEX_B111 ( 0x01 << MPU_RASR_TEX_Pos ) 99 #define NON_SHAREABLE 0 101 #define INNER_NORMAL_WB_RWA_TYPE(x) (( 0x04 << MPU_RASR_TEX_Pos ) | ( DISABLE << MPU_RASR_C_Pos ) | ( ENABLE << MPU_RASR_B_Pos ) | ( x << MPU_RASR_S_Pos )) 102 #define INNER_NORMAL_WB_NWA_TYPE(x) (( 0x04 << MPU_RASR_TEX_Pos ) | ( ENABLE << MPU_RASR_C_Pos ) | ( ENABLE << MPU_RASR_B_Pos ) | ( x << MPU_RASR_S_Pos )) 103 #define STRONGLY_ORDERED_SHAREABLE_TYPE (( 0x00 << MPU_RASR_TEX_Pos ) | ( DISABLE << MPU_RASR_C_Pos ) | ( DISABLE << MPU_RASR_B_Pos )) // DO not care // 104 #define SHAREABLE_DEVICE_TYPE (( 0x00 << MPU_RASR_TEX_Pos ) | ( DISABLE << MPU_RASR_C_Pos ) | ( ENABLE << MPU_RASR_B_Pos )) // DO not care // 120 #define ITCM_START_ADDRESS 0x00000000UL 121 #define ITCM_END_ADDRESS 0x003FFFFFUL 122 #define IFLASH_START_ADDRESS 0x00400000UL 123 #define IFLASH_END_ADDRESS 0x005FFFFFUL 126 #define IFLASH_PRIVILEGE_START_ADDRESS (IFLASH_START_ADDRESS) 127 #define IFLASH_PRIVILEGE_END_ADDRESS (IFLASH_START_ADDRESS + 0xFFF) 129 #define IFLASH_UNPRIVILEGE_START_ADDRESS (IFLASH_PRIVILEGE_END_ADDRESS + 1) 130 #define IFLASH_UNPRIVILEGE_END_ADDRESS (IFLASH_END_ADDRESS) 133 #define DTCM_START_ADDRESS 0x20000000UL 134 #define DTCM_END_ADDRESS 0x203FFFFFUL 139 #define SRAM_START_ADDRESS 0x20400000UL 140 #define SRAM_END_ADDRESS 0x2045FFFFUL 142 #if defined MPU_HAS_NOCACHE_REGION 143 #define NOCACHE_SRAM_REGION_SIZE 0x1000 147 #define SRAM_FIRST_START_ADDRESS (SRAM_START_ADDRESS) 148 #define SRAM_FIRST_END_ADDRESS (SRAM_FIRST_START_ADDRESS + 0x3FFFF) // (2^18) 256 KB 150 #if defined MPU_HAS_NOCACHE_REGION 151 #define SRAM_SECOND_START_ADDRESS (SRAM_FIRST_END_ADDRESS+1) 152 #define SRAM_SECOND_END_ADDRESS (SRAM_END_ADDRESS - NOCACHE_SRAM_REGION_SIZE ) // (2^17) 128 - 0x1000 KB 153 #define SRAM_NOCACHE_START_ADDRESS (SRAM_SECOND_END_ADDRESS + 1) 154 #define SRAM_NOCACHE_END_ADDRESS (SRAM_END_ADDRESS ) 156 #define SRAM_SECOND_START_ADDRESS (SRAM_FIRST_END_ADDRESS + 1) 157 #define SRAM_SECOND_END_ADDRESS (SRAM_END_ADDRESS) // (2^17) 128 KB 160 #define PERIPHERALS_START_ADDRESS 0x40000000UL 161 #define PERIPHERALS_END_ADDRESS 0x5FFFFFFFUL 164 #define EXT_EBI_START_ADDRESS 0x60000000UL 165 #define EXT_EBI_END_ADDRESS 0x6FFFFFFFUL 168 #define SDRAM_START_ADDRESS 0x70000000UL 169 #define SDRAM_END_ADDRESS 0x7FFFFFFFUL 172 #define QSPI_START_ADDRESS 0x80000000UL 173 #define QSPI_END_ADDRESS 0x9FFFFFFFUL 176 #define USBHSRAM_START_ADDRESS 0xA0100000UL 177 #define USBHSRAM_END_ADDRESS 0xA01FFFFFUL 183 void mpu_set_region(uint32_t dw_region_base_addr, uint32_t dw_region_attr);
187 void mpu_update_regions(uint32_t dw_region_num, uint32_t dw_region_base_addr, uint32_t dw_region_attr);
void mpu_update_regions(uint32_t dw_region_num, uint32_t dw_region_base_addr, uint32_t dw_region_attr)
Update MPU regions.
void mpu_disable_region(void)
Disable the current active region.
void mpu_set_region(uint32_t dw_region_base_addr, uint32_t dw_region_attr)
Setup a memory region.
Commonly used includes, types and macros.
uint32_t mpu_cal_mpu_region_size(uint32_t dw_actual_size_in_bytes)
Calculate region size for the RASR.
void mpu_enable(uint32_t dw_mpu_enable)
Enables the MPU module.
void mpu_set_region_num(uint32_t dw_region_num)
Set active memory region.