mirror of
https://github.com/micropython/micropython.git
synced 2025-12-15 17:30:14 +01:00
ports: Move definitions of ATOMIC_SECTION macros to mphalport.h.
Also move MICROPY_PY_PENDSV_ENTER/REENTER/EXIT to mphalport.h, for ports where these are not already there. This helps separate the hardware implementation of these macros from the MicroPython configuration (eg for renesas-ra and stm32, the IRQ static inline helper functions can now be moved to irq.h). Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -54,11 +54,26 @@ extern uint32_t irq_stats[IRQ_STATS_MAX];
|
||||
#define IRQ_EXIT(irq)
|
||||
#endif
|
||||
|
||||
// We have inlined IRQ functions for efficiency (they are generally
|
||||
// 1 machine instruction).
|
||||
//
|
||||
// Note on IRQ state: you should not need to know the specific
|
||||
// value of the state variable, but rather just pass the return
|
||||
// value from disable_irq back to enable_irq.
|
||||
|
||||
static inline uint32_t query_irq(void) {
|
||||
return __get_PRIMASK();
|
||||
}
|
||||
|
||||
// enable_irq and disable_irq are defined inline in mpconfigport.h
|
||||
static inline void enable_irq(mp_uint_t state) {
|
||||
__set_PRIMASK(state);
|
||||
}
|
||||
|
||||
static inline mp_uint_t disable_irq(void) {
|
||||
mp_uint_t state = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
return state;
|
||||
}
|
||||
|
||||
#if __CORTEX_M >= 0x03
|
||||
|
||||
|
||||
@@ -250,27 +250,6 @@ typedef unsigned int mp_uint_t; // must be pointer size
|
||||
|
||||
typedef long mp_off_t;
|
||||
|
||||
// We have inlined IRQ functions for efficiency (they are generally
|
||||
// 1 machine instruction).
|
||||
//
|
||||
// Note on IRQ state: you should not need to know the specific
|
||||
// value of the state variable, but rather just pass the return
|
||||
// value from disable_irq back to enable_irq. If you really need
|
||||
// to know the machine-specific values, see irq.h.
|
||||
|
||||
static inline void enable_irq(mp_uint_t state) {
|
||||
__set_PRIMASK(state);
|
||||
}
|
||||
|
||||
static inline mp_uint_t disable_irq(void) {
|
||||
mp_uint_t state = __get_PRIMASK();
|
||||
__disable_irq();
|
||||
return state;
|
||||
}
|
||||
|
||||
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
|
||||
#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state)
|
||||
|
||||
#if MICROPY_HW_ENABLE_USBDEV
|
||||
#define MICROPY_HW_USBDEV_TASK_HOOK extern void mp_usbd_task(void); mp_usbd_task();
|
||||
#define MICROPY_VM_HOOK_COUNT (10)
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#include "pin.h"
|
||||
#include "py/ringbuf.h"
|
||||
|
||||
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
|
||||
#define MICROPY_END_ATOMIC_SECTION(state) enable_irq(state)
|
||||
|
||||
#define MICROPY_PY_PENDSV_ENTER uint32_t atomic_state = raise_irq_pri(IRQ_PRI_PENDSV)
|
||||
#define MICROPY_PY_PENDSV_EXIT restore_irq_pri(atomic_state)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user