Skip to content

Commit 015774a

Browse files
committed
esp8266/modmachinewdt: Add .deinit() method.
1 parent 4a33677 commit 015774a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

esp8266/esp_mphal.c

-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@
3636
#include "extmod/misc.h"
3737
#include "lib/utils/pyexec.h"
3838

39-
extern void ets_wdt_disable(void);
40-
extern void wdt_feed(void);
41-
extern void ets_delay_us();
42-
4339
STATIC byte input_buf_array[256];
4440
ringbuf_t input_buf = {input_buf_array, sizeof(input_buf_array)};
4541
void mp_hal_debug_tx_strn_cooked(void *env, const char *str, uint32_t len);

esp8266/etshal.h

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ void ets_timer_arm_new(os_timer_t *tim, uint32_t millis, bool repeat, bool is_mi
2020
void ets_timer_setfn(os_timer_t *tim, ETSTimerFunc callback, void *cb_data);
2121
void ets_timer_disarm(os_timer_t *tim);
2222

23+
extern void ets_wdt_disable(void);
24+
extern void wdt_feed(void);
25+
2326
// Opaque structure
2427
typedef char MD5_CTX[64];
2528

esp8266/modmachinewdt.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "py/obj.h"
3232
#include "py/runtime.h"
3333
#include "user_interface.h"
34+
#include "etshal.h"
3435

3536
const mp_obj_type_t esp_wdt_type;
3637

@@ -63,8 +64,16 @@ STATIC mp_obj_t machine_wdt_feed(mp_obj_t self_in) {
6364
}
6465
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_wdt_feed_obj, machine_wdt_feed);
6566

67+
STATIC mp_obj_t machine_wdt_deinit(mp_obj_t self_in) {
68+
(void)self_in;
69+
ets_wdt_disable();
70+
return mp_const_none;
71+
}
72+
STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_wdt_deinit_obj, machine_wdt_deinit);
73+
6674
STATIC const mp_map_elem_t machine_wdt_locals_dict_table[] = {
67-
{ MP_OBJ_NEW_QSTR(MP_QSTR_feed), (mp_obj_t)&machine_wdt_feed_obj }
75+
{ MP_OBJ_NEW_QSTR(MP_QSTR_feed), (mp_obj_t)&machine_wdt_feed_obj },
76+
{ MP_OBJ_NEW_QSTR(MP_QSTR_deinit), (mp_obj_t)&machine_wdt_deinit_obj },
6877
};
6978
STATIC MP_DEFINE_CONST_DICT(machine_wdt_locals_dict, machine_wdt_locals_dict_table);
7079

0 commit comments

Comments
 (0)