Commit graph zephyr/drivers/adc
Author SHA1 Message Date
Benjamin Cabé
b788e76646 drivers: adc: use inclusive SPI terminology
Use controller/peripheral and SDO/SDI terminology in ADC drivers,
following coding guideline rule A.2: switch the SPI configuration
constants to SPI_OP_MODE_CONTROLLER and update comments and log
messages.

The AD7124 internal master clock identifiers refer to the ADC's
clock source as named in the Analog Devices datasheet, not to SPI
bus roles, and keep their names.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-09-01 21:04:50 -04:00
Parthiban Nallathambi
870e496811 license: fix malformed SPDX-FileCopyrightText headers
Two-line copyright notices were wrapped in the SPDX "<text>...</text>"
construct, which is only valid in an SPDX document, not a file header.
The REUSE tool then folds the literal "<text>" into the holder name
and drops the second line from the SBOM.

Remove the markers and tag the continuation line. Holder, year and
e-mail are left unchanged; only the syntax is fixed.

Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
2026-09-01 16:25:23 -04:00
Sylvio Alves
adf2bcd137 drivers: adc: esp32: hold analog clock in dma acquisition
The continuous acquisition path programs the analog calibration
registers and runs the shared front-end without holding the
analog i2c master clock, the same gap the oneshot path had.
Hold the reference counted clock from controller start until
stop so the acquisition does not depend on another user keeping
that clock enabled.

Assisted-by: Claude:opus-4-8
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-09-01 15:18:05 +01:00
Sylvio Alves
82e9da53e4 drivers: adc: esp32: fix oneshot read hang with wi-fi power save
The oneshot read path touched the analog calibration registers
and started conversions without holding the analog i2c master
clock. On SoCs where that clock is root gated it is shared with
the Wi-Fi modem, so the first modem sleep cycle gated it and the
conversion polling never returned.

Hold the reference counted analog clock across channel setup,
calibration load and conversion, and propagate a conversion
failure as -ETIMEDOUT so callers can retry when the shared
analog hardware is temporarily powered down by modem sleep. The
completion wait bound is adjustable through the new
ADC_ESP32_CONVERSION_TIMEOUT_US option.

Assisted-by: Claude:opus-4-8
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-09-01 15:18:05 +01:00
Anas Nashif
7dc5112b90 drivers: adc: smartbond: use portable IRQ pending API
Replace direct NVIC_SetPendingIRQ()/NVIC_ClearPendingIRQ()/
NVIC_EnableIRQ() calls with the portable k_irq_set_pending()/
k_irq_clear_pending()/irq_enable() equivalents. The Smartbond DA1469x
is a plain-NVIC Cortex-M33, so the pending-state capabilities are
always available where this code builds.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2026-08-27 22:12:38 -04:00
Sylvio Alves
4f522033f4 drivers: adc: esp32: take the unit lock in the polling read
The polling read programmed the chip-global unit and started the
conversion unlocked, so concurrent reads could return another
caller's channel or attenuation. Take the same per-unit lock the
dma read path already uses.

Assisted-by: Claude:opus-4-8
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-08-27 07:22:46 -07:00
Zhaoxiang Jin
bbb3ceab7d drivers: adc: mcux_lpadc: enable bandgap supply
Allow an LPADC channel node to reference an optional bandgap supply.
Enable the supply when channel setup selects the physical input
described by that node so continuous monitoring needs no additional
application control.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2026-08-27 07:21:12 -07:00
Etienne Carriere
308b241536 drivers: adc: stm32: Fix ADC_HAS_SEQUENCE_PRIORITY selection
Fix CONFIG_ADC_HAS_SEQUENCE_PRIORITY select by CONFIG_ADC_STM32.

Since st,adc-has-injected-support DT property is of boolean type, use of
dt_compat_any_has_prop(..., st,adc-has-injected-support) always returns
true. Set function argument value to True to get the expected behavior.

Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
2026-08-24 18:43:53 +02:00
Vladislav Pejic
66412a2a21 drivers: adc: AD405x RTIO stream fix
Fix for RTIO streaming. This solves the problem when ADC is
configured for streaming, but adc_stream is not called. If any
interrupt accrues, it will cause an exception because is_streaming is
set in config but sqe in driver data is not.

