|
PER Firmware
|
Standardized framework for CAN communication within PER vehicles.
generators/: Python generation pipeline for CAN and fault artifacts.firmware/common/can_library/generated/: Generated CAN headers.artifacts/superdbc/: Generated SuperDBC definitions and schema, relative to the repository root.Core Files:
can_init.c / can_common.h: Bus/peripheral initialization and CAN_init().can_rx.c: CAN RX task and the shared can_data instance.can_tx.c: CAN TX task and per-peripheral software queues.can_codec.h: Signal packing and unpacking helpers.firmware/cmake/can_library.cmake: CMake integration and node library generation.The high-level logic flow of an RX is shown here:
The high-level logic flow of a TX is shown here:
Periodic CAN messages are assigned a deadline of 2.5x their expected period. If a message is not received within the window, it's associated data is no longer valid.
generators/configs/; the generator validates them with its Pydantic declaration models.FDCAN1, FDCAN2, or FDCAN3.can_node_<NODE_NAME> to LIBS in your board's add_firmware_component(...) call (must match the uppercase node name from CMake).#include "can_library/generated/PDU.h" / #include "can_library/generated/<NODE_NAME>.h") in your main.c.CAN_init() after setting up RCC and GPIO.main.c using DEFINE_CAN_TASKS() and START_CAN_TASKS().START_CAN_TASKS() enables the CAN IRQsThe most recent rx'd data is available in the can_data struct, which is updated by the CAN RX task. Sending CAN messages is done via the generated CAN_SEND_<message_name>() functions, which enqueue messages to be sent by the CAN TX task.