Hardware timer class.
More...
#include <HardwareTimer.h>
HardwareTimer::HardwareTimer |
( |
HardwareTimerMode |
mode = eHWT_NonMaskable | ) |
|
Hardware timer.
- Parameters
-
- Note
- NMI has highest interrupt priority on system and can therefore occur within any other interrupt service routine. Similarly, the NMI service routine cannot itself be interrupted. This provides the most stable and reliable timing possible, and is therefore the default behaviour.
__forceinline void IRAM_ATTR HardwareTimer::call |
( |
| ) |
|
|
inline |
Call timer callback.
- Note
- Calls the timer callback function
uint32_t HardwareTimer::getIntervalMs |
( |
| ) |
|
|
inline |
Get timer interval.
- Return values
-
uint32_t | Timer interval in milliseconds |
uint32_t HardwareTimer::getIntervalUs |
( |
| ) |
|
|
inline |
Get timer interval.
- Return values
-
uint32_t | Timer interval in microseconds |
HardwareTimer& IRAM_ATTR HardwareTimer::initializeMs |
( |
uint32_t |
milliseconds, |
|
|
InterruptCallback |
callback = nullptr |
|
) |
| |
Initialise hardware timer.
- Parameters
-
milliseconds | Timer interval in milliseconds |
callback | Callback function to call when timer triggers (Default: none) |
- Return values
-
HardwareTimer& | Reference to timer |
HardwareTimer& IRAM_ATTR HardwareTimer::initializeUs |
( |
uint32_t |
microseconds, |
|
|
InterruptCallback |
callback = nullptr |
|
) |
| |
Initialise hardware timer.
- Parameters
-
microseconds | Timer interval in microseconds |
callback | Callback function to call when timer triggers (Default: none) |
- Return values
-
HardwareTimer& | Reference to timer |
bool HardwareTimer::isStarted |
( |
| ) |
|
|
inline |
Check if timer is started.
- Return values
-
bool IRAM_ATTR HardwareTimer::restart |
( |
| ) |
|
Restart timer.
- Return values
-
bool | True if timer started |
- Note
- Timer is stopped then started with current configuration
void IRAM_ATTR HardwareTimer::setCallback |
( |
InterruptCallback |
callback | ) |
|
Set timer trigger callback.
- Parameters
-
callback | Function to call when timer triggers |
__forceinline bool IRAM_ATTR HardwareTimer::setIntervalMs |
( |
uint32_t |
milliseconds | ) |
|
|
inline |
Set timer interval.
- Parameters
-
milliseconds | Interval time in milliseconds |
bool IRAM_ATTR HardwareTimer::setIntervalUs |
( |
uint32_t |
microseconds | ) |
|
Set timer interval.
- Parameters
-
microseconds | Interval time in microseconds (Default: 1ms) |
bool IRAM_ATTR HardwareTimer::start |
( |
bool |
repeating = true | ) |
|
Start timer running.
- Parameters
-
repeating | True to restart timer when it triggers, false for one-shot (Default: true) |
- Return values
-
bool | True if timer started |
__forceinline bool IRAM_ATTR HardwareTimer::startOnce |
( |
| ) |
|
|
inline |
Start one-shot timer.
- Return values
-
bool | True if timer started |
- Note
- Timer starts and will run for configured period then stop
void IRAM_ATTR HardwareTimer::stop |
( |
| ) |
|