2020-03-16 20:34:30 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020 Nordic Semiconductor ASA
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2022-05-09 18:10:05 +08:00
|
|
|
#include <zephyr/toolchain.h>
|
2020-12-08 21:40:19 +08:00
|
|
|
|
2023-06-30 15:58:41 +08:00
|
|
|
#include <cmsis_core.h>
|
2020-12-08 21:40:19 +08:00
|
|
|
#if CONFIG_CPU_HAS_NXP_MPU
|
|
|
|
#include <fsl_sysmpu.h>
|
|
|
|
#endif
|
2020-03-16 20:34:30 +08:00
|
|
|
|
|
|
|
void cleanup_arm_nvic(void) {
|
|
|
|
/* Allow any pending interrupts to be recognized */
|
|
|
|
__ISB();
|
|
|
|
__disable_irq();
|
|
|
|
|
|
|
|
/* Disable NVIC interrupts */
|
2020-05-28 01:25:41 +08:00
|
|
|
for (uint8_t i = 0; i < ARRAY_SIZE(NVIC->ICER); i++) {
|
2020-03-16 20:34:30 +08:00
|
|
|
NVIC->ICER[i] = 0xFFFFFFFF;
|
|
|
|
}
|
|
|
|
/* Clear pending NVIC interrupts */
|
2020-05-28 01:25:41 +08:00
|
|
|
for (uint8_t i = 0; i < ARRAY_SIZE(NVIC->ICPR); i++) {
|
2020-03-16 20:34:30 +08:00
|
|
|
NVIC->ICPR[i] = 0xFFFFFFFF;
|
|
|
|
}
|
|
|
|
}
|
2020-10-22 21:14:48 +08:00
|
|
|
|
2020-10-29 20:59:35 +08:00
|
|
|
#if CONFIG_CPU_HAS_ARM_MPU
|
2020-10-22 21:14:48 +08:00
|
|
|
__weak void z_arm_clear_arm_mpu_config(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
int num_regions =
|
|
|
|
((MPU->TYPE & MPU_TYPE_DREGION_Msk) >> MPU_TYPE_DREGION_Pos);
|
|
|
|
|
|
|
|
for (i = 0; i < num_regions; i++) {
|
|
|
|
ARM_MPU_ClrRegion(i);
|
|
|
|
}
|
|
|
|
}
|
2020-12-08 21:40:19 +08:00
|
|
|
#elif CONFIG_CPU_HAS_NXP_MPU
|
|
|
|
__weak void z_arm_clear_arm_mpu_config(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
int num_regions = FSL_FEATURE_SYSMPU_DESCRIPTOR_COUNT;
|
|
|
|
|
|
|
|
SYSMPU_Enable(SYSMPU, false);
|
|
|
|
|
|
|
|
/* NXP MPU region 0 is reserved for the debugger */
|
|
|
|
for (i = 1; i < num_regions; i++) {
|
|
|
|
SYSMPU_RegionEnable(SYSMPU, i, false);
|
|
|
|
}
|
|
|
|
}
|
2020-10-29 20:59:35 +08:00
|
|
|
#endif
|