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

Implementation of pico timer driver. More...

#include "no_os_error.h"
#include "no_os_util.h"
#include "no_os_timer.h"
#include "no_os_alloc.h"
#include "pico_timer.h"
#include "hardware/timer.h"
#include "hardware/irq.h"
Include dependency graph for pico_timer.c:

Macros

#define PICO_ALARM_MAX_NB   4
 

Functions

int32_t pico_timer_init (struct no_os_timer_desc **desc, const struct no_os_timer_init_param *param)
 Initialize the timer peripheral.
 
int32_t pico_timer_remove (struct no_os_timer_desc *desc)
 Free the resources allocated by no_os_timer_init().
 
int32_t pico_timer_start (struct no_os_timer_desc *desc)
 Start a timer.
 
int32_t pico_timer_stop (struct no_os_timer_desc *desc)
 Stop a timer from counting.
 
int32_t pico_timer_counter_get (struct no_os_timer_desc *desc, uint32_t *counter)
 Get the value of the counter register for the timer.
 
int32_t pico_timer_counter_set (struct no_os_timer_desc *desc, uint32_t new_val)
 Set the timer counter register value.
 
int32_t pico_timer_count_clk_get (struct no_os_timer_desc *desc, uint32_t *freq_hz)
 Get the timer clock frequency.
 
int32_t pico_timer_count_clk_set (struct no_os_timer_desc *desc, uint32_t freq_hz)
 Set the timer clock frequency.
 
int32_t pico_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

struct no_os_timer_desc * pico_alarm_desc [PICO_ALARM_MAX_NB] = {NULL}
 
const struct no_os_timer_platform_ops pico_timer_ops
 pico platform specific timer platform ops structure
 

Detailed Description

Implementation of pico timer driver.

Author
RBolboac (ramon.nosp@m.a.bo.nosp@m.lboac.nosp@m.a@an.nosp@m.alog..nosp@m.com)

Copyright 2022(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ PICO_ALARM_MAX_NB

#define PICO_ALARM_MAX_NB   4

Function Documentation

◆ pico_timer_count_clk_get()

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

◆ pico_timer_count_clk_set()

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

◆ pico_timer_counter_get()

int32_t pico_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
-ENOSYS

◆ pico_timer_counter_set()

int32_t pico_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
-ENOSYS

◆ pico_timer_get_elapsed_time_nsec()

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

◆ pico_timer_init()

int32_t pico_timer_init ( struct no_os_timer_desc ** desc,
const struct no_os_timer_init_param * param )

Initialize the timer peripheral.

Parameters
desc- The timer descriptor.
param- The structure that contains the timer parameters.
Returns
0 in case of success, error code otherwise.

◆ pico_timer_remove()

int32_t pico_timer_remove ( struct no_os_timer_desc * desc)

Free the resources allocated by no_os_timer_init().

Parameters
desc- The timer descriptor.
Returns
0 in case of success, error code otherwise.

◆ pico_timer_start()

int32_t pico_timer_start ( struct no_os_timer_desc * desc)

Start a timer.

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

◆ pico_timer_stop()

int32_t pico_timer_stop ( struct no_os_timer_desc * desc)

Stop a timer from counting.

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

Variable Documentation

◆ pico_alarm_desc

struct no_os_timer_desc* pico_alarm_desc[PICO_ALARM_MAX_NB] = {NULL}

◆ pico_timer_ops

const struct no_os_timer_platform_ops pico_timer_ops
Initial value:
= {
.init = &pico_timer_init,
.start = &pico_timer_start,
.stop = &pico_timer_stop,
.counter_get = &pico_timer_counter_get,
.counter_set = &pico_timer_counter_set,
.count_clk_get = &pico_timer_count_clk_get,
.count_clk_set = &pico_timer_count_clk_set,
.get_elapsed_time_nsec = &pico_timer_get_elapsed_time_nsec,
.remove = &pico_timer_remove
}
int32_t pico_timer_remove(struct no_os_timer_desc *desc)
Free the resources allocated by no_os_timer_init().
Definition pico_timer.c:93
int32_t pico_timer_stop(struct no_os_timer_desc *desc)
Stop a timer from counting.
Definition pico_timer.c:133
int32_t pico_timer_init(struct no_os_timer_desc **desc, const struct no_os_timer_init_param *param)
Initialize the timer peripheral.
Definition pico_timer.c:29
int32_t pico_timer_count_clk_get(struct no_os_timer_desc *desc, uint32_t *freq_hz)
Get the timer clock frequency.
Definition pico_timer.c:182
int32_t pico_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 pico_timer.c:232
int32_t pico_timer_start(struct no_os_timer_desc *desc)
Start a timer.
Definition pico_timer.c:111
int32_t pico_timer_counter_set(struct no_os_timer_desc *desc, uint32_t new_val)
Set the timer counter register value.
Definition pico_timer.c:169
int32_t pico_timer_count_clk_set(struct no_os_timer_desc *desc, uint32_t freq_hz)
Set the timer clock frequency.
Definition pico_timer.c:198
int32_t pico_timer_counter_get(struct no_os_timer_desc *desc, uint32_t *counter)
Get the value of the counter register for the timer.
Definition pico_timer.c:153

pico platform specific timer platform ops structure

pico specific timer platform ops structure