Commit graph

835 commits

Author SHA1 Message Date
Benjamin Cabé
1ee48cf421 drivers: adc: adopt new sys_count_bits util function
Adopt new sys_count_bits helper from util.h and avoid
having conflicting definition

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2025-09-09 17:27:15 +02:00
Michał Stasiak
2939ccdf42 drivers: adc: adc_nrfx_saadc: add nRF54LS05B analog pins
Added array of analong pins for nRF54LS05B.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-08-28 13:59:34 +02:00
Aksel Skauge Mellbye
af4cbdcf31 drivers: adc: gecko: Fix error return values
Enable the adc_error_cases test on Series 2 devices and change
the return values in the driver for unsupported configurations
to what the test expects.

Ensure that the resolution configuration in the test is valid
such that the invalid buffer test correctly receives -ENOMEM.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2025-08-28 00:39:57 +02:00
Jakub Zymelka
20cb820648 drivers: adc: nrfx_saadc: Fix for negative samples correction
Increment pointer only when channel was selected.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2025-08-22 12:37:06 +02:00
Sylvio Alves
34eb58c043 espressif: fix Kconfig style issues
Fix Kconfig style issues in Espressif files.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-08-21 18:41:52 +02:00
Minh Tang
3f13f25752 drivers: adc: Initial support for ADC driver on RX130
Add driver code and devicetree for 12-bit ADC on
RX130 MCU

Signed-off-by: Minh Tang <minh.tang.ue@bp.renesas.com>
2025-08-19 14:15:41 +02:00
Jakub Zymelka
138f977704 drivers: adc: nrfx: enable negative values for single-ended ADC readings
The ADC driver API already supports ADC readings which can return signed
values, these are differential readings. In Nordic's datasheet, we have
a mode called "single ended", but its just a name. "Single ended" is a
differential reading, with the negative channel tied to GND. This is not
compatible with zephyrs definition of a single ended reading.

To support Nordic's "single ended" mode, the user must configure
a differential reading, with the negative input tied to ground, which
the saadc driver can then use to configure the reading as Nordic SAADC
"single ended", and return negative values as expected.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2025-08-19 13:02:21 +02:00
Keith Packard
469d54e227 drivers/adc/adc_stm32: Check both single-ended and differential defines
The stm32u3x header files defines LL_ADC_SINGLE_ENDED but not
LL_ADC_DIFFERENTIAL as the device doesn't support differential mode. The
driver only checked for LL_ADC_SINGLE_ENDED and assumed that when that was
defined, LL_ADC_DIFFERENTIAL would also be defined.

Check for both when figuring out which calibration type will be required.

Signed-off-by: Keith Packard <keithp@keithp.com>
2025-08-18 22:01:08 +02:00
Jakub Zymelka
376b34ca63 drivers: adc: nrfx_saadc: Add support for SAADC internal sampling timer
The SAMPLERATE register can be used as a local timer instead
of triggering individual SAMPLE tasks. When SAMPLERATE.MODE is set
to Timers, it is sufficient to trigger SAMPLE task only once in order
to start the SAADC and triggering the STOP task will stop sampling.
The SAMPLERATE.CC field controls the sample rate.

The SAMPLERATE timer should not be combined with SCAN mode and
only one channel should be enabled when using the internal timer.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2025-08-18 21:59:50 +02:00
Phuc Pham
371f2925dc drivers: adc: Add ADC support for Renesas RZ/A3UL, T2M, N2L, V2L
Add ADC driver support for Renesas RZ/A3UL, T2M, N2L, V2L

Signed-off-by: Phuc Pham <phuc.pham.xr@bp.renesas.com>
Signed-off-by: Tien Nguyen <tien.nguyen.zg@renesas.com>
2025-08-18 11:56:47 +02:00
Declan Snyder
5e3a432fed adc: Remove CONFIG_ADC_MCUX_ETC
This Kconfig does not belong in the ADC folder, because there is not
actually a zephyr ADC driver for this. Also, remove HAS_MCUX_ADC_ETC as
well because it is a useless config.

