Zephyr API Documentation  3.5.0
A Scalable Open Source RTOS
3.5.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
21#include <zephyr/sys/__assert.h>
22#include <zephyr/sys/slist.h>
23
24#include <zephyr/types.h>
25#include <stddef.h>
26#include <zephyr/device.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
40};
41
50__subsystem struct tgpio_driver_api {
51 int (*pin_disable)(const struct device *dev, uint32_t pin);
52 int (*get_time)(const struct device *dev, uint64_t *current_time);
53 int (*cyc_per_sec)(const struct device *dev, uint32_t *cycles);
54 int (*set_perout)(const struct device *dev, uint32_t pin, uint64_t start_time,
55 uint64_t repeat_interval, bool periodic_enable);
56 int (*config_ext_ts)(const struct device *dev, uint32_t pin, uint32_t event_polarity);
57 int (*read_ts_ec)(const struct device *dev, uint32_t pin, uint64_t *timestamp,
58 uint64_t *event_count);
59};
60
74__syscall int tgpio_port_get_time(const struct device *dev, uint64_t *current_time);
75
76static inline int z_impl_tgpio_port_get_time(const struct device *dev, uint64_t *current_time)
77{
78 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
79
80 return api->get_time(dev, current_time);
81}
82
91__syscall int tgpio_port_get_cycles_per_second(const struct device *dev, uint32_t *cycles);
92
93static inline int z_impl_tgpio_port_get_cycles_per_second(const struct device *dev,
94 uint32_t *cycles)
95{
96 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
97
98 return api->cyc_per_sec(dev, cycles);
99}
100
109__syscall int tgpio_pin_disable(const struct device *dev, uint32_t pin);
110
111static inline int z_impl_tgpio_pin_disable(const struct device *dev, uint32_t pin)
112{
113 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
114
115 return api->pin_disable(dev, pin);
116}
117
127__syscall int tgpio_pin_config_ext_timestamp(const struct device *dev, uint32_t pin,
128 uint32_t event_polarity);
129
130static inline int z_impl_tgpio_pin_config_ext_timestamp(const struct device *dev, uint32_t pin,
131 uint32_t event_polarity)
132{
133 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
134
135 return api->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 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
158
159 return api->set_perout(dev, pin, start_time, repeat_interval, periodic_enable);
160}
161
172__syscall int tgpio_pin_read_ts_ec(const struct device *dev, uint32_t pin, uint64_t *timestamp,
173 uint64_t *event_count);
174
175static inline int z_impl_tgpio_pin_read_ts_ec(const struct device *dev, uint32_t pin,
176 uint64_t *timestamp, uint64_t *event_count)
177{
178 const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
179
180 return api->read_ts_ec(dev, pin, timestamp, event_count);
181}
182
187#ifdef __cplusplus
188}
189#endif
190
191#include <syscalls/timeaware_gpio.h>
192
193#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:36
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:39
@ TGPIO_RISING_EDGE
Definition: timeaware_gpio.h:37
@ TGPIO_FALLING_EDGE
Definition: timeaware_gpio.h:38
__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:381
const void * api
Address of the API structure exposed by the device instance.
Definition: device.h:387