FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
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
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 203 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 211 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 222 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 242 of file watchdog.h.

◆ reset()

void watchdog::WatchdogRTT::reset ( )
inline

Reset current counter to 0.

This method is synchronized.

Definition at line 251 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 268 of file watchdog.h.

Friends And Related Function Documentation

◆ isr_handler

friend struct isr_handler
friend

Definition at line 292 of file watchdog.h.


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