The cmake line to pull in this driver from the SDK in the zephyr repo is
totally unnecessary. If a user wants to use this SDK driver they can add
it to their build like any other SDK driver or any other
external code module. Zephyr should not be a cesspool of random build
glue for random pieces of code.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-08-15 10:10:32 +03:00
Declan Snyder
5ae654eeef modules: hal_nxp: Removed unused HAS_MCUX_* configs
Remove the configs that are not actually used for anything anymore or
never were, or that are redundant with other configs, and don't have any
code changes outside of Kconfig to remove.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2025-08-15 10:10:32 +03:00
Jakub Zymelka
fe0b6b3b55 drivers: adc: nrfx: Temporary fix for SAADC power consumption
This is temporary fix for SAADC power consumption. Need to be
removed after hal_nrfx version upgrade.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2025-08-14 10:44:43 +01:00
Jakub Zymelka
c535d6e5d1 drivers: adc: nrfx_saadc: Add support for DMM
Add support for DMM which manages cache and dedicated memory spaces.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2025-08-12 12:35:48 +02:00
Yunshao Chiang
db02fdc8ef drivers: adc: it51xxx: fix the ADC channels sampling flow
The original code process causes the following two issues:

1. The first sample is always 0 because the `ctx` sequence in `data` is
   assigned the input sequence until the `adc_context_start_read`. As a
   result, the `while (channels) { ... }` loop is not executed, and
   `adc_enable_measurement` is not called.

2. Since the `ctx` sequence in `data` is assigned in
   `adc_context_start_read`, which occurs after the `while (channels) {
   ... }` loop, the ADC samples the previously set channel.

Signed-off-by: Yunshao Chiang <Yunshao.Chiang@ite.com.tw>
2025-08-06 12:16:30 +03:00
Luna Pes
d299ce35d5 drivers: adc: ad7124: fix io control reg len
The IO_CONTROL_1 register is 3 bytes long according to the datasheet.
This fixes the register not being written to correctly.

Signed-off-by: Luna Pes <zephyr@orangemurker.com>
2025-08-05 13:20:41 -04:00
Michał Bainczyk
2e06c4ed20 drivers: nrf: add build asserts for memory-regions property
Add build asserts for "memory-regions" property in nrf drivers which is
required on targets with DMM for saadc, pdm, pwm, twim, twim_rtio, twis,
tdm, uarte, spim and spis. On targets where the property is not required
the assertion macro expands to nothing.

Signed-off-by: Michał Bainczyk <michal.bainczyk@nordicsemi.no>
2025-07-28 04:27:25 -04:00
Nikodem Kastelik
04f7fc5095 drivers: adc: nrfx_saadc: remove VDD and DVDD inputs for nRF54LV10A
MDK 8.72.1 does not specify VDD and DVDD internal analog inputs
for this SoC.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2025-07-25 08:20:09 -04:00
Matt Rodgers
56621fa1de drivers: adc: stm32: add support for differential mode
Differential mode support consists of:
- If differential mode is supported by the underlying hardware AND at
  least one differential channel is enabled in the devicetree for this
  ADC instance, then perform a differential mode calibration in addition
  to the usual single ended calibration during initialisation.
- Set channels to the appropriate differential or single ended mode
  during channel setup.

Currently the N6 series is not supported even though the underlying
hardware supports differential mode, due to complications in the
calibration procedure.

Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
Co-authored-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2025-07-21 07:25:30 -04:00
Julien Panis
afc5b6cb0d drivers: adc: cc23x0: Add power management
Add PM support to cc23x0 ADC module.

Signed-off-by: Julien Panis <jpanis@baylibre.com>
2025-07-19 15:31:37 -04:00
Hao Luo
0407185d43 drivers: adc: ambiq: fixed the error that caused adc_api test to fail
This commit fixed the failure of test_adc_asynchronous_call

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-07-19 13:49:14 -04:00
Jakub Zymelka
35044b64e4 drivers: adc: nrfx_saadc: Fix SAADC shim for nRF54LV10A
GAIN field is not present on LV10A, so instead we need to
check the input value to the function.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2025-07-19 13:40:29 -04:00
Pieter De Gendt
efecfe2678 drivers: adc: Place device APIs in linker sections
Use DEVICE_API macro to place driver API instances into a linker section.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2025-06-27 10:09:32 -05:00
Steven Chang
bffb1530ab drivers: adc: adc driver
Add adc driver for ENE KB106X

Signed-off-by: Steven Chang <steven@ene.com.tw>
2025-06-27 10:57:20 +02:00
b1cd947771 drivers: adc: add a driver for the CH32V003 ADC
The CH32V003 has a 8 channel, 10 bit onboard ADC. Add an immediate
mode driver and the appropriate pinctrl bindings. Note that the
CH32V003 GPIO pins have both a floating input and an analogue input
mode, and the pinctrl is needed to put the pin in analogue mode.

