Commit graph

546 commits

Author SHA1 Message Date
Cong Nguyen Huu a872aa9a5e drivers: adc: support adc shell for mr_canhubk3
Add device nxp_s32_adc_sar  to adc shell list

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2023-08-03 08:28:31 +00:00
Cong Nguyen Huu f809614136 drivers: adc: add NXP S32 ADC SAR driver
Add support ADC SAR for NXP S32. ADC SAR diver
support 3 group channels (precision, standard
and external), run normal trigger in oneshot
conversion mode with 2 callbacks normal end
of conversion and normal end chain callbacks.
An instance only run on 1 group channel and
1 kind of callback at the same time.

Signed-off-by: Cong Nguyen Huu <cong.nguyenhuu@nxp.com>
2023-07-28 08:55:38 -05:00
Marek Matej 6b57b3b786 soc: xtensa,riscv: esp32xx: refactor folder structure
Refactor the ESP32 target SOCs together with
all related boards. Most braking changes includes:

- changing the CONFIG_SOC_ESP32* to refer to
  the actual soc line (esp32,esp32s2,esp32s3,esp32c3)
- replacing CONFIG_SOC with the CONFIG_SOC_SERIES
- creating CONFIG_SOC_FAMILY_ESP32 to embrace all
  the ESP32 across all used architectures
- introducing CONFIG_SOC_PART_NUMBER_* to
  provide a SOC model config
- introducing the 'common' folder to hide all
  commonly used configs and files.
- updating west.yml to reflect previous changes in hal

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-07-25 18:12:33 +02:00
Carlo Caione 15e84cbfac dts: Move to 'zephyr,memory-attr'
Move to 'zephyr,memory-attr' and use the newly introduced helpers.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2023-07-25 11:22:10 +02:00
Benedikt Schmidt 332850a367 drivers: adc: configurable acquisition time for ADS114s0x
Implement a configurable acquisition time for the ADS114s0x.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-07-24 13:21:13 +00:00
Benedikt Schmidt d2e89eb512 drivers: adc: make all enabled ADCs available in the shell
Previously, only a single type of ADCs was always available
in the ADC shell. This change enables the usage of the ADC
shell for different ADC types at the same time.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-07-24 08:14:03 -05:00
Benedikt Schmidt 0d33ecd56a drivers: adc: configurable wait for completion timeout
Depending on the ADC implementation it might happen that
the driver is waiting on an external interrupt. If this interrupt
gets lost, for instance due to a race condition with an external
port expander, the system will get stuck.
Making this configurable allows the user to recover from such
an error.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-07-19 15:22:33 +00:00
Wojciech Sipak 48fc80fa79 drivers: adc: iadc_gecko: select proper bits from sample
Only 12-bit resolution is currently available in the driver,
and each of the 16-bit samples store the actual data
aligned to the left.
A sample should be shifted 4 bits to the right to allow
proper interpretation.

Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2023-07-18 16:21:09 +02:00
Wojciech Sipak c811a4f430 drivers: adc: add ADC driver for EFM32
This adds a driver for ADCs available on EFM32

Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2023-07-18 11:05:39 +00:00
Guillaume Gautier d15f3448b5 drivers: adc: Update ADC driver for STM32WBA series
Update ADC driver for STM32WBA series

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-07-12 11:48:10 +02:00
Elisabeth Friedrich f4356f3b2e drivers: lpadc: fix ADC command chaining
When reading multiple ADC channel in parallel, an ADC command chain will be
build. This is similar to a linked list, as every command references the
next command.

Before this patch every ADC command after the first, would always reference
this initial command. So that during execution only two commands (the last
and first) would be executed which resulted in readout of only two analog
values. As Zephyr expected more to come in, the `read_adc` function would
block endlessly.

The patch fixes the behaviour and allows a correct chain to build up.

Signed-off-by: Elisabeth Friedrich <auxsys@flowerpot.me>
2023-07-12 09:25:44 +02:00
Wojciech Sipak 490281a1d0 drivers: adc: fix missing ref_internal in iadc_gecko
The adc_driver_api structure provides .ref_internal
which previously was unset.
Now .ref_internal is set to the proper value.

Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
2023-07-10 15:10:23 +02:00
Brett Witherspoon 8f73a479d1 drivers: adc: stm32: use correct device in dma callback
The device passed to the DMA callback is the DMA device. Instead use
the ADC device available in the private data.

Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
2023-07-03 13:50:37 +00:00
Caspar Friedrich 9291c9f7d6 drivers: tla2021: Add driver
This adds a driver for Texas Instruments Cost-Optimized, Ultra-Small,
12-Bit, System-Monitoring ADCs. Currently only TLA2021 is supported,
TLA2022 and TLA2024 may follow based on this driver.

