no-OS
Classes | Functions | Variables
linux_timer.c File Reference

Source file for Linux timer platform driver. More...

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "no_os_error.h"
#include "no_os_timer.h"
#include "no_os_alloc.h"
Include dependency graph for linux_timer.c:

Classes

struct  linux_timer_desc
 Linux platform specific timer descriptor. More...
 

Functions

int linux_timer_init (struct no_os_timer_desc **desc, const struct no_os_timer_init_param *param)
 Timer driver init function. More...
 
int linux_timer_remove (struct no_os_timer_desc *desc)
 Timer driver remove function. More...
 
int linux_timer_start (struct no_os_timer_desc *desc)
 Timer count start function. More...
 
int linux_timer_stop (struct no_os_timer_desc *desc)
 Timer count stop function. More...
 
int linux_timer_counter_get (struct no_os_timer_desc *desc, uint32_t *counter)
 Function to get the current timer counter value. More...
 
int linux_timer_counter_set (struct no_os_timer_desc *desc, uint32_t new_val)
 Function to set the timer counter value. More...
 
int linux_timer_count_clk_get (struct no_os_timer_desc *desc, uint32_t *freq_hz)
 Function to get the timer frequency. More...
 
int linux_timer_count_clk_set (struct no_os_timer_desc *desc, uint32_t freq_hz)
 Function to set the timer frequency. More...
 
int linux_timer_get_elapsed_time_nsec (struct no_os_timer_desc *desc, uint64_t *elapsed_time)
 Not implemented. More...
 

Variables

const struct no_os_timer_platform_ops linux_timer_ops
 linux platform specific timer platform ops structure More...
 

Detailed Description

Source file for Linux timer platform driver.

Author
Dragos Bogdan (drago.nosp@m.s.bo.nosp@m.gdan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2023(c) Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ linux_timer_count_clk_get()

int linux_timer_count_clk_get ( struct no_os_timer_desc desc,
uint32_t *  freq_hz 
)

Function to get the timer frequency.

Parameters
desc- timer descriptor
freq_hz- the timer frequency value
Returns
0 in case of success, -EINVAL otherwise.

◆ linux_timer_count_clk_set()

int linux_timer_count_clk_set ( struct no_os_timer_desc desc,
uint32_t  freq_hz 
)

Function to set the timer frequency.

Parameters
desc- timer descriptor.
freq_hz- the timer frequency value to be set.
Returns
0 in case of success, negative errno error codes otherwise.

◆ linux_timer_counter_get()

int linux_timer_counter_get ( struct no_os_timer_desc desc,
uint32_t *  counter 
)

Function to get the current timer counter value.

Parameters
desc- timer descriptor
counter- the timer counter value
Returns
0 in case of success, -EINVAL otherwise.

◆ linux_timer_counter_set()

int linux_timer_counter_set ( struct no_os_timer_desc desc,
uint32_t  new_val 
)

Function to set the timer counter value.

Parameters
desc- timer descriptor
new_val- timer counter value to be set
Returns
0 in case of success, -EINVAL otherwise.

◆ linux_timer_get_elapsed_time_nsec()

int linux_timer_get_elapsed_time_nsec ( struct no_os_timer_desc desc,
uint64_t *  elapsed_time 
)

Not implemented.

Parameters
desc- timer descriptor
elapsed_time- time in nanoseconds
Returns
0 in case of success, negative errno error codes otherwise.

◆ linux_timer_init()

int linux_timer_init ( struct no_os_timer_desc **  desc,
const struct no_os_timer_init_param param 
)

Timer driver init function.

Parameters
desc- timer descriptor to be initialized
param- initialization parameter for the desc
Returns
0 in case of success, negative errno error codes otherwise.

◆ linux_timer_remove()

int linux_timer_remove ( struct no_os_timer_desc desc)

Timer driver remove function.

Parameters
desc- timer descriptor
Returns
0 in case of success, -EINVAL otherwise.

◆ linux_timer_start()

int linux_timer_start ( struct no_os_timer_desc desc)

Timer count start function.

Parameters
desc- timer descriptor
Returns
0 in case of success, -EINVAL otherwise.

◆ linux_timer_stop()

int linux_timer_stop ( struct no_os_timer_desc desc)

Timer count stop function.

Parameters
desc- timer descriptor
Returns
0 in case of success, -EINVAL otherwise.

Variable Documentation

◆ linux_timer_ops

const struct no_os_timer_platform_ops linux_timer_ops
Initial value:
= {
.init = (int32_t (*)())linux_timer_init,
.start = (int32_t (*)())linux_timer_start,
.stop = (int32_t (*)())linux_timer_stop,
.counter_get = (int32_t (*)())linux_timer_counter_get,
.counter_set = (int32_t (*)())linux_timer_counter_set,
.count_clk_get = (int32_t (*)())linux_timer_count_clk_get,
.count_clk_set = (int32_t (*)())linux_timer_count_clk_set,
.get_elapsed_time_nsec =
.remove = (int32_t (*)())linux_timer_remove
}

linux platform specific timer platform ops structure

Linux specific timer platform ops.

linux_timer_init
int linux_timer_init(struct no_os_timer_desc **desc, const struct no_os_timer_init_param *param)
Timer driver init function.
Definition: linux_timer.c:75
linux_timer_get_elapsed_time_nsec
int linux_timer_get_elapsed_time_nsec(struct no_os_timer_desc *desc, uint64_t *elapsed_time)
Not implemented.
Definition: linux_timer.c:244
linux_timer_start
int linux_timer_start(struct no_os_timer_desc *desc)
Timer count start function.
Definition: linux_timer.c:123
linux_timer_count_clk_set
int linux_timer_count_clk_set(struct no_os_timer_desc *desc, uint32_t freq_hz)
Function to set the timer frequency.
Definition: linux_timer.c:232
linux_timer_remove
int linux_timer_remove(struct no_os_timer_desc *desc)
Timer driver remove function.
Definition: linux_timer.c:110
linux_timer_stop
int linux_timer_stop(struct no_os_timer_desc *desc)
Timer count stop function.
Definition: linux_timer.c:140
linux_timer_count_clk_get
int linux_timer_count_clk_get(struct no_os_timer_desc *desc, uint32_t *freq_hz)
Function to get the timer frequency.
Definition: linux_timer.c:218
linux_timer_counter_get
int linux_timer_counter_get(struct no_os_timer_desc *desc, uint32_t *counter)
Function to get the current timer counter value.
Definition: linux_timer.c:157
linux_timer_counter_set
int linux_timer_counter_set(struct no_os_timer_desc *desc, uint32_t new_val)
Function to set the timer counter value.
Definition: linux_timer.c:191