AKOS  v1.0.0
Documentation
Loading...
Searching...
No Matches
timer.h
Go to the documentation of this file.
1/****************************************************************************/
12
13#ifndef TIMER_H
14#define TIMER_H
15
16#ifdef __cplusplus
17extern "C"
18{
19#endif
20#include "list.h"
21#include <stdint.h>
22#include <stdbool.h>
23
25 typedef struct ak_timer ak_timer_t;
27 typedef struct timer_pool timer_pool_t;
29 typedef uint8_t timer_id_t;
30
37 typedef void (*timer_cb)();
38
48
53 struct ak_timer
54 {
55 ak_timer_t *next;
57 list_item_t timer_list_item;
58 int32_t sig;
59 uint8_t des_thread_id;
61 uint32_t period;
62 };
63
67 void akos_timer_init(void); /* Runs on kernel init */
68
72 void akos_timer_processing(); /* Runs on timer thread */
73
74 /* These APIs are called from application threads. */
85 ak_timer_t *akos_timer_create(timer_id_t id, int32_t sig, timer_cb func_cb, uint8_t des_thread_id, uint32_t period, timer_type_t type);
86
92 void akos_timer_start(ak_timer_t *p_timer, uint32_t tick_to_wait);
97 void akos_timer_reset(ak_timer_t *p_timer);
102 void akos_timer_remove(ak_timer_t *p_timer);
103
104#ifdef __cplusplus
105}
106#endif
107#endif /* TIMER_H */
Doubly-linked list types and APIs for scheduler internals.
Software timer object type.
Definition timer.h:54
timer_cb func_cb
Definition timer.h:60
int32_t sig
Definition timer.h:58
uint8_t des_thread_id
Definition timer.h:59
timer_id_t id
Definition timer.h:56
list_item_t timer_list_item
Definition timer.h:57
ak_timer_t * next
Definition timer.h:55
uint32_t period
Definition timer.h:61
void akos_timer_remove(ak_timer_t *p_timer)
Remove timer from active lists and return to pool.
Definition timer.c:211
void akos_timer_processing()
Timer thread processing loop.
Definition timer.c:247
ak_timer_t * akos_timer_create(timer_id_t id, int32_t sig, timer_cb func_cb, uint8_t des_thread_id, uint32_t period, timer_type_t type)
Create a timer object from timer pool.
Definition timer.c:146
void akos_timer_reset(ak_timer_t *p_timer)
Reset a running timer.
Definition timer.c:321
void akos_timer_init(void)
Initialize timer module.
Definition timer.c:234
timer_type_t
Timer mode.
Definition timer.h:44
@ TIMER_PERIODIC
Definition timer.h:46
@ TIMER_ONE_SHOT
Definition timer.h:45
uint8_t timer_id_t
Timer identifier type.
Definition timer.h:29
struct timer_pool timer_pool_t
Internal timer pool type.
Definition timer.h:27
void(* timer_cb)()
Timer callback signature.
Definition timer.h:37
void akos_timer_start(ak_timer_t *p_timer, uint32_t tick_to_wait)
Start a timer.
Definition timer.c:306