Signed-off-by: Michael Hope <michaelh@juju.nz>
2025-06-26 09:42:20 +02:00
Marco Marche
f5f90395c9 drivers: adc: ad7124: add current sources support
Adds support for configuring the AD7124's excitation current sources.

Signed-off-by: Marco Marche <marco.marche@gmail.com>
2025-06-26 09:39:25 +02:00
Hao Luo
4a9412b5d4 drivers: adc: add dma support for ambiq adc driver
This commit adds dma support for ambiq adc driver

Signed-off-by: Hao Luo <hluo@ambiq.com>
2025-06-23 15:45:44 +01:00
Benjamin Cabé
2408ca6795 drivers: adc: renesas_rz: fix error handling
Fix a bunch of occurrences of API calls returning error codes that were
being ignored.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-21 08:19:28 +02:00
Colin Evrard
97f9411f32 drivers: adc: esp32: check reference at compile time
Check that the channels are configured with the reference
ADC_REF_INTERNAL when compiling the driver.

Signed-off-by: Colin Evrard <colin.evrard@mind.be>
2025-06-20 16:24:09 +02:00
Khaoula Bidani
f568b0d68a drivers: adc: update adc driver to integrate stm32u3
add u3 config_soc conditions in adc driver to handle
news peripherals.

Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
2025-06-19 22:27:35 -07:00
Benjamin Cabé
45920741dc drivers: adc: max1125x: fix typo in GPIO config
Corrected the property assignment for gpo0_enable.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-19 14:01:31 +02:00
Jakub Zymelka
f3d2507423 drivers: adc: rework Nordic SAADC driver
SHIM Nordic modification for the ADC driver controlling the SAADC
peripheral. Replaced HAL based implementation in favor of nrfx driver.

As a next step, it is planned to implement a feature that will allow
the peripheral SAADC timer to be used for sampling, and for this it is
necessary to use the nrfx driver in this SHIM.
This will allow more accurate and faster sampling than the kernel
mechanism currently provides.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2025-06-18 09:23:23 -04:00
Benjamin Cabé
a7405dc7bf drivers: adc: ti_am335x: fix timeout condition
Corrected the timeout condition in the ti_adc_sequencer_start function
to ensure proper timeout handling during ADC sequencer operations.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-18 11:22:57 +01:00
Andrzej Głąbek
616ec7522c drivers: adc_nrfx_saadc: Remove dead and misleading code
For a long time (since version 3.3.0) nrfx contained an incorrectly
defined symbol NRF_SAADC_8BIT_SAMPLE_WIDTH that was set to 8 for nRF54L
and nRF54H Series SoCs, which was probably only true for very early
engineering revisions of those. Based on this, the adc_nrfx_saadc driver
was incorrectly writing consecutive 8-bit samples in supplied buffers,
cutting off the highest 8 bits of the results. And for sequences with
multiple channels, it was even causing that the results written as
16-bit words by hardware were partially overwritten in next iteration.

In nrfx 3.12.0 (see commit f46798fa55)
this was finally corrected - the symbol is now deprecated and it is
always set to 16. This commit is a follow-up to the above and removes
parts of adc_nrfx_saadc that now became dead code to prevent further
confusion regarding 8-bit sampling.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-06-18 10:55:58 +02:00
Benjamin Cabé
e7f58da491 drivers: adc: use asserts in adc_gain_invert implementations
no need for runtime checks here, let's save a few bytes of code

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2025-06-17 16:25:15 -05:00
Michał Stasiak
4d6585488b drivers: adc: adc_nrfx_saadc: Extend internal reference values
Current target-reference mapping does not cover all cases.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-06-17 16:11:33 +02:00
Michał Stasiak
18c0c3aeb9 drivers: Extend analog pins mapping for nRF54L.
Extended analog pins mappings for more nRF54L targets.

Signed-off-by: Michał Stasiak <michal.stasiak@nordicsemi.no>
2025-06-17 16:11:33 +02:00
Aksel Skauge Mellbye
651ddd69af drivers: adc: silabs: Don't fail to init if clock is on
It is not an error if the clock source is already enabled. This
may happen if a bootloader has used the peripheral and not
de-initialized it before booting the application.

Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
2025-06-13 10:18:26 -07:00
sudarsan N
6d88a62417 drivers: adc: fix underflow in lmp90xxx_adc_start_read channel check
Prevent integer underflow when sequence->channels is 0.
Add an explicit check before calling find_msb_set().