Signed-off-by: Vladislav Pejic <vladislav.pejic@orioninc.com>
2026-08-20 14:15:15 +02:00
Richard Mc Sweeney
184d3d49d4 drivers: Add adc stream support to pse84
Added ADC stream for autanalog SAR in PSE84

Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Richard Mc Sweeney <Richard.McSweeney@infineon.com>
2026-08-18 20:22:11 -04:00
Richard Mc Sweeney
ba583b950b drivers: Add lp-mode to pse84 autanalog-sar
Added support for lp-mode for the autanalog-sar in PSE84.

Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Richard Mc Sweeney <Richard.McSweeney@infineon.com>
2026-08-18 20:22:11 -04:00
Lasse Fröhner
16f946f55e drivers: adc_emul: reuse ref_get in get_ref_voltage
Remove the duplicated reference switch by wrapping
adc_emul_ref_get() from adc_emul_get_ref_voltage().

Assisted-by: Cursor:grok-4.5
Signed-off-by: Lasse Fröhner <lasse@starcopter.com>
2026-08-17 14:15:53 +02:00
Lasse Fröhner
c864667958 drivers: adc: replace ref_internal_get with enum-keyed ref_get
Allow drivers to expose a runtime millivolt scale for any
adc_reference via optional ref_get. adc_ref_internal() becomes a
wrapper; adc_raw_to_*_dt prefers adc_ref_get() and falls back to
channel DT zephyr,vref-mv on failure.

Update adc_emul and tests accordingly.

Tested with: west twister -T tests/drivers/adc/adc_emul -p native_sim

Assisted-by: Cursor:grok-4.5
Signed-off-by: Lasse Fröhner <lasse@starcopter.com>
2026-08-17 14:15:53 +02:00
Lasse Fröhner
3bdef59f6b drivers: adc_emul: implement ref_internal_get for runtime INTERNAL ref
Wire emulator INTERNAL reference storage through the optional getter,
so host tests can exercise dynamic adc_ref_internal() via
adc_emul_ref_voltage_set().

Tested with: west twister -T tests/drivers/adc/adc_emul -p native_sim

Link: https://github.com/zephyrproject-rtos/zephyr/issues/113971
Assisted-by: Cursor:grok-4.5
Signed-off-by: Lasse Fröhner <lasse@starcopter.com>
2026-08-17 14:15:53 +02:00
Tim Lin
683e64de2b drivers/adc: it8xxx2: Improve sequence validation for ADC driver
Add validation for unsupported oversampling, invalid ADC resolution,
and unconfigured channels.
This fixes the ADC error handling and allows the driver to pass the
adc_api and adc_error_case tests.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2026-08-13 06:34:35 -04:00
John Batch
df98114028 drivers: adc: infineon: hppass: Refactor ADC register access
Updates the HPPASS SAR ADC driver to remove PDL runtime calls where
possible and replace with direct register operations instead.  Calls to
Cy_HPPASS_SAR_Init() and Cy_HPPASS_SAR_CrossTalkAdjust() are retained to
manage hardware calibration that isn't well documented in hardware
documentation.

Aligns the ADC driver with the new HPPASS MFD driver by removing AC
startup sequence that is now managed by MFD driver for all HPPASS
devices.

Assisted-by: Github Copilot:claude-opus-4.7
Signed-off-by: John Batch <john.batch@infineon.com>
2026-08-12 09:41:36 -07:00
JaeHwan Jin
615e0c306f drivers: adc: add TI ADCxx1C family ADC driver
Add support for the Texas Instruments ADC081C021/027, ADC101C021/027
and ADC121C021/027 single-channel I2C ADCs. The six parts share one
register map and differ only in the resolution of the left aligned
conversion result, so one driver handles all of them.

Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
2026-08-11 13:42:37 -04:00
Yuzhuo Liu
7df89814dd drivers: adc: add Realtek Bee series driver
Add ADC driver support for Realtek Bee series SoCs,
including RTL87x2G and RTL8752H.

This driver supports:
- 12-bit resolution
- Divide mode and Bypass mode

Signed-off-by: Yuzhuo Liu <yuzhuo_liu@realsil.com.cn>
2026-08-11 07:42:25 -04:00
Robert Budai
2c230a0755 drivers: adc: ad4170: add AD4195-8 and AD4190-8 support
The AD4170 driver already supports the "-4" members of this Sigma-Delta
ADC family (AD4170-4, AD4190-4, AD4195-4) from a single shared driver,
differentiated by compatible string and PRODUCT_ID.

Add support for the "-8" variants. Per their datasheets, the AD4195-8
and AD4190-8 both report PRODUCT_ID 0x49 and expose analog inputs
AIN8..AIN15 in addition to AIN0..AIN7; the register map, 24-bit
resolution, 16 channels, 8 setups and filters are identical to the rest
of the family.

