mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 01:40:14 +01:00
extmod/modmachine: Provide common implementation of disable/enable_irq.
The ports esp32, mimxrt, rp2 and samd all shared exactly the same
implementation of machine.disable_irq() and machine.enable_irq(),
implemented in terms of MICROPY_{BEGIN,END}_ATOMIC_SECTION. This commit
factors these implementations into extmod/modmachine.c.
The cc3200, esp8266, nrf, renesas-ra and stm32 ports do not yet use this
common implementation.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -59,9 +59,6 @@
|
||||
{ MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&machine_timer_type) }, \
|
||||
MICROPY_PY_MACHINE_RTC_ENTRY \
|
||||
\
|
||||
{ MP_ROM_QSTR(MP_QSTR_disable_irq), MP_ROM_PTR(&machine_disable_irq_obj) }, \
|
||||
{ MP_ROM_QSTR(MP_QSTR_enable_irq), MP_ROM_PTR(&machine_enable_irq_obj) }, \
|
||||
\
|
||||
/* Class constants. */ \
|
||||
/* Use numerical constants instead of the symbolic names, */ \
|
||||
/* since the names differ between SAMD21 and SAMD51. */ \
|
||||
@@ -111,19 +108,6 @@ STATIC void mp_machine_idle(void) {
|
||||
MICROPY_EVENT_POLL_HOOK;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t machine_disable_irq(void) {
|
||||
uint32_t state = MICROPY_BEGIN_ATOMIC_SECTION();
|
||||
return mp_obj_new_int(state);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq);
|
||||
|
||||
STATIC mp_obj_t machine_enable_irq(mp_obj_t state_in) {
|
||||
uint32_t state = mp_obj_get_int(state_in);
|
||||
MICROPY_END_ATOMIC_SECTION(state);
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(machine_enable_irq_obj, machine_enable_irq);
|
||||
|
||||
STATIC mp_int_t mp_machine_reset_cause(void) {
|
||||
#if defined(MCU_SAMD21)
|
||||
return PM->RCAUSE.reg;
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/samd/modmachine.c"
|
||||
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
|
||||
#define MICROPY_PY_MACHINE_BOOTLOADER (1)
|
||||
#define MICROPY_PY_MACHINE_DISABLE_IRQ_ENABLE_IRQ (1)
|
||||
#define MICROPY_PY_OS (1)
|
||||
#define MICROPY_PY_OS_INCLUDEFILE "ports/samd/modos.c"
|
||||
#define MICROPY_READER_VFS (1)
|
||||
|
||||
Reference in New Issue
Block a user