summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriabdalkader <i.abdalkader@gmail.com>2024-07-20 10:37:26 +0300
committerDamien George <damien@micropython.org>2024-08-08 18:02:13 +1000
commit9a48ce3051744fac20762199d67ffc380c1de1f6 (patch)
tree1a277340e6046286fbb4f6049a6c3002c591f54f
parentbc7e39d549678e3c51fa667ad2097f6eb2da6987 (diff)
stm32/mpu: Define the last used MPU region number.
The reason for this change is that it makes allows custom code, that needs to use an MPU region, to find a free one by using this macro or starting from the max number and downwards, without concern that it might change in the future. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
-rw-r--r--ports/stm32/mpu.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/ports/stm32/mpu.h b/ports/stm32/mpu.h
index 5ef146618..a87c04a58 100644
--- a/ports/stm32/mpu.h
+++ b/ports/stm32/mpu.h
@@ -36,12 +36,18 @@
#define MPU_REGION_QSPI3 (MPU_REGION_NUMBER3)
#define MPU_REGION_SDRAM1 (MPU_REGION_NUMBER4)
#define MPU_REGION_SDRAM2 (MPU_REGION_NUMBER5)
-#define MPU_REGION_OPENAMP (MPU_REGION_NUMBER15)
// Only relevant on CPUs with D-Cache, must be higher priority than SDRAM
#define MPU_REGION_DMA_UNCACHED_1 (MPU_REGION_NUMBER6)
#define MPU_REGION_DMA_UNCACHED_2 (MPU_REGION_NUMBER7)
+#ifdef MPU_REGION_NUMBER8
+#define MPU_REGION_OPENAMP (MPU_REGION_NUMBER8)
+#define MPU_REGION_LAST_USED (MPU_REGION_NUMBER8)
+#else
+#define MPU_REGION_LAST_USED (MPU_REGION_NUMBER7)
+#endif
+
// Attribute value to disable a region entirely, remove it from the MPU
// (i.e. the MPU_REGION_ENABLE bit is unset.)
#define MPU_CONFIG_DISABLE 0
@@ -135,6 +141,7 @@ static inline void mpu_config_end(uint32_t irq_state) {
#define MPU_REGION_SIG (MPU_REGION_NUMBER0)
#define MPU_REGION_ETH (MPU_REGION_NUMBER1)
+#define MPU_REGION_LAST_USED (MPU_REGION_NUMBER1)
#define ST_DEVICE_SIGNATURE_BASE (0x08fff800)
#define ST_DEVICE_SIGNATURE_LIMIT (0x08ffffff)