#include <soft_timer.hpp>
Public Member Functions | |
SoftTimer () | |
Default constructor. More... | |
SoftTimer (uint32_t ms) | |
Constructor to set timer while instantiating this object. More... | |
bool | expired (void) const |
void | restart (void) |
void | reset (uint64_t ms) |
void | reset (void) |
Resets the timer from this point of time using the previous timeout interval. More... | |
void | stop (void) |
Stops the timer. More... | |
bool | isRunning (void) const |
uint64_t | getTimerValueMs (void) const |
uint64_t | getTargetTimerValueMs (void) const |
uint64_t | getTimeToExpirationMs (void) const |
uint64_t | getTimeSinceExpirationMs (void) const |
Static Public Member Functions | |
static uint64_t | getCurrentTimeMs (void) |
Protected Attributes | |
uint64_t | mTargetMs |
Expire time with respect to OS tick. More... | |
uint64_t | mIntervalMs |
Timer interval. More... | |
Detailed Description
Soft timer class to provide thin layer of a timer. There is no hard-timer running in the background and this class imply relies on system timer to provide timer capability.
- Warning
- If you run FreeRTOS in "configUSE_TICKLESS_IDLE", then this timer will not work well since the OS ticks will not happen to drive the timer. In that case, you are better off using the true FreeRTOS timer which will not suppress the timer ticks if a timer expires.
Constructor & Destructor Documentation
|
inline |
Default constructor.
|
inline |
Constructor to set timer while instantiating this object.
Member Function Documentation
|
inline |
- Returns
- true if the timer has expired
|
inlinestatic |
Static function to get the timer value. This is the only method that is needed by the system.
- Note
- You can use this method without instantiating an object of the class: uint64_t timer = SoftTimer::getCurrentTimeMs();
- Returns
- the current timer value of the system
|
inline |
- Returns
- the absolute time value when timer will expire with respect to system timer (in milliseconds)
|
inline |
- Returns
- the timer value set by the constructor or reset(uint64_t)
|
inline |
- Returns
- the time value since expiration (in milliseconds)
- Note
- If timer hasn't expired, zero value is returned.
|
inline |
- Returns
- the time value until expiration (in milliseconds)
- Note
- If timer hasn't expired, zero value is returned.
|
inline |
- Returns
- true if the timer is set and running
|
inline |
Resets the timer from this point of time using the new timer value given.
- Parameters
-
ms The milliseconds at which timer should expire next.
|
inline |
Resets the timer from this point of time using the previous timeout interval.
|
inline |
Restarts the timer to provide consistent frequency of expired(). restart() is better suited to provide same frequency because in case we check for expired() at a later time that runs past our timer 3 times, then expired() in combination with restart() will return true 3 times. See example below :
|
inline |
Stops the timer.
Field Documentation
|
protected |
Timer interval.
|
protected |
Expire time with respect to OS tick.
uint64_t is large enough such that timer will never overflow
The documentation for this class was generated from the following file:
- /var/www/html/SJSU-DEV-Linux/firmware/default/lib/L3_Utils/soft_timer.hpp