no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
no_os_timer.h
Go to the documentation of this file.
1/***************************************************************************/
33
34#ifndef _NO_OS_SRC_TIMER_H_
35#define _NO_OS_SRC_TIMER_H_
36
37#include <stdint.h>
38
39#define TIMER_MAX_TABLE 4
40
47 void *mutex;
49 uint16_t id;
51 uint32_t freq_hz;
53 uint32_t ticks_count;
57 void *extra;
58};
59
66
73 uint16_t id;
75 uint32_t freq_hz;
77 uint32_t ticks_count;
81 void *extra;
82};
83
91 int32_t (*init)(struct no_os_timer_desc **,
92 const struct no_os_timer_init_param *);
94 int32_t (*start)(struct no_os_timer_desc *);
96 int32_t (*stop)(struct no_os_timer_desc *);
98 int32_t (*counter_get)(struct no_os_timer_desc *, uint32_t *counter);
100 int32_t (*counter_set)(struct no_os_timer_desc *, uint32_t new_val);
102 int32_t (*count_clk_get)(struct no_os_timer_desc *, uint32_t *freq_hz);
104 int32_t (*count_clk_set)(struct no_os_timer_desc *, uint32_t freq_hz);
107 uint64_t *elapsed_time);
109 int32_t (*remove)(struct no_os_timer_desc *);
110};
111
112/* Initialize hardware timer and the handler structure associated with it. */
113int32_t no_os_timer_init(struct no_os_timer_desc **desc,
114 const struct no_os_timer_init_param *param);
115
116/* Free the memory allocated by timer_setup(). */
117int32_t no_os_timer_remove(struct no_os_timer_desc *desc);
118
119/* Start a timer. */
120int32_t no_os_timer_start(struct no_os_timer_desc *desc);
121
122/* Stop a timer from counting. */
123int32_t no_os_timer_stop(struct no_os_timer_desc *desc);
124
125/* Get the value of the counter register for the timer. */
126int32_t no_os_timer_counter_get(struct no_os_timer_desc *desc,
127 uint32_t *counter);
128
129/* Set the timer counter register value. */
130int32_t no_os_timer_counter_set(struct no_os_timer_desc *desc,
131 uint32_t new_val);
132
133/* Get the timer clock frequency. */
135 uint32_t *freq_hz);
136
137/* Set the timer clock frequency. */
139 uint32_t freq_hz);
140
141/* Get the elapsed time in nsec for the timer. */
143 uint64_t *elapsed_time);
144
145#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:98
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:51
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:132
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:150
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:185
int32_t no_os_timer_stop(struct no_os_timer_desc *desc)
Stop a timer from counting.
Definition no_os_timer.c:114
int32_t no_os_timer_remove(struct no_os_timer_desc *desc)
Free the memory allocated by timer_init().
Definition no_os_timer.c:79
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:203
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:167
Structure holding timer descriptor.
Definition no_os_timer.h:45
void * extra
Definition no_os_timer.h:57
uint16_t id
Definition no_os_timer.h:49
void * mutex
Definition no_os_timer.h:47
uint32_t freq_hz
Definition no_os_timer.h:51
uint32_t ticks_count
Definition no_os_timer.h:53
const struct no_os_timer_platform_ops * platform_ops
Definition no_os_timer.h:55
Structure holding the parameters for timer initialization.
Definition no_os_timer.h:71
void * extra
Definition no_os_timer.h:81
uint16_t id
Definition no_os_timer.h:73
uint32_t freq_hz
Definition no_os_timer.h:75
const struct no_os_timer_platform_ops * platform_ops
Definition no_os_timer.h:79
uint32_t ticks_count
Definition no_os_timer.h:77
Structure holding timer function pointers that point to the platform specific function.
Definition no_os_timer.h:89
int32_t(* count_clk_get)(struct no_os_timer_desc *, uint32_t *freq_hz)
Definition no_os_timer.h:102
int32_t(* count_clk_set)(struct no_os_timer_desc *, uint32_t freq_hz)
Definition no_os_timer.h:104
int32_t(* remove)(struct no_os_timer_desc *)
Definition no_os_timer.h:109
int32_t(* stop)(struct no_os_timer_desc *)
Definition no_os_timer.h:96
int32_t(* counter_get)(struct no_os_timer_desc *, uint32_t *counter)
Definition no_os_timer.h:98
int32_t(* counter_set)(struct no_os_timer_desc *, uint32_t new_val)
Definition no_os_timer.h:100
int32_t(* start)(struct no_os_timer_desc *)
Definition no_os_timer.h:94
int32_t(* init)(struct no_os_timer_desc **, const struct no_os_timer_init_param *)
Definition no_os_timer.h:91
int32_t(* get_elapsed_time_nsec)(struct no_os_timer_desc *, uint64_t *elapsed_time)
Definition no_os_timer.h:106