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
52
53__subsystem struct tgpio_driver_api {
54 int (*pin_disable)(const struct device *dev, uint32_t pin);
55 int (*get_time)(const struct device *dev, uint64_t *current_time);
56 int (*cyc_per_sec)(const struct device *dev, uint32_t *cycles);
57 int (*set_perout)(const struct device *dev, uint32_t pin, uint64_t start_time,
58 uint64_t repeat_interval, bool periodic_enable);
59 int (*config_ext_ts)(const struct device *dev, uint32_t pin, uint32_t event_polarity);
60 int (*read_ts_ec)(const struct device *dev, uint32_t pin, uint64_t *timestamp,
61 uint64_t *event_count);
62};
63
67
77__syscall int tgpio_port_get_time(const struct device *dev, uint64_t *current_time);
78
79static inline int z_impl_tgpio_port_get_time(const struct device *dev, uint64_t *current_time)
80{
81 return DEVICE_API_GET(tgpio, dev)->get_time(dev, current_time);
82}
83
92__syscall int tgpio_port_get_cycles_per_second(const struct device *dev, uint32_t *cycles);
93
94static inline int z_impl_tgpio_port_get_cycles_per_second(const struct device *dev,
95 uint32_t *cycles)
96{
97 return DEVICE_API_GET(tgpio, dev)->cyc_per_sec(dev, cycles);
98}
99
108__syscall int tgpio_pin_disable(const struct device *dev, uint32_t pin);
109
110static inline int z_impl_tgpio_pin_disable(const struct device *dev, uint32_t pin)
111{
112 return DEVICE_API_GET(tgpio, dev)->pin_disable(dev, pin);
113}
114
124__syscall int tgpio_pin_config_ext_timestamp(const struct device *dev, uint32_t pin,
125 uint32_t event_polarity);
126
127static inline int z_impl_tgpio_pin_config_ext_timestamp(const struct device *dev, uint32_t pin,
128 uint32_t event_polarity)
129{
130 return DEVICE_API_GET(tgpio, dev)->config_ext_ts(dev, pin, event_polarity);
131}
132
144__syscall int tgpio_pin_periodic_output(const struct device *dev, uint32_t pin,
145 uint64_t start_time, uint64_t repeat_interval,
146 bool periodic_enable);
147
148static inline int z_impl_tgpio_pin_periodic_output(const struct device *dev, uint32_t pin,
149 uint64_t start_time, uint64_t repeat_interval,
150 bool periodic_enable)
151{
152 return DEVICE_API_GET(tgpio, dev)->set_perout(dev, pin, start_time, repeat_interval,
153 periodic_enable);
154}
155
166__syscall int tgpio_pin_read_ts_ec(const struct device *dev, uint32_t pin, uint64_t *timestamp,
167 uint64_t *event_count);
168
169static inline int z_impl_tgpio_pin_read_ts_ec(const struct device *dev, uint32_t pin,
170 uint64_t *timestamp, uint64_t *event_count)
171{
172 return DEVICE_API_GET(tgpio, dev)->read_ts_ec(dev, pin, timestamp, event_count);
173}
174
178
179#ifdef __cplusplus
180}
181#endif
182
183#include <zephyr/syscalls/timeaware_gpio.h>
184
185#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:1375
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
Definition timeaware_gpio.h:42
@ TGPIO_RISING_EDGE
Definition timeaware_gpio.h:40
@ TGPIO_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