no-OS
|
Implementation of TIMER driver for ADuCM302x. More...
#include <stdlib.h>
#include <drivers/pwr/adi_pwr.h>
#include "aducm3029_timer.h"
#include "no_os_timer.h"
#include "no_os_error.h"
#include "no_os_alloc.h"
Macros | |
#define | NO_OS_HFOSC_LOAD 26000u |
#define | NO_OS_FREQ_1KHZ 1000u |
#define | NO_OS_FREQ_1MHZ 1000000u |
#define | NO_OS_MHZ26_TO_US(count) ((NO_OS_HFOSC_LOAD - count) / (NO_OS_HFOSC_LOAD / 1000u)) |
Functions | |
int32_t | aducm3029_timer_init (struct no_os_timer_desc **desc, const struct no_os_timer_init_param *param) |
Initialize a instance of a timer. More... | |
int32_t | aducm3029_timer_remove (struct no_os_timer_desc *desc) |
Remove a instance of a timer. More... | |
int32_t | aducm3029_timer_start (struct no_os_timer_desc *desc) |
Enable counting in the timer instance. More... | |
int32_t | aducm3029_timer_stop (struct no_os_timer_desc *desc) |
Stop counting the timer instance. More... | |
int32_t | aducm3029_timer_counter_get (struct no_os_timer_desc *desc, uint32_t *counter) |
Get the value the timer is at. More... | |
int32_t | aducm3029_timer_counter_set (struct no_os_timer_desc *desc, uint32_t new_val) |
Set a new value for the timer. More... | |
int32_t | aducm3029_timer_count_clk_get (struct no_os_timer_desc *desc, uint32_t *freq_hz) |
Get the frequency the timer counts with. More... | |
int32_t | aducm3029_timer_count_clk_set (struct no_os_timer_desc *desc, uint32_t freq_hz) |
Set the frequency the timer counts with. More... | |
int32_t | aducm3029_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... | |
Variables | |
const struct no_os_timer_platform_ops | aducm_timer_ops |
aducm3029 platform specific timer platform ops structure More... | |
Implementation of TIMER driver for ADuCM302x.
This driver enables the user to create multiple instance of a timer using only one hardware timer of the ADuCM3029.
Copyright 2019(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:
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.
#define NO_OS_FREQ_1KHZ 1000u |
1 KHz value
#define NO_OS_FREQ_1MHZ 1000000u |
1 MHz value
#define NO_OS_HFOSC_LOAD 26000u |
With this load we get an interrupt each millisecond
#define NO_OS_MHZ26_TO_US | ( | count | ) | ((NO_OS_HFOSC_LOAD - count) / (NO_OS_HFOSC_LOAD / 1000u)) |
Converts the timer value into microseconds
int32_t aducm3029_timer_count_clk_get | ( | struct no_os_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 |
int32_t aducm3029_timer_count_clk_set | ( | struct no_os_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 |
int32_t aducm3029_timer_counter_get | ( | struct no_os_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. |
int32_t aducm3029_timer_counter_set | ( | struct no_os_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 |
int32_t aducm3029_timer_get_elapsed_time_nsec | ( | struct no_os_timer_desc * | desc, |
uint64_t * | elapsed_time | ||
) |
Get the elapsed time in nsec for the timer.
[in] | desc | - Pointer to the device handler. |
[in] | elapsed_time | - The elapsed time in nsec. |
int32_t aducm3029_timer_init | ( | struct no_os_timer_desc ** | desc, |
const struct no_os_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 no_os_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. |
int32_t aducm3029_timer_remove | ( | struct no_os_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. |
int32_t aducm3029_timer_start | ( | struct no_os_timer_desc * | desc | ) |
Enable counting in the timer instance.
The timer starts counting from the load value used in no_os_timer_init(), set by no_os_timer_counter_set() or from the value the timer stopped at.
desc | - Descriptor of the timer instance. |
int32_t aducm3029_timer_stop | ( | struct no_os_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. |
const struct no_os_timer_platform_ops aducm_timer_ops |
aducm3029 platform specific timer platform ops structure
aducm3029 specific timer platform ops structure