Wire up two new compatibles (adi,ad4195-8-adc, adi,ad4190-8-adc),
extend the ad4170_input enum and the dt-bindings header with the extra
analog inputs, and add the parts to the build_all coverage.

Signed-off-by: Robert Budai <robert.budai@analog.com>
2026-08-10 13:11:14 -07:00
Jason Yu
82b1195806 drivers: adc: mcux_gau_adc: Fix buffer size validation unit mismatch
The buffer size validation compared buffer_size (bytes) against
num_channels (sample count), allowing undersized buffers to pass.
The byte count was then stored in results_length and used as a
uint16_t slot count in the sample-reading worker, causing
out-of-bounds 16-bit writes.

Fix by:
- Using the shared adc_sequence_validate_buffer() helper to validate
  buffer_size against num_channels * sizeof(uint16_t), matching the
  common approach introduced for the other ADC drivers
- Storing buffer_size / sizeof(uint16_t) in results_length
- Using post-decrement (length-- > 0) instead of pre-decrement
  (--length > 0) to allow the correct number of writes

Assisted-by: Claude:opus-4.6
Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
2026-08-05 18:39:02 +01:00
Saksham Gupta
575560f14d adc: it8xxx2: properly complete context on buffer size error
When check_buffer_size() fails, the driver was returning early
without calling adc_context_complete(). This caused the caller
to hang indefinitely waiting for the context to complete. We now
properly complete the context with the -ENOMEM error code.

Fixes #115091

Signed-off-by: Saksham Gupta <saksham77779@gmail.com>
2026-08-05 09:28:11 +02:00
Liam Ogletree
d3e50bfcb3 drivers: adc: Unify runtime PM log messages
Propagates #113545 to ADC drivers.

Signed-off-by: Liam Ogletree <liam.ogletree@cirrus.com>
2026-08-05 09:25:36 +02:00
JaeHwan Jin
eadc2d9581 drivers: adc: add TI ADS7828/ADS7830 ADC driver
Add support for the Texas Instruments ADS7828 12-bit and ADS7830
8-bit 8-channel I2C ADCs. The two parts share one command byte and
channel permutation and differ only in resolution, so one source file
covers both. ADS7828-Q1 reuses the ADS7828 compatible.

Signed-off-by: JaeHwan Jin <jaehwan.jin@rakwireless.com>
2026-08-03 08:46:07 -04:00
Benjamin Cabé
5934608a23 drivers: adc: ambiq: Validate buffer size with the real channel count
The buffer check ran before active_channels was computed, so it
validated against zero required bytes and always passed, letting
undersized buffers through. Compute the channel count first.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-08-02 11:43:18 -04:00
Pete Johanson
3d0f9fb0d8 drivers: adc: Consistently return -ENOMEM for buffer size validation
Fix up ADC drivers to consistently return -ENOMEM when validation of a
sequence buffer size fails.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-07-28 18:09:40 -04:00
Pete Johanson
3bda971a52 drivers: adc: Use standard sequence buffer validation
Adjust the MAX32 and MCUX LPADC drivers to use the new common sequence
buffer validation utility.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-07-28 18:09:40 -04:00
Pete Johanson
9338c518bf drivers: adc: Add common sequece buffer validation
Extract a private common ADC sequence buffer validation function to be used
by drivers.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-07-28 18:09:40 -04:00
Benjamin Cabé
e547b8d8dd drivers: adc: ads1112: Fix PGA gain mapping
The gain switch mapped ADC_GAIN_3 to hardware gain 4 and ADC_GAIN_4
to gain 8, so requesting gain 4 configured gain 8 and the supported
gain 8 was rejected. Map ADC_GAIN_4 and ADC_GAIN_8 to their matching
PGA settings and drop the unsupported ADC_GAIN_3.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-23 18:13:29 +02:00
Benjamin Cabé
3260dea043 drivers: adc: ad405x: Fix async read callback name
The API table referenced ad405x_adc_read_async, which does not exist;
the function is adc_ad405x_read_async, so builds with
CONFIG_ADC_ASYNC failed.

Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2026-07-22 11:12:01 +01:00
Aric Radzin
b7d95129cc drivers: adc: add periodic read option to adc shell
Add an optional `period_ms` argument to the `read` command of adc shell
that makes the `read` command periodcially read and print until any key is
pressed.

