From 9a368ae831143e1dd47eb302e85f39862de3a758 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 20 May 2016 13:30:33 +0100 Subject: [PATCH] esp8266/modmachine: Add disable_irq and enable_irq functions. --- esp8266/modmachine.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/esp8266/modmachine.c b/esp8266/modmachine.c index c3c9494ac8..3974718539 100644 --- a/esp8266/modmachine.c +++ b/esp8266/modmachine.c @@ -34,6 +34,7 @@ #include "modpyb.h" #include "modpybrtc.h" +#include "xtirq.h" #include "os_type.h" #include "osapi.h" #include "etshal.h" @@ -189,6 +190,17 @@ const mp_obj_type_t esp_timer_type = { .locals_dict = (mp_obj_t)&esp_timer_locals_dict, }; +STATIC mp_obj_t machine_disable_irq(void) { + return mp_obj_new_int(disable_irq()); +} +MP_DEFINE_CONST_FUN_OBJ_0(machine_disable_irq_obj, machine_disable_irq); + +STATIC mp_obj_t machine_enable_irq(mp_obj_t state) { + enable_irq(mp_obj_get_int(state)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(machine_enable_irq_obj, machine_enable_irq); + STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_umachine) }, { MP_ROM_QSTR(MP_QSTR_mem8), MP_ROM_PTR(&machine_mem8_obj) }, @@ -201,6 +213,9 @@ STATIC const mp_rom_map_elem_t machine_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR_unique_id), MP_ROM_PTR(&machine_unique_id_obj) }, { MP_ROM_QSTR(MP_QSTR_deepsleep), MP_ROM_PTR(&machine_deepsleep_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) },