no-OS
|
Timer control module header. More...
#include <stdint.h>
Go to the source code of this file.
Classes | |
struct | timer_desc |
Structure holding timer descriptor. More... | |
struct | timer_init_param |
Structure holding the parameters for timer initialization. More... | |
Functions | |
int32_t | timer_init (struct timer_desc **desc, struct timer_init_param *param) |
Initialize a instance of a timer. More... | |
int32_t | timer_remove (struct timer_desc *desc) |
Remove a instance of a timer. More... | |
int32_t | timer_start (struct timer_desc *desc) |
Enable counting in the timer instance. More... | |
int32_t | timer_stop (struct timer_desc *desc) |
Stop counting the timer instance. More... | |
int32_t | timer_counter_get (struct timer_desc *desc, uint32_t *counter) |
Get the value the timer is at. More... | |
int32_t | timer_counter_set (struct timer_desc *desc, uint32_t new_val) |
Set a new value for the timer. More... | |
int32_t | timer_count_clk_get (struct timer_desc *desc, uint32_t *freq_hz) |
Get the frequency the timer counts with. More... | |
int32_t | timer_count_clk_set (struct timer_desc *desc, uint32_t freq_hz) |
Set the frequency the timer counts with. More... | |
int32_t | timer_get_elapsed_time_nsec (struct timer_desc *desc, uint64_t *elapsed_time) |
Timer control module header.
Copyright 2019(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.
Copyright 2020(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.
int32_t timer_count_clk_get | ( | struct timer_desc * | desc, |
uint32_t * | freq_hz | ||
) |
Get the frequency the timer counts with.
desc | - Descriptor of the timer instance. |
freq_hz | - Pointer where the frequency value will be stored |
Get the frequency the timer counts with.
[in] | desc | - Pointer to the device handler. |
[out] | freq_hz | - The value in Hz of the timer clock. |
Get the frequency the timer counts with.
[in] | desc | - Pointer to the device handler. |
[out] | freq_hz | - Pointer to the returned frequency. |
int32_t timer_count_clk_set | ( | struct timer_desc * | desc, |
uint32_t | freq_hz | ||
) |
Set the frequency the timer counts with.
desc | - Descriptor of the timer instance. |
freq_hz | - Value of the new frequency to be set |
Set the frequency the timer counts with.
[in] | desc | - Pointer to the device handler. |
[in] | freq_hz | - The value in Hz of the new timer clock. |
Set the frequency the timer counts with.
[in] | desc | - Pointer to the device handler. |
[in] | freq_hz | - New timer frequency in hertz. |
int32_t timer_counter_get | ( | struct timer_desc * | desc, |
uint32_t * | counter | ||
) |
Get the value the timer is at.
desc | - Descriptor of the timer instance. |
counter | - Pointer were the timer counter is stored. |
Get the value the timer is at.
[in] | desc | - Pointer to the device handler. |
[out] | counter | - Pointer to the counter value. |
Get the value the timer is at.
[in] | desc | - Pointer to the device handler. |
[out] | counter | - Pointer to the current counter value. |
int32_t timer_counter_set | ( | struct timer_desc * | desc, |
uint32_t | new_val | ||
) |
Set a new value for the timer.
desc | - Descriptor of the timer instance. |
new_val | - Value of the new counter to be set |
Set a new value for the timer.
[in] | desc | - Pointer to the device handler. |
[in] | new_val | - The new value of the counter register. |
Set a new value for the timer.
[in] | desc | - Pointer to the device handler. |
[in] | new_val | - New value for the timer counter. |
int32_t timer_get_elapsed_time_nsec | ( | struct timer_desc * | desc, |
uint64_t * | elapsed_time | ||
) |
int32_t timer_init | ( | struct timer_desc ** | desc, |
struct timer_init_param * | param | ||
) |
Initialize a instance of a timer.
The created descriptor must be used in the next driver calls to identify the timer instance.
The user can create multiple instances but only one hardware timer will be used.
The timer used is defined by the timer_init_param::id .
The driver will use the timer selected for the first instance for all the new ones. If it is needed to change the hardware timer, the user must remove all the instances and initialize a new one for the desired hardware timer.
desc | - Pointer to descriptor of the instance that will be created. |
param | - Parameter used to configure the new instance. The extra field is unused and should be NULL. |
Initialize a instance of a timer.
[out] | desc | - Pointer to the reference of the device handler. |
[in] | param | - Initialization structure. |
Initialize a instance of a timer.
[out] | desc | - Pointer to the reference of the device handler. |
[in] | param | - Initialization structure. |
int32_t timer_remove | ( | struct timer_desc * | desc | ) |
Remove a instance of a timer.
If there are no more instances it stops the hardware timer.
desc | - Descriptor of the timer instance. |
Remove a instance of a timer.
[in] | desc | - Pointer to the device handler. |
Remove a instance of a timer.
[in] | desc | - Pointer to the device handler. |
int32_t timer_start | ( | struct timer_desc * | desc | ) |
Enable counting in the timer instance.
The timer starts counting from the load value used in timer_init(), set by timer_counter_set() or from the value the timer stopped at.
desc | - Descriptor of the timer instance. |
Enable counting in the timer instance.
[in] | desc | - Pointer to the device handler. |
Enable counting in the timer instance.
[in] | desc | - Pointer to the device handler. |
int32_t timer_stop | ( | struct timer_desc * | desc | ) |
Stop counting the timer instance.
If there are no more timer instance started it also stops the hardware timer.
desc | - Descriptor of the timer instance. |
Stop counting the timer instance.
[in] | desc | - Pointer to the device handler. |
Stop counting the timer instance.
[in] | desc | - Pointer to the device handler. |