FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
watchdog.h File Reference

Watchdog API. More...

#include "boards/board.h"
#include "boards/board_traits.h"
#include <avr/interrupt.h>
#include "interrupts.h"
#include "events.h"
Include dependency graph for watchdog.h:

Go to the source code of this file.

Classes

class  watchdog::WatchdogSignal
 Simple API to handle watchdog signals. More...
 
class  watchdog::WatchdogRTT
 Simple API to use watchdog timer as a real-time clock. More...
 
class  watchdog::Watchdog< EVENT >
 Simple API to use watchdog timer as a clock for events generation. More...
 

Namespaces

namespace  watchdog
 Defines the simple API for Watchdog timer management.
 

Macros

#define REGISTER_WATCHDOG_CLOCK_ISR(EVENT)
 Register the necessary ISR (Interrupt Service Routine) for a watchdog::Watchdog to work properly. More...
 
#define REGISTER_WATCHDOG_RTT_ISR()
 Register the necessary ISR (Interrupt Service Routine) for a watchdog::WatchdogRTT to work properly. More...
 
#define REGISTER_WATCHDOG_ISR_METHOD(HANDLER, CALLBACK)
 Register the necessary ISR (Interrupt Service Routine) with a callback method that will be called every time a watchdog timeout occurs, according to how watchdog::WatchdogSignal was started. More...
 
#define REGISTER_WATCHDOG_ISR_FUNCTION(CALLBACK)
 Register the necessary ISR (Interrupt Service Routine) with a callback function that will be called every time a watchdog timeout occurs, according to how watchdog::WatchdogSignal was started. More...
 
#define REGISTER_WATCHDOG_ISR_EMPTY()   EMPTY_INTERRUPT(WDT_vect)
 Register an empty ISR (Interrupt Service Routine) for a watchdog::WatchdogSignal. More...
 
#define DECL_WATCHDOG_ISR_HANDLERS_FRIEND
 This macro shall be used in a class containing a private callback method, registered by REGISTER_WATCHDOG_ISR_METHOD. More...
 

Enumerations

enum class  watchdog::TimeOut : uint8_t {
  watchdog::TO_16ms = 0 ,
  watchdog::TO_32ms ,
  watchdog::TO_64ms ,
  watchdog::TO_125ms ,
  watchdog::TO_250ms ,
  watchdog::TO_500ms ,
  watchdog::TO_1s ,
  watchdog::TO_2s ,
  watchdog::TO_4s ,
  watchdog::TO_8s
}
 Defines the watchdog timeout period; watchdog interrupts will be triggered at the selected period. More...
 

Detailed Description

Watchdog API.

Definition in file watchdog.h.

Macro Definition Documentation

◆ REGISTER_WATCHDOG_CLOCK_ISR

#define REGISTER_WATCHDOG_CLOCK_ISR (   EVENT)
Value:
ISR(WDT_vect) \
{ \
watchdog::isr_handler::watchdog_clock<EVENT>(); \
}

Register the necessary ISR (Interrupt Service Routine) for a watchdog::Watchdog to work properly.

Parameters
EVENTthe type of Event<T> to be generated by the watchdog
See also
watchdog::Watchdog

Definition at line 36 of file watchdog.h.

◆ REGISTER_WATCHDOG_RTT_ISR

#define REGISTER_WATCHDOG_RTT_ISR ( )
Value:
ISR(WDT_vect) \
{ \
watchdog::isr_handler::watchdog_rtt(); \
}

Register the necessary ISR (Interrupt Service Routine) for a watchdog::WatchdogRTT to work properly.

See also
watchdog::WatchdogRTT

Definition at line 47 of file watchdog.h.

◆ REGISTER_WATCHDOG_ISR_METHOD

#define REGISTER_WATCHDOG_ISR_METHOD (   HANDLER,
  CALLBACK 
)
Value:
ISR(WDT_vect) \
{ \
watchdog::isr_handler::watchdog_method<HANDLER, CALLBACK>(); \
}

Register the necessary ISR (Interrupt Service Routine) with a callback method that will be called every time a watchdog timeout occurs, according to how watchdog::WatchdogSignal was started.

Parameters
HANDLERthe class holding the callback method
CALLBACKthe method of HANDLER that will be called when the interrupt is triggered; this must be a proper PTMF (pointer to member function).

Definition at line 61 of file watchdog.h.

◆ REGISTER_WATCHDOG_ISR_FUNCTION

#define REGISTER_WATCHDOG_ISR_FUNCTION (   CALLBACK)
Value:
ISR(WDT_vect) \
{ \
watchdog::isr_handler::watchdog_function<CALLBACK>() : \
}

Register the necessary ISR (Interrupt Service Routine) with a callback function that will be called every time a watchdog timeout occurs, according to how watchdog::WatchdogSignal was started.

Parameters
CALLBACKthe function that will be called when the interrupt is triggered

Definition at line 74 of file watchdog.h.

◆ REGISTER_WATCHDOG_ISR_EMPTY

#define REGISTER_WATCHDOG_ISR_EMPTY ( )    EMPTY_INTERRUPT(WDT_vect)

Register an empty ISR (Interrupt Service Routine) for a watchdog::WatchdogSignal.

This may be needed when using watchdog just to awaken a sleeping MCU, but without any necessary immediate callback.

Definition at line 85 of file watchdog.h.

◆ DECL_WATCHDOG_ISR_HANDLERS_FRIEND

#define DECL_WATCHDOG_ISR_HANDLERS_FRIEND
Value:
friend struct watchdog::isr_handler; \
friend void ::WDT_vect();

This macro shall be used in a class containing a private callback method, registered by REGISTER_WATCHDOG_ISR_METHOD.

It declares the class where it is used as a friend of all necessary functions so that the private callback method can be called properly.

Definition at line 93 of file watchdog.h.