Skip to content

CAN Integration

The can_helpers.h module interfaces with the FlexCAN_T4 library to listen to the vehicle's CAN bus, specifically looking for critical safety telemetry from the Battery Management System (BMS).

Received Messages

The Charger is primarily a consumer of CAN data and monitors two crucial message IDs:

1. BMS Errors (CAN_ID_BMS_ERRORS)

This frame contains a bitfield of various fault conditions detected by the BMS.

  • The driver extracts specific error bits (e.g., bits 8-15, 16, 22-28).
  • If any of these bits are high, the bms.any_error flag is set, which instantly triggers a fault in the FSM.

2. BMS Current / Safety (CAN_ID_BMS_CURRENT)

This frame provides the Charger_Safety flag.

  • The flag is extracted from bit 56 (byte 7, bit 0).
  • If the BMS pulls this safety bit low, the bms.charger_safety_can flag is cleared, preventing the FSM from leaving IDLE or forcing it into FAULT if actively charging.

Heartbeat Monitoring

Every time a relevant BMS message is received, the bms.valid flag is asserted and a timestamp (bms.last_rx) is recorded. This allows the system to implement a timeout/watchdog mechanism (monitored externally by the inputs parser) to ensure the physical CAN connection to the BMS hasn't been severed.

Released under the MIT License.