This is an automated email from the ASF dual-hosted git repository. jerzy pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
commit 51938d337fdad58a414615c4957061df94959cc8 Author: Jerzy Kasenberg <[email protected]> AuthorDate: Wed Oct 2 09:29:43 2024 +0200 hw/cmsis: Add NVIC_DisableAll and Cortex_DisableAll New function NVIC_DisableAll() disables all interrupts on NVIC. Cortex_DisableAll() disables all interrupts and SysTick Those function are intended to be called from hal_bsp_deinit to disable interrupts before application code reconfigures them from what boot loader set up. Signed-off-by: Jerzy Kasenberg <[email protected]> --- hw/cmsis-core/include/{mynewt_nvic.h => mynewt_cm.h} | 18 +++++++++++------- hw/cmsis-core/include/mynewt_nvic.h | 11 +++++++++++ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/hw/cmsis-core/include/mynewt_nvic.h b/hw/cmsis-core/include/mynewt_cm.h similarity index 77% copy from hw/cmsis-core/include/mynewt_nvic.h copy to hw/cmsis-core/include/mynewt_cm.h index d861225af..4e65a6908 100644 --- a/hw/cmsis-core/include/mynewt_nvic.h +++ b/hw/cmsis-core/include/mynewt_cm.h @@ -17,14 +17,18 @@ * under the License. */ -#ifndef MYNEWT_NVIC_H -#define MYNEWT_NVIC_H +#ifndef MYNEWT_CM_H +#define MYNEWT_CM_H -#include <mcu/cmsis_nvic.h> -#include <os/util.h> +#include <mynewt_nvic.h> -void NVIC_Relocate(void); -void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector); -uint32_t NVIC_GetVector(IRQn_Type IRQn); +static inline void +Cortex_DisableAll(void) +{ + /* Disable SysTick interrupt */ + SysTick->CTRL = 0; + /* Disable all NVIC interrupts */ + NVIC_DisableAll(); +} #endif diff --git a/hw/cmsis-core/include/mynewt_nvic.h b/hw/cmsis-core/include/mynewt_nvic.h index d861225af..cd58ca953 100644 --- a/hw/cmsis-core/include/mynewt_nvic.h +++ b/hw/cmsis-core/include/mynewt_nvic.h @@ -27,4 +27,15 @@ void NVIC_Relocate(void); void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector); uint32_t NVIC_GetVector(IRQn_Type IRQn); +static inline void +NVIC_DisableAll(void) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(NVIC->ICER); ++i) { + NVIC->ICER[i] = 0xffffffff; + NVIC->ICPR[i] = 0xffffffff; + } +} + #endif
