FastArduino  v1.7
C++ library to build fast but small Arduino/AVR projects
watchdog::WatchdogRTT Class Reference

Simple API to use watchdog timer as a real-time clock. More...

#include <fastarduino/watchdog.h>

Inheritance diagram for watchdog::WatchdogRTT:
Collaboration diagram for watchdog::WatchdogRTT:

Public Member Functions

 WatchdogRTT ()
 Construct a new watchdog-based clock that will count elapsed milliseconds since it was started with begin(). More...
 
void begin (TimeOut timeout=TimeOut::TO_16ms)
 Start the watchdog clock with the given timeout period. More...
 
uint32_t millis () const
 Get the number of milliseconds that elapsed since begin() was called. More...
 
void reset ()
 Reset current counter to 0. More...
 
void delay (uint32_t ms)
 Delay program execution for the given amount of milliseconds. More...
 
- Public Member Functions inherited from watchdog::WatchdogSignal
 WatchdogSignal (const WatchdogSignal &)=delete
 
WatchdogSignaloperator= (const WatchdogSignal &)=delete
 
void begin (TimeOut timeout=TimeOut::TO_16ms)
 Start the watchdog timer with the given timeout period. More...
 
void end ()
 Stop this watchdog timer. More...
 

Friends

struct isr_handler
 

Detailed Description

Simple API to use watchdog timer as a real-time clock.

For this to work correctly, you need to register the proper ISR through REGISTER_WATCHDOG_RTT_ISR() macro first.

Definition at line 201 of file watchdog.h.

Constructor & Destructor Documentation

◆ WatchdogRTT()

watchdog::WatchdogRTT::WatchdogRTT ( )
inline

Construct a new watchdog-based clock that will count elapsed milliseconds since it was started with begin().

See also
REGISTER_WATCHDOG_RTT_ISR()

Definition at line 209 of file watchdog.h.

Member Function Documentation

◆ begin()

void watchdog::WatchdogRTT::begin ( TimeOut  timeout = TimeOut::TO_16ms)
inline

Start the watchdog clock with the given timeout period.

From now on, watchdog interrupts get generated at timeout period, and the MCU gets awakened at this period too, if sleeping.

Parameters
timeoutthe watchdog timeout period

Definition at line 225 of file watchdog.h.

◆ millis()

uint32_t watchdog::WatchdogRTT::millis ( ) const
inline

Get the number of milliseconds that elapsed since begin() was called.

Note: the precision is limited by the timeout value used with begin().

Returns
number of milliseconds elpased since watchdog was started

Definition at line 245 of file watchdog.h.

◆ reset()

void watchdog::WatchdogRTT::reset ( )
inline

Reset current counter to 0.

This method is synchronized.

Definition at line 254 of file watchdog.h.

◆ delay()

void watchdog::WatchdogRTT::delay ( uint32_t  ms)
inline

Delay program execution for the given amount of milliseconds.

Contrarily to time::delay_ms(), this method does not perform a busy loop, but it calls time::yield() which will put the MCU in sleep mode but will be awakened by the watchdog interrupt and check if required delay has elapsed already. Note that the delay precision depends on the actual timeout value passed when begin() has been called.

Parameters
msthe number of milliseconds to hold program execution
See also
time::yield()

Definition at line 271 of file watchdog.h.


The documentation for this class was generated from the following file: