Skip to content

Commit 937be2c

Browse files
authored
feat[ADC]: 新增 ADC V2 驱动支持 (#11440)
* feat[ADC V2]: add ADC V2 driver support add ADC V2 core APIs, session state management, and sequence read support add STM32 ADC V2 HAL backend with internal-channel and VREF handling add per-series STM32 ADC V2 default configuration headers wire ADC V2 Kconfig and SConscript integration for components and STM32 BSP drivers keep ADC V2 mutually exclusive with the legacy ADC driver path * feat[ADC V2]: add ADC V2 MSH special channel read support add generic ADC V2 MSH commands for probing, configuring, raw reads, voltage reads, and sequence reads add STM32 ADC V2 backend special commands for VREFINT, temperature sensor, and VBAT reads add STM32 helper APIs for special logical channels, sampling time, resolution, and temperature calculation wire ADC V2 MSH sources through Kconfig and SConscript * feat[ADC V2]: add ADC V2 stream DMA support add ADC V2 stream APIs with latest-frame and FIFO buffering policies wire STM32 ADC V2 to circular DMA stream mode with per-instance Kconfig options extend STM32 ADC config headers and DMA helpers for stream DMA configuration add FinSH stream commands for start, read, cancel, and stop operations handle Cortex-M7 cache-safe DMA buffers for STM32 stream sampling * feat[ADC V2]: add timer trigger support for ADC V2 streams add ADC V2 trigger configuration, validation, and lifecycle coordination add timer update trigger support through clock timer TRGO controls map STM32 ADC V2 timer update triggers to HAL external trigger selector fields add Kconfig, SConscript, and MSH entries for ADC trigger setup and inspection * feat[ADCV2]: add timer and comparator trigger selectors add ADC V2 timer compare and analog comparator trigger configuration support extend clock timer trigger config with compare event and channel fields wire STM32 ADC external trigger selector mappings for TIM update, TIM compare, and COMP output add FinSH trigger_set commands and Kconfig switches for timer and comparator trigger backends * fix[ADC V2]: resolve ADC V1 compatibility Kconfig loop * ci[ADC V2][stm32]: add ADC v2 peripheral config for stm32f407-rt-spark BSP
1 parent 8a0fe09 commit 937be2c

45 files changed

Lines changed: 16951 additions & 50 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bsp/stm32/libraries/HAL_Drivers/drivers/Kconfig

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,116 @@ if BSP_USING_USBD
2424
# "ULPI: UTMI+ Low Pin Interface"
2525
endif
2626

27+
menuconfig BSP_USING_ADC_V2
28+
bool "Enable ADC V2"
29+
select RT_USING_ADC
30+
select RT_USING_ADC_V2
31+
default n
32+
33+
if BSP_USING_ADC_V2
34+
config BSP_USING_ADC1
35+
bool "Enable ADC1"
36+
default n
37+
38+
config BSP_USING_ADC2
39+
bool "Enable ADC2"
40+
depends on (SOC_SERIES_STM32F1 || SOC_SERIES_STM32F2 || SOC_SERIES_STM32F3 || \
41+
SOC_SERIES_STM32F4 || SOC_SERIES_STM32G4 || SOC_SERIES_STM32F7 || \
42+
SOC_SERIES_STM32H5 || SOC_SERIES_STM32H7 || SOC_SERIES_STM32H7RS || \
43+
SOC_SERIES_STM32L4 || SOC_SERIES_STM32L5 || SOC_SERIES_STM32MP1 || \
44+
SOC_SERIES_STM32U5)
45+
default n
46+
47+
config BSP_USING_ADC3
48+
bool "Enable ADC3"
49+
depends on (SOC_SERIES_STM32F1 || SOC_SERIES_STM32F2 || SOC_SERIES_STM32F3 || \
50+
SOC_SERIES_STM32F4 || SOC_SERIES_STM32G4 || SOC_SERIES_STM32F7 || \
51+
SOC_SERIES_STM32H7 || SOC_SERIES_STM32L4 || SOC_SERIES_STM32MP1)
52+
default n
53+
54+
config BSP_USING_ADC4
55+
bool "Enable ADC4"
56+
depends on (SOC_SERIES_STM32F3 || SOC_SERIES_STM32G4 || SOC_SERIES_STM32U5)
57+
default n
58+
59+
config BSP_ADC_USING_TRIGGER
60+
bool "Enable ADC V2 trigger backend"
61+
select RT_ADC_USING_TRIGGER
62+
default n
63+
help
64+
Enable STM32 ADC V2 trigger selector validation and backend
65+
encoding. The ADC backend maps the framework-cached trigger to STM32
66+
HAL ADC selector fields. Trigger-source frequency and lifecycle are
67+
owned by the ADC trigger framework and timer trigger backend.
68+
69+
config BSP_ADC_USING_TIMER_TRIGGER
70+
bool "Enable ADC V2 timer trigger selector backend"
71+
depends on BSP_ADC_USING_TRIGGER
72+
depends on BSP_USING_TIM
73+
depends on RT_USING_CLOCK_TIME
74+
select RT_ADC_TRIGGER_USING_TIMER
75+
select RT_USING_CLOCK_TIMER_TRIGGER
76+
default n
77+
help
78+
Enable STM32 TIMx update/TRGO and compare event to ADC external
79+
trigger selector mapping for ADC V2 stream pacing. Timer frequency,
80+
TRGO/compare setup, and lifecycle are handled through the clock
81+
timer trigger backend during ADC stream start and stop.
82+
83+
config BSP_ADC_USING_ANALOG_COMPARE_TRIGGER
84+
bool "Enable ADC V2 analog comparator trigger selector backend"
85+
depends on BSP_ADC_USING_TRIGGER
86+
select RT_ADC_TRIGGER_USING_COMPARE
87+
default n
88+
help
89+
Enable STM32 COMPx_OUT to ADC external trigger selector mapping for
90+
ADC V2. Comparator input, threshold, polarity, and enable state are
91+
owned by board code, application code, or a comparator driver.
92+
93+
config BSP_ADC_USING_STREAM_DMA
94+
bool
95+
96+
config BSP_ADC1_USING_DMA
97+
bool "Enable ADC1 stream DMA backend"
98+
depends on BSP_USING_ADC1
99+
select RT_ADC_USING_STREAM
100+
select BSP_ADC_USING_STREAM_DMA
101+
default n
102+
help
103+
Enable the STM32 ADC1 DMA backend for ADC V2 stream sessions.
104+
105+
This option only enables the board-level DMA backend. The stream
106+
framework and buffering policies are controlled by RT_ADC_USING_STREAM,
107+
RT_ADC_STREAM_USING_LATEST, and RT_ADC_STREAM_USING_FIFO.
108+
109+
config BSP_ADC2_USING_DMA
110+
bool "Enable ADC2 stream DMA backend"
111+
depends on BSP_USING_ADC2
112+
select RT_ADC_USING_STREAM
113+
select BSP_ADC_USING_STREAM_DMA
114+
default n
115+
help
116+
Enable the STM32 ADC2 DMA backend for ADC V2 stream sessions.
117+
118+
config BSP_ADC3_USING_DMA
119+
bool "Enable ADC3 stream DMA backend"
120+
depends on BSP_USING_ADC3
121+
select RT_ADC_USING_STREAM
122+
select BSP_ADC_USING_STREAM_DMA
123+
default n
124+
help
125+
Enable the STM32 ADC3 DMA backend for ADC V2 stream sessions.
126+
127+
config BSP_ADC4_USING_DMA
128+
bool "Enable ADC4 stream DMA backend"
129+
depends on BSP_USING_ADC4
130+
select RT_ADC_USING_STREAM
131+
select BSP_ADC_USING_STREAM_DMA
132+
default n
133+
help
134+
Enable the STM32 ADC4 DMA backend for ADC V2 stream sessions.
135+
endif
136+
27137
config BSP_USING_CRC
28138
bool "Enable CRC (CRC-32 0x04C11DB7 Polynomial)"
29139
select RT_USING_HWCRYPTO
@@ -59,4 +169,3 @@ config BSP_USING_UDID
59169
bool "Enable UDID (Unique Device Identifier)"
60170
select RT_USING_HWCRYPTO
61171
default n
62-

bsp/stm32/libraries/HAL_Drivers/drivers/SConscript

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,18 @@ if GetDepend(['RT_USING_I2C']):
4646
if GetDepend(['BSP_USING_ETH', 'RT_USING_LWIP']) and not GetDepend(['SOC_STM32H750_ARTPI']):
4747
src += ['drv_eth.c']
4848

49-
if GetDepend(['RT_USING_ADC']):
49+
if GetDepend(['RT_USING_ADC']) and not GetDepend(['RT_USING_ADC_V2']):
5050
src += ['drv_adc.c']
5151

52+
if GetDepend(['BSP_USING_ADC_V2']):
53+
src += ['drv_adc_v2.c']
54+
55+
if GetDepend(['BSP_ADC_USING_TRIGGER']):
56+
src += ['drv_adc_v2_trigger.c']
57+
58+
if GetDepend(['RT_USING_FINSH', 'RT_ADC_V2_USING_MSH']):
59+
src += ['drv_adc_v2_msh.c']
60+
5261
if GetDepend(['RT_USING_DAC']):
5362
src += ['drv_dac.c']
5463

0 commit comments

Comments
 (0)