18 #ifndef _SMING_CORE_HARDWARE_TIMER_H_ 19 #define _SMING_CORE_HARDWARE_TIMER_H_ 21 #include "Interrupts.h" 24 #define MAX_HW_TIMER_INTERVAL_US 0x7fffff 25 #define MIN_HW_TIMER_INTERVAL_US 0x32 28 enum HardwareTimerMode {
63 InterruptCallback callback =
nullptr);
71 InterruptCallback callback =
nullptr);
77 bool IRAM_ATTR
start(
bool repeating =
true);
90 void IRAM_ATTR
stop();
138 void IRAM_ATTR
setCallback(InterruptCallback callback);
143 __forceinline
void IRAM_ATTR
call()
145 if(callback !=
nullptr) {
151 uint32_t interval = 0;
152 InterruptCallback callback =
nullptr;
153 bool repeating =
false;
154 bool started =
false;
uint32_t IRAM_ATTR usToTimerTicks(uint32_t us)
Convert microseconds into timer ticks.
Definition: HardwareTimer.h:160
__forceinline bool IRAM_ATTR setIntervalMs(uint32_t milliseconds)
Set timer interval.
Definition: HardwareTimer.h:130
HardwareTimer(HardwareTimerMode mode=eHWT_NonMaskable)
Hardware timer.
bool IRAM_ATTR start(bool repeating=true)
Start timer running.
Hardware timer class.
Definition: HardwareTimer.h:44
uint32_t getIntervalMs()
Get timer interval.
Definition: HardwareTimer.h:117
bool IRAM_ATTR restart()
Restart timer.
uint32_t getIntervalUs()
Get timer interval.
Definition: HardwareTimer.h:109
HardwareTimer &IRAM_ATTR initializeMs(uint32_t milliseconds, InterruptCallback callback=nullptr)
Initialise hardware timer.
void IRAM_ATTR stop()
Stops timer.
__forceinline void IRAM_ATTR call()
Call timer callback.
Definition: HardwareTimer.h:143
void IRAM_ATTR setCallback(InterruptCallback callback)
Set timer trigger callback.
bool isStarted()
Check if timer is started.
Definition: HardwareTimer.h:101
HardwareTimer &IRAM_ATTR initializeUs(uint32_t microseconds, InterruptCallback callback=nullptr)
Initialise hardware timer.
__forceinline bool IRAM_ATTR startOnce()
Start one-shot timer.
Definition: HardwareTimer.h:83
uint32_t IRAM_ATTR timerTicksToUs(uint32_t ticks)
Convert timer ticks into microseconds.
bool IRAM_ATTR setIntervalUs(uint32_t microseconds)
Set timer interval.