qinclude: zephyr: misc: Added timeaware gpio header file
Added timeaware gpio interface. Signed-off-by: Anisetti Avinash Krishna <anisetti.avinash.krishna@intel.com>
This commit is contained in:
parent
60ad26403b
commit
667c35a019
6 changed files with 286 additions and 0 deletions
|
@ -5,3 +5,4 @@ add_subdirectory_ifdef(CONFIG_FT800 ft8xx)
|
|||
add_subdirectory_ifdef(CONFIG_GROVE_LCD_RGB grove_lcd_rgb)
|
||||
add_subdirectory_ifdef(CONFIG_PIO_RPI_PICO pio_rpi_pico)
|
||||
add_subdirectory_ifdef(CONFIG_NXP_S32_EMIOS nxp_s32_emios)
|
||||
add_subdirectory_ifdef(CONFIG_TIMEAWARE_GPIO timeaware_gpio)
|
||||
|
|
|
@ -9,5 +9,6 @@ source "drivers/misc/ft8xx/Kconfig"
|
|||
source "drivers/misc/grove_lcd_rgb/Kconfig"
|
||||
source "drivers/misc/pio_rpi_pico/Kconfig"
|
||||
source "drivers/misc/nxp_s32_emios/Kconfig"
|
||||
source "drivers/misc/timeaware_gpio/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
|
7
drivers/misc/timeaware_gpio/CMakeLists.txt
Normal file
7
drivers/misc/timeaware_gpio/CMakeLists.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_syscall_header(${ZEPHYR_BASE}/include/zephyr/drivers/misc/timeaware_gpio/timeaware_gpio.h)
|
||||
|
||||
zephyr_library()
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_USERSPACE timeaware_gpio_handlers.c)
|
24
drivers/misc/timeaware_gpio/Kconfig
Normal file
24
drivers/misc/timeaware_gpio/Kconfig
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Timeaware gpio config options
|
||||
|
||||
# Copyright (c) 2023 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
|
||||
menuconfig TIMEAWARE_GPIO
|
||||
bool "Timeaware GPIO driver"
|
||||
help
|
||||
Enable config options for timeaware GPIO driver.
|
||||
|
||||
if TIMEAWARE_GPIO
|
||||
|
||||
module = TIMEAWARE_GPIO
|
||||
module-str = timeaware_gpio
|
||||
source "subsys/logging/Kconfig.template.log_config"
|
||||
|
||||
config TIMEAWARE_GPIO_INIT_PRIORITY
|
||||
int "Timeaware GPIO initialization priority"
|
||||
default KERNEL_INIT_PRIORITY_DEVICE
|
||||
help
|
||||
System initialization priority for timeaware GPIO drivers.
|
||||
|
||||
endif # TIMEAWARE_GPIO
|
60
drivers/misc/timeaware_gpio/timeaware_gpio_handlers.c
Normal file
60
drivers/misc/timeaware_gpio/timeaware_gpio_handlers.c
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <zephyr/drivers/misc/timeaware_gpio/timeaware_gpio.h>
|
||||
#include <zephyr/syscall_handler.h>
|
||||
|
||||
static inline int z_vrfy_tgpio_port_get_time(const struct device *port, uint64_t *current_time)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_TGPIO(port, get_time));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(current_time, sizeof(uint64_t)));
|
||||
return z_impl_tgpio_port_get_time((const struct device *)port, (uint64_t *)current_time);
|
||||
}
|
||||
#include <syscalls/tgpio_port_get_time_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_tgpio_port_get_cycles_per_second(const struct device *port,
|
||||
uint32_t *cycles)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_TGPIO(port, cyc_per_sec));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(cycles, sizeof(uint32_t)));
|
||||
return z_impl_tgpio_port_get_cycles_per_second((const struct device *)port,
|
||||
(uint32_t *)cycles);
|
||||
}
|
||||
#include <syscalls/tgpio_port_get_cycles_per_second_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_tgpio_pin_periodic_output(const struct device *port, uint32_t pin,
|
||||
uint64_t start_time, uint64_t repeat_interval,
|
||||
bool periodic_enable)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_TGPIO(port, set_perout));
|
||||
return z_impl_tgpio_pin_periodic_output((const struct device *)port, pin, start_time,
|
||||
repeat_interval, periodic_enable);
|
||||
}
|
||||
#include <syscalls/tgpio_pin_periodic_output_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_tgpio_pin_disable(const struct device *port, uint32_t pin)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_TGPIO(port, pin_disable));
|
||||
return z_impl_tgpio_pin_disable((const struct device *)port, pin);
|
||||
}
|
||||
#include <syscalls/tgpio_pin_disable_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_tgpio_pin_config_ext_timestamp(const struct device *port, uint32_t pin,
|
||||
uint32_t event_polarity)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_TGPIO(port, config_ext_ts));
|
||||
return z_impl_tgpio_pin_config_ext_timestamp((const struct device *)port, pin,
|
||||
event_polarity);
|
||||
}
|
||||
#include <syscalls/tgpio_pin_config_ext_timestamp_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_tgpio_pin_read_ts_ec(const struct device *port, uint32_t pin,
|
||||
uint64_t *timestamp, uint64_t *event_count)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_TGPIO(port, read_ts_ec));
|
||||
return z_impl_tgpio_pin_read_ts_ec((const struct device *)port, pin, (uint64_t *)timestamp,
|
||||
(uint64_t *)event_count);
|
||||
}
|
||||
#include <syscalls/tgpio_pin_read_ts_ec_mrsh.c>
|
193
include/zephyr/drivers/misc/timeaware_gpio/timeaware_gpio.h
Normal file
193
include/zephyr/drivers/misc/timeaware_gpio/timeaware_gpio.h
Normal file
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief Public APIs for Time-aware GPIO drivers
|
||||
*/
|
||||
#ifndef ZEPHYR_DRIVERS_MISC_TIMEAWARE_GPIO_TIMEAWARE_GPIO
|
||||
#define ZEPHYR_DRIVERS_MISC_TIMEAWARE_GPIO_TIMEAWARE_GPIO
|
||||
|
||||
/**
|
||||
* @brief Time-aware GPIO Interface
|
||||
* @defgroup tgpio_interface Time-aware GPIO Interface
|
||||
* @ingroup io_interfaces
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include <zephyr/sys/__assert.h>
|
||||
#include <zephyr/sys/slist.h>
|
||||
|
||||
#include <zephyr/types.h>
|
||||
#include <stddef.h>
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/syscall_handler.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Event polarity
|
||||
*/
|
||||
enum tgpio_pin_polarity {
|
||||
TGPIO_RISING_EDGE = 0,
|
||||
TGPIO_FALLING_EDGE,
|
||||
TGPIO_TOGGLE_EDGE,
|
||||
};
|
||||
|
||||
/**
|
||||
* @cond INTERNAL_HIDDEN
|
||||
*
|
||||
* TGPIO driver API definition and system call entry points
|
||||
*
|
||||
* (Internal use only.)
|
||||
*/
|
||||
|
||||
__subsystem struct tgpio_driver_api {
|
||||
int (*pin_disable)(const struct device *dev, uint32_t pin);
|
||||
int (*get_time)(const struct device *dev, uint64_t *current_time);
|
||||
int (*cyc_per_sec)(const struct device *dev, uint32_t *cycles);
|
||||
int (*set_perout)(const struct device *dev, uint32_t pin, uint64_t start_time,
|
||||
uint64_t repeat_interval, bool periodic_enable);
|
||||
int (*config_ext_ts)(const struct device *dev, uint32_t pin, uint32_t event_polarity);
|
||||
int (*read_ts_ec)(const struct device *dev, uint32_t pin, uint64_t *timestamp,
|
||||
uint64_t *event_count);
|
||||
};
|
||||
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Get time from ART timer
|
||||
*
|
||||
* @param dev TGPIO device
|
||||
* @param current_time Pointer to store timer value in cycles
|
||||
*
|
||||
* @return 0 if successful
|
||||
* @return negative errno code on failure.
|
||||
*/
|
||||
__syscall int tgpio_port_get_time(const struct device *dev, uint64_t *current_time);
|
||||
|
||||
static inline int z_impl_tgpio_port_get_time(const struct device *dev, uint64_t *current_time)
|
||||
{
|
||||
const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
|
||||
|
||||
return api->get_time(dev, current_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get current running rate
|
||||
*
|
||||
* @param dev TGPIO device
|
||||
* @param cycles pointer to store current running requency
|
||||
*
|
||||
* @return 0 if successful, negative errno code on failure.
|
||||
*/
|
||||
__syscall int tgpio_port_get_cycles_per_second(const struct device *dev, uint32_t *cycles);
|
||||
|
||||
static inline int z_impl_tgpio_port_get_cycles_per_second(const struct device *dev,
|
||||
uint32_t *cycles)
|
||||
{
|
||||
const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
|
||||
|
||||
return api->cyc_per_sec(dev, cycles);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disable operation on pin
|
||||
*
|
||||
* @param dev TGPIO device
|
||||
* @param pin TGPIO pin
|
||||
*
|
||||
* @return 0 if successful, negative errno code on failure.
|
||||
*/
|
||||
__syscall int tgpio_pin_disable(const struct device *dev, uint32_t pin);
|
||||
|
||||
static inline int z_impl_tgpio_pin_disable(const struct device *dev, uint32_t pin)
|
||||
{
|
||||
const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
|
||||
|
||||
return api->pin_disable(dev, pin);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable/Continue operation on pin
|
||||
*
|
||||
* @param dev TGPIO device
|
||||
* @param pin TGPIO pin
|
||||
* @param event_polarity TGPIO pin event polarity
|
||||
*
|
||||
* @return 0 if successful, negative errno code on failure.
|
||||
*/
|
||||
__syscall int tgpio_pin_config_ext_timestamp(const struct device *dev, uint32_t pin,
|
||||
uint32_t event_polarity);
|
||||
|
||||
static inline int z_impl_tgpio_pin_config_ext_timestamp(const struct device *dev, uint32_t pin,
|
||||
uint32_t event_polarity)
|
||||
{
|
||||
const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
|
||||
|
||||
return api->config_ext_ts(dev, pin, event_polarity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Enable periodic pulse generation on a pin
|
||||
*
|
||||
* @param dev TGPIO device
|
||||
* @param pin TGPIO pin
|
||||
* @param start_time start_time of first pulse in hw cycles
|
||||
* @param repeat_interval repeat interval between two pulses in hw cycles
|
||||
* @param periodic_enable enables periodic mode if 'true' is passed.
|
||||
*
|
||||
* @return 0 if successful, negative errno code on failure.
|
||||
*/
|
||||
__syscall int tgpio_pin_periodic_output(const struct device *dev, uint32_t pin,
|
||||
uint64_t start_time, uint64_t repeat_interval,
|
||||
bool periodic_enable);
|
||||
|
||||
static inline int z_impl_tgpio_pin_periodic_output(const struct device *dev, uint32_t pin,
|
||||
uint64_t start_time, uint64_t repeat_interval,
|
||||
bool periodic_enable)
|
||||
{
|
||||
const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
|
||||
|
||||
return api->set_perout(dev, pin, start_time, repeat_interval, periodic_enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read timestamp and event counter from TGPIO
|
||||
*
|
||||
* @param dev TGPIO device
|
||||
* @param pin TGPIO pin
|
||||
* @param timestamp timestamp of the last pulse received
|
||||
* @param event_count number of pulses received since the pin is enabled
|
||||
*
|
||||
* @return 0 if successful, negative errno code on failure.
|
||||
*/
|
||||
__syscall int tgpio_pin_read_ts_ec(const struct device *dev, uint32_t pin, uint64_t *timestamp,
|
||||
uint64_t *event_count);
|
||||
|
||||
static inline int z_impl_tgpio_pin_read_ts_ec(const struct device *dev, uint32_t pin,
|
||||
uint64_t *timestamp, uint64_t *event_count)
|
||||
{
|
||||
const struct tgpio_driver_api *api = (const struct tgpio_driver_api *)dev->api;
|
||||
|
||||
return api->read_ts_ec(dev, pin, timestamp, event_count);
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <syscalls/timeaware_gpio.h>
|
||||
|
||||
#endif /* ZEPHYR_DRIVERS_MISC_TIMEAWARE_GPIO_TIMEAWARE_GPIO */
|
Loading…
Add table
Add a link
Reference in a new issue