Signed-off-by: Caspar Friedrich <c.s.w.friedrich@gmail.com>
2023-07-03 09:30:54 +02:00
Daniel Leung 26ecaba4af drivers: syscalls: use zephyr_syscall_header
This adds a few line use zephyr_syscall_header() to include
headers containing syscall function prototypes.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-06-17 07:57:45 -04:00
Jordan Montgomery b1e9a813fe drivers: adc: adc-shell: Add support for ADS111x ADCs to adc-shell.c
The adc-shell uses a hardcoded list of defines to check whether it should
throw a compile-time error. The ADS1119 and ADS1112 driver both support
the APIs needed by the shell, so this commit enables support for them in
the hardcoded support list.

Signed-off-by: Jordan Montgomery <jordan.montgomery@getcruise.com>
2023-06-17 07:49:59 -04:00
Jordan Montgomery a7014d01da drivers: adc: Add support for TI ADS1112 ADCs
This PR adds a custom driver for the ADS1112 ADCs. Unlike ADS1113/4/5
family served by the ADS1x1x driver, the ADS1112 does not use an address
pointer to address config registers. Instead, there is only one writable
register and all i2c writes will set it. The registers resemble the
ADS1119 device, but config bitmap is different, include a distinct data
rate table, gain table, and input multiplexing table. There is also not a
status register to be monitored with the ADS1112, as it uses config bit 7
for the same purpose instead of a separate register.

The driver was tested on hardware using the ADC shell interface. Manual
probing validated the voltages for the MUX_SINGLE configs at datarate 15
in CM_SINGLE. Higher gains were not tested and CM_CONTINUOUS is not
supported in this initial implementation.

The new driver has also been added to the existing ADC test using adc_emul
for completeness.

Origin: original
License: Apache 2.0
Purpose: Adding support for ADS1112 ADCs

Signed-off-by: Jordan Montgomery <jordan.montgomery@getcruise.com>
2023-06-17 07:49:59 -04:00
Ryan McClelland 77fb2025a8 drivers: adc: ads1x1x: fix pga enum comment
The pga enum internal reference voltage and gain values
were fixed in the code, but a comment was forgotten to be
updated. Correct the comment to match how the code uses
the enum.

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2023-05-31 10:35:53 +02:00
Benedikt Schmidt 4540c833a8 drivers: adc: Implement the current sources of ADS114S08
Implement support for the current sources of ADS114S08.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-05-27 05:33:52 -04:00
Benedikt Schmidt bb679532f4 dts: bindings: adc: Add configurable current source pin for ADCs
Add a property to the ADC channels which allows the configuration
of the current source pin.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-05-27 05:33:52 -04:00
Guillaume Gautier ec73e7dae5 drivers: adc: stm32: use feature macros instead of series macros
Define two macros for calibration and oversampling for STM32 series that
possess these features, and use these macros instead of a list of series.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-05-25 13:32:08 +00:00
Guillaume Gautier 3ee6ddff29 drivers: adc: rework oversampling for stm32 adc
Rework oversampling by creating a const table containing possible
oversampling values and using this table instead of switch case.
Also disable ADC for all series before setting oversampling.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-05-25 13:32:08 +00:00
Rihards Skuja ecc3315cf8 drivers: adc: stm32: allow to use multiple ADCs with STM32F3 series
STM32F3 have multiple ADCs that share the same IRQ.

Signed-off-by: Rihards Skuja <rihards.s@origin-robotics.com>
2023-05-22 15:26:26 +02:00
Jerzy Kasenberg ce4018511f drivers: adc: add adc support for Smartbond devices
Renesas Renesas SmartBond(tm) have two ADC blocks:
GPADC and SDADC.
This change adds drivers for both.
Each ADC supports only one channel setup, drivers allow
to have multiply channels in sequence. Switching
between ADC sources in done in software.

GPADC has 10 bit resolution (accuracy can be increase
with oversampling). Values up to 3.6V can be measured
on selected pins. V30 and VBAT1 can also be measured.
SDADC has 14 bit resolution and can take measurements
from 8 pins (single of differential) and VBAT.

