Commit graph

808 commits

Author SHA1 Message Date
BH Li
2f40168287 drivers: adc: add ambiq adc driver
Add Ambiq adc driver

Signed-off-by: BH Li <bli@ambiq.com>
2024-08-14 10:45:47 +01:00
Julia Azziz
e7cfb05c72 drivers: adc: fix missing ref_internal in adc_sam0
The .ref_internal field in the adc_driver_api
struct was previously unset.
Now it's set to the proper value, 1 V.

Signed-off-by: Julia Azziz <juliaazziz7@gmail.com>
2024-08-04 16:20:16 -05:00
Lucas Tamborrino
7b27d4c9d5 drivers: adc: esp32: Fix calibration scheme for esp32s3
ESP32S3 requires ESP_ADC_CAL_VAL_EFUSE_TP_FIT calibration
scheme. The use of ESP_ADC_CAL_VAL_EFUSE_TP is not supported
in the SoC..

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
2024-08-01 16:49:25 +01:00
Bjarki Arge Andreasen
bb2f49fb51 drivers: adc: adc_nrfx_saadc: remove redundant code
Remove redundant copy of error code and 0 initialization of static
m_data struct.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-07-12 19:50:27 +02:00
Bjarki Arge Andreasen
13658a6687 drivers: adc: adc_nrfx_saadc: Patch neg single ended readings
The NRF SAADC produces negative values in single ended mode if the
positive input is below 0V (ground). This behavior does not match
the ADC device driver API, which states that in single ended mode,
the readings must be positive [0 .. 2^resolution - 1].

This commit extends the adc_nrfx_saadc device driver to track which
channels in a sequence are configured to be single ended, to then
corrects negative readings for these channels to 0.

This patch only works if the ADC resolution is lower than the sample
bit size. This is the case for 8, 10, 12 and 14 bit resolutions for
the nRF 52, 53 and 91 series which store readings in a int16_t.

The nRF 54H and 54L series store 8-bit resolution readings in a 8-bit
sample size. A check has been added to start_read() to prevent single
ended mode readings if the resolution is 8-bit for these platforms.

Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
2024-07-12 19:50:27 +02:00
Marcio Ribeiro
3416f9ab47 drivers: adc: esp32: fix invalid width mask and calibration
Fixed WIDTH_MASK invalid values and use HW calibration.

Fixes #72983
Fixes #73798
Fixes #73400

Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
2024-07-12 06:25:53 -04:00
Zhaoxiang Jin
630203de97 drivers: lpadc: Update lpadc driver to use the latest feature
Updated nxp lpadc driver, because the phandle type property
'nxp,reference-supply' was removed, and a new phandle-array
type property 'nxp,references' added.

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2024-07-08 14:57:55 -04:00
Jared Kangas
8ec3c045f8 drivers: adc: lmp90xxx: fix checksum mismatch return value
During channel reads, zero is returned on CRC mismatches: the returned
error variable is not written to after a previous non-zero check. Return
-EIO to mirror other drivers' checksum validation behaviors.

Signed-off-by: Jared Kangas <kangas.jd@gmail.com>
2024-07-03 15:29:07 +02:00
Guillaume Gautier
c93d6b8559 drivers: adc: stm32: apply extended calibration on u5
Some STM32U5 can apply an extended calibration to enhance the ADC
performance.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-07-01 09:06:22 -04:00
Guillaume Gautier
aa670f7e4a drivers: adc: stm32: check ldo ready bit
For STM32H7, U5 and WBA, check the LDORDY bit of the ADC ISR register
after enabling the internal regulator. This method is safer than the
delay.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-07-01 09:06:22 -04:00
Karol Lasończyk
ed8d70c2a5 drivers: adc: saadc: Extend gains support for nRF54L15
Add support for gains: 1/2, 1/3, 2/5, 1/4.

Signed-off-by: Karol Lasończyk <karol.lasonczyk@nordicsemi.no>
2024-06-27 10:57:54 -04:00
Lingao Meng
302422ad9d everywhere: replace double words
import os
import re

common_words = set([
    'about', 'after', 'all', 'also', 'an', 'and',
     'any', 'are', 'as', 'at',
    'be', 'because', 'but', 'by', 'can', 'come',
    'could', 'day', 'do', 'even',
    'first', 'for', 'get', 'give', 'go', 'has',
    'have', 'he', 'her',
    'him', 'his', 'how', 'I', 'in', 'into', 'it',
    'its', 'just',
    'know', 'like', 'look', 'make', 'man', 'many',
    'me', 'more', 'my', 'new',
    'no', 'not', 'now', 'of', 'one', 'only', 'or',
    'other', 'our', 'out',
    'over', 'people', 'say', 'see', 'she', 'so',
    'some', 'take', 'tell', 'than',
    'their', 'them', 'then', 'there', 'these',
    'they', 'think',
    'this', 'time', 'two', 'up', 'use', 'very',
    'want', 'was', 'way',
    'we', 'well', 'what', 'when', 'which', 'who',
    'will', 'with', 'would',
    'year', 'you', 'your'
])

