esp8266/modmachinewdt: Add .deinit() method.

This commit is contained in:
Paul Sokolovsky 2016-09-03 20:45:11 +03:00
parent 4a33677c97
commit 015774a04f
3 changed files with 13 additions and 5 deletions

View File

@ -36,10 +36,6 @@
#include "extmod/misc.h"
#include "lib/utils/pyexec.h"
extern void ets_wdt_disable(void);
extern void wdt_feed(void);
extern void ets_delay_us();
STATIC byte input_buf_array[256];
ringbuf_t input_buf = {input_buf_array, sizeof(input_buf_array)};
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len);

View File

@ -20,6 +20,9 @@ void ets_timer_arm_new(os_timer_t *tim, uint32_t millis, bool repeat, bool is_mi
void ets_timer_setfn(os_timer_t *tim, ETSTimerFunc callback, void *cb_data);
void ets_timer_disarm(os_timer_t *tim);
extern void ets_wdt_disable(void);
extern void wdt_feed(void);
// Opaque structure
typedef char MD5_CTX[64];

View File

@ -31,6 +31,7 @@
#include "py/obj.h"
#include "py/runtime.h"
#include "user_interface.h"
#include "etshal.h"
const mp_obj_type_t esp_wdt_type;
@ -63,8 +64,16 @@ STATIC mp_obj_t machine_wdt_feed(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_wdt_feed_obj, machine_wdt_feed);
STATIC mp_obj_t machine_wdt_deinit(mp_obj_t self_in) {
(void)self_in;
ets_wdt_disable();
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_wdt_deinit_obj, machine_wdt_deinit);
STATIC const mp_map_elem_t machine_wdt_locals_dict_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_feed), (mp_obj_t)&machine_wdt_feed_obj }
{ MP_OBJ_NEW_QSTR(MP_QSTR_feed), (mp_obj_t)&machine_wdt_feed_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_deinit), (mp_obj_t)&machine_wdt_deinit_obj },
};
STATIC MP_DEFINE_CONST_DICT(machine_wdt_locals_dict, machine_wdt_locals_dict_table);