fix[STM32][I2C]: stabilize hard i2c async transfer routing#11470
Conversation
|
👋 感谢您对 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)
📊 Current Review Status (Last Updated: 2026-06-12 10:09 CST)
📝 Review Instructions
|
|
centralize hard I2C per-message route state for DMA, interrupt, and polling paths make multi-message and no-stop transfers use sequential HAL APIs only snapshot scheduler and interrupt context once for stable async transfer decisions reuse the transaction timeout for async wait logging and abort recovery
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
STM32 hard I2C 驱动同时支持 polling、interrupt 和 DMA 传输路径。当前异步传输路径中,单帧短传输、多帧 repeated-start/no-stop 传输、以及异常后的 abort recovery 需要保持一致的路由策略,否则可能出现同一事务内路径选择不稳定、顺序传输误落到非顺序接口、或恢复等待策略与事务入口上下文不一致的问题。
本 PR 用于稳定 hard I2C master transfer 的异步路由和恢复流程,明确区分普通单帧传输与必须使用 STM32 HAL sequential API 的多帧/no-stop 传输。
你的解决方案是什么 (what is your solution)
stm32_i2c_xfer_route,集中保存每个 message 的 HAL mode、timeout、sequential requirement、async allowed 和 wait requirement。BSP_I2C_DMA_TRANS_MIN_LEN,默认保持为16U。请提供验证的bsp和config (provide the config and bsp)
HAL_Drivers/drivers/drv_hard_i2c.c差异生成 PR 描述,提交前请替换为实际验证 BSP 路径。BSP_USING_HARD_I2C*,以及对应 I2C 的*_TX_USING_INT/*_RX_USING_INT或*_TX_USING_DMA/*_RX_USING_DMA配置;提交前请替换为实际.config变更项。]
当前拉取/合并请求的状态 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