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>
This commit is contained in:
parent
39d4153a8d
commit
cc8fc450a6
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue