Sming Framework API
Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.
HardwareTimer Class Reference

Hardware timer class. More...

#include <HardwareTimer.h>

Inheritance diagram for HardwareTimer:
Hardware_Timer

Public Member Functions

 HardwareTimer (HardwareTimerMode mode=eHWT_NonMaskable)
 Hardware timer. More...
 
HardwareTimer &IRAM_ATTR initializeUs (uint32_t microseconds, InterruptCallback callback=nullptr)
 Initialise hardware timer. More...
 
HardwareTimer &IRAM_ATTR initializeMs (uint32_t milliseconds, InterruptCallback callback=nullptr)
 Initialise hardware timer. More...
 
bool IRAM_ATTR start (bool repeating=true)
 Start timer running. More...
 
__forceinline bool IRAM_ATTR startOnce ()
 Start one-shot timer. More...
 
void IRAM_ATTR stop ()
 Stops timer. More...
 
bool IRAM_ATTR restart ()
 Restart timer. More...
 
bool isStarted ()
 Check if timer is started. More...
 
uint32_t getIntervalUs ()
 Get timer interval. More...
 
uint32_t getIntervalMs ()
 Get timer interval. More...
 
bool IRAM_ATTR setIntervalUs (uint32_t microseconds)
 Set timer interval. More...
 
__forceinline bool IRAM_ATTR setIntervalMs (uint32_t milliseconds)
 Set timer interval. More...
 
void IRAM_ATTR setCallback (InterruptCallback callback)
 Set timer trigger callback. More...
 
__forceinline void IRAM_ATTR call ()
 Call timer callback. More...
 

Detailed Description

Hardware timer class.

Constructor & Destructor Documentation

HardwareTimer::HardwareTimer ( HardwareTimerMode  mode = eHWT_NonMaskable)

Hardware timer.

Parameters
mode
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.

Member Function Documentation

__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_tTimer interval in milliseconds
uint32_t HardwareTimer::getIntervalUs ( )
inline

Get timer interval.

Return values
uint32_tTimer interval in microseconds
HardwareTimer& IRAM_ATTR HardwareTimer::initializeMs ( uint32_t  milliseconds,
InterruptCallback  callback = nullptr 
)

Initialise hardware timer.

Parameters
millisecondsTimer interval in milliseconds
callbackCallback 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
microsecondsTimer interval in microseconds
callbackCallback 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
boolTrue if started
bool IRAM_ATTR HardwareTimer::restart ( )

Restart timer.

Return values
boolTrue if timer started
Note
Timer is stopped then started with current configuration
void IRAM_ATTR HardwareTimer::setCallback ( InterruptCallback  callback)

Set timer trigger callback.

Parameters
callbackFunction to call when timer triggers
__forceinline bool IRAM_ATTR HardwareTimer::setIntervalMs ( uint32_t  milliseconds)
inline

Set timer interval.

Parameters
millisecondsInterval time in milliseconds
bool IRAM_ATTR HardwareTimer::setIntervalUs ( uint32_t  microseconds)

Set timer interval.

Parameters
microsecondsInterval time in microseconds (Default: 1ms)
bool IRAM_ATTR HardwareTimer::start ( bool  repeating = true)

Start timer running.

Parameters
repeatingTrue to restart timer when it triggers, false for one-shot (Default: true)
Return values
boolTrue if timer started
__forceinline bool IRAM_ATTR HardwareTimer::startOnce ( )
inline

Start one-shot timer.

Return values
boolTrue if timer started
Note
Timer starts and will run for configured period then stop
void IRAM_ATTR HardwareTimer::stop ( )

Stops timer.