esp8266/modmachine: Add disable_irq and enable_irq functions.

This commit is contained in:
Damien George 2016-05-20 13:30:33 +01:00
parent 849eb835f0
commit 9a368ae831

View File

@ -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) },