mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 04:00:28 +01:00
alif/mpu: Add function to set read-only bit on MRAM MPU region.
To allow writing to MRAM region. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include "irq.h"
|
||||
#include "mpu.h"
|
||||
#include ALIF_CMSIS_H
|
||||
|
||||
@@ -76,3 +77,13 @@ void MPU_Load_Regions(void) {
|
||||
// Load the MPU regions from the table.
|
||||
ARM_MPU_Load(0, mpu_table, sizeof(mpu_table) / sizeof(ARM_MPU_Region_t));
|
||||
}
|
||||
|
||||
void mpu_config_mram(bool read_only) {
|
||||
uintptr_t atomic = disable_irq();
|
||||
ARM_MPU_Disable();
|
||||
MPU->RNR = MP_MPU_REGION_MRAM;
|
||||
MPU->RBAR = ARM_MPU_RBAR(MRAM_BASE, ARM_MPU_SH_NON, read_only, 1, 0);
|
||||
MPU->RLAR = ARM_MPU_RLAR(MRAM_BASE + MRAM_SIZE - 1, MP_MPU_ATTR_NORMAL_WT_RA);
|
||||
ARM_MPU_Enable(MPU_CTRL_PRIVDEFENA_Msk | MPU_CTRL_HFNMIENA_Msk);
|
||||
enable_irq(atomic);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user