Signed-off-by: Jerzy Kasenberg <jerzy.kasenberg@codecoup.pl>
2023-05-22 12:41:42 +02:00
Guillaume Gautier b5e750851e drivers: adc: make use of new stm32 adc compatibles
Several sections of the STM32 ADC driver are #ifdef by a combination of the
same SOC defines that share similar IPs. These are F2/F4/F7/L1, and
F1/F37x.
Each of these combinations is now replaced by a specific compatible, which
makes the code a bit lighter and more succinct.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-05-16 18:18:51 +02:00
Guillaume Gautier 649742f47e drivers: adc: add ifdef for stm32f37x adc
Add ifdef around some functions that don't exist for STM32F37x (ADC_V2_5)
like it is done for STM32F1x.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-05-16 18:18:51 +02:00
Guillaume Gautier c1a601397f drivers: adc: cleanup stm32 adc driver
Inverts the logic of some #ifdef, replacing lists of newer series by a
list of NOT older series. This makes it shorter, and more future-proof as
future series are more likely to work out of the box, without need to
manually add a new define in each place.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-05-16 18:18:51 +02:00
Guillaume Gautier bab52fbc81 drivers: adc: clean stm32 adc calibration
Rework and clean some code around STM32 ADC calibration

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-05-16 18:18:51 +02:00
Guillaume Gautier 5180b6fac6 drivers: adc: rewrite stm32 adc enable
Some STM32 families that need to check the ADRDY flag after enabling the
ADC were not doing it. The #ifdef has been updated to fix that.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-05-16 18:18:51 +02:00
Guillaume Gautier 291e4c2561 drivers: adc: add comment to describe different adc versions
Add comment to describe different ADC versions

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-05-16 18:18:51 +02:00
Andrei Emeltchenko 7119cc1605 drivers: adc: adc_ads114s0x: Fix missing assignment
Fixes assignment before error check.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2023-05-15 09:58:28 +02:00
Benedikt Schmidt ecac441171 drivers: gpio: implement GPIOs in ADS114S08
Implement GPIO exander within the ADC ADS114S08.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-05-11 12:04:15 -04:00
Guillaume Gautier a7b8a5d61f drivers: adc: use dts properties for stm32 adc sampling time
Use the new dts properties for sampling time in the STM32 ADC driver:
- Get the sampling time from dts
- Remove all sampling time macro concatenation.
- Simplify/refactor setting of sampling time
- Check that sampling time is the same for all series using common channel

This also fixes a few cases where wrong sampling times were used for an
ADC instance (like ADC4 on U5, or ADC3 on STM32H723).

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-05-11 10:25:54 +00:00
Jared Baumann 26ee337517 drivers: adc: Rename gecko IADC config option
Renamed CONFIG_ADC_GECKO to CONFIG_IADC_GECKO to eliminate confusion
between the Incremental ADC found on series 2 silabs gecko MCUs, and the
ADC found on earlier gecko series.

Signed-off-by: Jared Baumann <jared.baumann8@t-mobile.com>
2023-05-09 23:31:45 +09:00
Antonio Tessarolo 4598e6bf0a drivers/adc: imx6sx ADC support.
This commit adds support for adc_vf610 ADC.

Signed-off-by: Antonio Tessarolo <anthonytexdev@gmail.com>
2023-05-08 16:42:40 +02:00
Cyril Fougeray 1be72d9888 dma: callback with 2 status codes for successful transfers
Make use of positive status values in the DMA callback to pass
info to the DMA client after a successful DMA operation.
A completed DMA transfer uses the status 0 while a reached
water mark uses the status 1.

Signed-off-by: Cyril Fougeray <cyril.fougeray@worldcoin.org>
2023-05-08 09:57:32 +02:00
Benedikt Schmidt 6d6f6eb3ee drivers: adc: add driver for ADS114S08
Implement a driver for the ADC ADS114S08

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-05-04 10:47:56 +02:00
Tom Burdick da5030eae1 adc: ADS7052 correct spi configuration
SPI configuration did not set bit ordering or more importantly the clock
polarity which seemed to be misconfigured. Setting this corrects one more
quirk when working with this part on the TDK Robokit1

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-05-03 08:46:37 -05:00
Declan Snyder 4b45928e86 drivers: lpadc: Move SOC code out of driver
To be consistent with the current NXP clocking scheme,
move the LPADC clocking code to the SOC files where
all of the other peripheral clocking is done.

