Skip to content

Updated Lightning to Determine Its Own Lightning State#28

Open
bjackson312006 wants to merge 7 commits intomainfrom
feature/lightning-shutdown
Open

Updated Lightning to Determine Its Own Lightning State#28
bjackson312006 wants to merge 7 commits intomainfrom
feature/lightning-shutdown

Conversation

@bjackson312006
Copy link
Copy Markdown
Contributor

Lightning now determines the lightning board light state on its own, independent of VCU.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 plain cmake -S . -B build (without presets), CMake will likely pick the host compiler instead of gcc-arm-none-eabi, producing a broken build. Consider adding a guarded fallback to set CMAKE_TOOLCHAIN_FILE when 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.

Comment thread Core/Src/u_statemachine.c
Comment thread Core/Src/u_statemachine.c Outdated
Comment thread Core/Src/u_statemachine.c
Comment thread Core/Src/u_statemachine.c
Comment thread Core/Inc/u_can.h Outdated
Comment thread Core/Src/u_inbox.c
Comment thread Core/Src/can_messages_rx.c
Comment thread Core/Inc/u_statemachine.h
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Core/Src/can_messages_rx.c
Comment thread Core/Src/can_messages_tx.c
Comment thread Core/Src/u_statemachine.c
Comment thread Core/Src/u_statemachine.c
Comment thread Core/Src/u_statemachine.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants