Esp8266/Components/driver/include/driver/os_timer.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * os_timer.h
8  *
9  * @author: 13 August 2018 - mikee47 <mike@sillyhouse.net>
10  *
11  * An alternative method for setting software timers based on the tick count.
12  *
13  */
14 
15 #pragma once
16 
17 #include <esp_system.h>
18 
19 // Disarmed
20 #define OS_TIMER_DEFAULT() \
21  { \
22  .timer_next = (os_timer_t*)-1, \
23  }
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
44 void os_timer_arm_ticks(os_timer_t* ptimer, uint32_t ticks, bool repeat_flag);
45 
46 static inline bool os_timer_is_armed(const os_timer_t* ptimer)
47 {
48  return ptimer != nullptr && int(ptimer->timer_next) != -1;
49 }
50 
51 static inline uint64_t os_timer_expire(const os_timer_t* ptimer)
52 {
53  if(ptimer == nullptr || int(ptimer->timer_next) == -1) {
54  return 0;
55  }
56  return ptimer->timer_expire;
57 }
58 
59 static inline void os_timer_done(os_timer_t* ptimer)
60 {
61  ets_timer_disarm(ptimer);
62 }
63 
66 #ifdef __cplusplus
67 }
68 #endif
void os_timer_arm_ticks(os_timer_t *ptimer, uint32_t ticks, bool repeat_flag)
Set a software timer using the Timer2 tick value.
This is the structure used by the Espressif timer API.
Definition: Rp2040/Components/driver/include/driver/os_timer.h:28
struct os_timer_t * timer_next
If disarmed, set to -1, otherwise points to the next queued timer (or NULL if last in the list)
Definition: Rp2040/Components/driver/include/driver/os_timer.h:30
static uint64_t os_timer_expire(const os_timer_t *ptimer)
Definition: Esp8266/Components/driver/include/driver/os_timer.h:51
uint32_t timer_expire
Set to the next Timer2 count value when the timer will expire.
Definition: Rp2040/Components/driver/include/driver/os_timer.h:32
static void os_timer_done(os_timer_t *ptimer)
Definition: Esp8266/Components/driver/include/driver/os_timer.h:59
static bool os_timer_is_armed(const os_timer_t *ptimer)
Definition: Esp8266/Components/driver/include/driver/os_timer.h:46