From a490ce449ae0730d242ee3fbebcc63eba073bd04 Mon Sep 17 00:00:00 2001 From: Baptiste Le Duc Date: Sat, 20 Sep 2025 12:07:30 +0200 Subject: [PATCH 1/4] drivers/ads101x: rename driver to ads1x1x --- drivers/ads101x/Makefile.include | 2 - drivers/ads101x/ads101x.c | 218 ------------------ drivers/ads101x/include/ads101x_params.h | 102 -------- drivers/ads101x/include/ads101x_regs.h | 106 --------- drivers/{ads101x => ads1x1x}/Kconfig | 10 +- drivers/{ads101x => ads1x1x}/Makefile | 0 drivers/{ads101x => ads1x1x}/Makefile.dep | 0 drivers/ads1x1x/Makefile.include | 2 + drivers/ads1x1x/ads1x1x.c | 218 ++++++++++++++++++ .../ads101x_saul.c => ads1x1x/ads1x1x_saul.c} | 18 +- drivers/ads1x1x/include/ads1x1x_internal.h | 106 +++++++++ drivers/ads1x1x/include/ads1x1x_params.h | 102 ++++++++ drivers/include/{ads101x.h => ads1x1x.h} | 56 ++--- 13 files changed, 470 insertions(+), 470 deletions(-) delete mode 100644 drivers/ads101x/Makefile.include delete mode 100644 drivers/ads101x/ads101x.c delete mode 100644 drivers/ads101x/include/ads101x_params.h delete mode 100644 drivers/ads101x/include/ads101x_regs.h rename drivers/{ads101x => ads1x1x}/Kconfig (73%) rename drivers/{ads101x => ads1x1x}/Makefile (100%) rename drivers/{ads101x => ads1x1x}/Makefile.dep (100%) create mode 100644 drivers/ads1x1x/Makefile.include create mode 100644 drivers/ads1x1x/ads1x1x.c rename drivers/{ads101x/ads101x_saul.c => ads1x1x/ads1x1x_saul.c} (78%) create mode 100644 drivers/ads1x1x/include/ads1x1x_internal.h create mode 100644 drivers/ads1x1x/include/ads1x1x_params.h rename drivers/include/{ads101x.h => ads1x1x.h} (72%) diff --git a/drivers/ads101x/Makefile.include b/drivers/ads101x/Makefile.include deleted file mode 100644 index c4f88c2b4997..000000000000 --- a/drivers/ads101x/Makefile.include +++ /dev/null @@ -1,2 +0,0 @@ -USEMODULE_INCLUDES_ads101x := $(LAST_MAKEFILEDIR)/include -USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_ads101x) diff --git a/drivers/ads101x/ads101x.c b/drivers/ads101x/ads101x.c deleted file mode 100644 index 3b7974c15cd0..000000000000 --- a/drivers/ads101x/ads101x.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (C) 2017 OTA keys S.A. - * 2018 Acutam Automation, LLC - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup drivers_ads101x - * @{ - * - * @file - * @brief ADS101x/111x ADC device driver - * - * @author Vincent Dupont - * @author Matthew Blue - * @} - */ - -#include "assert.h" -#include "periph/i2c.h" -#include "periph/gpio.h" -#include "ztimer.h" - -#include "ads101x.h" -#include "ads101x_params.h" -#include "ads101x_regs.h" - -#define ENABLE_DEBUG 0 -#include "debug.h" - -#ifndef ADS101X_READ_DELAY_MS -#define ADS101X_READ_DELAY_MS 8 /* ompatible with 128SPS */ -#endif - -#define DEV (dev->params.i2c) -#define ADDR (dev->params.addr) - -static int _ads101x_init_test(i2c_t i2c, uint8_t addr); - -int ads101x_init(ads101x_t *dev, const ads101x_params_t *params) -{ - assert(dev && params); - - dev->params = *params; - - return _ads101x_init_test(DEV, ADDR); -} - -int ads101x_alert_init(ads101x_alert_t *dev, - const ads101x_alert_params_t *params) -{ - assert(dev && params); - - dev->params = *params; - dev->cb = NULL; - dev->arg = NULL; - - /* Set up alerts */ - ads101x_set_alert_parameters(dev, dev->params.low_limit, - dev->params.high_limit); - - return _ads101x_init_test(DEV, ADDR); -} - -static int _ads101x_init_test(i2c_t i2c, uint8_t addr) -{ - uint8_t regs[2]; - - i2c_acquire(i2c); - - /* Register read test */ - if (i2c_read_regs(i2c, addr, ADS101X_CONF_ADDR, ®s, 2, 0x0) < 0) { - DEBUG("[ads101x] init - error: unable to read reg %x\n", - ADS101X_CONF_ADDR); - i2c_release(i2c); - return ADS101X_NODEV; - } - - regs[1] = (regs[1] & ~ADS101X_DATAR_MASK) | ADS101X_DATAR_3300; - - /* Register write test */ - if (i2c_write_regs(i2c, addr, ADS101X_CONF_ADDR, ®s, 2, 0x0) < 0) { - DEBUG("[ads101x] init - error: unable to write reg %x\n", - ADS101X_CONF_ADDR); - i2c_release(i2c); - return ADS101X_NODEV; - } - - i2c_read_regs(i2c, addr, ADS101X_CONF_ADDR, ®s, 2, 0x0); - - i2c_release(i2c); - - /* Write should have actually written the register */ - if ((regs[1] & ADS101X_DATAR_MASK) != ADS101X_DATAR_3300) { - DEBUG("[ads101x] init - error: unable to set reg (reg=%x)\n", regs[1]); - return ADS101X_NODEV; - } - - return ADS101X_OK; -} - -int ads101x_set_mux_gain(const ads101x_t *dev, uint8_t mux_gain) -{ - uint8_t regs[2]; - - i2c_acquire(DEV); - - i2c_read_regs(DEV, ADDR, ADS101X_CONF_ADDR, ®s, 2, 0x0); - - /* Zero mux and gain */ - regs[0] &= ~ADS101X_MUX_MASK; - regs[0] &= ~ADS101X_PGA_MASK; - - /* Write mux and gain */ - regs[0] |= mux_gain; - - i2c_write_regs(DEV, ADDR, ADS101X_CONF_ADDR, ®s, 2, 0x0); - - i2c_release(DEV); - - return ADS101X_OK; -} - -int ads101x_read_raw(const ads101x_t *dev, int16_t *raw) -{ - uint8_t regs[2]; - - i2c_acquire(DEV); - - /* Read control register */ - i2c_read_regs(DEV, ADDR, ADS101X_CONF_ADDR, ®s, 2, 0x0); - - /* Tell the ADC to acquire a single-shot sample */ - regs[0] |= ADS101X_CONF_OS_CONV; - i2c_write_regs(DEV, ADDR, ADS101X_CONF_ADDR, ®s, 2, 0x0); - - /* Wait for the sample to be acquired */ - ztimer_sleep(ZTIMER_MSEC, ADS101X_READ_DELAY_MS); - - /* Read the sample */ - if (i2c_read_regs(DEV, ADDR, ADS101X_CONV_RES_ADDR, ®s, 2, 0x0) < 0) { - i2c_release(DEV); - return ADS101X_NODATA; - } - - i2c_release(DEV); - - /* If all okay, change raw value */ - *raw = (int16_t)(regs[0] << 8) | (int16_t)(regs[1]); - - return ADS101X_OK; -} - -int ads101x_enable_alert(ads101x_alert_t *dev, - ads101x_alert_cb_t cb, void *arg) -{ - uint8_t regs[2]; - - if (!gpio_is_valid(dev->params.alert_pin)) { - return ADS101X_OK; - } - - /* Read control register */ - i2c_acquire(DEV); - i2c_read_regs(DEV, ADDR, ADS101X_CONF_ADDR, ®s, 2, 0x0); - - /* Enable alert comparator */ - regs[1] &= ~ADS101X_CONF_COMP_DIS; - i2c_write_regs(DEV, ADDR, ADS101X_CONF_ADDR, ®s, 2, 0x0); - - i2c_release(DEV); - - /* Enable interrupt */ - dev->arg = arg; - dev->cb = cb; - gpio_init_int(dev->params.alert_pin, GPIO_IN, GPIO_FALLING, cb, arg); - - return ADS101X_OK; -} - -int ads101x_set_alert_parameters(const ads101x_alert_t *dev, - int16_t low_limit, int16_t high_limit) -{ - uint8_t regs[2]; - - i2c_acquire(DEV); - - /* Set up low_limit */ - regs[0] = (uint8_t)(low_limit >> 8); - regs[1] = (uint8_t)low_limit; - i2c_write_regs(DEV, ADDR, ADS101X_LOW_LIMIT_ADDR, ®s, 2, 0x0); - - /* Set up high_limit */ - regs[0] = (uint8_t)(high_limit >> 8); - regs[1] = (uint8_t)high_limit; - i2c_write_regs(DEV, ADDR, ADS101X_HIGH_LIMIT_ADDR, ®s, 2, 0x0); - - /* Read control register */ - i2c_read_regs(DEV, ADDR, ADS101X_CONF_ADDR, ®s, 2, 0x0); - - /* Set up window mode */ - if (low_limit != 0) { - /* Enable window mode */ - regs[1] |= ADS101X_CONF_COMP_MODE_WIND; - } - else { - /* Disable window mode */ - regs[1] &= ~ADS101X_CONF_COMP_MODE_WIND; - } - i2c_write_regs(DEV, ADDR, ADS101X_CONF_ADDR, ®s, 2, 0x0); - - i2c_release(DEV); - - return ADS101X_OK; -} diff --git a/drivers/ads101x/include/ads101x_params.h b/drivers/ads101x/include/ads101x_params.h deleted file mode 100644 index 036403d5d900..000000000000 --- a/drivers/ads101x/include/ads101x_params.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) 2017 OTA keys S.A. - * 2018 Acutam Automation, LLC - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -#pragma once - -/** - * @ingroup drivers_ads101x - * @{ - * - * @file - * @brief Default configuration for ADS101x/111x devices - * - * @author Vincent Dupont - * @author Matthew Blue - */ - -#include "board.h" -#include "saul_reg.h" -#include "ads101x.h" -#include "ads101x_regs.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @name Set default configuration parameters for the ADS101x/111x driver - * @{ - */ -#ifndef ADS101X_PARAM_I2C -#define ADS101X_PARAM_I2C (I2C_DEV(0)) -#endif -#ifndef ADS101X_PARAM_ADDR -#define ADS101X_PARAM_ADDR (CONFIG_ADS101X_I2C_ADDRESS) -#endif -#ifndef ADS101X_PARAM_MUX_GAIN -#define ADS101X_PARAM_MUX_GAIN (ADS101X_AIN0_DIFFM_AIN1 \ - | ADS101X_PGA_FSR_2V048) -#endif -#ifndef ADS101X_PARAM_ALERT_PIN -#define ADS101X_PARAM_ALERT_PIN (GPIO_UNDEF) -#endif -#ifndef ADS101X_PARAM_LOW_LIMIT -#define ADS101X_PARAM_LOW_LIMIT (10000U) -#endif -#ifndef ADS101X_PARAM_HIGH_LIMIT -#define ADS101X_PARAM_HIGH_LIMIT (20000U) -#endif - -#ifndef ADS101X_PARAMS -#define ADS101X_PARAMS { .i2c = ADS101X_PARAM_I2C, \ - .addr = ADS101X_PARAM_ADDR, \ - .mux_gain = ADS101X_PARAM_MUX_GAIN } -#endif - -#ifndef ADS101X_ALERT_PARAMS -#define ADS101X_ALERT_PARAMS { .i2c = ADS101X_PARAM_I2C, \ - .addr = ADS101X_PARAM_ADDR, \ - .alert_pin = ADS101X_PARAM_ALERT_PIN, \ - .low_limit = ADS101X_PARAM_LOW_LIMIT, \ - .high_limit = ADS101X_PARAM_HIGH_LIMIT } -#endif -#ifndef ADS101X_SAUL_INFO -#define ADS101X_SAUL_INFO { .name = "ads101x" } -#endif -/** @} */ - -/** - * @brief ADS101X/111x defaults if not defined for a board or application - */ -static const ads101x_params_t ads101x_params[] = -{ - ADS101X_PARAMS -}; - -/** - * @brief ADS101X/111x alert defaults if not defined for a board or application - */ -static const ads101x_alert_params_t ads101x_alert_params[] = -{ - ADS101X_ALERT_PARAMS -}; - -/** - * @brief Additional meta information to keep in the SAUL registry - */ -static const saul_reg_info_t ads101x_saul_info[] = -{ - ADS101X_SAUL_INFO -}; - -#ifdef __cplusplus -} -#endif - -/** @} */ diff --git a/drivers/ads101x/include/ads101x_regs.h b/drivers/ads101x/include/ads101x_regs.h deleted file mode 100644 index dfc92e5d71e2..000000000000 --- a/drivers/ads101x/include/ads101x_regs.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2017 OTA keys S.A. - * 2018 Acutam Automation, LLC - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -#pragma once - -/** - * @ingroup drivers_ads101x - * @{ - * - * @file - * @brief Register definition for ADS101x/111x devices - * - * @author Vincent Dupont - * @author Matthew Blue - */ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @name ADS101x/111x register addresses - * @{ - */ -#define ADS101X_CONV_RES_ADDR (0) -#define ADS101X_CONF_ADDR (1) -#define ADS101X_LOW_LIMIT_ADDR (2) -#define ADS101X_HIGH_LIMIT_ADDR (3) -/** @} */ - -/** - * @name ADS101x/111x Config flags - * - * Comparator flags have no effect on ADS1013 and ADS1113. - * - * @{ - */ -#define ADS101X_CONF_OS_CONV (1 << 7) -#define ADS101X_CONF_COMP_MODE_WIND (1 << 4) -#define ADS101X_CONF_COMP_DIS ((1 << 1) | (1 << 0)) -/** @} */ - -/** - * @name ADS101x/111x mux settings - * - * Supports both single mode and differential. - * This has no effect on ADS1013-4 and ADS1113-4. - * - * @{ - */ -#define ADS101X_MUX_MASK ((1 << 6) | (1 << 5) | (1 << 4)) -#define ADS101X_AIN0_DIFFM_AIN1 ((0 << 6) | (0 << 5) | (0 << 4)) -#define ADS101X_AIN0_DIFFM_AIN3 ((0 << 6) | (0 << 5) | (1 << 4)) -#define ADS101X_AIN1_DIFFM_AIN3 ((0 << 6) | (1 << 5) | (0 << 4)) -#define ADS101X_AIN2_DIFFM_AIN3 ((0 << 6) | (1 << 5) | (1 << 4)) -#define ADS101X_AIN0_SINGM ((1 << 6) | (0 << 5) | (0 << 4)) -#define ADS101X_AIN1_SINGM ((1 << 6) | (0 << 5) | (1 << 4)) -#define ADS101X_AIN2_SINGM ((1 << 6) | (1 << 5) | (0 << 4)) -#define ADS101X_AIN3_SINGM ((1 << 6) | (1 << 5) | (1 << 4)) -/** @} */ - -/** - * @name ADS101x/111x programmable gain - * - * Sets the full-scale range (max voltage value). - * This has no effect on ADS1013 and ADS1113 (both use 2.048V FSR). - * - * @{ - */ -#define ADS101X_PGA_MASK ((1 << 3) | (1 << 2) | (1 << 1)) -#define ADS101X_PGA_FSR_6V144 ((0 << 3) | (0 << 2) | (0 << 1)) -#define ADS101X_PGA_FSR_4V096 ((0 << 3) | (0 << 2) | (1 << 1)) -#define ADS101X_PGA_FSR_2V048 ((0 << 3) | (1 << 2) | (0 << 1)) -#define ADS101X_PGA_FSR_1V024 ((0 << 3) | (1 << 2) | (1 << 1)) -#define ADS101X_PGA_FSR_0V512 ((1 << 3) | (0 << 2) | (0 << 1)) -#define ADS101X_PGA_FSR_0V256 ((1 << 3) | (0 << 2) | (1 << 1)) -/** @} */ - -/** - * @name ADS101x/111x data rate settings - * - * Determines how quickly samples are taken (even on one-shot mode) - * - * @{ - */ -#define ADS101X_DATAR_MASK ((1 << 7) | (1 << 6) | (1 << 5)) -#define ADS101X_DATAR_128 ((0 << 7) | (0 << 6) | (0 << 5)) -#define ADS101X_DATAR_250 ((0 << 7) | (0 << 6) | (1 << 5)) -#define ADS101X_DATAR_490 ((0 << 7) | (1 << 6) | (0 << 5)) -#define ADS101X_DATAR_920 ((0 << 7) | (1 << 6) | (1 << 5)) -#define ADS101X_DATAR_1600 ((1 << 7) | (0 << 6) | (0 << 5)) -#define ADS101X_DATAR_2400 ((1 << 7) | (0 << 6) | (1 << 5)) -#define ADS101X_DATAR_3300 ((1 << 7) | (1 << 6) | (0 << 5)) -/** @} */ - -#ifdef __cplusplus -} -#endif - -/** @} */ diff --git a/drivers/ads101x/Kconfig b/drivers/ads1x1x/Kconfig similarity index 73% rename from drivers/ads101x/Kconfig rename to drivers/ads1x1x/Kconfig index 8b0772b139b2..7336323dbea7 100644 --- a/drivers/ads101x/Kconfig +++ b/drivers/ads1x1x/Kconfig @@ -5,16 +5,16 @@ # directory for more details. # -menu "ADS101X driver" - depends on USEMODULE_ADS101X +menu "ADS1X1X driver" + depends on USEMODULE_ADS1X1X -config ADS101X_I2C_ADDRESS +config ADS1X1X_I2C_ADDRESS hex "Default I2C address" range 0x48 0x51 default 0x48 help - ADS101X allows for upto 4 devices on Single Bus. The value depends on + ADS1X1X allows for upto 4 devices on Single Bus. The value depends on the state of ADDR Pin. Default value (0x48) corresponds to ADDR pin tied to GND. For more information refer I2C Address Selection in Datasheet. -endmenu # ADS101X driver +endmenu # ADS1X1X driver diff --git a/drivers/ads101x/Makefile b/drivers/ads1x1x/Makefile similarity index 100% rename from drivers/ads101x/Makefile rename to drivers/ads1x1x/Makefile diff --git a/drivers/ads101x/Makefile.dep b/drivers/ads1x1x/Makefile.dep similarity index 100% rename from drivers/ads101x/Makefile.dep rename to drivers/ads1x1x/Makefile.dep diff --git a/drivers/ads1x1x/Makefile.include b/drivers/ads1x1x/Makefile.include new file mode 100644 index 000000000000..37d036e35136 --- /dev/null +++ b/drivers/ads1x1x/Makefile.include @@ -0,0 +1,2 @@ +USEMODULE_INCLUDES_ads1x1x := $(LAST_MAKEFILEDIR)/include +USEMODULE_INCLUDES += $(USEMODULE_INCLUDES_ads1x1x) diff --git a/drivers/ads1x1x/ads1x1x.c b/drivers/ads1x1x/ads1x1x.c new file mode 100644 index 000000000000..673790af82eb --- /dev/null +++ b/drivers/ads1x1x/ads1x1x.c @@ -0,0 +1,218 @@ +/* + * Copyright (C) 2017 OTA keys S.A. + * 2018 Acutam Automation, LLC + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup drivers_ads1x1x + * @{ + * + * @file + * @brief ADS101x/111x ADC device driver + * + * @author Vincent Dupont + * @author Matthew Blue + * @} + */ + +#include "assert.h" +#include "periph/i2c.h" +#include "periph/gpio.h" +#include "ztimer.h" + +#include "ads1x1x.h" +#include "ads1x1x_params.h" +#include "ads1x1x_internal.h" + +#define ENABLE_DEBUG 0 +#include "debug.h" + +#ifndef ADS1X1X_READ_DELAY_MS +#define ADS1X1X_READ_DELAY_MS 8 /* ompatible with 128SPS */ +#endif + +#define DEV (dev->params.i2c) +#define ADDR (dev->params.addr) + +static int _ads1x1x_init_test(i2c_t i2c, uint8_t addr); + +int ads1x1x_init(ads1x1x_t *dev, const ads1x1x_params_t *params) +{ + assert(dev && params); + + dev->params = *params; + + return _ads1x1x_init_test(DEV, ADDR); +} + +int ads1x1x_alert_init(ads1x1x_alert_t *dev, + const ads1x1x_alert_params_t *params) +{ + assert(dev && params); + + dev->params = *params; + dev->cb = NULL; + dev->arg = NULL; + + /* Set up alerts */ + ads1x1x_set_alert_parameters(dev, dev->params.low_limit, + dev->params.high_limit); + + return _ads1x1x_init_test(DEV, ADDR); +} + +static int _ads1x1x_init_test(i2c_t i2c, uint8_t addr) +{ + uint8_t regs[2]; + + i2c_acquire(i2c); + + /* Register read test */ + if (i2c_read_regs(i2c, addr, ADS1X1X_CONF_ADDR, ®s, 2, 0x0) < 0) { + DEBUG("[ads1x1x] init - error: unable to read reg %x\n", + ADS1X1X_CONF_ADDR); + i2c_release(i2c); + return ADS1X1X_NODEV; + } + + regs[1] = (regs[1] & ~ADS1X1X_DATAR_MASK) | ADS1X1X_DATAR_3300; + + /* Register write test */ + if (i2c_write_regs(i2c, addr, ADS1X1X_CONF_ADDR, ®s, 2, 0x0) < 0) { + DEBUG("[ads1x1x] init - error: unable to write reg %x\n", + ADS1X1X_CONF_ADDR); + i2c_release(i2c); + return ADS1X1X_NODEV; + } + + i2c_read_regs(i2c, addr, ADS1X1X_CONF_ADDR, ®s, 2, 0x0); + + i2c_release(i2c); + + /* Write should have actually written the register */ + if ((regs[1] & ADS1X1X_DATAR_MASK) != ADS1X1X_DATAR_3300) { + DEBUG("[ads1x1x] init - error: unable to set reg (reg=%x)\n", regs[1]); + return ADS1X1X_NODEV; + } + + return ADS1X1X_OK; +} + +int ads1x1x_set_mux_gain(const ads1x1x_t *dev, uint8_t mux_gain) +{ + uint8_t regs[2]; + + i2c_acquire(DEV); + + i2c_read_regs(DEV, ADDR, ADS1X1X_CONF_ADDR, ®s, 2, 0x0); + + /* Zero mux and gain */ + regs[0] &= ~ADS1X1X_MUX_MASK; + regs[0] &= ~ADS1X1X_PGA_MASK; + + /* Write mux and gain */ + regs[0] |= mux_gain; + + i2c_write_regs(DEV, ADDR, ADS1X1X_CONF_ADDR, ®s, 2, 0x0); + + i2c_release(DEV); + + return ADS1X1X_OK; +} + +int ads1x1x_read_raw(const ads1x1x_t *dev, int16_t *raw) +{ + uint8_t regs[2]; + + i2c_acquire(DEV); + + /* Read control register */ + i2c_read_regs(DEV, ADDR, ADS1X1X_CONF_ADDR, ®s, 2, 0x0); + + /* Tell the ADC to acquire a single-shot sample */ + regs[0] |= ADS1X1X_CONF_OS_CONV; + i2c_write_regs(DEV, ADDR, ADS1X1X_CONF_ADDR, ®s, 2, 0x0); + + /* Wait for the sample to be acquired */ + ztimer_sleep(ZTIMER_MSEC, ADS1X1X_READ_DELAY_MS); + + /* Read the sample */ + if (i2c_read_regs(DEV, ADDR, ADS1X1X_CONV_RES_ADDR, ®s, 2, 0x0) < 0) { + i2c_release(DEV); + return ADS1X1X_NODATA; + } + + i2c_release(DEV); + + /* If all okay, change raw value */ + *raw = (int16_t)(regs[0] << 8) | (int16_t)(regs[1]); + + return ADS1X1X_OK; +} + +int ads1x1x_enable_alert(ads1x1x_alert_t *dev, + ads1x1x_alert_cb_t cb, void *arg) +{ + uint8_t regs[2]; + + if (!gpio_is_valid(dev->params.alert_pin)) { + return ADS1X1X_OK; + } + + /* Read control register */ + i2c_acquire(DEV); + i2c_read_regs(DEV, ADDR, ADS1X1X_CONF_ADDR, ®s, 2, 0x0); + + /* Enable alert comparator */ + regs[1] &= ~ADS1X1X_CONF_COMP_DIS; + i2c_write_regs(DEV, ADDR, ADS1X1X_CONF_ADDR, ®s, 2, 0x0); + + i2c_release(DEV); + + /* Enable interrupt */ + dev->arg = arg; + dev->cb = cb; + gpio_init_int(dev->params.alert_pin, GPIO_IN, GPIO_FALLING, cb, arg); + + return ADS1X1X_OK; +} + +int ads1x1x_set_alert_parameters(const ads1x1x_alert_t *dev, + int16_t low_limit, int16_t high_limit) +{ + uint8_t regs[2]; + + i2c_acquire(DEV); + + /* Set up low_limit */ + regs[0] = (uint8_t)(low_limit >> 8); + regs[1] = (uint8_t)low_limit; + i2c_write_regs(DEV, ADDR, ADS1X1X_LOW_LIMIT_ADDR, ®s, 2, 0x0); + + /* Set up high_limit */ + regs[0] = (uint8_t)(high_limit >> 8); + regs[1] = (uint8_t)high_limit; + i2c_write_regs(DEV, ADDR, ADS1X1X_HIGH_LIMIT_ADDR, ®s, 2, 0x0); + + /* Read control register */ + i2c_read_regs(DEV, ADDR, ADS1X1X_CONF_ADDR, ®s, 2, 0x0); + + /* Set up window mode */ + if (low_limit != 0) { + /* Enable window mode */ + regs[1] |= ADS1X1X_CONF_COMP_MODE_WIND; + } + else { + /* Disable window mode */ + regs[1] &= ~ADS1X1X_CONF_COMP_MODE_WIND; + } + i2c_write_regs(DEV, ADDR, ADS1X1X_CONF_ADDR, ®s, 2, 0x0); + + i2c_release(DEV); + + return ADS1X1X_OK; +} diff --git a/drivers/ads101x/ads101x_saul.c b/drivers/ads1x1x/ads1x1x_saul.c similarity index 78% rename from drivers/ads101x/ads101x_saul.c rename to drivers/ads1x1x/ads1x1x_saul.c index a4cba082c921..ca1bed8e6050 100644 --- a/drivers/ads101x/ads101x_saul.c +++ b/drivers/ads1x1x/ads1x1x_saul.c @@ -8,7 +8,7 @@ */ /** - * @ingroup drivers_ads101x + * @ingroup drivers_ads1x1x * @{ * * @file @@ -24,8 +24,8 @@ #include #include "saul.h" -#include "ads101x.h" -#include "ads101x_regs.h" +#include "ads1x1x.h" +#include "ads1x1x_internal.h" /* LSB conversion to power of 10 * (5/8) * 2^16 = 40960 */ @@ -33,20 +33,20 @@ static int read_adc(const void *dev, phydat_t *res) { - const ads101x_t *mydev = dev; + const ads1x1x_t *mydev = dev; /* Change the mux channel */ - ads101x_set_mux_gain(mydev, mydev->params.mux_gain); + ads1x1x_set_mux_gain(mydev, mydev->params.mux_gain); /* Read raw value */ - if (ads101x_read_raw(mydev, res->val) < 0) { + if (ads1x1x_read_raw(mydev, res->val) < 0) { return ECANCELED; } /* Special case for 2.048V */ /* (this is the fixed FSR of ADS1013 and ADS1113) */ - if ((mydev->params.mux_gain & ADS101X_PGA_MASK) - == ADS101X_PGA_FSR_2V048) { + if ((mydev->params.mux_gain & ADS1X1X_PGA_MASK) + == ADS1X1X_PGA_FSR_2V048) { /* LSB == 62.5uV to LSB == 100uV */ *(res->val) = (int16_t)((CONV_TO_B10 * (int32_t)*(res->val)) >> 16); @@ -64,7 +64,7 @@ static int read_adc(const void *dev, phydat_t *res) return 1; } -const saul_driver_t ads101x_saul_driver = { +const saul_driver_t ads1x1x_saul_driver = { .read = read_adc, .write = saul_write_notsup, .type = SAUL_SENSE_ANALOG, diff --git a/drivers/ads1x1x/include/ads1x1x_internal.h b/drivers/ads1x1x/include/ads1x1x_internal.h new file mode 100644 index 000000000000..638f8907b508 --- /dev/null +++ b/drivers/ads1x1x/include/ads1x1x_internal.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2017 OTA keys S.A. + * 2018 Acutam Automation, LLC + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +#pragma once + +/** + * @ingroup drivers_ads1x1x + * @{ + * + * @file + * @brief Register definition for ADS1X1X/111x devices + * + * @author Vincent Dupont + * @author Matthew Blue + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name ADS101X/111x register addresses + * @{ + */ +#define ADS1X1X_CONV_RES_ADDR (0) +#define ADS1X1X_CONF_ADDR (1) +#define ADS1X1X_LOW_LIMIT_ADDR (2) +#define ADS1X1X_HIGH_LIMIT_ADDR (3) +/** @} */ + +/** + * @name ADS101X/111x Config flags + * + * Comparator flags have no effect on ADS1013 and ADS1113. + * + * @{ + */ +#define ADS1X1X_CONF_OS_CONV (1 << 7) +#define ADS1X1X_CONF_COMP_MODE_WIND (1 << 4) +#define ADS1X1X_CONF_COMP_DIS ((1 << 1) | (1 << 0)) +/** @} */ + +/** + * @name ADS101X/111x mux settings + * + * Supports both single mode and differential. + * This has no effect on ADS1013-4 and ADS1113-4. + * + * @{ + */ +#define ADS1X1X_MUX_MASK ((1 << 6) | (1 << 5) | (1 << 4)) +#define ADS1X1X_AIN0_DIFFM_AIN1 ((0 << 6) | (0 << 5) | (0 << 4)) +#define ADS1X1X_AIN0_DIFFM_AIN3 ((0 << 6) | (0 << 5) | (1 << 4)) +#define ADS1X1X_AIN1_DIFFM_AIN3 ((0 << 6) | (1 << 5) | (0 << 4)) +#define ADS1X1X_AIN2_DIFFM_AIN3 ((0 << 6) | (1 << 5) | (1 << 4)) +#define ADS1X1X_AIN0_SINGM ((1 << 6) | (0 << 5) | (0 << 4)) +#define ADS1X1X_AIN1_SINGM ((1 << 6) | (0 << 5) | (1 << 4)) +#define ADS1X1X_AIN2_SINGM ((1 << 6) | (1 << 5) | (0 << 4)) +#define ADS1X1X_AIN3_SINGM ((1 << 6) | (1 << 5) | (1 << 4)) +/** @} */ + +/** + * @name ADS101X/111x programmable gain + * + * Sets the full-scale range (max voltage value). + * This has no effect on ADS1013 and ADS1113 (both use 2.048V FSR). + * + * @{ + */ +#define ADS1X1X_PGA_MASK ((1 << 3) | (1 << 2) | (1 << 1)) +#define ADS1X1X_PGA_FSR_6V144 ((0 << 3) | (0 << 2) | (0 << 1)) +#define ADS1X1X_PGA_FSR_4V096 ((0 << 3) | (0 << 2) | (1 << 1)) +#define ADS1X1X_PGA_FSR_2V048 ((0 << 3) | (1 << 2) | (0 << 1)) +#define ADS1X1X_PGA_FSR_1V024 ((0 << 3) | (1 << 2) | (1 << 1)) +#define ADS1X1X_PGA_FSR_0V512 ((1 << 3) | (0 << 2) | (0 << 1)) +#define ADS1X1X_PGA_FSR_0V256 ((1 << 3) | (0 << 2) | (1 << 1)) +/** @} */ + +/** + * @name ADS101X/111x data rate settings + * + * Determines how quickly samples are taken (even on one-shot mode) + * + * @{ + */ +#define ADS1X1X_DATAR_MASK ((1 << 7) | (1 << 6) | (1 << 5)) +#define ADS1X1X_DATAR_128 ((0 << 7) | (0 << 6) | (0 << 5)) +#define ADS1X1X_DATAR_250 ((0 << 7) | (0 << 6) | (1 << 5)) +#define ADS1X1X_DATAR_490 ((0 << 7) | (1 << 6) | (0 << 5)) +#define ADS1X1X_DATAR_920 ((0 << 7) | (1 << 6) | (1 << 5)) +#define ADS1X1X_DATAR_1600 ((1 << 7) | (0 << 6) | (0 << 5)) +#define ADS1X1X_DATAR_2400 ((1 << 7) | (0 << 6) | (1 << 5)) +#define ADS1X1X_DATAR_3300 ((1 << 7) | (1 << 6) | (0 << 5)) +/** @} */ + +#ifdef __cplusplus +} +#endif + +/** @} */ diff --git a/drivers/ads1x1x/include/ads1x1x_params.h b/drivers/ads1x1x/include/ads1x1x_params.h new file mode 100644 index 000000000000..bab4e3ad5806 --- /dev/null +++ b/drivers/ads1x1x/include/ads1x1x_params.h @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2017 OTA keys S.A. + * 2018 Acutam Automation, LLC + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +#pragma once + +/** + * @ingroup drivers_ads1x1x + * @{ + * + * @file + * @brief Default configuration for ADS101x/111x devices + * + * @author Vincent Dupont + * @author Matthew Blue + */ + +#include "board.h" +#include "saul_reg.h" +#include "ads1x1x.h" +#include "ads1x1x_internal.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Set default configuration parameters for the ADS101x/111x driver + * @{ + */ +#ifndef ADS1X1X_PARAM_I2C +#define ADS1X1X_PARAM_I2C (I2C_DEV(0)) +#endif +#ifndef ADS1X1X_PARAM_ADDR +#define ADS1X1X_PARAM_ADDR (CONFIG_ADS1X1X_I2C_ADDRESS) +#endif +#ifndef ADS1X1X_PARAM_MUX_GAIN +#define ADS1X1X_PARAM_MUX_GAIN (ADS1X1X_AIN0_DIFFM_AIN1 \ + | ADS1X1X_PGA_FSR_2V048) +#endif +#ifndef ADS1X1X_PARAM_ALERT_PIN +#define ADS1X1X_PARAM_ALERT_PIN (GPIO_UNDEF) +#endif +#ifndef ADS1X1X_PARAM_LOW_LIMIT +#define ADS1X1X_PARAM_LOW_LIMIT (10000U) +#endif +#ifndef ADS1X1X_PARAM_HIGH_LIMIT +#define ADS1X1X_PARAM_HIGH_LIMIT (20000U) +#endif + +#ifndef ADS1X1X_PARAMS +#define ADS1X1X_PARAMS { .i2c = ADS1X1X_PARAM_I2C, \ + .addr = ADS1X1X_PARAM_ADDR, \ + .mux_gain = ADS1X1X_PARAM_MUX_GAIN } +#endif + +#ifndef ADS1X1X_ALERT_PARAMS +#define ADS1X1X_ALERT_PARAMS { .i2c = ADS1X1X_PARAM_I2C, \ + .addr = ADS1X1X_PARAM_ADDR, \ + .alert_pin = ADS1X1X_PARAM_ALERT_PIN, \ + .low_limit = ADS1X1X_PARAM_LOW_LIMIT, \ + .high_limit = ADS1X1X_PARAM_HIGH_LIMIT } +#endif +#ifndef ADS1X1X_SAUL_INFO +#define ADS1X1X_SAUL_INFO { .name = "ads1x1x" } +#endif +/** @} */ + +/** + * @brief ADS101X/111x defaults if not defined for a board or application + */ +static const ads1x1x_params_t ads1x1x_params[] = +{ + ADS1X1X_PARAMS +}; + +/** + * @brief ADS101X/111x alert defaults if not defined for a board or application + */ +static const ads1x1x_alert_params_t ads1x1x_alert_params[] = +{ + ADS1X1X_ALERT_PARAMS +}; + +/** + * @brief Additional meta information to keep in the SAUL registry + */ +static const saul_reg_info_t ads1x1x_saul_info[] = +{ + ADS1X1X_SAUL_INFO +}; + +#ifdef __cplusplus +} +#endif + +/** @} */ diff --git a/drivers/include/ads101x.h b/drivers/include/ads1x1x.h similarity index 72% rename from drivers/include/ads101x.h rename to drivers/include/ads1x1x.h index 09ecbe4dd335..13b61cc14518 100644 --- a/drivers/include/ads101x.h +++ b/drivers/include/ads1x1x.h @@ -10,7 +10,7 @@ #pragma once /** - * @defgroup drivers_ads101x ADS101x/111x ADC device driver + * @defgroup drivers_ads1x1x ADS101x/111x ADC device driver * @ingroup drivers_sensors * @ingroup drivers_saul * @brief I2C Analog-to-Digital Converter device driver @@ -38,7 +38,7 @@ extern "C" { #include "periph/gpio.h" /** - * @defgroup drivers_ads101x_config ADS101 driver compile configuration + * @defgroup drivers_ads1x1x_config ADS101 driver compile configuration * @ingroup config_drivers_sensors * @{ */ @@ -48,8 +48,8 @@ extern "C" { * * Address pin tied to: GND (0x48), Vcc (0x49), SDA (0x50), SCL (0x51) */ -#ifndef CONFIG_ADS101X_I2C_ADDRESS -#define CONFIG_ADS101X_I2C_ADDRESS (0x48) +#ifndef CONFIG_ADS1X1X_I2C_ADDRESS +#define CONFIG_ADS1X1X_I2C_ADDRESS (0x48) #endif /** @} */ @@ -57,52 +57,52 @@ extern "C" { * @brief Named return values */ enum { - ADS101X_OK = 0, /**< everything was fine */ - ADS101X_NOI2C = -1, /**< I2C communication failed */ - ADS101X_NODEV = -2, /**< no ADS101X device found on the bus */ - ADS101X_NODATA = -3 /**< no data available */ + ADS1X1X_OK = 0, /**< everything was fine */ + ADS1X1X_NOI2C = -1, /**< I2C communication failed */ + ADS1X1X_NODEV = -2, /**< no ADS1X1X device found on the bus */ + ADS1X1X_NODATA = -3 /**< no data available */ }; /** * @brief ADS101x/111x params */ -typedef struct ads101x_params { +typedef struct ads1x1x_params { i2c_t i2c; /**< i2c device */ uint8_t addr; /**< i2c address */ uint8_t mux_gain; /**< Mux and gain boolean settings */ -} ads101x_params_t; +} ads1x1x_params_t; /** * @brief ADS101x/111x alert params */ -typedef struct ads101x_alert_params { +typedef struct ads1x1x_alert_params { i2c_t i2c; /**< i2c device */ uint8_t addr; /**< i2c address */ gpio_t alert_pin; /**< alert pin (GPIO_UNDEF if not connected) */ int16_t low_limit; /**< alert low value */ int16_t high_limit; /**< alert high value */ -} ads101x_alert_params_t; +} ads1x1x_alert_params_t; /** * @brief ADS101x/111x device descriptor */ -typedef struct ads101x { - ads101x_params_t params; /**< device driver configuration */ -} ads101x_t; +typedef struct ads1x1x { + ads1x1x_params_t params; /**< device driver configuration */ +} ads1x1x_t; /** * @brief ADS101x/111x alert callback */ -typedef void (*ads101x_alert_cb_t)(void *); +typedef void (*ads1x1x_alert_cb_t)(void *); /** * @brief ADS101x/111x alert device descriptor */ -typedef struct ads101x_alert { - ads101x_alert_params_t params; /**< device driver configuration */ - ads101x_alert_cb_t cb; /**< alert callback */ +typedef struct ads1x1x_alert { + ads1x1x_alert_params_t params; /**< device driver configuration */ + ads1x1x_alert_cb_t cb; /**< alert callback */ void *arg; /**< alert callback param */ -} ads101x_alert_t; +} ads1x1x_alert_t; /** * @brief Initialize an ADS101x/111x ADC device (ADC only) @@ -112,7 +112,7 @@ typedef struct ads101x_alert { * * @return zero on successful initialization, non zero on error */ -int ads101x_init(ads101x_t *dev, const ads101x_params_t *params); +int ads1x1x_init(ads1x1x_t *dev, const ads1x1x_params_t *params); /** * @brief Initialize an ADS101x/111x alert device @@ -122,8 +122,8 @@ int ads101x_init(ads101x_t *dev, const ads101x_params_t *params); * * @return zero on successful initialization, non zero on error */ -int ads101x_alert_init(ads101x_alert_t *dev, - const ads101x_alert_params_t *params); +int ads1x1x_alert_init(ads1x1x_alert_t *dev, + const ads1x1x_alert_params_t *params); /** * @brief Set mux and gain @@ -136,7 +136,7 @@ int ads101x_alert_init(ads101x_alert_t *dev, * * @return zero on successful read, non zero on error */ -int ads101x_set_mux_gain(const ads101x_t *dev, uint8_t mux_gain); +int ads1x1x_set_mux_gain(const ads1x1x_t *dev, uint8_t mux_gain); /** * @brief Read a raw ADC value @@ -146,7 +146,7 @@ int ads101x_set_mux_gain(const ads101x_t *dev, uint8_t mux_gain); * * @return zero on successful read, non zero on error */ -int ads101x_read_raw(const ads101x_t *dev, int16_t *raw); +int ads1x1x_read_raw(const ads1x1x_t *dev, int16_t *raw); /** * @brief Enable alert interrupt @@ -159,8 +159,8 @@ int ads101x_read_raw(const ads101x_t *dev, int16_t *raw); * * @return zero on success, non zero on error */ -int ads101x_enable_alert(ads101x_alert_t *dev, - ads101x_alert_cb_t cb, void *arg); +int ads1x1x_enable_alert(ads1x1x_alert_t *dev, + ads1x1x_alert_cb_t cb, void *arg); /** * @brief Set the alert parameters @@ -173,7 +173,7 @@ int ads101x_enable_alert(ads101x_alert_t *dev, * * @return zero on success, non zero on error */ -int ads101x_set_alert_parameters(const ads101x_alert_t *dev, +int ads1x1x_set_alert_parameters(const ads1x1x_alert_t *dev, int16_t low_limit, int16_t high_limit); #ifdef __cplusplus From 43e3aadf40330af5b31f7b23c49354134976119a Mon Sep 17 00:00:00 2001 From: Baptiste Le Duc Date: Sat, 20 Sep 2025 12:16:39 +0200 Subject: [PATCH 2/4] drivers/ads101x: rename ads101x driver test --- tests/drivers/{ads101x => ads1x1x}/Makefile | 2 +- .../drivers/{ads101x => ads1x1x}/Makefile.ci | 0 tests/drivers/{ads101x => ads1x1x}/main.c | 40 +++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) rename tests/drivers/{ads101x => ads1x1x}/Makefile (85%) rename tests/drivers/{ads101x => ads1x1x}/Makefile.ci (100%) rename tests/drivers/{ads101x => ads1x1x}/main.c (63%) diff --git a/tests/drivers/ads101x/Makefile b/tests/drivers/ads1x1x/Makefile similarity index 85% rename from tests/drivers/ads101x/Makefile rename to tests/drivers/ads1x1x/Makefile index 890c623cf927..6f2fbc87e546 100644 --- a/tests/drivers/ads101x/Makefile +++ b/tests/drivers/ads1x1x/Makefile @@ -1,6 +1,6 @@ include ../Makefile.drivers_common -USEMODULE += ads101x +USEMODULE += ads1x1x USEMODULE += ztimer USEMODULE += ztimer_msec diff --git a/tests/drivers/ads101x/Makefile.ci b/tests/drivers/ads1x1x/Makefile.ci similarity index 100% rename from tests/drivers/ads101x/Makefile.ci rename to tests/drivers/ads1x1x/Makefile.ci diff --git a/tests/drivers/ads101x/main.c b/tests/drivers/ads1x1x/main.c similarity index 63% rename from tests/drivers/ads101x/main.c rename to tests/drivers/ads1x1x/main.c index 2f9f550f8cff..19430a13fa1a 100644 --- a/tests/drivers/ads101x/main.c +++ b/tests/drivers/ads1x1x/main.c @@ -22,14 +22,14 @@ #include #include "ztimer.h" -#include "ads101x.h" -#include "ads101x_params.h" -#include "ads101x_regs.h" +#include "ads1x1x.h" +#include "ads1x1x_params.h" +#include "ads1x1x_internal.h" #define SLEEP_MSEC 100 -static ads101x_t dev; -static ads101x_alert_t alert_dev; +static ads1x1x_t dev; +static ads1x1x_alert_t alert_dev; static void alert_cb(void *arg) { @@ -41,11 +41,11 @@ int main(void) { int16_t data; - puts("ADS101X analog to digital driver test application\n"); + puts("ADS1X1X analog to digital driver test application\n"); printf("Initializing ADS101x analog to digital at I2C_DEV(%i)... ", - ads101x_params->i2c); + ads1x1x_params->i2c); - if (ads101x_init(&dev, ads101x_params) == ADS101X_OK) { + if (ads1x1x_init(&dev, ads1x1x_params) == ADS1X1X_OK) { puts("[OK]"); } else { @@ -53,10 +53,10 @@ int main(void) return -1; } - printf("Initializing ADS101x alert at I2C_DEV(%i)... ", - ads101x_alert_params->i2c); + printf("Initializing ADS1X1X alert at I2C_DEV(%i)... ", + ads1x1x_alert_params->i2c); - if (ads101x_alert_init(&alert_dev, ads101x_alert_params) == ADS101X_OK) { + if (ads1x1x_alert_init(&alert_dev, ads1x1x_alert_params) == ADS1X1X_OK) { puts("[OK]"); } else { @@ -65,7 +65,7 @@ int main(void) } printf("Enabling alert interrupt: "); - if (ads101x_enable_alert(&alert_dev, alert_cb, NULL) == ADS101X_OK) { + if (ads1x1x_enable_alert(&alert_dev, alert_cb, NULL) == ADS1X1X_OK) { puts("[OK]"); } else { @@ -75,8 +75,8 @@ int main(void) while (1) { printf("Raw analog read. CH0: "); - ads101x_set_mux_gain(&dev, ADS101X_AIN0_SINGM | ADS101X_PGA_FSR_2V048); - if (ads101x_read_raw(&dev, &data) == ADS101X_OK) { + ads1x1x_set_mux_gain(&dev, ADS1X1X_AIN0_SINGM | ADS1X1X_PGA_FSR_2V048); + if (ads1x1x_read_raw(&dev, &data) == ADS1X1X_OK) { printf("%d", data); } else { @@ -85,8 +85,8 @@ int main(void) } printf(" CH1: "); - ads101x_set_mux_gain(&dev, ADS101X_AIN1_SINGM | ADS101X_PGA_FSR_2V048); - if (ads101x_read_raw(&dev, &data) == ADS101X_OK) { + ads1x1x_set_mux_gain(&dev, ADS1X1X_AIN1_SINGM | ADS1X1X_PGA_FSR_2V048); + if (ads1x1x_read_raw(&dev, &data) == ADS1X1X_OK) { printf("%d", data); } else { @@ -95,8 +95,8 @@ int main(void) } printf(" CH2: "); - ads101x_set_mux_gain(&dev, ADS101X_AIN2_SINGM | ADS101X_PGA_FSR_2V048); - if (ads101x_read_raw(&dev, &data) == ADS101X_OK) { + ads1x1x_set_mux_gain(&dev, ADS1X1X_AIN2_SINGM | ADS1X1X_PGA_FSR_2V048); + if (ads1x1x_read_raw(&dev, &data) == ADS1X1X_OK) { printf("%d", data); } else { @@ -105,8 +105,8 @@ int main(void) } printf(" CH3: "); - ads101x_set_mux_gain(&dev, ADS101X_AIN3_SINGM | ADS101X_PGA_FSR_2V048); - if (ads101x_read_raw(&dev, &data) == ADS101X_OK) { + ads1x1x_set_mux_gain(&dev, ADS1X1X_AIN3_SINGM | ADS1X1X_PGA_FSR_2V048); + if (ads1x1x_read_raw(&dev, &data) == ADS1X1X_OK) { printf("%d", data); } else { From 2c1a26c0f65cdfff07909ae21a0f9be2eb46c436 Mon Sep 17 00:00:00 2001 From: Baptiste Le Duc Date: Thu, 25 Sep 2025 11:03:31 +0200 Subject: [PATCH 3/4] drivers/ads101x: rename Kconfig --- drivers/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/Kconfig b/drivers/Kconfig index a2f3ee786768..1bc4b1d09366 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -29,7 +29,7 @@ rsource "periph_common/Kconfig" endmenu # Peripherals drivers menu "Sensor Device Drivers" -rsource "ads101x/Kconfig" +rsource "ads1x1x/Kconfig" rsource "bmx055/Kconfig" rsource "fxos8700/Kconfig" rsource "gp2y10xx/Kconfig" From 3fcc23a01feabd1b2bf06399bc52f5a3f42410ab Mon Sep 17 00:00:00 2001 From: Baptiste Le Duc Date: Wed, 1 Oct 2025 09:44:57 +0200 Subject: [PATCH 4/4] drivers/ads101x: rename doxygen excludes --- dist/tools/doccheck/exclude_simple | 80 +++++++++++++++--------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/dist/tools/doccheck/exclude_simple b/dist/tools/doccheck/exclude_simple index 13ccbb6713b6..9b389b62fb3f 100644 --- a/dist/tools/doccheck/exclude_simple +++ b/dist/tools/doccheck/exclude_simple @@ -106,46 +106,46 @@ warning: Member ADI_SET (macro definition) of file cc26xx_cc13xx.h is not docume warning: Member ADPS9960_PARAM_ADDR (macro definition) of file board.h is not documented. warning: Member ADPS9960_PARAM_I2C (macro definition) of file board.h is not documented. warning: Member ADPS9960_PARAM_PIN_INT (macro definition) of file board.h is not documented. -warning: Member ADS101X_AIN0_DIFFM_AIN1 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_AIN0_DIFFM_AIN3 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_AIN0_SINGM (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_AIN1_DIFFM_AIN3 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_AIN1_SINGM (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_AIN2_DIFFM_AIN3 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_AIN2_SINGM (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_AIN3_SINGM (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_ALERT_PARAMS (macro definition) of file ads101x_params.h is not documented. -warning: Member ADS101X_CONF_ADDR (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_CONF_COMP_DIS (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_CONF_COMP_MODE_WIND (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_CONF_OS_CONV (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_CONV_RES_ADDR (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_DATAR_128 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_DATAR_1600 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_DATAR_2400 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_DATAR_250 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_DATAR_3300 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_DATAR_490 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_DATAR_920 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_DATAR_MASK (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_HIGH_LIMIT_ADDR (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_LOW_LIMIT_ADDR (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_MUX_MASK (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_PARAM_ADDR (macro definition) of file ads101x_params.h is not documented. -warning: Member ADS101X_PARAM_ALERT_PIN (macro definition) of file ads101x_params.h is not documented. -warning: Member ADS101X_PARAM_HIGH_LIMIT (macro definition) of file ads101x_params.h is not documented. -warning: Member ADS101X_PARAM_I2C (macro definition) of file ads101x_params.h is not documented. -warning: Member ADS101X_PARAM_LOW_LIMIT (macro definition) of file ads101x_params.h is not documented. -warning: Member ADS101X_PARAM_MUX_GAIN (macro definition) of file ads101x_params.h is not documented. -warning: Member ADS101X_PARAMS (macro definition) of file ads101x_params.h is not documented. -warning: Member ADS101X_PGA_FSR_0V256 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_PGA_FSR_0V512 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_PGA_FSR_1V024 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_PGA_FSR_2V048 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_PGA_FSR_4V096 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_PGA_FSR_6V144 (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_PGA_MASK (macro definition) of file ads101x_regs.h is not documented. -warning: Member ADS101X_SAUL_INFO (macro definition) of file ads101x_params.h is not documented. +warning: Member ADS1X1X_AIN0_DIFFM_AIN1 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_AIN0_DIFFM_AIN3 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_AIN0_SINGM (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_AIN1_DIFFM_AIN3 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_AIN1_SINGM (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_AIN2_DIFFM_AIN3 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_AIN2_SINGM (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_AIN3_SINGM (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_ALERT_PARAMS (macro definition) of file ads1x1x_params.h is not documented. +warning: Member ADS1X1X_CONF_ADDR (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_CONF_COMP_DIS (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_CONF_COMP_MODE_WIND (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_CONF_OS_CONV (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_CONV_RES_ADDR (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_DATAR_128 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_DATAR_1600 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_DATAR_2400 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_DATAR_250 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_DATAR_3300 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_DATAR_490 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_DATAR_920 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_DATAR_MASK (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_HIGH_LIMIT_ADDR (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_LOW_LIMIT_ADDR (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_MUX_MASK (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_PARAM_ADDR (macro definition) of file ads1x1x_params.h is not documented. +warning: Member ADS1X1X_PARAM_ALERT_PIN (macro definition) of file ads1x1x_params.h is not documented. +warning: Member ADS1X1X_PARAM_HIGH_LIMIT (macro definition) of file ads1x1x_params.h is not documented. +warning: Member ADS1X1X_PARAM_I2C (macro definition) of file ads1x1x_params.h is not documented. +warning: Member ADS1X1X_PARAM_LOW_LIMIT (macro definition) of file ads1x1x_params.h is not documented. +warning: Member ADS1X1X_PARAM_MUX_GAIN (macro definition) of file ads1x1x_params.h is not documented. +warning: Member ADS1X1X_PARAMS (macro definition) of file ads1x1x_params.h is not documented. +warning: Member ADS1X1X_PGA_FSR_0V256 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_PGA_FSR_0V512 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_PGA_FSR_1V024 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_PGA_FSR_2V048 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_PGA_FSR_4V096 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_PGA_FSR_6V144 (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_PGA_MASK (macro definition) of file ads1x1x_internal.h is not documented. +warning: Member ADS1X1X_SAUL_INFO (macro definition) of file ads1x1x_params.h is not documented. warning: Member ADT7310_CONF_CT_POL_MASK (macro definition) of group drivers_adt7310 is not documented. warning: Member ADT7310_CONF_CT_POL_SHIFT (macro definition) of group drivers_adt7310 is not documented. warning: Member ADT7310_CONF_CT_POL(x) (macro definition) of group drivers_adt7310 is not documented.