Firmware for Nucleo-L432KC based Power Distribution and Controls board.
- Run
git submodule update --init. - Run
pio run.
mainstarts the board, optional debug mode, and the CAN transmit loop.IOManagementreads GPIO and ADC values. It writes accel and regen DAC outputs.speed_calccounts MCU speed pulses and setsrpmandmph.motor_controlruns the PARK, IDLE, FORWARD, and REVERSE state machine.canPDCreceives driver inputs on CAN. It transmits telem on CAN.
Set these flags in include/const.h. Set DEBUG_TECHNIQUE in main.cpp.
| Flag | Role |
|---|---|
DEBUG_PRINTS |
Print status on Serial. This flag is on by default. |
TEST_MODE |
Use the CAN bounce test board path. |
DEBUG_TECHNIQUE |
0 is production. 1 sends random CAN echo data. |
The parking brake sensor is not on the car. The firmware sets park_brake to false. The controller leaves PARK and runs.
| Signal | Pin |
|---|---|
| Accel DAC | PA5 |
| Regen DAC | PA4 |
| Brake switch | PA0 (internal pulldown) |
| MCU speed pulse | PA8 |
| Direction | PB7 |
| Eco | PB1 |
Receive from the steering wheel:
0x300direction0x301regen0x302throttle0x303eco or power mode
Transmit:
0x200through0x208: accel out, regen, LV telem, brake, digital pack, mph