Formula Student Electronics & Software
The code for the embedded software
Loading...
Searching...
No Matches
VolatileMetro Class Reference

Volatile version of Metro class for interrupt-safe operations. More...

#include <metro.h>

Collaboration diagram for VolatileMetro:
Collaboration graph

Public Member Functions

 VolatileMetro (unsigned long interval_millis, uint8_t autoreset=0)
 Constructor to initialize the timer with a given interval and autoreset behavior.
 
void interval (unsigned long interval_millis) volatile
 Sets a new interval for the timer.
 
bool check () volatile
 Checks if the interval has passed and resets the timer if true.
 
bool checkWithoutReset () const volatile
 Checks if the interval has passed without resetting the timer.
 
void reset () volatile
 Resets the timer to the current time.
 

Detailed Description

Volatile version of Metro class for interrupt-safe operations.

This class provides the same functionality as Metro but with volatile qualifiers to ensure safe access from interrupt handlers and multi-threaded contexts.

Definition at line 135 of file metro.h.

Constructor & Destructor Documentation

◆ VolatileMetro()

VolatileMetro::VolatileMetro ( unsigned long  interval_millis,
uint8_t  autoreset = 0 
)
inline

Constructor to initialize the timer with a given interval and autoreset behavior.

Parameters
interval_millisThe interval in milliseconds for the timer
autoresetIf set to non-zero, the timer will reset automatically upon a successful check

Definition at line 174 of file metro.h.

Here is the call graph for this function:

Member Function Documentation

◆ check()

bool VolatileMetro::check ( ) volatile
inline

Checks if the interval has passed and resets the timer if true.

Returns
true if the interval has passed, false otherwise

Definition at line 186 of file metro.h.

◆ checkWithoutReset()

bool VolatileMetro::checkWithoutReset ( ) const volatile
inline

Checks if the interval has passed without resetting the timer.

Returns
true if the interval has passed, false otherwise

Definition at line 203 of file metro.h.

Here is the caller graph for this function:

◆ interval()

void VolatileMetro::interval ( unsigned long  interval_millis) volatile
inline

Sets a new interval for the timer.

Parameters
interval_millisThe new interval in milliseconds

Definition at line 181 of file metro.h.

Here is the caller graph for this function:

◆ reset()

void VolatileMetro::reset ( ) volatile
inline

Resets the timer to the current time.

Definition at line 212 of file metro.h.

Here is the caller graph for this function:

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