From c36fd8275307829617e2516402d58ba10114ba7a Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 25 Mar 2024 10:30:33 +1100 Subject: [PATCH] codal_port/mphalport: Move irq and atomic section defns to mphalport.h. Following how this is has changed in MicroPython v1.22.0. Signed-off-by: Damien George --- src/codal_port/mpconfigport.h | 17 ----------------- src/codal_port/mphalport.h | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/codal_port/mpconfigport.h b/src/codal_port/mpconfigport.h index fcf2546..cca2378 100644 --- a/src/codal_port/mpconfigport.h +++ b/src/codal_port/mpconfigport.h @@ -121,23 +121,6 @@ #define MP_STATE_PORT MP_STATE_VM -// These functions allow nested calls. -extern void target_disable_irq(void); -extern void target_enable_irq(void); - -static inline uint32_t disable_irq(void) { - target_disable_irq(); - return 0; -} - -static inline void enable_irq(uint32_t state) { - (void)state; - target_enable_irq(); -} - -#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq() -#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state) - #define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((uint32_t)(p) | 1)) #define MP_SSIZE_MAX (0x7fffffff) diff --git a/src/codal_port/mphalport.h b/src/codal_port/mphalport.h index 951a8e1..cf5f546 100644 --- a/src/codal_port/mphalport.h +++ b/src/codal_port/mphalport.h @@ -28,6 +28,23 @@ #include "microbithal.h" #include "nrf.h" +#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq() +#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state) + +// These functions allow nested calls. +extern void target_disable_irq(void); +extern void target_enable_irq(void); + +static inline uint32_t disable_irq(void) { + target_disable_irq(); + return 0; +} + +static inline void enable_irq(uint32_t state) { + (void)state; + target_enable_irq(); +} + static inline mp_uint_t mp_hal_ticks_cpu(void) { if (!(DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk)) { CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;