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

Hardware timer class. More...

#include <HardwareTimer.h>

Public Member Functions

 Hardware_Timer ()
 Hardware timer. More...
 
Hardware_Timer &IRAM_ATTR initializeUs (uint32_t microseconds, InterruptCallback callback=NULL)
 Initialise hardware timer. More...
 
Hardware_Timer &IRAM_ATTR initializeMs (uint32_t milliseconds, InterruptCallback callback=NULL)
 Initialise hardware timer. More...
 
bool IRAM_ATTR start (bool repeating=true)
 Start timer running. More...
 
bool __forceinline IRAM_ATTR startOnce ()
 Start one-shot timer. More...
 
bool 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=1000000)
 Set timer interval. More...
 
bool IRAM_ATTR setIntervalMs (uint32_t milliseconds=1000000)
 Set timer interval. More...
 
void IRAM_ATTR setCallback (InterruptCallback callback)
 Set timer trigger callback. More...
 
void __forceinline IRAM_ATTR call ()
 Call timer callback. More...
 

Detailed Description

Hardware timer class.

Constructor & Destructor Documentation

Hardware_Timer::Hardware_Timer ( )

Hardware timer.

Member Function Documentation

void __forceinline IRAM_ATTR Hardware_Timer::call ( )
inline

Call timer callback.

Note
Calls the timer callback function
uint32_t Hardware_Timer::getIntervalMs ( )

Get timer interval.

Return values
uint32_tTimer interval in milliseconds
uint32_t Hardware_Timer::getIntervalUs ( )

Get timer interval.

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

Initialise hardware timer.

Parameters
millisecondsTimer interval in milliseconds
callbackCallback function to call when timer triggers (Default: none)
Return values
Hardware_Timer&Reference to timer
Hardware_Timer& IRAM_ATTR Hardware_Timer::initializeUs ( uint32_t  microseconds,
InterruptCallback  callback = NULL 
)

Initialise hardware timer.

Parameters
microsecondsTimer interval in microseconds
callbackCallback function to call when timer triggers (Default: none)
Return values
Hardware_Timer&Reference to timer
bool Hardware_Timer::isStarted ( )

Check if timer is started.

Return values
boolTrue if started
bool IRAM_ATTR Hardware_Timer::restart ( )

Restart timer.

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

Set timer trigger callback.

Parameters
callbackFunction to call when timer triggers
bool IRAM_ATTR Hardware_Timer::setIntervalMs ( uint32_t  milliseconds = 1000000)

Set timer interval.

Parameters
millisecondsInterval time in milliseconds (Default: 1s)
bool IRAM_ATTR Hardware_Timer::setIntervalUs ( uint32_t  microseconds = 1000000)

Set timer interval.

Parameters
microsecondsInterval time in microseconds (Default: 1ms)
bool IRAM_ATTR Hardware_Timer::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
bool __forceinline IRAM_ATTR Hardware_Timer::startOnce ( )
inline

Start one-shot timer.

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

Stops timer.

Return values
boolAlways false
Todo:
Why always return false from Hardware_timer::stop()?