This is a peripheral object that summarizes the procedures for using the watchdog timer.
mwf_periph_wwdt - WWDT
the_wwdt
, a peripheral object that summarizes the procedures for using the watchdog timer, is implemented.
With TWENET, this is used implicitly, so no initialization is required in the user’s program.
Code example
void setup_func() {
mwf::gobal_init_wwdt_manager();
the_wwdt.init(); // timeout in 4000ms approx.
}
// in some function called periodically (e.g. invoked by SysTick Timer.)
void do_every_tick() {
the_wwdt.refresh();
}
class mwf::periph::wwdt
global_init_wwdt_manager()
, global_deinit_wwdt_manager()
static void global_init_wwdt_manager();
static void global_deinit_wwdt_manager();
These functions create and destroy the the_wwdt
class object.
init()
, deinit()
void init(uint32_t u32ms = 0);
void deinit();
These functions initialize and stop the watchdog timer (*1).
- The
u32ms
parameter during initialization specifies the timeout in milliseconds (ms). If it is0
or omitted, the timeout will be 4000ms. - *1 Due to hardware limitations, a watchdog timer that has been started once cannot be stopped.
deinit()
is provided as a library procedure (e.g., when restarting the timer, you would executedeinit()
and then callinit()
again).
set_timeout()
void set_timeout(uint32_t u32ms);
This function changes the watchdog timer’s timeout duration. For u32ms
, specify the timeout duration in milliseconds (ms).
- The validity of
u32ms
is not validated. Whileinit()
used0
as a default value, the behavior of this function when0
is provided is undefined.
refresh()
void refresh();
This is the refresh function that must be called before the watchdog timer’s timeout.
class mwf::periph::wwdt (sys_ev_handler)
on_sleep()
Performs the WWDT stop procedure.
on_wakeup()
Performs the WWDT start procedure.
- If it was active before sleep, the WWDT is reactivated.