Skip to content

feat[serial][v2]: add RX DMA event mode control#11487

Open
wdfk-prog wants to merge 1 commit into
RT-Thread:masterfrom
wdfk-prog:feat_serial_dma_mode
Open

feat[serial][v2]: add RX DMA event mode control#11487
wdfk-prog wants to merge 1 commit into
RT-Thread:masterfrom
wdfk-prog:feat_serial_dma_mode

Conversation

@wdfk-prog

Copy link
Copy Markdown
Contributor

拉取/合并请求描述:(PR description)

[

为什么提交这份PR (why to submit this PR)

Serial v2 在 RX DMA 模式下目前缺少统一的 DMA half/full transfer 事件策略配置。STM32 UART RX DMA 场景中,部分应用需要保留 UART IDLE 接收上报,同时减少 DMA half-transfer 中断,或显式选择 half/full transfer 上报策略。

该 PR 为 serial v2 配置增加 RX DMA event mode,并在 STM32 USART v2 驱动中按配置控制 RX DMA HT/TC 中断处理,使默认行为保持兼容,同时允许应用侧选择更低中断频率的 RX DMA 事件模式。

你的解决方案是什么 (what is your solution)

  • struct serial_configure 中为 DMA 构建增加 rx_dma_event_mode 配置项,并在默认配置中使用 RT_SERIAL_RX_DMA_EVENT_AUTO
  • 新增 RX DMA event mode 枚举,用于表达默认模式、只上报 full-transfer,以及同时上报 half/full-transfer 的策略。
  • 在 serial v2 control 路径中校验 rx_dma_event_mode,并在 backend configure 失败时恢复旧配置。
  • 在 STM32 USART v2 驱动中解析有效 RX DMA event mode,并据此配置 DMA HT/TC 中断。
  • 在 STM32 RX DMA ISR 路径中按事件模式过滤 HT/TC 事件,同时保持 UART IDLE 事件可用于接收数据上报。
  • 修正 STM32 USART v2 DMA RX IDLE 判断条件,避免 TX DMA 标志导致 RX DMA IDLE 路径被错误触发。

请提供验证的bsp和config (provide the config and bsp)

  • BSP: 未在上传材料中提供实测 BSP;提交前建议使用目标 STM32 BSP 验证,例如启用 USART RX DMA 的 bsp/stm32/<target-board>
  • .config: RT_USING_SERIAL_V2, RT_SERIAL_USING_DMA, BSP_USING_UARTx, BSP_UARTx_RX_USING_DMA,以及对应 BSP 的 UART RX DMA 配置。
  • action: 未在上传材料中提供 action 链接;提交前建议补充 PR 分支触发的 manual_dist.yml 或目标 BSP 编译 action 链接。

]

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown

📌 Code Review Assignment

🏷️ Tag: bsp_stm32

Reviewers: Liang1795 hamburger-os wdfk-prog

Changed Files (Click to expand)
  • bsp/stm32/libraries/HAL_Drivers/drivers/drv_usart_v2.c

🏷️ Tag: components

Reviewers: Maihuanyi

Changed Files (Click to expand)
  • components/drivers/include/drivers/dev_serial_v2.h
  • components/drivers/serial/dev_serial_v2.c

🏷️ Tag: components_driver_serial_v2

Reviewers: Ryan-CW-Code

Changed Files (Click to expand)
  • components/drivers/serial/dev_serial_v2.c

📊 Current Review Status (Last Updated: 2026-06-15 14:32 CST)

  • Liang1795 Pending Review
  • Maihuanyi Pending Review
  • Ryan-CW-Code Pending Review
  • hamburger-os Pending Review
  • wdfk-prog Pending Review

📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@github-actions

Copy link
Copy Markdown

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  • 将目标分支设置为 \ Set the target branch to:feat_serial_dma_mode
  • 设置PR number为 \ Set the PR number to:11487
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将自动推送至你的分支。
    The formatted code will be automatically pushed to your branch.

完成后,提交将自动更新至 feat_serial_dma_mode 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the feat_serial_dma_mode branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

@wdfk-prog

Copy link
Copy Markdown
Contributor Author

add serial v2 RX DMA event mode configuration for DMA-enabled builds
support STM32 UART RX DMA half/full transfer interrupt policy selection
validate RX DMA event mode before applying serial configuration
restore serial configuration when backend configure fails
@wdfk-prog wdfk-prog force-pushed the feat_serial_dma_mode branch from 520b29c to d2d4e13 Compare June 15, 2026 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant