Skip to content

Commit c36fd82

Browse files
committed
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 <damien@micropython.org>
1 parent 03d5c04 commit c36fd82

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/codal_port/mpconfigport.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -121,23 +121,6 @@
121121

122122
#define MP_STATE_PORT MP_STATE_VM
123123

124-
// These functions allow nested calls.
125-
extern void target_disable_irq(void);
126-
extern void target_enable_irq(void);
127-
128-
static inline uint32_t disable_irq(void) {
129-
target_disable_irq();
130-
return 0;
131-
}
132-
133-
static inline void enable_irq(uint32_t state) {
134-
(void)state;
135-
target_enable_irq();
136-
}
137-
138-
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
139-
#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state)
140-
141124
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void *)((uint32_t)(p) | 1))
142125

143126
#define MP_SSIZE_MAX (0x7fffffff)

src/codal_port/mphalport.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@
2828
#include "microbithal.h"
2929
#include "nrf.h"
3030

31+
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
32+
#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state)
33+
34+
// These functions allow nested calls.
35+
extern void target_disable_irq(void);
36+
extern void target_enable_irq(void);
37+
38+
static inline uint32_t disable_irq(void) {
39+
target_disable_irq();
40+
return 0;
41+
}
42+
43+
static inline void enable_irq(uint32_t state) {
44+
(void)state;
45+
target_enable_irq();
46+
}
47+
3148
static inline mp_uint_t mp_hal_ticks_cpu(void) {
3249
if (!(DWT->CTRL & DWT_CTRL_CYCCNTENA_Msk)) {
3350
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;

0 commit comments

Comments
 (0)