fix(can): Eliminate persistent CAN RX latency after startup bursts#64
Merged
Conversation
Drain all pending CAN frames in each RX interrupt on c_board and rmcs_board, and clear the MCAN RX new-message interrupt before draining the FIFO. This fixes a long-standing issue where heavy CAN traffic during board startup could leave a backlog that delayed all later CAN reception.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
Walkthrough修改c_board与rmcs_board固件中CAN模块的上行接收处理逻辑,将原先单次读取一条报文的方式改为循环读取直至FIFO为空。同时调整rmcs_board中断处理函数对中断标志的清除时机,改为分阶段清除。未涉及公开接口声明变更。 ChangesCAN上行FIFO批量读取改造
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant IRQ as CAN中断
participant Handle as handle_uplink
participant Reg as FIFO寄存器/MCAN接口
participant Serializer as serializer
IRQ->>Handle: 触发上行中断处理
loop 队列非空
Handle->>Reg: 读取一条报文数据
Handle->>Serializer: write_can(数据)
Handle->>Reg: 清除/推进队列指针
end
Handle-->>IRQ: 处理完成返回
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Drain all pending CAN frames in each RX interrupt on c_board and rmcs_board, and clear the MCAN RX new-message interrupt before draining the FIFO.
This fixes a long-standing issue where heavy CAN traffic during board startup could leave a backlog that delayed all later CAN reception.
本次变更优化了 c_board 与 rmcs_board 的 CAN 接收中断处理,核心目标是消除启动阶段突发流量后残留的 RX 积压与后续接收延迟。
主要改动:
Can::handle_uplink改为在 FIFO0 中仍有待处理报文时持续循环读取并逐条处理,而不是只读一帧;每次处理后清除 FIFO0 读完成标记。Can::handle_uplink同样改为持续读取 MCAN RX FIFO0,直到队列为空为止。Can::irq_handler调整了中断标志清除顺序,先处理并清除RXFIFO0_NEW_MSG,执行接收处理后,再统一清除剩余标志,避免一次性清除带来的处理时序问题。整体效果是让中断服务期间尽可能“清空”当前积压的 CAN 帧,减少高负载启动场景下的接收滞后。