valid_extensions = set([
    'c', 'h', 'yaml', 'cmake', 'conf', 'txt', 'overlay',
    'rst', 'dtsi',
    'Kconfig', 'dts', 'defconfig', 'yml', 'ld', 'sh', 'py',
    'soc', 'cfg'
])

def filter_repeated_words(text):
    # Split the text into lines
    lines = text.split('\n')

    # Combine lines into a single string with unique separator
    combined_text = '/*sep*/'.join(lines)

    # Replace repeated words within a line
    def replace_within_line(match):
        return match.group(1)

    # Regex for matching repeated words within a line
    within_line_pattern =
	re.compile(r'\b(' +
		'|'.join(map(re.escape, common_words)) +
		r')\b\s+\b\1\b')
    combined_text = within_line_pattern.
		sub(replace_within_line, combined_text)

    # Replace repeated words across line boundaries
    def replace_across_lines(match):
        return match.group(1) + match.group(2)

    # Regex for matching repeated words across line boundaries
    across_lines_pattern = re.
		compile(r'\b(' + '|'.join(
			map(re.escape, common_words)) +
			r')\b(\s*[*\/\n\s]*)\b\1\b')
    combined_text = across_lines_pattern.
		sub(replace_across_lines, combined_text)

    # Split the text back into lines
    filtered_text = combined_text.split('/*sep*/')

    return '\n'.join(filtered_text)

def process_file(file_path):
    with open(file_path, 'r', encoding='utf-8') as file:
        text = file.read()

    new_text = filter_repeated_words(text)

    with open(file_path, 'w', encoding='utf-8') as file:
        file.write(new_text)

def process_directory(directory_path):
    for root, dirs, files in os.walk(directory_path):
        dirs[:] = [d for d in dirs if not d.startswith('.')]
        for file in files:
            # Filter out hidden files
            if file.startswith('.'):
                continue
            file_extension = file.split('.')[-1]
            if
	file_extension in valid_extensions:  # 只处理指定后缀的文件
                file_path = os.path.join(root, file)
                print(f"Processed file: {file_path}")
                process_file(file_path)

directory_to_process = "/home/mi/works/github/zephyrproject/zephyr"
process_directory(directory_to_process)

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-06-25 06:05:35 -04:00
Maksim Salau
da9b308563 drivers: adc: saadc: Disable burst mode on unused channels
Burst mode enabled on an unused channel causes a freeze during a
conversion consisting of several channels (not including the one with
burst mode enabled).

Discovered on nRF52832 (nRF52-DK) using the following approach:
  channels 0-3 are used for application purposes as a sequence
  channel 4 is used for battery measurements with oversampling

After few successful conversions the sequence (channels 0-3) freezes the
thread while waiting for semaphore to end the conversion.

Signed-off-by: Maksim Salau <maksim.salau@gmail.com>
2024-06-25 09:04:41 +02:00
Jordan Yates
07870934e3 everywhere: replace double words
Treewide search and replace on a range of double word combinations:
    * `the the`
    * `to to`
    * `if if`
    * `that that`
    * `on on`
    * `is is`
    * `from from`

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-22 05:40:22 -04:00
Ioannis Damigos
0a0bccabd8 drivers/smartbond: Fix PM device runtime support
Removed PM device runtime support from drivers in PD_SYS domain.

Update the rest device drivers to call pm_device_runtime_get/put()
functions when CONFIG_PM_DEVICE_RUNTIME is enabled.

Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
2024-06-18 14:36:38 -04:00
Francois Ramu
da8a812582 drivers: adc: stm32 adc driver supporting the stm32H7RS
Introduce the stm32h7RS serie to the ADC driver,
based on the stm32h7: two ADC 12 resolution
For stm32h7rs ADC calibration, the
LL_ADC_SetCalibrationFactor is not used.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-06-14 11:13:54 +02:00
Niek Ilmer
3bb95104e8 drivers: adc device: smartbond: Add power management
Add support for power management to the sdadc.

Signed-off-by: Niek Ilmer <niek.ilmer.aj@renesas.com>
2024-06-11 20:04:02 +03:00
Niek Ilmer
be71be5db9 drivers: adc device: smartbond: Add power management
Add support for power management to the gpadc.

Signed-off-by: Niek Ilmer <niek.ilmer.aj@renesas.com>
2024-06-11 16:36:25 +03:00
Karol Lasończyk
13196ec7c8 drivers: adc: Update adc driver to support nRF54H20 device
Expands driver to cover nRF54H20 features like 8bit sample width.

