drivers: adc: ads114s0x: Rename variables, preparing for adding new devices

Renamed ads114s0x/8 to ads1x4s0x.

Signed-off-by: Terry Geng <terry@terriex.com>
This commit is contained in:
Terry Geng 2025-01-27 10:00:24 -05:00 committed by Benjamin Cabé
parent cec083edd1
commit 43079c8086
11 changed files with 644 additions and 644 deletions

View File

@ -34,7 +34,7 @@ zephyr_library_sources_ifdef(CONFIG_ADC_GD32 adc_gd32.c)
zephyr_library_sources_ifdef(CONFIG_ADC_ADS1112 adc_ads1112.c)
zephyr_library_sources_ifdef(CONFIG_ADC_ADS1119 adc_ads1119.c)
zephyr_library_sources_ifdef(CONFIG_ADC_ADS7052 adc_ads7052.c)
zephyr_library_sources_ifdef(CONFIG_ADC_ADS114S0X adc_ads114s0x.c)
zephyr_library_sources_ifdef(CONFIG_ADC_ADS1X4S0X adc_ads114s0x.c)
zephyr_library_sources_ifdef(CONFIG_ADC_ADS131M02 adc_ads131m02.c)
zephyr_library_sources_ifdef(CONFIG_ADC_RPI_PICO adc_rpi_pico.c)
zephyr_library_sources_ifdef(CONFIG_ADC_XMC4XXX adc_xmc4xxx.c)

View File

@ -2,43 +2,43 @@
#
# SPDX-License-Identifier: Apache-2.0
menuconfig ADC_ADS114S0X
bool "Texas instruments ADS114S0x"
menuconfig ADC_ADS1X4S0X
bool "Texas instruments ADS1X4S0X"
default y
depends on DT_HAS_TI_ADS114S08_ENABLED
depends on DT_HAS_TI_ADS1X4S08_ENABLED
select SPI
select ADC_CONFIGURABLE_INPUTS
select ADC_CONFIGURABLE_EXCITATION_CURRENT_SOURCE_PIN
select ADC_CONFIGURABLE_VBIAS_PIN
help
Enable the driver implementation for the ADS114S0X family
Enable the driver implementation for the ADS1X4S0X family
config ADC_ADS114S0X_ASYNC_THREAD_INIT_PRIO
int "ADC ADS114S0x async thread priority"
config ADC_ADS1X4S0X_ASYNC_THREAD_INIT_PRIO
int "ADC ADS1X4S0X async thread priority"
default 0
depends on ADC_ADS114S0X
depends on ADC_ADS1X4S0X
config ADC_ADS114S0X_ACQUISITION_THREAD_STACK_SIZE
config ADC_ADS1X4S0X_ACQUISITION_THREAD_STACK_SIZE
int "Stack size for the ADC data acquisition thread"
default 400
depends on ADC_ADS114S0X
depends on ADC_ADS1X4S0X
help
Size of the stack used for the internal data acquisition
thread.
config ADC_ADS114S0X_GPIO
config ADC_ADS1X4S0X_GPIO
bool "GPIO support"
default n
depends on GPIO && ADC_ADS114S0X
depends on GPIO && ADC_ADS1X4S0X
help
Enable GPIO child device support in the ADS114S0x ADC driver.
Enable GPIO child device support in the ADS1X4S0X ADC driver.
The GPIO functionality is handled by the ADS114S0x GPIO
The GPIO functionality is handled by the ADS1X4S0X GPIO
driver.
config ADC_ADS114S0X_WAIT_FOR_COMPLETION_TIMEOUT_MS
config ADC_ADS1X4S0X_WAIT_FOR_COMPLETION_TIMEOUT_MS
int "Timeout for wait for completion of a read in ms"
default 1000
depends on ADC_ADS114S0X
depends on ADC_ADS1X4S0X
help
This is the wait time in ms until a read is completed.

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ zephyr_library()
# zephyr-keep-sorted-start
zephyr_library_sources_ifdef(CONFIG_GPIO_AD559X gpio_ad559x.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_ADP5585 gpio_adp5585.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_ADS114S0X gpio_ads114s0x.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_ADS1X4S0X gpio_ads114s0x.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_ALTERA_PIO gpio_altera_pio.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_AMBIQ gpio_ambiq.c)
zephyr_library_sources_ifdef(CONFIG_GPIO_ANDES_ATCGPIO100 gpio_andes_atcgpio100.c)

