objc

timer.h
Go to the documentation of this file.
1 
23 #pragma once
24 #include <stdbool.h>
25 #include <stddef.h>
26 #include <stdint.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
39 #define SYS_TIMER_CTX_SIZE 32
40 
48 typedef struct sys_timer_t {
49  void (*callback)(struct sys_timer_t *);
50  uint32_t interval;
51  void *userdata;
52  union {
53  void *ptr;
54  uint8_t
56  } ctx;
57 } sys_timer_t;
58 
74 extern sys_timer_t sys_timer_init(uint32_t interval_ms, void *userdata,
75  void (*callback)(sys_timer_t *));
76 
86 extern bool sys_timer_start(sys_timer_t *timer);
87 
98 extern bool sys_timer_finalize(sys_timer_t *timer);
99 
106 extern bool sys_timer_valid(sys_timer_t *timer);
107 
108 #ifdef __cplusplus
109 }
110 #endif
#define SYS_TIMER_CTX_SIZE
Size of the timer context buffer.
Definition: timer.h:39
bool sys_timer_valid(sys_timer_t *timer)
Checks if a timer is valid, configured and running.
bool sys_timer_finalize(sys_timer_t *timer)
Cancels and finalizes a timer.
struct sys_timer_t sys_timer_t
Timer context structure.
sys_timer_t sys_timer_init(uint32_t interval_ms, void *userdata, void(*callback)(sys_timer_t *))
Initializes a new timer context.
void * ptr
Pointer to external timer context (platform-specific)
Definition: timer.h:53
uint32_t interval
Timer interval in milliseconds.
Definition: timer.h:50
void * userdata
User-defined data passed to callback.
Definition: timer.h:51
void(* callback)(struct sys_timer_t *)
Function called when timer fires.
Definition: timer.h:49
Timer context structure.
Definition: timer.h:48
bool sys_timer_start(sys_timer_t *timer)
Starts a timer.
uint8_t ctx[SYS_TIMER_CTX_SIZE]
Internal context buffer for timer state.
Definition: timer.h:55