Skip to content

Commit

Permalink
codal_port/mphalport: Move irq and atomic section defns to mphalport.h.
Browse files Browse the repository at this point in the history
Following how this is has changed in MicroPython v1.22.0.

Signed-off-by: Damien George <[email protected]>
  • Loading branch information
dpgeorge committed Mar 24, 2024
1 parent 03d5c04 commit c36fd82
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
17 changes: 0 additions & 17 deletions src/codal_port/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions src/codal_port/mphalport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c36fd82

Please sign in to comment.