Signed-off-by: Aric Radzin <aric.radzin@gmail.com>
2026-07-22 10:59:55 +01:00
Guillaume Gautier
ebc1228ab4 drivers: adc: stm32: improve error message for common sampling times
For ADCs that use a common register for sampling times, improve the error
message when the common registers are already set and can't accept a new
value.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2026-07-20 08:35:34 -05:00
Marin Jurjević
c97ff35c75 drivers: adc: stm32: fix resetting PCSEL register
To reset channel preselection register (PCSEL), low-level function
LL_ADC_SetChannelPreselection has been used. This function does not clear
any bit as it uses bitwise OR and can only set the bit. Replace this with
stm32_reg_write() to clear whole register with 0.

Signed-off-by: Marin Jurjević <marinjurjevic@outlook.com>
2026-07-17 11:54:39 -04:00
Marin Jurjević
5be85a76fb drivers: adc: stm32: fix channel preselection setup condition
Channel preselection condition uses bitwise operation on raw
register value to check if channel needs setup. Use BIT(channel_id)
macro to extract relevant bit instead of channel.

Signed-off-by: Marin Jurjević <marinjurjevic@outlook.com>
2026-07-17 11:54:39 -04:00
Flavio Ceolin
d79c845634 adc: Remove redundant casts in syscall handlers
The syscall handler functions forward parameters with identical casts
that are redundant since the variables already have those types.  Drop
the casts to let the compiler type-check the arguments unobstructed.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-07-15 19:04:12 -04:00
minyuan xue
4a5df6d9cc drivers: adc: add ameba adc driver
Add realtek ameba adc driver.

Signed-off-by: minyuan xue <minyuan_xue@realsil.com.cn>
2026-07-15 15:20:27 +02:00
Hasler Pauline
b08eeb0c6d drivers: adc: Add support for ADC ADS1220
Implement a driver for the ADC ADS1220.
Currently only the single shot mode is supported.
Origin: Original

Signed-off-by: Hasler Pauline <phasler@baumer.com>
2026-07-15 15:19:44 +02:00
Alberto Escolar Piedras
05333a61b1 drivers: adc: adc_tla2528: Remove double const
DEVICE_API already includes const, with another const,
clang warns us about the double specifier.

Remove it to avoid the warning.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2026-07-14 17:57:24 +02:00
Oliver Schmidhauser
e72986dc95 drivers: adc, gpio, mfd: add TLA2528 driver
Adds support for the TI TLA2528 I2C ADC with GPIOs.
The TLA2528 is a 12-bit 8-channel ADC, where each channel can also be
configured as a GPIO in- or output in push-pull or open-drain.

Signed-off-by: Oliver Schmidhauser <oliver.schmidhauser@leica-geosystems.com>
2026-07-14 09:56:45 -04:00
Jakub Zymelka
f8832c51b5 drivers: adc: nrfx_saadc: Add support for VDD reference
Add support for VDD reference in SAADC SHIM.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2026-07-14 09:37:39 +02:00
Fabrice DJIATSA
05e3f0a644 drivers: adc: stm32: skip buffer check in stream mode
In streaming mode the application does not supply a buffer in the
adc_sequence; sample data is written into a buffer allocated from the
RTIO mempool inside the ISR. Skip the sequence buffer size validation
in start_read() when CONFIG_ADC_STREAM is enabled, which otherwise
fails with a spurious -ENOMEM "Provided buffer is too small" error.

Signed-off-by: Fabrice DJIATSA <fabrice.djiatsa-ext@st.com>
2026-06-30 11:54:37 -04:00
Basile GRUNER
6c430754bf stm32: adc: Enable ADC differential on STM32N6 SoC series
Change calibration process to handle differential calibration
Configure channel 10 to differential for Nucleo N657X0-Q and
STM32N6570-DK in `adc_api` test
Pin PA10 (Arduino A2) is shared as positive input for channel 11
and negative input for channel 10, allowing to keep default pin
configuration to test single and differential input.

Signed-off-by: Basile GRUNER <basile.gruner@smile.fr>
2026-06-25 06:17:58 -04:00
Andrej Butok
a1e609f594 drivers: adc: nxp: lpadc: fix LPADC_DO_OFFSET_CALIBRATION warning
- Fixes "warning: LPADC_DO_OFFSET_CALIBRATION
  (defined at drivers/adc/Kconfig.mcux:109) was assigned the
  value 'y' but got the value 'n'..." in any application that did not
  independently enable ADC.
