43 #if defined(ARDUINO_ARCH_ESP8266)
47 #if defined(ARDUINO_ARCH_ESP32)
48 #include "esp_timer.h"
55 #define UTIMERLIB_TYPE_OFF 0
59 #define UTIMERLIB_TYPE_TIMEOUT 1
63 #define UTIMERLIB_TYPE_INTERVAL 2
65 #if defined(_VARIANT_ARDUINO_STM32_) || defined(ARDUINO_ARCH_STM32)
66 #include "HardwareTimer.h"
74 extern HardwareTimer Timer3;
94 #if defined(_VARIANT_ARDUINO_STM32_) || defined(ARDUINO_ARCH_STM32)
95 volatile static unsigned long int _overflows;
96 volatile static unsigned long int __overflows;
97 volatile static unsigned long int _remaining;
98 volatile static unsigned long int __remaining;
101 volatile static unsigned char _type;
112 #if defined(ARDUINO_ARCH_ESP32)
113 static void interrupt(
void* arg);
116 #if defined(ARDUINO_ARCH_ESP8266)
117 #pragma message "ESP8266 can only reach a ms resolution so any us interrupt will be rounded to that"
118 static void interrupt();
122 TcCount16* _TC = (TcCount16*) TC3;
126 #pragma message "SAMD51 support is still experimental"
132 #if defined(_VARIANT_ARDUINO_STM32_) || defined(ARDUINO_ARCH_STM32)
137 HardwareTimer *Timer3 =
new HardwareTimer(TIM3);
140 volatile unsigned long int _overflows = 0;
141 volatile unsigned long int __overflows = 0;
142 #ifdef ARDUINO_ARCH_AVR
143 volatile unsigned char _remaining = 0;
144 volatile unsigned char __remaining = 0;
146 volatile unsigned long int _remaining = 0;
147 volatile unsigned long int __remaining = 0;
149 void (*_cb)() = NULL;
153 void _loadRemaining();
155 void _attachInterrupt_us(
unsigned long int);
156 void _attachInterrupt_s(
unsigned long int);
159 #if defined(ARDUINO_ARCH_ESP32)
160 esp_timer_handle_t _timer;
163 #if defined(ARDUINO_ARCH_ESP8266)
Arduino tiny and cross-device compatible timer library.
Definition: uTimerLib.h:78
void setTimeout_us(void(*)(), unsigned long int)
Attaches a callback function to be executed once when us microseconds have passed.
Definition: uTimerLib.cpp:74
void setInterval_us(void(*)(), unsigned long int)
Attaches a callback function to be executed each us microseconds.
Definition: uTimerLib.cpp:55
void setInterval_s(void(*)(), unsigned long int)
Attaches a callback function to be executed each s seconds.
Definition: uTimerLib.cpp:93
uTimerLib()
Constructor.
Definition: uTimerLib.cpp:47
void clearTimer()
Loads last bit of time needed to precisely count until desired time (non complete loop)
void setTimeout_s(void(*)(), unsigned long int)
Attaches a callback function to be executed once when s seconds have passed.
Definition: uTimerLib.cpp:112
void _interrupt()
Internal intermediate function to control timer interrupts.
uTimerLib TimerLib
Declares TimerLib variable to access this library's methods.
#define UTIMERLIB_TYPE_OFF
Internal status.
Definition: uTimerLib.h:55