View File

@ -1,25 +1,25 @@
# ADS114S0x GPIO configuration options
# ADS1X4S0X GPIO configuration options
# Copyright (c) 2023 SILA Embedded Solutions GmbH
# SPDX-License-Identifier: Apache-2.0
menuconfig GPIO_ADS114S0X
bool "ADS114S0x GPIO driver"
menuconfig GPIO_ADS1X4S0X
bool "ADS1X4S0X GPIO driver"
default y
depends on DT_HAS_TI_ADS114S0X_GPIO_ENABLED
depends on ADC_ADS114S0X_GPIO
depends on DT_HAS_TI_ADS1X4S0X_GPIO_ENABLED
depends on ADC_ADS1X4S0X_GPIO
help
Enable GPIO driver for ADS114S0x.
Enable GPIO driver for ADS1X4S0X.
The ADS114S0x is a multi-channel analog frontend (AFE).
The ADS1X4S0X is a multi-channel analog frontend (AFE).
The GPIO port of the ADS114S0x (GPIO0 to GPIO3) is exposed as a
The GPIO port of the ADS1X4S0X (GPIO0 to GPIO3) is exposed as a
GPIO controller driver with read/write support.
config GPIO_ADS114S0X_INIT_PRIORITY
config GPIO_ADS1X4S0X_INIT_PRIORITY
int "Driver init priority"
default 99
depends on GPIO_ADS114S0X
depends on GPIO_ADS1X4S0X
help
Device driver initialization priority. This driver must be
initialized after the ADS114S0x ADC driver.
initialized after the ADS1X4S0X ADC driver.

View File

