Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
timeaware_gpio.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_DRIVERS_MISC_TIMEAWARE_GPIO_TIMEAWARE_GPIO
13#define ZEPHYR_DRIVERS_MISC_TIMEAWARE_GPIO_TIMEAWARE_GPIO
14
23
24#include <zephyr/sys/__assert.h>
25#include <zephyr/sys/slist.h>
26
27#include <zephyr/types.h>
28#include <stddef.h>
29#include <zephyr/device.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
44
50
54__subsystem struct tgpio_driver_api {
56 int (*pin_disable)(const struct device *dev, uint32_t pin);
58 int (*get_time)(const struct device *dev, uint64_t *current_time);
60 int (*cyc_per_sec)(const struct device *dev, uint32_t *cycles);
62 int (*set_perout)(const struct device *dev, uint32_t pin, uint64_t start_time,
63 uint64_t repeat_interval, bool periodic_enable);
65 int (*config_ext_ts)(const struct device *dev, uint32_t pin, uint32_t event_polarity);
67 int (*read_ts_ec)(const struct device *dev, uint32_t pin, uint64_t *timestamp,
68 uint64_t *event_count);
69};
70
72
82__syscall int tgpio_port_get_time(const struct device *dev, uint64_t *current_time);
83
84static inline int z_impl_tgpio_port_get_time(const struct device *dev, uint64_t *current_time)
85{
86 return DEVICE_API_GET(tgpio, dev)->get_time(dev, current_time);
87}
88
97__syscall int tgpio_port_get_cycles_per_second(const struct device *dev, uint32_t *cycles);
98
99static inline int z_impl_tgpio_port_get_cycles_per_second(const struct device *dev,
100 uint32_t *cycles)
101{
102 return DEVICE_API_GET(tgpio, dev)->cyc_per_sec(dev, cycles);
103}
104
113__syscall int tgpio_pin_disable(const struct device *dev, uint32_t pin);
114
115static inline int z_impl_tgpio_pin_disable(const struct device *dev, uint32_t pin)
116{
117 return DEVICE_API_GET(tgpio, dev)->pin_disable(dev, pin);
118}
119
129__syscall int tgpio_pin_config_ext_timestamp(const struct device *dev, uint32_t pin,
130 uint32_t event_polarity);
131
132static inline int z_impl_tgpio_pin_config_ext_timestamp(const struct device *dev, uint32_t pin,
133 uint32_t event_polarity)
134{
135 return DEVICE_API_GET(tgpio, dev)->config_ext_ts(dev, pin, event_polarity);
136}
137
149__syscall int tgpio_pin_periodic_output(const struct device *dev, uint32_t pin,
150 uint64_t start_time, uint64_t repeat_interval,
151 bool periodic_enable);
152
153static inline int z_impl_tgpio_pin_periodic_output(const struct device *dev, uint32_t pin,
154 uint64_t start_time, uint64_t repeat_interval,
155 bool periodic_enable)
156{
157 return DEVICE_API_GET(tgpio, dev)->set_perout(dev, pin, start_time, repeat_interval,
158 periodic_enable);
159}
160
171__syscall int tgpio_pin_read_ts_ec(const struct device *dev, uint32_t pin, uint64_t *timestamp,
172 uint64_t *event_count);
173
174static inline int z_impl_tgpio_pin_read_ts_ec(const struct device *dev, uint32_t pin,
175 uint64_t *timestamp, uint64_t *event_count)
176{
177 return DEVICE_API_GET(tgpio, dev)->read_ts_ec(dev, pin, timestamp, event_count);
178}
179
183
184#ifdef __cplusplus
185}
186#endif
187
188#include <zephyr/syscalls/timeaware_gpio.h>
189
190#endif /* ZEPHYR_DRIVERS_MISC_TIMEAWARE_GPIO_TIMEAWARE_GPIO */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
int tgpio_pin_read_ts_ec(const struct device *dev, uint32_t pin, uint64_t *timestamp, uint64_t *event_count)
Read timestamp and event counter from TGPIO.
int tgpio_pin_config_ext_timestamp(const struct device *dev, uint32_t pin, uint32_t event_polarity)
Enable/Continue operation on pin.
int tgpio_pin_disable(const struct device *dev, uint32_t pin)
Disable operation on pin.
int tgpio_port_get_time(const struct device *dev, uint64_t *current_time)
Get time from ART timer.
int tgpio_port_get_cycles_per_second(const struct device *dev, uint32_t *cycles)
Get current running rate.
tgpio_pin_polarity
Event polarity.
Definition timeaware_gpio.h:39
int tgpio_pin_periodic_output(const struct device *dev, uint32_t pin, uint64_t start_time, uint64_t repeat_interval, bool periodic_enable)
Enable periodic pulse generation on a pin.
@ TGPIO_TOGGLE_EDGE
Toggle edge.
Definition timeaware_gpio.h:42
@ TGPIO_RISING_EDGE
Rising edge.
Definition timeaware_gpio.h:40
@ TGPIO_FALLING_EDGE
Falling edge.
Definition timeaware_gpio.h:41
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
<span class="mlabel">Driver Operations</span> Time-aware GPIO driver operations
Definition timeaware_gpio.h:54
int(* set_perout)(const struct device *dev, uint32_t pin, uint64_t start_time, uint64_t repeat_interval, bool periodic_enable)
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition timeaware_gpio.h:62
int(* get_time)(const struct device *dev, uint64_t *current_time)
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition timeaware_gpio.h:58
int(* pin_disable)(const struct device *dev, uint32_t pin)
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition timeaware_gpio.h:56
int(* cyc_per_sec)(const struct device *dev, uint32_t *cycles)
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition timeaware_gpio.h:60
int(* read_ts_ec)(const struct device *dev, uint32_t pin, uint64_t *timestamp, uint64_t *event_count)
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition timeaware_gpio.h:67
int(* config_ext_ts)(const struct device *dev, uint32_t pin, uint32_t event_polarity)
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition timeaware_gpio.h:65