Signed-off-by: Karol Lasończyk <karol.lasonczyk@nordicsemi.no>
2024-06-11 11:37:59 +01:00
Karol Lasończyk
5f1fdc4b4d drivers: adc: Update adc driver to support nRF54L15 device
Expands driver to cover nRF54L15 features like AIN as GPIO configuration,
new reference voltage, different set of supported gain options.

Signed-off-by: Karol Lasończyk <karol.lasonczyk@nordicsemi.no>
2024-06-11 11:37:59 +01:00
Marcio Ribeiro
19d8ade5fa drivers: adc: esp32: dma enable
adc dma mode operation on ESP32S3 and ESP32C3

Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
2024-06-10 07:02:19 -07:00
Jeppe Odgaard
052eb6180d drivers: adc: adc_ad559x: fix 5593 adc read
The AD5593 conversion result also contains the channel read and not just a
value:
| adc channel (3 bits) | adc value (12 bits) |

This value was not removed from the result before using it as an adc value.

Reuse the AD5592 code to fix the issue.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2024-06-04 16:36:14 +02:00
Yong Cong Sin
bbe5e1e6eb build: namespace the generated headers with zephyr/
Namespaced the generated headers with `zephyr` to prevent
potential conflict with other headers.

Introduce a temporary Kconfig `LEGACY_GENERATED_INCLUDE_PATH`
that is enabled by default. This allows the developers to
continue the use of the old include paths for the time being
until it is deprecated and eventually removed. The Kconfig will
generate a build-time warning message, similar to the
`CONFIG_TIMER_RANDOM_GENERATOR`.

Updated the includes path of in-tree sources accordingly.

Most of the changes here are scripted, check the PR for more
info.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-05-28 22:03:55 +02:00
Zhaoxiang Jin
db87c6c0ff drivers: adc: Support regulator output as reference to LPADC
Support regulator output different voltage as reference to LPADC
the regulator output voltage can be set through property
zephyr,vref-mv

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2024-05-15 17:28:38 +02:00
Karol Lasończyk
3ca3131a7d drivers: adc: Update adc driver to support nRF54L15 device
Expands driver to cover nRF54L15 features like AIN as GPIO configuration,
new reference voltage, different set of supported gain options.

Signed-off-by: Karol Lasończyk <karol.lasonczyk@nordicsemi.no>
2024-05-15 15:33:41 +01:00
Declan Snyder
b9e89ef688 drivers: adc: Add NXP GAU ADC Driver
Add driver for NXP GAU ADC using MCUX HAL.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
2024-05-14 18:23:22 -04:00
Benjamin Cabé
30ce8b1b18 drivers: fix bad SPDX-License-Identifier header
fix typo in SPDX header

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
2024-05-08 09:23:16 -04:00
cyliang tw
0190ed2713 drivers: adc: support Nuvoton numaker m2l31x
Update m2l31x.dtsi for adc support and update adc_numaker.c
to support acquisition time in 0~255 ADC ticks.

Signed-off-by: cyliang tw <cyliang@nuvoton.com>
2024-05-02 09:58:43 +01:00
Caspar Friedrich
666a89221b drivers: adc: tla2021: Fix reference voltage
This fixes the problem that `adc_raw_to_millivolts` only returns half of
the actual voltage.

Signed-off-by: Caspar Friedrich <c.s.w.friedrich@gmail.com>
2024-04-25 15:12:14 +02:00
François Baldassari
4fe9909949 ADC: kb1200: start_read returns uninitialzed value
Found via static analyis. When `adc_kb1200_start_read` succeeds, no
value is set for `error` so it is still uninitialized when it is
returned.

Signed-off-by: François Baldassari <francois@memfault.com>
2024-04-25 11:06:11 +00:00
Lukasz Madej
71e7a77e99 drivers: adc: adc_ad559x: improve adc read
Use information encoded in conversion result value to validate it.
Check if MSB bit is set to zero.
Check if channel number included in the result matches channel
number selected for conversion.
Use bitmask to extract converted value instead of math calculations.

Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
2024-04-25 12:15:19 +02:00
Lukasz Madej
f565f4cae7 drivers: adc: adc_ad559x: fix driver init
k_thread_name_set() function returns an error if CONFIG_THREAD_NAME is
not enabled which may make the driver not functional.

Fix the issue by adding a check against CONFIG_THREAD_NAME avaliability
before calling k_thread_name_set() function so the driver can operate
properly with CONFIG_THREAD_NAME disabled.

Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
2024-04-25 12:15:19 +02:00
Lukasz Madej
55235712fb drivers: adc: adc_ad559x: add invernal vref value
Add configuration of internal refference voltage value so raw ADC
readings can be converted to mV utilizing adc_raw_to_millivolts()
ADC API function.

Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
2024-04-25 12:15:19 +02:00
Zhaoxiang Jin
fefb472700 drivers: lpadc/adc_mcux_lpadc/: enable nxp lpadc acquisition time feature
Enable nxp lpadc driver acquisition time feature

Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
2024-04-18 11:16:45 +02:00
Jan Kubiznak
ba90f160b9 drivers: adc: adc_ads1119: Fix configuration register access.
The adc_ads1119 driver is unable to overwrite the configuration register,
the chip therefore always works with its default settings. Register access
macros are fixed by this commit.

