no-OS
no_os_timer.h
Go to the documentation of this file.
1 /***************************************************************************/
40 #ifndef _NO_OS_SRC_TIMER_H_
41 #define _NO_OS_SRC_TIMER_H_
42 
43 /******************************************************************************/
44 /***************************** Include Files **********************************/
45 /******************************************************************************/
46 
47 #include <stdint.h>
48 
49 /******************************************************************************/
50 /*************************** Types Declarations *******************************/
51 /******************************************************************************/
52 
59  uint16_t id;
61  uint32_t freq_hz;
63  uint32_t ticks_count;
67  void *extra;
68 };
69 
76 
83  uint16_t id;
85  uint32_t freq_hz;
87  uint32_t ticks_count;
91  void *extra;
92 };
93 
101  int32_t (*init)(struct no_os_timer_desc **,
102  const struct no_os_timer_init_param *);
104  int32_t (*start)(struct no_os_timer_desc *);
106  int32_t (*stop)(struct no_os_timer_desc *);
108  int32_t (*counter_get)(struct no_os_timer_desc *, uint32_t *counter);
110  int32_t (*counter_set)(struct no_os_timer_desc *, uint32_t new_val);
112  int32_t (*count_clk_get)(struct no_os_timer_desc *, uint32_t *freq_hz);
114  int32_t (*count_clk_set)(struct no_os_timer_desc *, uint32_t freq_hz);
117  uint64_t *elapsed_time);
119  int32_t (*remove)(struct no_os_timer_desc *);
120 };
121 
122 /******************************************************************************/
123 /************************ Functions Declarations ******************************/
124 /******************************************************************************/
125 
126 /* Initialize hardware timer and the handler structure associated with it. */
127 int32_t no_os_timer_init(struct no_os_timer_desc **desc,
128  struct no_os_timer_init_param *param);
129 
130 /* Free the memory allocated by timer_setup(). */
131 int32_t no_os_timer_remove(struct no_os_timer_desc *desc);
132 
133 /* Start a timer. */
134 int32_t no_os_timer_start(struct no_os_timer_desc *desc);
135 
136 /* Stop a timer from counting. */
137 int32_t no_os_timer_stop(struct no_os_timer_desc *desc);
138 
139 /* Get the value of the counter register for the timer. */
140 int32_t no_os_timer_counter_get(struct no_os_timer_desc *desc,
141  uint32_t *counter);
142 
143 /* Set the timer counter register value. */
144 int32_t no_os_timer_counter_set(struct no_os_timer_desc *desc,
145  uint32_t new_val);
146 
147 /* Get the timer clock frequency. */
148 int32_t no_os_timer_count_clk_get(struct no_os_timer_desc *desc,
149  uint32_t *freq_hz);
150 
151 /* Set the timer clock frequency. */
152 int32_t no_os_timer_count_clk_set(struct no_os_timer_desc *desc,
153  uint32_t freq_hz);
154 
155 /* Get the elapsed time in nsec for the timer. */
157  uint64_t *elapsed_time);
158 
159 #endif // _NO_OS_SRC_TIMER_H_
no_os_timer_platform_ops
Structure holding timer function pointers that point to the platform specific function.
Definition: no_os_timer.h:99
no_os_timer_init
int32_t no_os_timer_init(struct no_os_timer_desc **desc, struct no_os_timer_init_param *param)
Initialize hardware timer and the handler structure associated with it.
Definition: no_os_timer.c:56
no_os_timer_init_param::id
uint16_t id
Definition: no_os_timer.h:83
no_os_timer_platform_ops::count_clk_set
int32_t(* count_clk_set)(struct no_os_timer_desc *, uint32_t freq_hz)
Definition: no_os_timer.h:114
no_os_timer_desc::platform_ops
const struct no_os_timer_platform_ops * platform_ops
Definition: no_os_timer.h:65
no_os_timer_platform_ops::get_elapsed_time_nsec
int32_t(* get_elapsed_time_nsec)(struct no_os_timer_desc *, uint64_t *elapsed_time)
Definition: no_os_timer.h:116
no_os_timer_count_clk_set
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:159
no_os_timer_count_clk_get
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:144
no_os_timer_platform_ops::count_clk_get
int32_t(* count_clk_get)(struct no_os_timer_desc *, uint32_t *freq_hz)
Definition: no_os_timer.h:112
no_os_timer_init_param::ticks_count
uint32_t ticks_count
Definition: no_os_timer.h:87
no_os_timer_platform_ops::counter_get
int32_t(* counter_get)(struct no_os_timer_desc *, uint32_t *counter)
Definition: no_os_timer.h:108
no_os_timer_init_param::freq_hz
uint32_t freq_hz
Definition: no_os_timer.h:85
no_os_timer_platform_ops::counter_set
int32_t(* counter_set)(struct no_os_timer_desc *, uint32_t new_val)
Definition: no_os_timer.h:110
no_os_timer_desc::ticks_count
uint32_t ticks_count
Definition: no_os_timer.h:63
no_os_timer_desc::id
uint16_t id
Definition: no_os_timer.h:59
no_os_timer_start
int32_t no_os_timer_start(struct no_os_timer_desc *desc)
Start a timer.
Definition: no_os_timer.c:88
no_os_timer_stop
int32_t no_os_timer_stop(struct no_os_timer_desc *desc)
Stop a timer from counting.
Definition: no_os_timer.c:101
no_os_timer_platform_ops::init
int32_t(* init)(struct no_os_timer_desc **, const struct no_os_timer_init_param *)
Definition: no_os_timer.h:101
no_os_timer_remove
int32_t no_os_timer_remove(struct no_os_timer_desc *desc)
Free the memory allocated by timer_init().
Definition: no_os_timer.c:75
no_os_timer_get_elapsed_time_nsec
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:174
no_os_timer_init_param::platform_ops
const struct no_os_timer_platform_ops * platform_ops
Definition: no_os_timer.h:89
no_os_timer_platform_ops::remove
int32_t(* remove)(struct no_os_timer_desc *)
Definition: no_os_timer.h:119
no_os_timer_counter_get
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:115
no_os_timer_init_param
Structure holding the parameters for timer initialization.
Definition: no_os_timer.h:81
no_os_timer_platform_ops::start
int32_t(* start)(struct no_os_timer_desc *)
Definition: no_os_timer.h:104
no_os_timer_desc::freq_hz
uint32_t freq_hz
Definition: no_os_timer.h:61
no_os_timer_counter_set
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:130
no_os_timer_desc::extra
void * extra
Definition: no_os_timer.h:67
no_os_timer_init_param::extra
void * extra
Definition: no_os_timer.h:91
no_os_timer_desc
Structure holding timer descriptor.
Definition: no_os_timer.h:57
no_os_timer_platform_ops::stop
int32_t(* stop)(struct no_os_timer_desc *)
Definition: no_os_timer.h:106