Updated Lightning to Determine Its Own Lightning State#28
Open
bjackson312006 wants to merge 7 commits intomainfrom
Open
Updated Lightning to Determine Its Own Lightning State#28bjackson312006 wants to merge 7 commits intomainfrom
bjackson312006 wants to merge 7 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR shifts Lightning’s board light behavior to be derived locally from incoming CAN status messages (IMD + BMS), rather than being directly commanded by the VCU.
Changes:
- Reworked the lightning light “statemachine” to compute GREEN/RED/OFF from IMD/BMS status messages.
- Updated CAN inbox routing and enabled FDCAN2 interrupts (IT0/IT1) to support receiving relevant status frames.
- Added autogenerated CAN RX decode sources and wired them into the build.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| Lightning.ioc | Enables FDCAN2 interrupt lines and updates CubeMX project metadata. |
| Core/Src/u_threads.c | GPIO lights thread now queries statemachine_getState() instead of reading an externally-set state. |
| Core/Src/u_test.c | Removes test-driven random state setting (now a no-op). |
| Core/Src/u_statemachine.c | Implements derived light state from IMD/BMS messages with “first contact” gating. |
| Core/Src/u_mutexes.c | Removes statemachine mutex initialization (statemachine now uses atomics). |
| Core/Src/u_inbox.c | Routes IMD/BMS CAN messages to the statemachine handlers. |
| Core/Src/stm32h5xx_it.c | Adds FDCAN2 IT0/IT1 IRQ handlers that call HAL_FDCAN_IRQHandler. |
| Core/Src/stm32h5xx_hal_msp.c | Enables/disables NVIC IRQs for FDCAN2 IT0/IT1. |
| Core/Src/can_messages_tx.c | Cleans up/improves message length initialization for several TX messages. |
| Core/Src/can_messages_rx.c | Adds autogenerated CAN RX unpacking implementation. |
| Core/Inc/u_statemachine.h | Updates statemachine API to “get state + handle messages”. |
| Core/Inc/u_mutexes.h | Removes exported statemachine mutex declaration. |
| Core/Inc/u_can.h | Adds CAN IDs for IMD/BMS status messages (BMS ID currently marked placeholder). |
| Core/Inc/stm32h5xx_it.h | Declares new FDCAN2 IRQ handlers. |
| Core/Inc/can_messages_rx.h | Adds autogenerated CAN RX unpacking header. |
| compose.yml | Moves container image tag to embedded-base:main. |
| CMakeLists.txt | Adds can_messages_rx.c to build and removes unconditional toolchain include. |
| .mxproject | Updates CubeMX project bookkeeping. |
Comments suppressed due to low confidence (1)
CMakeLists.txt:27
- Toolchain selection is no longer enforced from
CMakeLists.txt. If someone configures with plaincmake -S . -B build(without presets), CMake will likely pick the host compiler instead ofgcc-arm-none-eabi, producing a broken build. Consider adding a guarded fallback to setCMAKE_TOOLCHAIN_FILEwhen not provided, or document that presets are required.
endif()
# Set the project name
set(CMAKE_PROJECT_NAME Lightning)
# Enable compile command to ease indexing with e.g. clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 21 out of 22 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Lightning now determines the lightning board light state on its own, independent of VCU.