summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-11-27 12:00:27 +1100
committerDamien George <damien@micropython.org>2023-11-30 16:11:11 +1100
commitcc8fc450a67204f254356454d34e27c19cea6d10 (patch)
treec480a3bbe689e679746b25f89346a6318cdca6f9
parent39d4153a8d91f1db3f2f034e5fa448b79ca14bc7 (diff)
esp8266/modmachine: Use common implementation of disable/enable_irq.
Now that the MICROPY_BEGIN_ATOMIC_SECTION/MICROPY_END_ATOMIC_SECTION macros act the same as disable_irq/enable_irq, it's possible to use the common extmod implementation of these machine functions. Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r--ports/esp8266/modmachine.c22
-rw-r--r--ports/esp8266/mpconfigport.h1
2 files changed, 1 insertions, 22 deletions
diff --git a/ports/esp8266/modmachine.c b/ports/esp8266/modmachine.c
index d55a656ce..f41c84e14 100644
--- a/ports/esp8266/modmachine.c
+++ b/ports/esp8266/modmachine.c
@@ -43,9 +43,6 @@
#define MICROPY_PY_MACHINE_EXTRA_GLOBALS \
{ MP_ROM_QSTR(MP_QSTR_sleep), MP_ROM_PTR(&machine_lightsleep_obj) }, \
\
- { 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) }, \
- \
{ MP_ROM_QSTR(MP_QSTR_RTC), MP_ROM_PTR(&pyb_rtc_type) }, \
{ MP_ROM_QSTR(MP_QSTR_Timer), MP_ROM_PTR(&esp_timer_type) }, \
{ MP_ROM_QSTR(MP_QSTR_Pin), MP_ROM_PTR(&pyb_pin_type) }, \
@@ -331,25 +328,6 @@ MP_DEFINE_CONST_OBJ_TYPE(
locals_dict, &esp_timer_locals_dict
);
-// this bit is unused in the Xtensa PS register
-#define ETS_LOOP_ITER_BIT (12)
-
-STATIC mp_obj_t machine_disable_irq(void) {
- uint32_t state = disable_irq();
- state = (state & ~(1 << ETS_LOOP_ITER_BIT)) | (ets_loop_iter_disable << ETS_LOOP_ITER_BIT);
- ets_loop_iter_disable = 1;
- 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);
- ets_loop_iter_disable = (state >> ETS_LOOP_ITER_BIT) & 1;
- enable_irq(state & ~(1 << ETS_LOOP_ITER_BIT));
- return mp_const_none;
-}
-MP_DEFINE_CONST_FUN_OBJ_1(machine_enable_irq_obj, machine_enable_irq);
-
// Custom version of this function that feeds system WDT if necessary
mp_uint_t machine_time_pulse_us(mp_hal_pin_obj_t pin, int pulse_level, mp_uint_t timeout_us) {
int nchanges = 2;
diff --git a/ports/esp8266/mpconfigport.h b/ports/esp8266/mpconfigport.h
index ec36291ed..ad9fefe0c 100644
--- a/ports/esp8266/mpconfigport.h
+++ b/ports/esp8266/mpconfigport.h
@@ -66,6 +66,7 @@
#define MICROPY_PY_MACHINE (1)
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/esp8266/modmachine.c"
#define MICROPY_PY_MACHINE_BARE_METAL_FUNCS (1)
+#define MICROPY_PY_MACHINE_DISABLE_IRQ_ENABLE_IRQ (1)
#define MICROPY_PY_MACHINE_ADC (1)
#define MICROPY_PY_MACHINE_ADC_INCLUDEFILE "ports/esp8266/machine_adc.c"
#define MICROPY_PY_MACHINE_ADC_READ (1)