VSF Documented
vsf_eda_timer.c
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18
19/*============================ INCLUDES ======================================*/
20
22
23#if VSF_USE_KERNEL == ENABLED && defined(__EDA_GADGET__)
24
25#if __IS_COMPILER_IAR__
27# pragma diag_suppress=pe111
28#endif
29
30/*============================ MACROS ========================================*/
31/*============================ MACROFIED FUNCTIONS ===========================*/
32
33#if VSF_CALLBACK_TIMER_CFG_SUPPORT_ISR == ENABLED
34# define __vsf_callback_timer_protect vsf_protect(interrupt)
35# define __vsf_callback_timer_unprotect vsf_unprotect(interrupt)
36#else
37# define __vsf_callback_timer_protect vsf_protect(scheduler)
38# define __vsf_callback_timer_unprotect vsf_unprotect(scheduler)
39#endif
40
41/*============================ TYPES =========================================*/
42/*============================ GLOBAL VARIABLES ==============================*/
43/*============================ LOCAL VARIABLES ===============================*/
44/*============================ PROTOTYPES ====================================*/
45
46#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
47# if VSF_SYSTIMER_CFG_IMPL_MODE != VSF_SYSTIMER_IMPL_NONE
48# if (VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICKLESS) \
49 && (VSF_SYSTIMER_CFG_IMPL_MODE == VSF_SYSTIMER_IMPL_TICK_MODE)
50# error systimer is in tick mode while tickless mode is required on kernel
51# endif
52# if (VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICK) \
53 && (VSF_SYSTIMER_CFG_IMPL_MODE != VSF_SYSTIMER_IMPL_TICK_MODE)
54# warning systimer is not in tick mode while tick mode is required on kernel,\
55 ignore this warning if your arch does not support tick mode systimer,\
56 or set VSF_SYSTIMER_CFG_IMPL_MODE to VSF_SYSTIMER_IMPL_TICK_MODE\
57 for better optimization.
58# endif
59# endif
60
61# if VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICKLESS \
62 && (VSF_SYSTIMER_CFG_IMPL_MODE == VSF_SYSTIMER_IMPL_NONE)
64extern vsf_err_t vsf_systimer_start(void);
70# endif
71
72VSF_CAL_SECTION(".text.vsf.kernel.teda")
73static void __vsf_teda_timer_enqueue(vsf_teda_t *this_ptr, vsf_systimer_tick_t due);
74
77#endif
78
79/*============================ IMPLEMENTATION ================================*/
80
81#if VSF_KERNEL_CFG_EDA_SUPPORT_TIMER == ENABLED
82// __vsf_systimer_update: reprogram the systimer for the new earliest due
83// timer. Shared by BOTH kernel timer modes (tick and tickless), and
84// DEFINED ONLY when the systimer impl supports programming:
85// - NONE / TICK_MODE systimer impl: nothing to reprogram (the periodic
86// tick drives the queue) -- no definition, and every call site is
87// guarded by the same condition, so nothing is emitted at all;
88// - NORMAL/COMP_TIMER systimer impl: vsf_systimer_set() is mandatory on
89// COMP_TIMER (no periodic round would fire otherwise) and avoids a
90// one-round latency on NORMAL_TIMER.
91// pre_tick dedupe and the post-on-set-failure wakeup only exist in
92// tickless mode (the timer.pre_tick field and __vsf_systimer_wakeup are
93// tickless-only); in tick mode a failed set merely delays the timeout to
94// the next systimer round, nothing is lost.
95#if (VSF_SYSTIMER_CFG_IMPL_MODE != VSF_SYSTIMER_IMPL_NONE) \
96 && (VSF_SYSTIMER_CFG_IMPL_MODE != VSF_SYSTIMER_IMPL_TICK_MODE)
97# if VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICKLESS
98static void __vsf_systimer_wakeup(void);
99# endif
100static void __vsf_systimer_update(bool force)
101{
102 vsf_teda_t *teda;
103
104 // TODO: need protect here?
105 vsf_timq_peek(&__vsf_eda.timer.timq, teda);
106 if (NULL == teda) {
108 return;
109 }
110# if VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICKLESS
111 if (force || (teda->due != __vsf_eda.timer.pre_tick)) {
112 __vsf_eda.timer.pre_tick = teda->due;
113 if (!vsf_systimer_set(teda->due)) {
114 __vsf_systimer_wakeup();
115 }
116 }
117# else
118 (void)force;
119 vsf_systimer_set(teda->due);
120# endif
121}
122#endif
123
124#if VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICKLESS
125
126static void __vsf_systimer_wakeup(void)
127{
128 if (!__vsf_eda.timer.processing) {
129 __vsf_eda.timer.processing = true;
130 if (vsf_eda_post_evt((vsf_eda_t *)&__vsf_eda.task, VSF_EVT_TIMER)) {
131 __vsf_eda.timer.processing = false;
132 }
133 }
134}
135
136VSF_CAL_SECTION(".text.vsf.kernel.teda")
137static bool __vsf_systimer_is_due(vsf_systimer_tick_t due)
138{
139 return vsf_systimer_is_due(due);
140}
141
142VSF_CAL_SECTION(".text.vsf.kernel.teda")
143static void __vsf_systimer_start(void)
144{
145 vsf_systimer_prio_set(__vsf_eda.timer.arch_prio);
146
148}
149
150// DO NOT add section on vsf_systimer_evthandler, it's a weak function in arch
151void vsf_systimer_evthandler(vsf_systimer_tick_t tick)
152{
153#if VSF_KERNEL_CFG_TRACE == ENABLED
154 if (!__vsf_eda.timer.is_isr_info_sent) {
155 __vsf_eda.timer.is_isr_info_sent = true;
156 vsf_kernel_trace_isr_info(vsf_get_interrupt_id(), "systimer");
157 }
158 vsf_kernel_trace_isr_enter(vsf_get_interrupt_id());
159#endif
160
161 VSF_UNUSED_PARAM(tick);
162 __vsf_systimer_wakeup();
163
164#if VSF_KERNEL_CFG_TRACE == ENABLED
165 vsf_kernel_trace_isr_leave(vsf_get_interrupt_id());
166#endif
167}
168
169VSF_CAL_SECTION(".text.vsf.kernel.teda")
170static vsf_err_t __vsf_teda_set_timer_imp(vsf_teda_t *this_ptr, vsf_systimer_tick_t due)
171{
172 __vsf_teda_timer_enqueue(this_ptr, due);
173#if (VSF_SYSTIMER_CFG_IMPL_MODE != VSF_SYSTIMER_IMPL_NONE) \
174 && (VSF_SYSTIMER_CFG_IMPL_MODE != VSF_SYSTIMER_IMPL_TICK_MODE)
175 __vsf_systimer_update(false);
176#endif
177 return VSF_ERR_NONE;
178}
179
180VSF_CAL_SECTION(".text.vsf.kernel.teda")
182{
183 return vsf_systimer_get();
184}
185#else // VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICKLESS
186VSF_CAL_SECTION(".text.vsf.kernel.teda")
187static void __vsf_systimer_start(void)
188{
189 // in tick timer mode, user will initialize timer and call vsf_systimer_on_tick
190}
191
192VSF_CAL_SECTION(".text.vsf.kernel.teda")
193static bool __vsf_systimer_is_due(vsf_systimer_tick_t due)
194{
195 return vsf_systimer_is_due(due);
196}
197
198VSF_CAL_SECTION(".text.vsf.kernel.teda")
199void vsf_systimer_on_tick(void)
200{
201 // Tick mode dedupe, race-free form: skip the post whenever the kernel
202 // task eda has ANY queued event. If the pending event is a TIMER event,
203 // its dispatch walks the whole due timq/callback_timq anyway; if it is
204 // another event (MESSAGE/CALLBACK_TIMER), that dispatch does NOT walk
205 // the timer queues, but the queue drains and the next tick re-posts --
206 // worst case is a bounded delay (busy period + 1 tick), never a loss.
207 // An earlier flag-based dedupe (producer sets, consumer clears)
208 // could wedge with evt_pending==1 and an empty queue -> all timer
209 // processing stopped (observed as the TLS-window freeze).
210 // Worst case is a duplicate TIMER event (extra timq walk), which is
211 // harmless. Posting every systick allocs an evt node per tick from a
212 // 16-entry pool; without dedupe a slow/preempted drain exhausts the
213 // pool (assert -> halt).
214 // NOTE: the pending-event check is implementation-specific -- evt_list
215 // exists only in __VSF_OS_CFG_EVTQ_LIST, evt_cnt in
216 // __VSF_OS_CFG_EVTQ_ARRAY; the single-slot evt_pending variant absorbs
217 // repeat posts by design and needs no dedupe.
218 vsf_eda_t *task = (vsf_eda_t *)&__vsf_eda.task;
219#if defined(__VSF_OS_CFG_EVTQ_LIST)
220 if (vsf_slist_queue_is_empty(&task->evt_list)) {
221 vsf_eda_post_evt(task, VSF_EVT_TIMER);
222 }
223#elif defined(__VSF_OS_CFG_EVTQ_ARRAY)
224 if (0 == task->evt_cnt) {
225 vsf_eda_post_evt(task, VSF_EVT_TIMER);
226 }
227#else
229#endif
230}
231
232VSF_CAL_SECTION(".text.vsf.kernel.teda")
233static vsf_err_t __vsf_teda_set_timer_imp(vsf_teda_t *this_ptr, vsf_systimer_tick_t due)
234{
235 __vsf_teda_timer_enqueue(this_ptr, due);
236 // reprogram the systimer for the new earliest due (mandatory on
237 // COMP_TIMER, latency optimization on NORMAL_TIMER; TICK_MODE
238 // systimers are driven by the periodic tick and need nothing)
239#if (VSF_SYSTIMER_CFG_IMPL_MODE != VSF_SYSTIMER_IMPL_NONE) \
240 && (VSF_SYSTIMER_CFG_IMPL_MODE != VSF_SYSTIMER_IMPL_TICK_MODE)
241 __vsf_systimer_update(false);
242#endif
243 return VSF_ERR_NONE;
244}
245
246VSF_CAL_SECTION(".text.vsf.kernel.teda")
248{
249 return vsf_systimer_get();
250}
251#endif // VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICKLESS
252
253VSF_CAL_SECTION(".text.vsf.kernel.teda")
254static void __vsf_systimer_init(void)
255{
256#if VSF_KERNEL_CFG_TIMER_MODE == VSF_KERNEL_CFG_TIMER_MODE_TICKLESS
257 __vsf_eda.timer.processing = false;
258#endif
259 vsf_timq_init(&__vsf_eda.timer.timq);
260#if VSF_KERNEL_CFG_SUPPORT_CALLBACK_TIMER == ENABLED
261 vsf_callback_timq_init(&__vsf_eda.timer.callback_timq);
262 vsf_callback_timq_init(&__vsf_eda.timer.callback_timq_done);
263#endif
264
265#if VSF_SYSTIMER_CFG_IMPL_MODE != VSF_SYSTIMER_IMPL_NONE
267#endif
268}
269
270VSF_CAL_SECTION(".text.vsf.kernel.teda")
271static void __vsf_teda_timer_enqueue(vsf_teda_t *this_ptr, vsf_systimer_tick_t due)
272{
273 VSF_KERNEL_ASSERT((this_ptr != NULL) && !this_ptr->use_as__vsf_eda_t.flag.state.is_timed);
274 this_ptr->due = due;
275
276 vsf_timq_insert(&__vsf_eda.timer.timq, this_ptr);
277 this_ptr->use_as__vsf_eda_t.flag.state.is_timed = true;
278#if VSF_KERNEL_OPT_AVOID_UNNECESSARY_YIELD_EVT == ENABLED
279 vsf_protect_t origlevel = vsf_protect_int();
280 this_ptr->use_as__vsf_eda_t.is_evt_incoming = true;
281 vsf_unprotect_int(origlevel);
282#endif
283}
284
285#if VSF_KERNEL_CFG_SUPPORT_CALLBACK_TIMER == ENABLED
286VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_init")
288{
289 timer->due = 0;
290}
291
292VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_add_due")
294{
295 vsf_protect_t origlevel;
296# if VSF_CALLBACK_TIMER_CFG_SUPPORT_ISR == ENABLED
297 vsf_protect_t lock_status;
298# endif
299 bool is_to_update = false;
300 VSF_KERNEL_ASSERT(timer != NULL);
301 VSF_KERNEL_ASSERT(due != 0);
302
303 if (timer->due != 0) {
305 return VSF_ERR_FAIL;
306 }
307
308 origlevel = vsf_protect_sched();
309# if VSF_CALLBACK_TIMER_CFG_SUPPORT_ISR == ENABLED
310 lock_status = __vsf_callback_timer_protect();
311# endif
312 timer->due = due;
313 vsf_callback_timq_insert(&__vsf_eda.timer.callback_timq, timer);
314 if (NULL == timer->timer_node.prev) {
315 is_to_update = true;
316 }
317# if VSF_CALLBACK_TIMER_CFG_SUPPORT_ISR == ENABLED
318 __vsf_callback_timer_unprotect(lock_status);
319# endif
320 if (is_to_update) {
321 __vsf_teda_cancel_timer((vsf_teda_t *)&__vsf_eda.task);
322 __vsf_teda_set_timer_imp((vsf_teda_t *)&__vsf_eda.task, timer->due);
323 }
324 vsf_unprotect_sched(origlevel);
325 return VSF_ERR_NONE;
326}
327
328VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_add")
330{
332}
333
334VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_remove")
336{
337 vsf_protect_t lock_status;
338 VSF_KERNEL_ASSERT(timer != NULL);
339
340 lock_status = __vsf_callback_timer_protect();
341 if (timer->due != 0) {
342 timer->due = 0;
343 vsf_callback_timq_remove(&__vsf_eda.timer.callback_timq, timer);
344 }
345 __vsf_callback_timer_unprotect(lock_status);
346 return VSF_ERR_NONE;
347}
348
349# if VSF_CALLBACK_TIMER_CFG_SUPPORT_ISR == ENABLED
350VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_add_due_isr")
352{
353 VSF_KERNEL_ASSERT(timer != NULL);
354 if (timer->due != 0) {
356 return VSF_ERR_FAIL;
357 }
358
359 timer->due = due;
360 return vsf_eda_post_evt_msg((vsf_eda_t *)&__vsf_eda.task, VSF_KERNEL_EVT_CALLBACK_TIMER_ADD, timer);
361}
362
363VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_add_isr")
365{
367}
368
369VSF_CAL_SECTION(".text.vsf.kernel.vsf_callback_timer_remove_isr")
371{
372 return vsf_callback_timer_remove(timer);
373}
374# endif // VSF_CALLBACK_TIMER_CFG_SUPPORT_ISR
375#endif // VSF_KERNEL_CFG_SUPPORT_CALLBACK_TIMER
376
377VSF_CAL_SECTION(".text.vsf.kernel.vsf_systimer_get_duration")
379{
380 return (vsf_systimer_tick_t)(to_time - from_time);
381}
382
383VSF_CAL_SECTION(".text.vsf.kernel.vsf_systimer_get_elapsed")
385{
387}
388
389VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_start")
391{
392 VSF_KERNEL_ASSERT(this_ptr != NULL);
393 return vsf_eda_start(&(this_ptr->use_as__vsf_eda_t), cfg);
394}
395
396VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_set_due_ex")
398{
399 vsf_protect_t origlevel;
400 vsf_err_t err;
401
402 origlevel = vsf_protect_sched();
403 err = __vsf_teda_set_timer_imp(this_ptr, due);
404 vsf_unprotect_sched(origlevel);
405 return err;
406}
407
408VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_set_timer_ex")
410{
411 if (0 == tick) {
412 VSF_KERNEL_ASSERT(false);
414 }
415 return vsf_teda_set_due_ex(this_ptr, vsf_systimer_get_tick() + tick);
416}
417
418#if __IS_COMPILER_ARM_COMPILER_6__
419# pragma clang diagnostic push
420# pragma clang diagnostic ignored "-Wcast-align"
421#endif
422
423#if __IS_COMPILER_GCC__
424# pragma GCC diagnostic push
425# pragma GCC diagnostic ignored "-Wcast-align"
426#endif
427
428VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_set_timer")
430{
432 VSF_KERNEL_ASSERT(teda != NULL);
433 return vsf_teda_set_timer_ex(teda, tick);
434}
435
436#if __IS_COMPILER_ARM_COMPILER_6__
437# pragma clang diagnostic pop
438#endif
439
440#if __IS_COMPILER_GCC__
441# pragma GCC diagnostic pop
442#endif
443
444#if __IS_COMPILER_ARM_COMPILER_6__
445# pragma clang diagnostic push
446# pragma clang diagnostic ignored "-Wcast-align"
447#endif
448
449#if __IS_COMPILER_GCC__
450# pragma GCC diagnostic push
451# pragma GCC diagnostic ignored "-Wcast-align"
452#endif
453
454VSF_CAL_SECTION(".text.vsf.kernel.__vsf_teda_cancel_timer")
456{
457 vsf_protect_t lock_status;
458 this_ptr = (vsf_teda_t *)__vsf_eda_get_valid_eda((vsf_eda_t *)this_ptr);
459
460 VSF_KERNEL_ASSERT(this_ptr != NULL);
461
462 lock_status = vsf_protect_sched();
463 if (this_ptr->use_as__vsf_eda_t.flag.state.is_timed) {
464 vsf_timq_remove(&__vsf_eda.timer.timq, this_ptr);
465 this_ptr->use_as__vsf_eda_t.flag.state.is_timed = false;
466 }
467#if (VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED) && defined(__VSF_OS_CFG_EVTQ_LIST)
468 this_ptr->use_as__vsf_eda_t.flag.state.is_to_set_due = false;
469#endif
470 vsf_unprotect_sched(lock_status);
471 return VSF_ERR_NONE;
472}
473
474VSF_CAL_SECTION(".text.vsf.kernel.vsf_teda_cancel_timer")
476{
478#if VSF_KERNEL_CFG_ALLOW_KERNEL_BEING_PREEMPTED == ENABLED
480#endif
481 return VSF_ERR_NONE;
482}
483
484#if __IS_COMPILER_ARM_COMPILER_6__
485# pragma clang diagnostic pop
486#endif
487
488#if __IS_COMPILER_GCC__
489# pragma GCC diagnostic pop
490#endif
491
492#endif // VSF_KERNEL_CFG_EDA_SUPPORT_TIMER
493
494#if __IS_COMPILER_IAR__
496# pragma diag_warning=pe111
497#endif
498
499#endif // VSF_USE_KERNEL && __EDA_GADGET__
#define VSF_CAL_SECTION(__SEC_STR)
Definition __compiler.h:189
#define VSF_UNUSED_PARAM(__VAL)
Definition __type.h:190
vsf_err_t
Definition __type.h:42
@ VSF_ERR_NONE
none error
Definition __type.h:44
@ VSF_ERR_NOT_AVAILABLE
service not available
Definition __type.h:47
@ VSF_ERR_FAIL
failed
Definition __type.h:51
Task-independent timer; when it expires the kernel task invokes the user callback.
Definition vsf_eda.h:1937
The event-driven task (TCB); every VSF task is an eda at the bottom. Tasks share stacks and only occu...
Definition vsf_eda.h:1838
eda with timer support (can use vsf_teda_set_timer() etc.); derived classes (task/pt/thread) inherit ...
Definition vsf_eda.h:1916
uint64_t vsf_systimer_tick_t
Definition cortex_a_generic.h:70
void vsf_systimer_prio_set(vsf_arch_prio_t priority)
Definition cortex_m_generic.c:249
int vsf_get_interrupt_id(void)
Definition cortex_m_generic.c:434
void vsf_systimer_set_idle(void)
Definition linux_generic.c:398
bool vsf_systimer_is_due(vsf_systimer_tick_t due)
Definition linux_generic.c:430
vsf_systimer_tick_t vsf_systimer_ms_to_tick(uint_fast32_t time_ms)
Definition linux_generic.c:440
vsf_systimer_tick_t vsf_systimer_us_to_tick(uint_fast32_t time_us)
Definition linux_generic.c:435
vsf_systimer_tick_t vsf_systimer_tick_to_ms(vsf_systimer_tick_t tick)
Definition linux_generic.c:450
vsf_err_t vsf_systimer_start(void)
Definition linux_generic.c:390
bool vsf_systimer_set(vsf_systimer_tick_t due)
Definition linux_generic.c:409
#define NULL
Definition lvgl.h:26
unsigned int uint_fast32_t
Definition stdint.h:27
Configuration for starting an eda/teda task (vsf_eda_start(), vsf_teda_start(), init_vsf_peda(),...
Definition vsf_eda.h:1804
uintalu_t vsf_protect_t
Definition vsf_arch_abstraction.h:60
#define vsf_protect_int
Definition vsf_arch_abstraction.h:376
#define vsf_unprotect_int
Definition vsf_arch_abstraction.h:377
vsf_err_t vsf_eda_post_evt(vsf_eda_t *pthis, vsf_evt_t evt)
Post an event to an eda task.
Definition vsf_eda.c:935
vsf_err_t vsf_eda_post_evt_msg(vsf_eda_t *pthis, vsf_evt_t evt, void *msg)
Post an event carrying a pointer message to an eda task; the pointer is retrieved with vsf_eda_get_cu...
Definition vsf_eda.c:969
vsf_eda_t * vsf_eda_get_cur(void)
Get the eda task currently being dispatched.
Definition vsf_eda.c:416
vsf_err_t vsf_eda_start(vsf_eda_t *pthis, vsf_eda_cfg_t *cfg_ptr)
Start an eda task with the given configuration and post VSF_EVT_INIT to it.
Definition vsf_eda.c:835
void vsf_kernel_err_report(enum vsf_kernel_error_t err)
Report a kernel error.
Definition vsf_eda.c:409
void vsf_systimer_on_tick(void)
System timer tick handler; called by the user on every system tick to drive the kernel timers.
vsf_err_t vsf_teda_cancel_timer(void)
Cancel the pending timer of the current teda task.
vsf_err_t vsf_callback_timer_add_isr(vsf_callback_timer_t *timer, vsf_systimer_tick_t tick)
Add a callback timer with a relative interval in ticks from interrupt context.
vsf_err_t vsf_callback_timer_remove_isr(vsf_callback_timer_t *timer)
Remove a callback timer from interrupt context.
vsf_err_t vsf_teda_set_timer(vsf_systimer_tick_t tick)
Set a one-shot timer of the given ticks for the current teda task; the task receives VSF_EVT_TIMER wh...
@ VSF_EVT_TIMER
teda timer expired (only for teda tasks)
Definition vsf_eda.h:1569
@ VSF_KERNEL_ERR_INVALID_USAGE
API used incorrectly.
Definition vsf_eda.h:2370
void vsf_callback_timer_init(vsf_callback_timer_t *timer)
Initialize a task-independent callback timer; set the on_timer callback before adding the timer.
vsf_systimer_tick_t vsf_systimer_get_elapsed(vsf_systimer_tick_t from_time)
Get the ticks elapsed from the given tick count to now.
vsf_systimer_tick_t vsf_systimer_get_tick(void)
Get the current system timer tick count.
vsf_err_t vsf_callback_timer_add_due(vsf_callback_timer_t *timer, vsf_systimer_tick_t due)
Add a callback timer with an absolute due tick.
vsf_err_t vsf_teda_set_timer_ex(vsf_teda_t *pthis, vsf_systimer_tick_t tick)
Set a one-shot timer of the given ticks for the given teda task; the task receives VSF_EVT_TIMER when...
vsf_err_t vsf_callback_timer_add(vsf_callback_timer_t *timer, vsf_systimer_tick_t tick)
Add a callback timer with a relative interval in ticks.
vsf_err_t vsf_teda_start(vsf_teda_t *pthis, vsf_eda_cfg_t *cfg)
Start a teda (eda with timer support) task with the given configuration and post VSF_EVT_INIT to it.
@ VSF_KERNEL_EVT_CALLBACK_TIMER_ADD
Definition vsf_eda.h:1608
vsf_err_t vsf_teda_set_due_ex(vsf_teda_t *this_ptr, vsf_systimer_tick_t due)
Set a one-shot timer with an absolute due tick for the given teda task.
vsf_err_t vsf_callback_timer_add_due_isr(vsf_callback_timer_t *timer, vsf_systimer_tick_t due)
Add a callback timer with an absolute due tick from interrupt context.
vsf_systimer_tick_t vsf_systimer_get_duration(vsf_systimer_tick_t from_time, vsf_systimer_tick_t to_time)
Get the tick duration between two tick counts, handling wrap-around.
vsf_err_t __vsf_teda_cancel_timer(vsf_teda_t *pthis)
Cancel the pending timer of the given teda task.
vsf_err_t vsf_callback_timer_remove(vsf_callback_timer_t *timer)
Remove a callback timer before it expires.
void vsf_evtq_clean_evt(vsf_evt_t evt)
Clean the pending event(s) posted to the current eda.
Definition vsf_evtq_list.c:257
#define __VSF_OS_CFG_EVTQ_LIST
Definition vsf_kernel_cfg.h:304
#define VSF_KERNEL_ASSERT
Definition vsf_kernel_cfg.h:32
#define vsf_slist_queue_is_empty(__queue_ptr)
Definition vsf_list.h:642
#define vsf_protect_sched()
Lock the scheduler and return the previous status as vsf_protect_t.
Definition vsf_os.h:271
#define vsf_unprotect_sched(__prot)
Restore the scheduler lock status saved by vsf_protect_sched()
Definition vsf_os.h:283
vsf_systimer_tick_t vsf_systimer_get(void)
Definition linux_generic.c:402
vsf_systimer_tick_t vsf_systimer_tick_to_us(vsf_systimer_tick_t tick)
Definition linux_generic.c:445
vsf_err_t vsf_systimer_init(void)
initialise SysTick to generate a system timer !
Definition linux_generic.c:365
#define vsf_callback_timq_remove(__queue, __timer)
Remove a callback timer from the timer queue.
Definition vsf_timq_dlist.h:184
#define vsf_timq_peek(__queue, __teda)
Get the head timer eda (the earliest due) of the timer queue without removing it.
Definition vsf_timq_dlist.h:95
#define vsf_timq_init(__queue)
Initialize a timer queue.
Definition vsf_timq_dlist.h:42
#define vsf_timq_insert(__queue, __teda)
Insert a timer eda into the timer queue, sorted in ascending order of due.
Definition vsf_timq_dlist.h:56
#define vsf_callback_timq_init(__queue)
Initialize a callback timer queue.
Definition vsf_timq_dlist.h:133
#define vsf_timq_remove(__queue, __teda)
Remove a timer eda from the timer queue.
Definition vsf_timq_dlist.h:75
#define vsf_callback_timq_insert(__queue, __timer)
Insert a callback timer into the timer queue, sorted in ascending order of due.
Definition vsf_timq_dlist.h:165
Generated from commit: vsfteam/vsf@d7c7a8f