Fixes: #70091

Signed-off-by: Jan Kubiznak <jan.kubiznak@deveritec.com>
2024-04-11 09:09:20 +02:00
Lucas Tamborrino
fe57a12cf2 drivers: esp32: update to hal_espressif v5.1
Modify necessary drivers to meet updated hal.

Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2024-04-05 13:39:53 +02:00
Jeppe Odgaard
17b1912bc3 drivers: ad559x: add i2c bus support
Rename ad5592 files in dts, driver and include to ad559x and add support
for I2C bus which is required for AD5593.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2024-04-01 12:18:47 -05:00
Steven Chang
7d12798a22 drivers: adc: initial device driver for ENE KB1200
Add adc driver for ENE KB1200

Signed-off-by: Steven Chang <steven@ene.com.tw>
2024-03-15 09:39:48 +00:00
Guillaume Gautier
3b50237699 drivers: adc: stm32: use correct macros for dma transfer
Use the correct dedicated macros for enabling DMA transfer for STM32H7 and
U5.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-03-12 19:28:54 -04:00
Guillaume Gautier
5d2558bdad drivers: adc: stm32: dma fixes
Add a blank define for the case where DMA channels are defined in ADC node
of the dts but STM32_ADC_DMA is not enabled. Otherwise compilation fails.
Also fix the way the DMA channel is configured by using a standard DT
macro, otherwise it doesn't work for dma-v2bis DMA types.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-03-12 19:28:54 -04:00
Guillaume Gautier
e91860d8c7 drivers: adc: stm32: disable dma before calibration
For some STM32 series, DMA has to be disabled before starting ADC
calibration.

Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
2024-03-12 10:41:55 +01:00
Benedikt Schmidt
b47c66e3f2 drivers: adc: implement voltage biasing for ADS114s08
Implement voltage biasing on the inputs of the ADC ADS114s08.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2024-03-11 19:34:34 -04:00
Benedikt Schmidt
d03778f9e6 drivers: adc: reset data ready signal for ADS114s0x
Reset the data ready signal for a new read operation
with a ADS114s0x.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2024-03-11 17:23:54 +01:00
Alexandre Poizat
0195f774ba drivers: adc: stm32: disable ADC before writing oversampling bits for g0
Added the STM32G0X SOC series to the list of SOC that need to disable the
ADC while setting the oversampling bits to prevent writing over the
CKMODE bits.

Signed-off-by: Alexandre Poizat <apoizat@kalrayinc.com>
2024-03-11 14:21:13 +01:00
Benedikt Schmidt
c08b66cfee drivers: adc: set name for acquisition thread of MCP320x
Set the name of the acquisition thread for the ADC MCP320x.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2024-03-07 21:37:54 +00:00
Henrik Brix Andersen
79d5857e9f drivers: adc: max1125x: use K_KERNEL_STACK_SIZEOF()
Use K_KERNEL_STACK_SIZEOF() for calculating thread stack size, as this
takes K_KERNEL_STACK_RESERVED into account.

Fixes: #69129

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-02-19 12:52:52 -06:00
Henrik Brix Andersen
ad85283906 drivers: adc: ad5592: use K_KERNEL_STACK_SIZEOF()
Use K_KERNEL_STACK_SIZEOF() for calculating thread stack size, as this
takes K_KERNEL_STACK_RESERVED into account.

Fixes: #69133

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-02-19 12:52:52 -06:00
Henrik Brix Andersen
4274d1b365 drivers: adc: ads7052: use K_KERNEL_STACK_SIZEOF()
Use K_KERNEL_STACK_SIZEOF() for calculating thread stack size, as this
takes K_KERNEL_STACK_RESERVED into account.

Fixes: #69132

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-02-19 12:52:52 -06:00
Henrik Brix Andersen
0e321ecc90 drivers: adc: lmp90xxx: use K_KERNEL_STACK_SIZEOF()
Use K_KERNEL_STACK_SIZEOF() for calculating thread stack size, as this
takes K_KERNEL_STACK_RESERVED into account.

Fixes: #69131

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-02-19 12:52:52 -06:00
Henrik Brix Andersen
ae81429a81 drivers: adc: mcp320x: use K_KERNEL_STACK_SIZEOF()
Use K_KERNEL_STACK_SIZEOF() for calculating thread stack size, as this
takes K_KERNEL_STACK_RESERVED into account.

Fixes: #69130

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-02-19 12:52:52 -06:00