summaryrefslogtreecommitdiffstatshomepage
path: root/ports/stm32/mpu.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-07-03 00:47:32 +1000
committerDamien George <damien.p.george@gmail.com>2019-07-03 01:27:33 +1000
commitf7eb2c72f76be6033a32247c145128153e3449ac (patch)
treed791eea2fe1d34633c194515d756c6ad4a59f65d /ports/stm32/mpu.h
parent8dcf25e1bd9bfd1c6d8723b6a2d9c27615b109c2 (diff)
downloadmicropython-f7eb2c72f76be6033a32247c145128153e3449ac.tar.gz
micropython-f7eb2c72f76be6033a32247c145128153e3449ac.zip
stm32/eth: Use MPU helper functions to configure MPU for ETH use.
Diffstat (limited to 'ports/stm32/mpu.h')
-rw-r--r--ports/stm32/mpu.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/ports/stm32/mpu.h b/ports/stm32/mpu.h
index d90a768e7a..c0cd2108c1 100644
--- a/ports/stm32/mpu.h
+++ b/ports/stm32/mpu.h
@@ -28,6 +28,8 @@
#if defined(STM32F7) || defined(STM32H7)
+#define MPU_REGION_ETH (MPU_REGION_NUMBER0)
+
#define MPU_CONFIG_DISABLE(srd, size) ( \
MPU_INSTRUCTION_ACCESS_DISABLE << MPU_RASR_XN_Pos \
| MPU_REGION_NO_ACCESS << MPU_RASR_AP_Pos \
@@ -40,6 +42,18 @@
| MPU_REGION_ENABLE << MPU_RASR_ENABLE_Pos \
)
+#define MPU_CONFIG_ETH(size) ( \
+ MPU_INSTRUCTION_ACCESS_DISABLE << MPU_RASR_XN_Pos \
+ | MPU_REGION_FULL_ACCESS << MPU_RASR_AP_Pos \
+ | MPU_TEX_LEVEL1 << MPU_RASR_TEX_Pos \
+ | MPU_ACCESS_SHAREABLE << MPU_RASR_S_Pos \
+ | MPU_ACCESS_NOT_CACHEABLE << MPU_RASR_C_Pos \
+ | MPU_ACCESS_NOT_BUFFERABLE << MPU_RASR_B_Pos \
+ | 0x00 << MPU_RASR_SRD_Pos \
+ | (size) << MPU_RASR_SIZE_Pos \
+ | MPU_REGION_ENABLE << MPU_RASR_ENABLE_Pos \
+ )
+
static inline void mpu_init(void) {
MPU->CTRL = MPU_PRIVILEGED_DEFAULT | MPU_CTRL_ENABLE_Msk;
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;