cc3200: Add make_new method to the WDT.
This commit is contained in:
parent
fca3493442
commit
8096be089e
@ -275,7 +275,7 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_SPI), (mp_obj_t)&pyb_spi_type },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_UART), (mp_obj_t)&pyb_uart_type },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_Timer), (mp_obj_t)&pyb_timer_type },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_WDT), (mp_obj_t)&pyb_wdt_obj },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_WDT), (mp_obj_t)&pyb_wdt_type },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_Sleep), (mp_obj_t)&pyb_sleep_obj },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_HeartBeat), (mp_obj_t)&pyb_heartbeat_obj },
|
||||
|
||||
|
@ -63,6 +63,7 @@ typedef struct {
|
||||
DECLARE PRIVATE DATA
|
||||
******************************************************************************/
|
||||
static pybwdt_data_t pybwdt_data = {.servers = false, .servers_sleeping = false, .simplelink = false, .running = false};
|
||||
STATIC const mp_obj_base_t pyb_wdt_obj = {&pyb_wdt_type};
|
||||
|
||||
/******************************************************************************
|
||||
DEFINE PUBLIC FUNCTIONS
|
||||
@ -96,11 +97,14 @@ void pybwdt_sl_alive (void) {
|
||||
/******************************************************************************/
|
||||
// Micro Python bindings
|
||||
|
||||
/// \function wdt_enable('msec')
|
||||
/// Enabled the watchdog timer with msec timeout value
|
||||
STATIC mp_obj_t pyb_enable_wdt(mp_obj_t self, mp_obj_t msec_in) {
|
||||
mp_int_t msec = mp_obj_get_int(msec_in);
|
||||
/// \function constructor('msec')
|
||||
/// Enables the watchdog timer with msec timeout value
|
||||
STATIC mp_obj_t pyb_wdt_make_new (mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
// check the arguments
|
||||
mp_arg_check_num(n_args, n_kw, 0, 1, false);
|
||||
|
||||
if (n_args > 0) {
|
||||
mp_int_t msec = mp_obj_get_int(args[0]);
|
||||
if (msec < PYBWDT_MIN_TIMEOUT_MS) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
|
||||
}
|
||||
@ -114,10 +118,10 @@ STATIC mp_obj_t pyb_enable_wdt(mp_obj_t self, mp_obj_t msec_in) {
|
||||
// Unlock to be able to configure the registers
|
||||
MAP_WatchdogUnlock(WDT_BASE);
|
||||
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG
|
||||
// make the WDT stall when the debugger stops on a breakpoint
|
||||
MAP_WatchdogStallEnable (WDT_BASE);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// set the watchdog timer reload value
|
||||
// the WDT trigger a system reset after the second timeout
|
||||
@ -127,10 +131,10 @@ STATIC mp_obj_t pyb_enable_wdt(mp_obj_t self, mp_obj_t msec_in) {
|
||||
// start the timer. Once it's started, it cannot be disabled.
|
||||
MAP_WatchdogEnable(WDT_BASE);
|
||||
pybwdt_data.running = true;
|
||||
}
|
||||
|
||||
return mp_const_none;
|
||||
return (mp_obj_t)&pyb_wdt_obj;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(pyb_enable_wdt_obj, pyb_enable_wdt);
|
||||
|
||||
/// \function wdt_kick()
|
||||
/// Kicks the watchdog timer
|
||||
@ -141,15 +145,14 @@ STATIC mp_obj_t pyb_kick_wdt(mp_obj_t self) {
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_kick_wdt_obj, pyb_kick_wdt);
|
||||
|
||||
STATIC const mp_map_elem_t pybwdt_locals_dict_table[] = {
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_enable), (mp_obj_t)&pyb_enable_wdt_obj },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR_kick), (mp_obj_t)&pyb_kick_wdt_obj },
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(pybwdt_locals_dict, pybwdt_locals_dict_table);
|
||||
|
||||
static const mp_obj_type_t pybwdt_type = {
|
||||
const mp_obj_type_t pyb_wdt_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_WDT,
|
||||
.make_new = pyb_wdt_make_new,
|
||||
.locals_dict = (mp_obj_t)&pybwdt_locals_dict,
|
||||
};
|
||||
|
||||
const mp_obj_base_t pyb_wdt_obj = {&pybwdt_type};
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "py/obj.h"
|
||||
|
||||
extern const mp_obj_base_t pyb_wdt_obj;
|
||||
extern const mp_obj_type_t pyb_wdt_type;
|
||||
|
||||
void pybwdt_init0 (void);
|
||||
void pybwdt_kick (void);
|
||||
|
@ -275,7 +275,6 @@ Q(WPS_PIN)
|
||||
|
||||
// for WDT class
|
||||
Q(WDT)
|
||||
Q(enable)
|
||||
Q(kick)
|
||||
|
||||
// for HeartBeat class
|
||||
|
Loading…
x
Reference in New Issue
Block a user