Zephyr API 3.6.99
|
Public API for counter and timer drivers. More...
#include <errno.h>
#include <zephyr/types.h>
#include <stddef.h>
#include <zephyr/device.h>
#include <zephyr/sys_clock.h>
#include <stdbool.h>
#include <zephyr/syscalls/counter.h>
Go to the source code of this file.
Data Structures | |
struct | counter_alarm_cfg |
Alarm callback structure. More... | |
struct | counter_top_cfg |
Top value configuration structure. More... | |
struct | counter_config_info |
Structure with generic counter features. More... | |
struct | counter_driver_api |
Macros | |
Counter device capabilities | |
#define | COUNTER_CONFIG_INFO_COUNT_UP BIT(0) |
Counter count up flag. | |
Flags used by counter_top_cfg. | |
#define | COUNTER_TOP_CFG_DONT_RESET BIT(0) |
Flag preventing counter reset when top value is changed. | |
#define | COUNTER_TOP_CFG_RESET_WHEN_LATE BIT(1) |
Flag instructing counter to reset itself if changing top value results in counter going out of new top value bound. | |
Alarm configuration flags | |
Used in alarm configuration structure (counter_alarm_cfg). | |
#define | COUNTER_ALARM_CFG_ABSOLUTE BIT(0) |
Counter alarm absolute value flag. | |
#define | COUNTER_ALARM_CFG_EXPIRE_WHEN_LATE BIT(1) |
Alarm flag enabling immediate expiration when driver detects that absolute alarm was set too late. | |
Counter guard period flags | |
Used by counter_set_guard_period and counter_get_guard_period. | |
#define | COUNTER_GUARD_PERIOD_LATE_TO_SET BIT(0) |
Identifies guard period needed for detection of late setting of absolute alarm (see counter_set_channel_alarm). | |
Typedefs | |
typedef void(* | counter_alarm_callback_t) (const struct device *dev, uint8_t chan_id, uint32_t ticks, void *user_data) |
Alarm callback. | |
typedef void(* | counter_top_callback_t) (const struct device *dev, void *user_data) |
Callback called when counter turns around. | |
typedef int(* | counter_api_start) (const struct device *dev) |
typedef int(* | counter_api_stop) (const struct device *dev) |
typedef int(* | counter_api_get_value) (const struct device *dev, uint32_t *ticks) |
typedef int(* | counter_api_get_value_64) (const struct device *dev, uint64_t *ticks) |
typedef int(* | counter_api_set_alarm) (const struct device *dev, uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) |
typedef int(* | counter_api_cancel_alarm) (const struct device *dev, uint8_t chan_id) |
typedef int(* | counter_api_set_top_value) (const struct device *dev, const struct counter_top_cfg *cfg) |
typedef uint32_t(* | counter_api_get_pending_int) (const struct device *dev) |
typedef uint32_t(* | counter_api_get_top_value) (const struct device *dev) |
typedef uint32_t(* | counter_api_get_guard_period) (const struct device *dev, uint32_t flags) |
typedef int(* | counter_api_set_guard_period) (const struct device *dev, uint32_t ticks, uint32_t flags) |
typedef uint32_t(* | counter_api_get_freq) (const struct device *dev) |
Functions | |
bool | counter_is_counting_up (const struct device *dev) |
Function to check if counter is counting up. | |
uint8_t | counter_get_num_of_channels (const struct device *dev) |
Function to get number of alarm channels. | |
uint32_t | counter_get_frequency (const struct device *dev) |
Function to get counter frequency. | |
uint32_t | counter_us_to_ticks (const struct device *dev, uint64_t us) |
Function to convert microseconds to ticks. | |
uint64_t | counter_ticks_to_us (const struct device *dev, uint32_t ticks) |
Function to convert ticks to microseconds. | |
uint32_t | counter_get_max_top_value (const struct device *dev) |
Function to retrieve maximum top value that can be set. | |
int | counter_start (const struct device *dev) |
Start counter device in free running mode. | |
int | counter_stop (const struct device *dev) |
Stop counter device. | |
int | counter_get_value (const struct device *dev, uint32_t *ticks) |
Get current counter value. | |
int | counter_get_value_64 (const struct device *dev, uint64_t *ticks) |
Get current counter 64-bit value. | |
int | counter_set_channel_alarm (const struct device *dev, uint8_t chan_id, const struct counter_alarm_cfg *alarm_cfg) |
Set a single shot alarm on a channel. | |
int | counter_cancel_channel_alarm (const struct device *dev, uint8_t chan_id) |
Cancel an alarm on a channel. | |
int | counter_set_top_value (const struct device *dev, const struct counter_top_cfg *cfg) |
Set counter top value. | |
int | counter_get_pending_int (const struct device *dev) |
Function to get pending interrupts. | |
uint32_t | counter_get_top_value (const struct device *dev) |
Function to retrieve current top value. | |
int | counter_set_guard_period (const struct device *dev, uint32_t ticks, uint32_t flags) |
Set guard period in counter ticks. | |
uint32_t | counter_get_guard_period (const struct device *dev, uint32_t flags) |
Return guard period. | |
Public API for counter and timer drivers.