Skip to content

pcb

Purpose

The CAN-Gateway board is the sensor and control bridge for the car. It reads the board-local inputs, shapes them into clean runtime values, and publishes the result onto the vehicle CAN network. It also listens for incoming commands that affect outputs such as NMOS control, bootloader requests, and dashboard-driven actions.

The same repository supports both the front and rear gateway variants. The code switches behavior at compile time via a preprocessor macro defined in repos/CAN-Gateway/Core/Inc/App/system_var.h, so the documentation treats them as one board family with variant-specific behavior.

What the board owns

The firmware is organized around a small set of responsibilities that stay close to the hardware:

  • Communication: Keeps the CAN bus moving, enqueues periodic frames, and handles incoming command frames (buzzer, LEDs, calibration triggers).
  • Data Processing: Reads DMA-backed ADC buffers, filters raw sensor values with Kalman filters, and checks APPS validation limits.
  • Sensors I/O: Binds physical inputs (wheel speed, suspension, brake pressure, temp, flow) to their driver objects.
  • FSM and Main Loop: Orchestrates execution state and handles bootloader or fault transitions.

Hardware & stack

LayerWhat we use
MCUSTM32G473xx (Cortex-M4)
Peripheral ConfigFDCAN2 (CAN 2.0 at 500 KBps), Dual ADCs (DMA-backed), USB CDC (Virtual COM Port)
Execution ModelCooperative Main Loop + Interrupt Handlers
ConcurrencyEvent-driven State Machine with interrupt-based FDCAN reception
Power ControlOn-board NMOS switches for power distribution to external components

How the data flows

Producers (ADC DMA callbacks and timers) write raw values to buffers. The state machine's process task filters the samples and feeds them to the communication task to be transmitted on the CAN bus. Consumers like NMOS power switches read command packets from the FDCAN RX ring buffer.

Where to go next

Start with the Module Index for the full file inventory, or jump into a group:

Configuration

All variant-independent schedules, update rates, and filters live in repos/CAN-Gateway/Core/Inc/App/DataProcessing/DP_scheduler_vals.h. Variant type and ADC rank macros are defined in repos/CAN-Gateway/Core/Inc/App/system_var.h.

NOTE

When modifying code, keep this live: if you change how the state machine transitions, add a sensor mapping, or edit the CAN layout, update the corresponding submodule page in your Pull Request.

Released under the MIT License.