no-OS
Loading...
Searching...
No Matches
generic_timer.c File Reference

Timer control module source. More...

#include "no_os_error.h"
#include "no_os_timer.h"
#include "no_os_util.h"
Include dependency graph for generic_timer.c:

Functions

int32_t generic_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.
 
int32_t generic_timer_remove (struct no_os_timer_desc *desc)
 Free the memory allocated by timer_setup().
 
int32_t generic_timer_start (struct no_os_timer_desc *desc)
 Start a timer.
 
int32_t generic_timer_stop (struct no_os_timer_desc *desc)
 Stop a timer from counting.
 
int32_t generic_timer_counter_get (struct no_os_timer_desc *desc, uint32_t *counter)
 Get the value of the counter register for the timer.
 
int32_t generic_timer_counter_set (struct no_os_timer_desc *desc, uint32_t new_val)
 Set the timer counter register value.
 
int32_t generic_timer_count_clk_get (struct no_os_timer_desc *desc, uint32_t *freq_hz)
 Get the timer clock frequency.
 
int32_t generic_timer_count_clk_set (struct no_os_timer_desc *desc, uint32_t freq_hz)
 Set the timer clock frequency.
 
int32_t generic_timer_get_elapsed_time_nsec (struct no_os_timer_desc *desc, uint64_t *elapsed_time)
 Get the elapsed time in nsec for the timer.
 

Variables

const struct no_os_timer_platform_ops generic_timer_ops
 generic platform specific timer platform ops structure
 

Detailed Description

Timer control module source.

Author
Andrei Drimbarean (andre.nosp@m.i.dr.nosp@m.imbar.nosp@m.ean@.nosp@m.analo.nosp@m.g.co.nosp@m.m)

Copyright 2019(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ generic_timer_count_clk_get()

int32_t generic_timer_count_clk_get ( struct no_os_timer_desc * desc,
uint32_t * freq_hz )

Get the timer clock frequency.

Parameters
[in]desc- Pointer to the device handler.
[out]freq_hz- The value in Hz of the timer clock.
Returns
0 in case of success, error code otherwise.

◆ generic_timer_count_clk_set()

int32_t generic_timer_count_clk_set ( struct no_os_timer_desc * desc,
uint32_t freq_hz )

Set the timer clock frequency.

Parameters
[in]desc- Pointer to the device handler.
[in]freq_hz- The value in Hz of the new timer clock.
Returns
0 in case of success, error code otherwise.

◆ generic_timer_counter_get()

int32_t generic_timer_counter_get ( struct no_os_timer_desc * desc,
uint32_t * counter )

Get the value of the counter register for the timer.

Parameters
[in]desc- Pointer to the device handler.
[out]counter- Pointer to the counter value.
Returns
0 in case of success, error code otherwise.

◆ generic_timer_counter_set()

int32_t generic_timer_counter_set ( struct no_os_timer_desc * desc,
uint32_t new_val )

Set the timer counter register value.

Parameters
[in]desc- Pointer to the device handler.
[in]new_val- The new value of the counter register.
Returns
0 in case of success, error code otherwise.

◆ generic_timer_get_elapsed_time_nsec()

int32_t generic_timer_get_elapsed_time_nsec ( struct no_os_timer_desc * desc,
uint64_t * elapsed_time )

Get the elapsed time in nsec for the timer.

Parameters
[in]desc- Pointer to the device handler.
[in]elapsed_time- The elapsed time in nsec.
Returns
0 in case of success, error code otherwise.

◆ generic_timer_init()

int32_t generic_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.

Parameters
[out]desc- Pointer to the reference of the device handler.
[in]param- Initialization structure.
Returns
0 in case of success, negative error code otherwise

◆ generic_timer_remove()

int32_t generic_timer_remove ( struct no_os_timer_desc * desc)

Free the memory allocated by timer_setup().

Parameters
[in]desc- Pointer to the device handler.
Returns
0 in case of success, negative error code otherwise

◆ generic_timer_start()

int32_t generic_timer_start ( struct no_os_timer_desc * desc)

Start a timer.

Parameters
[in]desc- Pointer to the device handler.
Returns
0 in case of success, negative error code otherwise

◆ generic_timer_stop()

int32_t generic_timer_stop ( struct no_os_timer_desc * desc)

Stop a timer from counting.

Parameters
[in]desc- Pointer to the device handler.
Returns
0 in case of success, negative error code otherwise

Variable Documentation

◆ generic_timer_ops

const struct no_os_timer_platform_ops generic_timer_ops
Initial value:
= {
.counter_get = &generic_timer_counter_get,
.counter_set = &generic_timer_counter_set,
.count_clk_get = &generic_timer_count_clk_get,
.count_clk_set = &generic_timer_count_clk_set,
.get_elapsed_time_nsec = &generic_timer_get_elapsed_time_nsec,
}
int32_t generic_timer_counter_set(struct no_os_timer_desc *desc, uint32_t new_val)
Set the timer counter register value.
Definition generic_timer.c:88
int32_t generic_timer_counter_get(struct no_os_timer_desc *desc, uint32_t *counter)
Get the value of the counter register for the timer.
Definition generic_timer.c:73
int32_t generic_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 generic_timer.c:22
int32_t generic_timer_remove(struct no_os_timer_desc *desc)
Free the memory allocated by timer_setup().
Definition generic_timer.c:36
int32_t generic_timer_stop(struct no_os_timer_desc *desc)
Stop a timer from counting.
Definition generic_timer.c:60
int32_t generic_timer_count_clk_get(struct no_os_timer_desc *desc, uint32_t *freq_hz)
Get the timer clock frequency.
Definition generic_timer.c:103
int32_t generic_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 generic_timer.c:133
int32_t generic_timer_count_clk_set(struct no_os_timer_desc *desc, uint32_t freq_hz)
Set the timer clock frequency.
Definition generic_timer.c:118
int32_t generic_timer_start(struct no_os_timer_desc *desc)
Start a timer.
Definition generic_timer.c:48

generic platform specific timer platform ops structure