Zephyr API Documentation  3.7.0
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
11#ifndef ZEPHYR_DRIVERS_MISC_TIMEAWARE_GPIO_TIMEAWARE_GPIO
12#define ZEPHYR_DRIVERS_MISC_TIMEAWARE_GPIO_TIMEAWARE_GPIO
13
23#include <zephyr/sys/__assert.h>
24#include <zephyr/sys/slist.h>
25
26#include <zephyr/types.h>
27#include <stddef.h>
28#include <zephyr/device.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
42};
43
52__subsystem struct tgpio_driver_api {
53 int (*pin_disable)(const struct device *dev, uint32_t pin);
54 int (*get_time)(const struct device *dev, uint64_t *current_time);
55 int (*cyc_per_sec)(const struct device *dev, uint32_t *cycles);
56 int (*set_perout)(const struct device *dev, uint32_t pin, uint64_t start_time,
57 uint64_t repeat_interval, bool periodic_enable);
58 int (*config_ext_ts)(const struct device *dev, uint32_t pin, uint32_t event_polarity);
59 int (*read_ts_ec)(const struct device *dev, uint32_t pin, uint64_t *timestamp,
60 uint64_t *event_count);
61};
62
76__syscall int tgpio_port_get_time(const struct device *dev, uint64_t *current_time);
77
78static inline int z_impl_tgpio_port_get_time(const struct device *dev, uint64_t *current_time)
79{
80 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
81
82 return api->get_time(dev, current_time);
83}
84
93__syscall int tgpio_port_get_cycles_per_second(const struct device *dev, uint32_t *cycles);
94
95static inline int z_impl_tgpio_port_get_cycles_per_second(const struct device *dev,
96 uint32_t *cycles)
97{
98 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
99
100 return api->cyc_per_sec(dev, cycles);
101}
102
111__syscall int tgpio_pin_disable(const struct device *dev, uint32_t pin);
112
113static inline int z_impl_tgpio_pin_disable(const struct device *dev, uint32_t pin)
114{
115 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
116
117 return api->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 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
136
137 return api->config_ext_ts(dev, pin, event_polarity);
138}
139
151__syscall int tgpio_pin_periodic_output(const struct device *dev, uint32_t pin,
152 uint64_t start_time, uint64_t repeat_interval,
153 bool periodic_enable);
154
155static inline int z_impl_tgpio_pin_periodic_output(const struct device *dev, uint32_t pin,
156 uint64_t start_time, uint64_t repeat_interval,
157 bool periodic_enable)
158{
159 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
160
161 return api->set_perout(dev, pin, start_time, repeat_interval, periodic_enable);
162}
163
174__syscall int tgpio_pin_read_ts_ec(const struct device *dev, uint32_t pin, uint64_t *timestamp,
175 uint64_t *event_count);
176
177static inline int z_impl_tgpio_pin_read_ts_ec(const struct device *dev, uint32_t pin,
178 uint64_t *timestamp, uint64_t *event_count)
179{
180 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
181
182 return api->read_ts_ec(dev, pin, timestamp, event_count);
183}
184
189#ifdef __cplusplus
190}
191#endif
192
193#include <zephyr/syscalls/timeaware_gpio.h>
194
195#endif /* ZEPHYR_DRIVERS_MISC_TIMEAWARE_GPIO_TIMEAWARE_GPIO */
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:38
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:41
@ TGPIO_RISING_EDGE
Definition: timeaware_gpio.h:39
@ TGPIO_FALLING_EDGE
Definition: timeaware_gpio.h:40
__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:403
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:409