feat(firmware/rmcs_board): Add WS2812 status LED feedback#50
Conversation
|
Note Reviews pausedUse the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough该 PR 在 rmcs_board 上新增 WS2812 驱动(PWM+DMA)与 LED 控制逻辑、引入 1 kHz 的周期滴答定时器并将其与 LED 更新关联,更新若干通信模块在缓冲区溢出时触发 LED 指示,添加板级 WS2812 / GPTMR 初始化和中断接入;同时为 utility::Lazy 添加文档并新增非断言访问器 ChangesLED/Timer 集成(主 DAG)
工具类改动(独立 DAG)
Sequence DiagramsequenceDiagram
participant App as App
participant Timer as Tick Timer
participant LED as Led Controller
participant WS2812 as WS2812 Driver
participant CANUARTUSB as CAN/UART/USB Buffers
participant IRQ as IRQ Handler
App->>Timer: timer::tick.init()
App->>LED: led::led.init()
LED->>WS2812: ws2812.init()
WS2812->>WS2812: 配置 PWM + DMA
loop 每 ~1ms
IRQ->>Timer: GPTMR1 重载中断
Timer->>Timer: tick_counter++
Timer->>LED: update(tick_counter)
LED->>WS2812: set_value(...) (根据计数器和相位)
end
CANUARTUSB->>LED: 缓冲区满触发
LED->>LED: 设置相应计数器 = 5000
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@firmware/rmcs_board/app/src/led/ws2812.hpp`:
- Around line 113-116: The DMA transfer size is set incorrectly in set_value():
ctrl.TRANSIZE uses compare_values_.size() (element count) but must be a byte
count to match init_dma() and tx semantics; change the assignment in set_value()
so ctrl.TRANSIZE is the number of bytes (e.g., sizeof(compare_values_)) rather
than the element count, consistent with how TRANSIZE is used in init_dma() and
tx_buffer.hpp.
In `@firmware/rmcs_board/app/src/utility/lazy.hpp`:
- Around line 54-63: Lazy::get() now returns nullptr instead of asserting;
update all callers to handle that case: search for uses of Lazy::get() (e.g.,
variables can1, can2 and the call sequence where can = can1.get(); can =
can2.get(); followed by can->handle_uplink()) and add a null-check before any
dereference (or replace with a checked accessor) and handle the uninitialized
path consistently (log/error/early-return or assert_if_critical). Ensure every
call site that previously assumed non-nullation either guards the pointer or
calls a new checked accessor on Lazy.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 46612772-632a-404c-a994-eadbd03ef43b
📒 Files selected for processing (16)
firmware/c_board/app/src/utility/lazy.hppfirmware/rmcs_board/app/src/app.cppfirmware/rmcs_board/app/src/can/can.hppfirmware/rmcs_board/app/src/gpio/analog_gpio_pin.hppfirmware/rmcs_board/app/src/led/led.hppfirmware/rmcs_board/app/src/led/ws2812.hppfirmware/rmcs_board/app/src/timer/tick.cppfirmware/rmcs_board/app/src/timer/tick.hppfirmware/rmcs_board/app/src/uart/uart.hppfirmware/rmcs_board/app/src/usb/interrupt_safe_buffer.hppfirmware/rmcs_board/app/src/utility/assert.cppfirmware/rmcs_board/app/src/utility/lazy.hppfirmware/rmcs_board/boards/lite/app/board_app.cppfirmware/rmcs_board/boards/lite/app/board_app.hppfirmware/rmcs_board/boards/pro/app/board_app.cppfirmware/rmcs_board/boards/pro/app/board_app.hpp
|
@coderabbitai pause |
✅ Actions performedReviews paused. |
- Expose USB, UART, and CAN backpressure plus fatal asserts through a shared status light path so board health is visible without a debugger. - Keep the pro variant initialized but non-driving so the same firmware path is ready for the next hardware revision.
- Introduce an explicit nullable probe accessor for firmware Lazy wrappers and keep get(), operator->(), and operator*() as strict accessors that require prior initialization. - Use try_get() in the rmcs_board assert WS2812 path so assert handling can probe LED availability without re-entering Lazy assertions or triggering clang-tidy recursion diagnostics. - Add Doxygen comments to document the split between nullable probing and strict access across both firmware variants.
WS2812 状态指示灯反馈功能(更新)
该拉取请求为固件添加了共享的 WS2812 状态指示灯路径,用于在无需调试器的情况下通过可视反馈暴露 USB/UART/CAN 的背压状态及致命断言信息;同时保留 pro 硬件变体的初始化但不驱动线路,以便未来硬件修订复用相同固件路径。
核心功能
集成点(缓冲区/传输失败 -> 指示灯)
断言视觉反馈
Lazy 访问语义变更(重要,破坏性)
板级与 GPIO 改动
其它