no-OS
Loading...
Searching...
No Matches
no_os_timer.h
Go to the documentation of this file.
1/***************************************************************************/
34
35#ifndef _NO_OS_SRC_TIMER_H_
36#define _NO_OS_SRC_TIMER_H_
37
38#include <stdint.h>
39
40#define TIMER_MAX_TABLE 4
41
48 void *mutex;
50 uint16_t id;
52 uint32_t freq_hz;
54 uint32_t ticks_count;
58 void *extra;
59};
60
67
74 uint16_t id;
76 uint32_t freq_hz;
78 uint32_t ticks_count;
82 void *extra;
83};
84
92 int32_t (*init)(struct no_os_timer_desc **,
93 const struct no_os_timer_init_param *);
95 int32_t (*set_callback)(struct no_os_timer_desc *,
96 void (*handler)(void *),
97 void *ctx);
99 int32_t (*start)(struct no_os_timer_desc *);
101 int32_t (*stop)(struct no_os_timer_desc *);
103 int32_t (*counter_get)(struct no_os_timer_desc *, uint32_t *counter);
105 int32_t (*counter_set)(struct no_os_timer_desc *, uint32_t new_val);
107 int32_t (*count_clk_get)(struct no_os_timer_desc *, uint32_t *freq_hz);
109 int32_t (*count_clk_set)(struct no_os_timer_desc *, uint32_t freq_hz);
112 uint64_t *elapsed_time);
114 int32_t (*remove)(struct no_os_timer_desc *);
115};
116
117/* Initialize hardware timer and the handler structure associated with it. */
118int32_t no_os_timer_init(struct no_os_timer_desc **desc,
119 const struct no_os_timer_init_param *param);
120
121/* Free the memory allocated by timer_setup(). */
122int32_t no_os_timer_remove(struct no_os_timer_desc *desc);
123
124/* Start a timer. */
125int32_t no_os_timer_start(struct no_os_timer_desc *desc);
126
127/* Stop a timer from counting. */
128int32_t no_os_timer_stop(struct no_os_timer_desc *desc);
129
130/* Get the value of the counter register for the timer. */
131int32_t no_os_timer_counter_get(struct no_os_timer_desc *desc,
132 uint32_t *counter);
133
134/* Set the timer counter register value. */
135int32_t no_os_timer_counter_set(struct no_os_timer_desc *desc,
136 uint32_t new_val);
137
138/* Get the timer clock frequency. */
140 uint32_t *freq_hz);
141
142/* Set the timer clock frequency. */
144 uint32_t freq_hz);
145
146/* Get the elapsed time in nsec for the timer. */
148 uint64_t *elapsed_time);
149
150/* Register timer callback and context. */
151int32_t no_os_timer_set_callback(struct no_os_timer_desc *desc,
152 void (*handler)(void *),
153 void *ctx);
154
155#endif // _NO_OS_SRC_TIMER_H_
int32_t no_os_timer_start(struct no_os_timer_desc *desc)
Start a timer.
Definition no_os_timer.c:99
int32_t no_os_timer_set_callback(struct no_os_timer_desc *desc, void(*handler)(void *), void *ctx)
Register timer callback and context.
Definition no_os_timer.c:223
int32_t no_os_timer_init(struct no_os_timer_desc **desc, const struct no_os_timer_init_param *param)
Initialize hardware timer and the handler structure associated with it.
Definition no_os_timer.c:52
int32_t no_os_timer_counter_get(struct no_os_timer_desc *desc, uint32_t *counter)
Get the value of the counter register for the timer.
Definition no_os_timer.c:133
int32_t no_os_timer_counter_set(struct no_os_timer_desc *desc, uint32_t new_val)
Set the timer counter register value.
Definition no_os_timer.c:151
int32_t no_os_timer_count_clk_set(struct no_os_timer_desc *desc, uint32_t freq_hz)
Set the timer clock frequency.
Definition no_os_timer.c:186
int32_t no_os_timer_stop(struct no_os_timer_desc *desc)
Stop a timer from counting.
Definition no_os_timer.c:115
int32_t no_os_timer_remove(struct no_os_timer_desc *desc)
Free the memory allocated by timer_init().
Definition no_os_timer.c:80
int32_t no_os_timer_get_elapsed_time_nsec(struct no_os_timer_desc *desc, uint64_t *elapsed_time)
Get the elapsed time in nsec for the timer.
Definition no_os_timer.c:204
int32_t no_os_timer_count_clk_get(struct no_os_timer_desc *desc, uint32_t *freq_hz)
Get the timer clock frequency.
Definition no_os_timer.c:168
Structure holding timer descriptor.
Definition no_os_timer.h:46
void * extra
Definition no_os_timer.h:58
uint16_t id
Definition no_os_timer.h:50
void * mutex
Definition no_os_timer.h:48
uint32_t freq_hz
Definition no_os_timer.h:52
uint32_t ticks_count
Definition no_os_timer.h:54
const struct no_os_timer_platform_ops * platform_ops
Definition no_os_timer.h:56
Structure holding the parameters for timer initialization.
Definition no_os_timer.h:72
void * extra
Definition no_os_timer.h:82
uint16_t id
Definition no_os_timer.h:74
uint32_t freq_hz
Definition no_os_timer.h:76
const struct no_os_timer_platform_ops * platform_ops
Definition no_os_timer.h:80
uint32_t ticks_count
Definition no_os_timer.h:78
Structure holding timer function pointers that point to the platform specific function.
Definition no_os_timer.h:90
int32_t(* count_clk_get)(struct no_os_timer_desc *, uint32_t *freq_hz)
Definition no_os_timer.h:107
int32_t(* count_clk_set)(struct no_os_timer_desc *, uint32_t freq_hz)
Definition no_os_timer.h:109
int32_t(* remove)(struct no_os_timer_desc *)
Definition no_os_timer.h:114
int32_t(* stop)(struct no_os_timer_desc *)
Definition no_os_timer.h:101
int32_t(* counter_get)(struct no_os_timer_desc *, uint32_t *counter)
Definition no_os_timer.h:103
int32_t(* counter_set)(struct no_os_timer_desc *, uint32_t new_val)
Definition no_os_timer.h:105
int32_t(* start)(struct no_os_timer_desc *)
Definition no_os_timer.h:99
int32_t(* set_callback)(struct no_os_timer_desc *, void(*handler)(void *), void *ctx)
Definition no_os_timer.h:95
int32_t(* init)(struct no_os_timer_desc **, const struct no_os_timer_init_param *)
Definition no_os_timer.h:92
int32_t(* get_elapsed_time_nsec)(struct no_os_timer_desc *, uint64_t *elapsed_time)
Definition no_os_timer.h:111