@ -9,37 +9,37 @@
* @brief GPIO driver for the ADS114S0x AFE.
*/
#define DT_DRV_COMPAT ti_ads114s0x_gpio
#define DT_DRV_COMPAT ti_ads1x4s0x_gpio
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
#define LOG_LEVEL CONFIG_GPIO_LOG_LEVEL
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(gpio_ads114s0x);
LOG_MODULE_REGISTER(gpio_ads1x4s0x);
#include <zephyr/drivers/adc/ads114s0x.h>
#include <zephyr/drivers/gpio/gpio_utils.h>
struct gpio_ads114s0x_config {
struct gpio_ads1x4s0x_config {
/* gpio_driver_config needs to be first */
struct gpio_driver_config common;
const struct device *parent;
};
struct gpio_ads114s0x_data {
struct gpio_ads1x4s0x_data {
/* gpio_driver_data needs to be first */
struct gpio_driver_data common;
};
static int gpio_ads114s0x_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags)
static int gpio_ads1x4s0x_config(const struct device *dev, gpio_pin_t pin, gpio_flags_t flags)
{
const struct gpio_ads114s0x_config *config = dev->config;
const struct gpio_ads1x4s0x_config *config = dev->config;
int err = 0;
if ((flags & (GPIO_INPUT | GPIO_OUTPUT)) == GPIO_DISCONNECTED) {
return ads114s0x_gpio_deconfigure(config->parent, pin);
return ads1x4s0x_gpio_deconfigure(config->parent, pin);
}
if ((flags & GPIO_SINGLE_ENDED) != 0) {
@ -51,16 +51,16 @@ static int gpio_ads114s0x_config(const struct device *dev, gpio_pin_t pin, gpio_
}
if (flags & GPIO_INT_ENABLE) {
/* ads114s0x GPIOs do not support interrupts */
/* ads1x4s0x GPIOs do not support interrupts */
return -ENOTSUP;
}
switch (flags & GPIO_DIR_MASK) {
case GPIO_INPUT:
err = ads114s0x_gpio_set_input(config->parent, pin);
err = ads1x4s0x_gpio_set_input(config->parent, pin);
break;
case GPIO_OUTPUT:
err = ads114s0x_gpio_set_output(config->parent, pin,
err = ads1x4s0x_gpio_set_output(config->parent, pin,
(flags & GPIO_OUTPUT_INIT_HIGH) != 0);
break;
default:
@ -70,76 +70,76 @@ static int gpio_ads114s0x_config(const struct device *dev, gpio_pin_t pin, gpio_
return err;
}
static int gpio_ads114s0x_port_get_raw(const struct device *dev, gpio_port_value_t *value)
static int gpio_ads1x4s0x_port_get_raw(const struct device *dev, gpio_port_value_t *value)
{
const struct gpio_ads114s0x_config *config = dev->config;
const struct gpio_ads1x4s0x_config *config = dev->config;
return ads114s0x_gpio_port_get_raw(config->parent, value);
return ads1x4s0x_gpio_port_get_raw(config->parent, value);
}
static int gpio_ads114s0x_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask,
static int gpio_ads1x4s0x_port_set_masked_raw(const struct device *dev, gpio_port_pins_t mask,
gpio_port_value_t value)
{
const struct gpio_ads114s0x_config *config = dev->config;
const struct gpio_ads1x4s0x_config *config = dev->config;
return ads114s0x_gpio_port_set_masked_raw(config->parent, mask, value);
return ads1x4s0x_gpio_port_set_masked_raw(config->parent, mask, value);
}
static int gpio_ads114s0x_port_set_bits_raw(const struct device *dev, gpio_port_pins_t pins)
static int gpio_ads1x4s0x_port_set_bits_raw(const struct device *dev, gpio_port_pins_t pins)
{
const struct gpio_ads114s0x_config *config = dev->config;
const struct gpio_ads1x4s0x_config *config = dev->config;
return ads114s0x_gpio_port_set_masked_raw(config->parent, pins, pins);
return ads1x4s0x_gpio_port_set_masked_raw(config->parent, pins, pins);
}
static int gpio_ads114s0x_port_clear_bits_raw(const struct device *dev, gpio_port_pins_t pins)
static int gpio_ads1x4s0x_port_clear_bits_raw(const struct device *dev, gpio_port_pins_t pins)
{
const struct gpio_ads114s0x_config *config = dev->config;
const struct gpio_ads1x4s0x_config *config = dev->config;
return ads114s0x_gpio_port_set_masked_raw(config->parent, pins, 0);
return ads1x4s0x_gpio_port_set_masked_raw(config->parent, pins, 0);
}
static int gpio_ads114s0x_port_toggle_bits(const struct device *dev, gpio_port_pins_t pins)
static int gpio_ads1x4s0x_port_toggle_bits(const struct device *dev, gpio_port_pins_t pins)
{
const struct gpio_ads114s0x_config *config = dev->config;
const struct gpio_ads1x4s0x_config *config = dev->config;
return ads114s0x_gpio_port_toggle_bits(config->parent, pins);
return ads1x4s0x_gpio_port_toggle_bits(config->parent, pins);
}
static int gpio_ads114s0x_init(const struct device *dev)
static int gpio_ads1x4s0x_init(const struct device *dev)
{
const struct gpio_ads114s0x_config *config = dev->config;
const struct gpio_ads1x4s0x_config *config = dev->config;
if (!device_is_ready(config->parent)) {
LOG_ERR("parent ads114s0x device '%s' not ready", config->parent->name);
LOG_ERR("parent ads1x4s0x device '%s' not ready", config->parent->name);
return -EINVAL;
}
return 0;
}
static DEVICE_API(gpio, gpio_ads114s0x_api) = {
.pin_configure = gpio_ads114s0x_config,
.port_set_masked_raw = gpio_ads114s0x_port_set_masked_raw,
.port_set_bits_raw = gpio_ads114s0x_port_set_bits_raw,
.port_clear_bits_raw = gpio_ads114s0x_port_clear_bits_raw,
.port_toggle_bits = gpio_ads114s0x_port_toggle_bits,
.port_get_raw = gpio_ads114s0x_port_get_raw,
static DEVICE_API(gpio, gpio_ads1x4s0x_api) = {
.pin_configure = gpio_ads1x4s0x_config,
.port_set_masked_raw = gpio_ads1x4s0x_port_set_masked_raw,
.port_set_bits_raw = gpio_ads1x4s0x_port_set_bits_raw,
.port_clear_bits_raw = gpio_ads1x4s0x_port_clear_bits_raw,
.port_toggle_bits = gpio_ads1x4s0x_port_toggle_bits,
.port_get_raw = gpio_ads1x4s0x_port_get_raw,
};
BUILD_ASSERT(CONFIG_GPIO_ADS114S0X_INIT_PRIORITY > CONFIG_ADC_INIT_PRIORITY,
"ADS114S0X GPIO driver must be initialized after ADS114S0X ADC driver");
BUILD_ASSERT(CONFIG_GPIO_ADS1X4S0X_INIT_PRIORITY > CONFIG_ADC_INIT_PRIORITY,
"ADS1X4S0X GPIO driver must be initialized after ADS1X4S0X ADC driver");
#define GPIO_ADS114S0X_DEVICE(id) \
static const struct gpio_ads114s0x_config gpio_ads114s0x_##id##_cfg = { \
#define GPIO_ADS1X4S0X_DEVICE(id) \
static const struct gpio_ads1x4s0x_config gpio_ads1x4s0x_##id##_cfg = { \
.common = {.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_INST(id)}, \
.parent = DEVICE_DT_GET(DT_INST_BUS(id)), \
}; \
\
static struct gpio_ads114s0x_data gpio_ads114s0x_##id##_data; \
static struct gpio_ads1x4s0x_data gpio_ads1x4s0x_##id##_data; \
\
DEVICE_DT_INST_DEFINE(id, gpio_ads114s0x_init, NULL, &gpio_ads114s0x_##id##_data, \
&gpio_ads114s0x_##id##_cfg, POST_KERNEL, \
CONFIG_GPIO_ADS114S0X_INIT_PRIORITY, &gpio_ads114s0x_api);
DEVICE_DT_INST_DEFINE(id, gpio_ads1x4s0x_init, NULL, &gpio_ads1x4s0x_##id##_data, \
&gpio_ads1x4s0x_##id##_cfg, POST_KERNEL, \
CONFIG_GPIO_ADS1X4S0X_INIT_PRIORITY, &gpio_ads1x4s0x_api);
DT_INST_FOREACH_STATUS_OKAY(GPIO_ADS114S0X_DEVICE)
DT_INST_FOREACH_STATUS_OKAY(GPIO_ADS1X4S0X_DEVICE)

View File

@ -6,7 +6,7 @@
description: TI ADS114S0x GPIO controller binding
compatible: "ti,ads114s0x-gpio"
compatible: "ti,ads1x4s0x-gpio"
include: [gpio-controller.yaml, base.yaml]

View File

@ -4,32 +4,32 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_DRIVERS_ADC_ADS114S0X_H_
#define ZEPHYR_INCLUDE_DRIVERS_ADC_ADS114S0X_H_
#ifndef ZEPHYR_INCLUDE_DRIVERS_ADC_ADS1X4S0X_H_
#define ZEPHYR_INCLUDE_DRIVERS_ADC_ADS1X4S0X_H_
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
int ads114s0x_gpio_set_output(const struct device *dev, uint8_t pin, bool initial_value);
int ads1x4s0x_gpio_set_output(const struct device *dev, uint8_t pin, bool initial_value);
int ads114s0x_gpio_set_input(const struct device *dev, uint8_t pin);
int ads1x4s0x_gpio_set_input(const struct device *dev, uint8_t pin);
int ads114s0x_gpio_deconfigure(const struct device *dev, uint8_t pin);
int ads1x4s0x_gpio_deconfigure(const struct device *dev, uint8_t pin);
int ads114s0x_gpio_set_pin_value(const struct device *dev, uint8_t pin,
int ads1x4s0x_gpio_set_pin_value(const struct device *dev, uint8_t pin,
bool value);
int ads114s0x_gpio_get_pin_value(const struct device *dev, uint8_t pin,
int ads1x4s0x_gpio_get_pin_value(const struct device *dev, uint8_t pin,
bool *value);
int ads114s0x_gpio_port_get_raw(const struct device *dev,
int ads1x4s0x_gpio_port_get_raw(const struct device *dev,
gpio_port_value_t *value);
int ads114s0x_gpio_port_set_masked_raw(const struct device *dev,
int ads1x4s0x_gpio_port_set_masked_raw(const struct device *dev,
gpio_port_pins_t mask,
gpio_port_value_t value);
int ads114s0x_gpio_port_toggle_bits(const struct device *dev,
int ads1x4s0x_gpio_port_toggle_bits(const struct device *dev,
gpio_port_pins_t pins);
#endif /* ZEPHYR_INCLUDE_DRIVERS_ADC_ADS114S0X_H_ */
#endif /* ZEPHYR_INCLUDE_DRIVERS_ADC_ADS1X4S0X_H_ */

View File

@ -4,26 +4,26 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_ADC_ADS114S0X_ADC_H_
#define ZEPHYR_INCLUDE_DT_BINDINGS_ADC_ADS114S0X_ADC_H_
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_ADC_ADS1X4S0X_ADC_H_
#define ZEPHYR_INCLUDE_DT_BINDINGS_ADC_ADS1X4S0X_ADC_H_
/*
* These are the available data rates described as samples per second. They
* can be used with the time unit ticks for the acquisition time.
*/
#define ADS114S0X_CONFIG_DR_2_5 0
#define ADS114S0X_CONFIG_DR_5 1
#define ADS114S0X_CONFIG_DR_10 2
#define ADS114S0X_CONFIG_DR_16_6 3
#define ADS114S0X_CONFIG_DR_20 4
#define ADS114S0X_CONFIG_DR_50 5
#define ADS114S0X_CONFIG_DR_60 6
#define ADS114S0X_CONFIG_DR_100 7
#define ADS114S0X_CONFIG_DR_200 8
#define ADS114S0X_CONFIG_DR_400 9
#define ADS114S0X_CONFIG_DR_800 10
#define ADS114S0X_CONFIG_DR_1000 11
#define ADS114S0X_CONFIG_DR_2000 12
#define ADS114S0X_CONFIG_DR_4000 13
#define ADS1X4S0X_CONFIG_DR_2_5 0
#define ADS1X4S0X_CONFIG_DR_5 1
#define ADS1X4S0X_CONFIG_DR_10 2
#define ADS1X4S0X_CONFIG_DR_16_6 3
#define ADS1X4S0X_CONFIG_DR_20 4
#define ADS1X4S0X_CONFIG_DR_50 5
#define ADS1X4S0X_CONFIG_DR_60 6
#define ADS1X4S0X_CONFIG_DR_100 7
#define ADS1X4S0X_CONFIG_DR_200 8
#define ADS1X4S0X_CONFIG_DR_400 9
#define ADS1X4S0X_CONFIG_DR_800 10
#define ADS1X4S0X_CONFIG_DR_1000 11
#define ADS1X4S0X_CONFIG_DR_2000 12
#define ADS1X4S0X_CONFIG_DR_4000 13
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_ADC_ADS114S0X_ADC_H_ */
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_ADC_ADS1X4S0X_ADC_H_ */

View File

@ -40,7 +40,7 @@
start-sync-gpios = <&test_gpio 0 0>;
test_spi_ads114s08_gpio: ads114s0x_gpio {
compatible = "ti,ads114s0x-gpio";
compatible = "ti,ads1x4s0x-gpio";
gpio-controller;
ngpios = <4>;
#gpio-cells = <2>;

View File

@ -26,7 +26,7 @@ tests:
depends_on: gpio
extra_args: DTC_OVERLAY_FILE="altera.overlay"
drivers.gpio.build.adc_ads1145s0x_gpio:
drivers.gpio.build.adc_ads1x4s0x_gpio:
min_ram: 32
platform_allow:
- m5stack_core2/esp32/procpu
@ -44,7 +44,7 @@ tests:
extra_configs:
- CONFIG_ADC=y
- CONFIG_ADC_INIT_PRIORITY=80
- CONFIG_ADC_ADS114S0X_GPIO=y
- CONFIG_ADC_ADS1X4S0X_GPIO=y
drivers.gpio.build.adc_lmp90xxx_gpio:
min_ram: 32