Also remove any other SOC-specific code to the
respective SOC file and out of this driver.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-04-28 10:08:05 +02:00
Declan Snyder af6b9d857f drivers: lpadc: re-add power level code
Code for power level property was accidentally
removed by accident from driver in commit 9921c59f40

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-04-28 10:08:05 +02:00
Bill Waters 3e02d48e4e driver: adc: infineon: Adding ADC driver
- This includes the driver, test app, and sample app
- Only the boards\arm\cy8cproto_062_4343w board is supported for now

Signed-off-by: Bill Waters <bill.waters@infineon.com>
2023-04-27 10:16:23 -07:00
Guillaume Gautier f3a8279996 drivers: adc: get resolutions from dtsi for stm32 adc
Simplify the STM32 ADC driver code by using the new ADC resolutions
property in dtsi files.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2023-04-26 12:53:03 +02:00
Declan Snyder 9921c59f40 drivers: lpadc: Make DT props match RM
- Remove build asserts in favor of DT enums
- Remove power level property since it is unused by SDK
- Correct voltage ref value in DT to correspond to
  chip specific values documented in reference manuals
  instead of corresponding to SDK enum names.
- Fix SOC devicetrees affected by these changes.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2023-04-25 19:59:23 +02:00
Brian Juel Folkmann f05b6f412e drivers: adc: stm32h5 adc driver must wait about 1ms after enabling
port commit f7f47dc to stm32h5

Without this fix, ADC driver will hang when reading internal channels.

Signed-off-by: Brian Juel Folkmann <bju@trackunit.com>
2023-04-24 13:34:50 +02:00
Gerard Marull-Paretas 989d103d53 drivers: all: mcux: remove conditional support for pinctrl
The MCUX platform always uses pinctrl, there's no need to keep extra
macrology around pinctrl. Also updated driver's Kconfig options to
`select PINCTRL` (note that some already did).

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-24 13:34:22 +02:00
Mateusz Sierszulski 0417d38d4d drivers/adc: add Gecko IADC driver
This commit adds the Gecko IADC driver and support for it to the
efr32bg_sltb010a board.

Signed-off-by: Mateusz Sierszulski <msierszulski@antmicro.com>
Signed-off-by: Roman Dobrodii <rdobrodii@antmicro.com>
2023-04-21 16:24:39 +02:00
Benjamin Björnsson f08b80054e drivers: adc: adc_emul: Move semicolon to allow for multi-instancing
Move semicolon from end of DT_INST_FOREACH to DEVICE_DT_INST_DEFINE
to make multi-instancing possible. This caused some problems with
CI after adding adc node to native_posix dts.

Signed-off-by: Benjamin Björnsson <benjamin.bjornsson@gmail.com>
2023-04-20 10:48:33 +02:00
Gerard Marull-Paretas 1eb683a514 device: remove redundant init functions
Remove all init functions that do nothing, and provide a `NULL` to
*DEVICE*DEFINE* macros.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-19 10:00:25 +02:00
Tim Lin bcb173becd tests: drivers: Unit test for it82xx2_evb board
The below is the unit test result for the driver and kernel of
it82xx2_evb board.

GPIO/gpio_basic_api: PASS
I2C/i2c_api: PASS
Flash: PASS
UART/uart_basic_api: PASS
PWM/pwm_api: PASS
WDT/wdt_basic_api: PASS
KSCAN/kscan_api: PASS
kernel/sched/schedule_api: PASS
kernel/sched/preempt: PASS
kernel/timer/timer_api: PASS
kernel/sleep: PASS
ADC/adc_api: PASS.
ADC note: conversion time~=61.6us
          sample time delay~=60us
          wait voltage stable time~=202.8us
Set sampling time to 500us will pass for ADC test.

Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
2023-04-19 03:48:38 -04:00
Gerard Marull-Paretas 667eeb11fb shell: fix MISRA 5.7 violations on struct shell
MISRA Rule 5.7 requires uniqueness of tag identifiers. Shell is
frequently problematic because many code uses `const struct shell
*shell`. This causes CI noise every time one of these shell files is
edited, so let's update all of them with `const struct shell *sh`
instead.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-04-14 12:21:08 +02:00