no-OS
Functions | Variables
xilinx_timer.c File Reference

Timer and GIC control module source. More...

#include <stdlib.h>
#include <xparameters.h>
#include "no_os_timer.h"
#include "xilinx_timer.h"
#include "no_os_error.h"
#include "no_os_alloc.h"
Include dependency graph for xilinx_timer.c:

Functions

int32_t xilinx_timer_start (struct no_os_timer_desc *desc)
 Start a timer. More...
 
int32_t xilinx_timer_stop (struct no_os_timer_desc *desc)
 Stop a timer from counting. More...
 
int32_t xilinx_timer_counter_get (struct no_os_timer_desc *desc, uint32_t *counter)
 Get the current counter value of the timer. More...
 
int32_t xilinx_timer_counter_set (struct no_os_timer_desc *desc, uint32_t new_val)
 Set the current counter value of the timer. More...
 
int32_t xilinx_timer_count_clk_get (struct no_os_timer_desc *desc, uint32_t *freq_hz)
 Get the timer clock frequency. More...
 
int32_t xilinx_timer_count_clk_set (struct no_os_timer_desc *desc, uint32_t freq_hz)
 Set the timer clock frequency. More...
 
int32_t xilinx_timer_get_elapsed_time_nsec (struct no_os_timer_desc *desc, uint64_t *elapsed_time)
 Get the elapsed time in nsec for the timer. More...
 
int32_t xilinx_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. More...
 
int32_t xilinx_timer_remove (struct no_os_timer_desc *desc)
 Free the memory allocated by timer_setup(). More...
 

Variables

const struct no_os_timer_platform_ops xil_timer_ops
 Xilinx platform specific timer platform ops structure. More...
 

Detailed Description

Timer and GIC 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 2020(c) Analog Devices, Inc.

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

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 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

◆ xilinx_timer_count_clk_get()

int32_t xilinx_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- Pointer to the returned frequency.
Returns
0 in case of success, -1 otherwise

◆ xilinx_timer_count_clk_set()

int32_t xilinx_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- New timer frequency in hertz.
Returns
0 in case of success, -1 otherwise
Here is the caller graph for this function:

◆ xilinx_timer_counter_get()

int32_t xilinx_timer_counter_get ( struct no_os_timer_desc desc,
uint32_t *  counter 
)

Get the current counter value of the timer.

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

◆ xilinx_timer_counter_set()

int32_t xilinx_timer_counter_set ( struct no_os_timer_desc desc,
uint32_t  new_val 
)

Set the current counter value of the timer.

Parameters
[in]desc- Pointer to the device handler.
[in]new_val- New value for the timer counter.
Returns
0 in case of success, -1 otherwise
Here is the caller graph for this function:

◆ xilinx_timer_get_elapsed_time_nsec()

int32_t xilinx_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
-ENOSYS.

◆ xilinx_timer_init()

int32_t xilinx_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, -1 otherwise

◆ xilinx_timer_remove()

int32_t xilinx_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, -1 otherwise

◆ xilinx_timer_start()

int32_t xilinx_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, -1 otherwise

◆ xilinx_timer_stop()

int32_t xilinx_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, -1 otherwise

Variable Documentation

◆ xil_timer_ops

const struct no_os_timer_platform_ops xil_timer_ops
Initial value:
= {
.start = &xilinx_timer_start,
.counter_get = &xilinx_timer_counter_get,
.counter_set = &xilinx_timer_counter_set,
.count_clk_get = &xilinx_timer_count_clk_get,
.count_clk_set = &xilinx_timer_count_clk_set,
.get_elapsed_time_nsec = &xilinx_timer_get_elapsed_time_nsec,
}

Xilinx platform specific timer platform ops structure.

xilinx_timer_stop
int32_t xilinx_timer_stop(struct no_os_timer_desc *desc)
Stop a timer from counting.
Definition: xilinx_timer.c:94
xilinx_timer_count_clk_set
int32_t xilinx_timer_count_clk_set(struct no_os_timer_desc *desc, uint32_t freq_hz)
Set the timer clock frequency.
Definition: xilinx_timer.c:243
xilinx_timer_counter_set
int32_t xilinx_timer_counter_set(struct no_os_timer_desc *desc, uint32_t new_val)
Set the current counter value of the timer.
Definition: xilinx_timer.c:168
xilinx_timer_counter_get
int32_t xilinx_timer_counter_get(struct no_os_timer_desc *desc, uint32_t *counter)
Get the current counter value of the timer.
Definition: xilinx_timer.c:129
xilinx_timer_init
int32_t xilinx_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: xilinx_timer.c:298
xilinx_timer_get_elapsed_time_nsec
int32_t xilinx_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: xilinx_timer.c:284
xilinx_timer_start
int32_t xilinx_timer_start(struct no_os_timer_desc *desc)
Start a timer.
Definition: xilinx_timer.c:62
xilinx_timer_remove
int32_t xilinx_timer_remove(struct no_os_timer_desc *desc)
Free the memory allocated by timer_setup().
Definition: xilinx_timer.c:403
xilinx_timer_count_clk_get
int32_t xilinx_timer_count_clk_get(struct no_os_timer_desc *desc, uint32_t *freq_hz)
Get the timer clock frequency.
Definition: xilinx_timer.c:205