- CONFIG_LPADC_DO_OFFSET_CALIBRATION is only meaningful when
  CONFIG_ADC_MCUX_LPADC is enabled. Setting `default y'.
- Remove the now-redundant CONFIG_LPADC_DO_OFFSET_CALIBRATION=y
  from the defconfigs of all NXP FRDM MCXA boards.

Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
2026-06-22 14:26:19 +02:00
Michael Zimmermann
8a7ae0bed1 modules: hal_silabs: rename gecko kconfigs
- Kconfigs in modules/ should not define configs with an SOC_ prefix.
  Furthermore, these options are SDK specific, not SoC specific.
- The simplicity_sdk configs do the same.

Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
2026-06-17 08:05:45 +02:00
Richard Mc Sweeney
71b3e03a1c drivers: add FIFO support to pse84 sar
Added FIFO support for PSE84 autanalog SAR. The FIFO is 512 elements
deep. It can be subdivided into x8 64 elements to support 8 independent
streams of ADC data.

Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Richard Mc Sweeney <Richard.McSweeney@infineon.com>
2026-06-12 21:44:21 +02:00
Richard Mc Sweeney
10f7dd7fb1 drivers: add FIR for pse84 autanalog sar
Added support for FIR filters in the PSE84 autanalog SAR ADC. There
are two filters, each supporting up to 64 taps. The output can
optionally be fed into the SAR FIFOs.

Assisted-by: Claude:claude-opus-4.6
Signed-off-by: Richard Mc Sweeney <Richard.McSweeney@infineon.com>
2026-06-12 21:44:21 +02:00
Sylvio Alves
1df3062e3a drivers: esp32: align with updated hal_espressif hal apis
Adopt the new HAL/LL interfaces: ADC_LL_* macros,
esp_clk_tree_* clock helpers, and rng_ll_* entropy reads
across the adc, i2c, pwm, mdio and entropy drivers.

Update the Radio blobs to latest version.

Update linkers to include new sleep cache calls.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2026-06-11 15:03:44 -04:00
Jean Yuan
7af0cd35b0 drivers: adc: add support for ADS1118 ADC
- Implement ADS1118 ADC driver
- Add support for temperature sensor mode
- Add ADS1118 ADC configuration in Kconfig

Signed-off-by: Jean Yuan <jyuan@testo.net.cn>
2026-06-10 10:52:48 +02:00
Raluca Bozdog
ba18d49b13 drivers: adc: Fix AD7124 new_cfg zero initialized
Initialized new_cfg in adc_ad7124_channel_setup.
In order to determine if two channel configurations
are identical, memcmp is used. The channel configurations
are stored in structs, which means that there are padding
bytes which are also compared when using memcmp.
The proposed solution is to initialize the struct with 0,
which forces the padding bytes to also be zero. Later,
when assigning values to the actual fields of the structure,
the padding remains 0. This means that comparing two
zero-initialized structs with memcmp will only compare
the respective values of the fields inside the struct,
which is the expected behavior. A better idea might be
to actually compare field-by-field values.

Signed-off-by: Raluca Bozdog <raluca.bozdog@analog.com>
2026-06-08 13:57:52 +02:00
Raluca Bozdog
671fda677c drivers: adc: Fix AD7124 current-source selection
Added runtime selection of current-source: reselected before each
read operation, allowing channels to be read regardless of having
a shared current-source with another channel or not.
Multiple ADC channels share the same current-source pin,
which means that after the init of the ADC the current-source
which actually is set is the one of the last configured channel.
Reading from other channels in the same application will not
return correct values, because the current-sources of the other
channels are only shortly configured during init and then
written over by the last channel configuration.
To overcome this, the application would need to call the
channel_setup function before each sample read, which
essentially means that a runtime reconfiguration should be
handled by the user, which comes against the expected ADC behavior.
To solve this, the proposed method is to apply the current source pin
inside the driver, before each read. The current_source_pin, thus,
becomes a property of an adc_channel itself, instead of being an adc
global field. The iout index value is also added to make sure that IOUT0
fields of the IO_CONTROL_1 register are not overwritten when modifying
the values of IOUT01 fields of the same register.

Signed-off-by: Raluca Bozdog <raluca.bozdog@analog.com>
2026-06-08 13:57:52 +02:00
Raluca Bozdog
429097e168 drivers: adc: Fix AD7124 slot allocation logic
Modified ADC configuration slot allocation logic:
The ADC has only 8 slots available for storing
channel configurations. The previous slot
allocation logic always tried to fill a new slot.
If none was available, it checked for an already
existing similar configuration to be used instead.
This caused problems when trying to read 9 channels.
Once all the slots are filled, no distinct configurations can be added.
The fix proposes this logic instead:
check if any similar configuration is already stored;
if so, use the similar one; otherwise, try to find a new slot;
if all spots are filled, an error code is returned

Signed-off-by: Raluca Bozdog <raluca.bozdog@analog.com>
2026-06-08 13:57:52 +02:00