feat[ADC]: 新增 ADC V2 驱动支持#11440
Conversation
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
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
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
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
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
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: bsp_stm32Reviewers: Liang1795 hamburger-os wdfk-prog Changed Files (Click to expand)
🏷️ Tag: componentsReviewers: Maihuanyi Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-06-04 17:57 CST)
📝 Review Instructions
|
There was a problem hiding this comment.
Pull request overview
English: This PR introduces a new ADC V2 driver framework in RT-Thread, adds STM32 HAL-based backend support, and expands the clock-time timer interface to support hardware trigger output for ADC streaming/trigger scenarios while keeping legacy ADC and ADC V2 mutually exclusive.
中文:本 PR 在 RT-Thread 中引入新的 ADC V2 驱动框架,新增 STM32 HAL 后端支持,并扩展 clock_time 定时器接口以支持 硬件触发输出(用于 ADC 触发/流式采样场景),同时保证 legacy ADC 与 ADC V2 互斥。
Changes:
- English: Adds ADC V2 Kconfig/SConscript integration and public headers (incl. trigger framework API).
中文:新增 ADC V2 的 Kconfig/SConscript 接入与公共头文件(包含 trigger 框架 API)。 - English: Extends clock_time timer control interface to support trigger config/start/stop/release and trigger event descriptors.
中文:扩展 clock_time 定时器控制接口,新增触发配置/启动/停止/释放及触发事件描述结构。 - English: Adds ADC V2 trigger framework implementation and STM32 config header scaffolding for multiple series.
中文:新增 ADC V2 trigger 框架实现,并为多个 STM32 系列补充 adc_config_v2.h 配置头文件体系。
Notes (project checklist):
- 🟡 English: PR title
"feat[ADC]: ..."does not match the repo’s recommended lowercase bracket-prefix pattern like[module][subsystem] Description. Consider something like:[drivers][adc] Add ADC V2 framework and STM32 backend.
中文:PR 标题"feat[ADC]: ..."与仓库推荐的小写前缀格式(如[module][subsystem] 描述)不一致。建议改为类似:[drivers][adc] Add ADC V2 framework and STM32 backend。
Reviewed changes
Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| components/drivers/Kconfig | Sources the new adc/Kconfig under drivers. |
| components/drivers/include/rtdevice.h | Adds conditional include for ADC V2 public header. |
| components/drivers/include/drivers/clock_time.h | Adds clock timer trigger control commands and trigger config/event types. |
| components/drivers/clock_time/Kconfig | Adds RT_USING_CLOCK_TIMER_TRIGGER option to enable timer trigger output controls. |
| components/drivers/adc/SConscript | Adds build integration for ADC V2 core/trigger/MSH sources based on Kconfig dependencies. |
| components/drivers/adc/Kconfig | Introduces ADC V2 Kconfig options (trigger/stream/buffering policies/MSH). |
| components/drivers/include/drivers/adc_v2_trigger.h | New public ADC V2 trigger framework declarations and APIs. |
| components/drivers/adc/adc_v2_trigger.c | New ADC V2 trigger framework implementation (validation + timer-trigger lifecycle integration). |
| bsp/stm32/libraries/HAL_Drivers/drivers/config/f4/dma_config.h | Adjusts STM32F4 DMA mapping relevant to ADC/SPI usage. |
| bsp/stm32/libraries/HAL_Drivers/drivers/config/*/adc_config_v2.h | Adds STM32 series-specific ADC V2 configuration headers (multi-series support scaffolding). |
|
大佬,我向你的分支提了一个修改。这个问题我觉得应该参考 serial 的处理方式来兼容,否则会有 Kconfig 依赖嵌套/循环的风险。 目前有些 BSP 会直接通过 BSP_USING_ADC1 去 select RT_USING_ADC,也有些 BSP 会直接使能 RT_USING_ADC。如果 ADC V2 再用 depends on !RT_USING_ADC 这类互斥条件,就容易在 dist 或 pyconfig 时触发依赖环。 |
拉取/合并请求描述:(PR description)
为什么提交这份PR (why to submit this PR)
本 PR 新增 ADC V2 驱动框架和 STM32 HAL 后端支持,用于在保留 legacy ADC 路径的同时提供新的 ADC 会话、序列采样、MSH 调试、DMA 流式采样和触发源配置能力。
该实现解决了以下问题:
你的解决方案是什么 (what is your solution)
请提供验证的bsp和config (provide the config and bsp)
STM32F4
建议按验证范围启用以下配置项:
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up