Coverity CID: 487765

Signed-off-by: sudarsan N <sudarsansamy2002@gmail.com>
2025-06-11 09:55:42 +02:00
Julien Panis
45a8a0f0c6 drivers: adc: cc23x0: Add support for DMA mode
The ADC has a dedicated interface for communicating with the DMA.
The ADC module provides four interrupt sources (one for each
conversion result storage register) which can be configured to
source the DMA trigger.

Signed-off-by: Julien Panis <jpanis@baylibre.com>
2025-06-10 12:07:54 +02:00
Sai Santhosh Malae
bfe4065657 drivers: adc: siwx91x: Add siwx91x ADC driver
Implement ADC driver for siwx91x device

Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
2025-06-10 12:07:33 +02:00
sudarsan N
1d51942c50 drivers: adc: fix overflow and div-by-zero in adc_ad7124_odr_to_fs
Add check for odr <= 0 and cast odr to uint32_t before multiplication
to avoid integer overflow and division by zero.

Fixes: CID 489220

Signed-off-by: sudarsan N <sudarsansamy2002@gmail.com>
2025-06-10 08:48:05 +02:00
Jordan Yates
8ab300d63e adc: 64bit gain inversion function
Add a variant of `adc_gain_invert` that operates on an `int64_t` instead
of `int32_t`.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2025-06-09 10:25:52 +01:00
Henrik Lindblom
24b4ce189f drivers: stm32: dma: fix external dcache support
Several drivers checked for the presense and availability of data cache
through Kconfig symbol. This is supported according to the current
documentation, but the symbol DCACHE masks two types of cache devices: arch
and external caches. The latter is present on some Cortex-M33 chips, like
the STM32U5xx. The external dcache is bypassed when accessing internal
SRAM and only used for external memories.

In commit a2dd232410 ("drivers: adc: stm32: dma support") the rationale
for gating dcache for adc_stm32 behind STM32H7X is only hinted at, but
reason seems to be that it was the only SOC the change was tested on. The
SOC configures DCACHE=y so it is most likely safe to swap the SOC gate for
DCACHE.

The DCACHE ifdefs are now hidden inside the shared stm32_buf_in_nocache()
implementation.

Signed-off-by: Henrik Lindblom <henrik.lindblom@vaisala.com>
2025-06-06 10:19:58 +02:00
Amneesh Singh
07c1d95d69 drivers: adc: ti_am335x: initial support
This patch adds the ADC driver for TI K3 family of SoCs. Technical
reference can be found in the Technical Reference Manual (TRM) of the
board.

Signed-off-by: Amneesh Singh <a-singh7@ti.com>
2025-06-06 08:42:32 +02:00
Nikodem Kastelik
647477c851 drivers: adc: nrf: align to non-gain configuration
Some nRF devices do not allow to configure gain.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2025-06-04 17:03:48 +02:00
Nikodem Kastelik
5abf43c7dd drivers: adc: nrf: align to channel-wide burst configuration
Some nRF devices allow to configure burst setting per channel
while others globally.

Signed-off-by: Nikodem Kastelik <nikodem.kastelik@nordicsemi.no>
2025-06-04 17:03:48 +02:00
Johan Lafon
cf569036d1 driver: adc: add MCP3561/2/4R driver
Add driver for the microchip MCP3561/2/4R ADC. Registers lock and
CRCCFG protection mecanism is not implemented. Tested on an MCP3564R.

Signed-off-by: Johan Lafon <johan.lafon@syslinbit.com>
2025-06-04 16:58:52 +02:00
Sudarsan N
34f5f8d556 drivers: adc: Prevent overflow in max1125x_read_sample
Fix potential integer overflow caused by unsafe shift when computing
ADC mid-scale offset. Applies resolution bounds and uses unsigned
shift to avoid undefined behavior.

Fixes: CID 487740
Signed-off-by: Sudarsan N <sudarsansamy2002@gmail.com>
2025-06-04 10:04:14 +02:00
Andrzej Głąbek
a9405d005c drivers: adc_ad4130|adc_7124: Add ret initialization in *_perform_read()
Add initialization of `ret` to avoid reports of uninitialized variable
being returned. This variable normally gets initialized while the loop
iterates over channels, but potentially it could be left uninitialized
if the loop finished in its first iteration because of no channels to
be processed.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2025-05-28 15:33:14 +02:00