Skip to content

Commit 7c7db00

Browse files
cybertalenashif
authored andcommitted
drivers: adc: add driver support for ADC1 of stm32
This commit adds driver support for ADC1 on all 8 supported series of stm32 with resolution and conversion time selection and calibration. Currently DMA is not supported for all series, and without it, zephyr won't be able to catch up ADC's end of conversion interrupt, so this version of the driver supports one channel conversion only. Users want multi-channel conversion should use multiple sequences in their app code. This driver uses LL lib rather than HAL because the current HAL lib for ADC will call HAL_DMA_* functions rather than using zephyr's common DMA interface, so that way the driver will break the consistency of the code. This driver has been tested on multiple nucleo boards including NUCLEO_F091RC/F103RB/F207ZG/F302R8/F401RE/F746ZG/L073RZ/L476RG and all passed the test cases in tests/drivers/adc/adc_api. If the external ADC line is floating, it may fail the tests since ADC may get 0V and the test cases think 0 is failing. Connect it to any voltage source between 0-3.3V will help passing the test cases. Signed-off-by: Song Qiang <songqiang1304521@gmail.com>
1 parent 5e94263 commit 7c7db00

File tree

14 files changed

+709
-0
lines changed

14 files changed

+709
-0
lines changed

CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
/drivers/*/*stm32* @erwango
101101
/drivers/*/*native_posix* @aescolar
102102
/drivers/adc/ @anangl
103+
/drivers/adc/adc_stm32.c @cybertale
103104
/drivers/bluetooth/ @joerchan @jhedberg @Vudentz
104105
/drivers/can/ @alexanderwachter
105106
/drivers/can/*mcp2515* @karstenkoenig
@@ -155,6 +156,7 @@
155156
/dts/riscv32/rv32m1* @MaureenHelm
156157
/dts/bindings/ @galak
157158
/dts/bindings/can/ @alexanderwachter
159+
/dts/bindings/iio/adc/st,stm32-adc.yaml @cybertale
158160
/dts/bindings/serial/ns16550.yaml @gnuless
159161
/dts/bindings/*/nordic* @anangl
160162
/dts/bindings/*/nxp* @MaureenHelm

drivers/adc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ zephyr_library_sources_ifdef(CONFIG_ADC_NRFX_SAADC adc_nrfx_saadc.c)
99
zephyr_library_sources_ifdef(CONFIG_ADC_INTEL_QUARK_SE_C1000_SS adc_intel_quark_se_c1000_ss.c)
1010
zephyr_library_sources_ifdef(CONFIG_ADC_INTEL_QUARK_D2000 adc_intel_quark_d2000.c)
1111
zephyr_library_sources_ifdef(CONFIG_ADC_SAM0 adc_sam0.c)
12+
zephyr_library_sources_ifdef(CONFIG_ADC_STM32 adc_stm32.c)
1213
zephyr_library_sources_ifdef(CONFIG_USERSPACE adc_handlers.c)

drivers/adc/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,6 @@ source "drivers/adc/Kconfig.intel_quark"
5757

5858
source "drivers/adc/Kconfig.sam0"
5959

60+
source "drivers/adc/Kconfig.stm32"
61+
6062
endif # ADC

drivers/adc/Kconfig.stm32

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Kconfig - ADC configuration options
2+
3+
#
4+
# Copyright (c) 2019 Intel Corporation
5+
# Copyright (c) 2019 Endre Karlson
6+
# Copyright (c) 2019 Song Qiang <songqiang1304521@gmail.com>
7+
#
8+
# SPDX-License-Identifier: Apache-2.0
9+
#
10+
11+
menuconfig ADC_STM32
12+
bool "STM32 ADC driver"
13+
depends on SOC_FAMILY_STM32
14+
help
15+
Enable the driver implementation for the stm32xx ADC
16+
17+
if ADC_STM32
18+
19+
config ADC_1
20+
bool "ADC1"
21+
default y
22+
help
23+
Enable ADC1
24+
25+
endif # ADC_STM32

0 commit comments

Comments
 (0)