feat: UART command protocol for Jetson-STM32 (Issue #629) #639

Merged
sl-jetson merged 1 commits from sl-firmware/issue-629-uart-protocol into main 2026-03-15 16:30:10 -04:00
Collaborator

Summary

  • Implements binary UART command protocol on UART5 (PC12/PD2) at 115200 baud for Jetson→STM32 communication
  • Frame format: STX(0x02) + LEN + CMD + PAYLOAD + CRC8-SMBUS + ETX(0x03)
  • DMA1_Stream0_Channel4 circular 256-byte RX ring; TX polled (frames <20 B)
  • Commands: SET_VELOCITY (RPM direct to CAN motors), GET_STATUS, SET_PID, ESTOP, CLEAR_ESTOP
  • STATUS frame pushed at 10 Hz: pitch, motor_cmd, vbat_mv, balance_state, estop_active
  • Heartbeat timeout: 500 ms (UART_PROT_HB_TIMEOUT_MS)
  • Note: Spec requested USART1 @ 115200; USART1 occupied by JLink @ 921600 — implemented on UART5 instead

Files

  • include/uart_protocol.h — frame constants, command/response IDs, uart_prot_status_t, UartProtState, API
  • src/uart_protocol.c — UART5 + DMA init, CRC8, parser state machine, dispatcher, TX helpers
  • include/config.hUART_PROT_BAUD, UART_PROT_HB_TIMEOUT_MS
  • src/main.cuart_protocol_init(), uart_protocol_process(), command dispatch, 10 Hz STATUS TX

Test plan

  • Verify UART5 pinout PC12/PD2 on hardware schematic
  • Send SET_VELOCITY from Jetson; confirm CAN velocity commands update
  • Send ESTOP; confirm balance disarm + motor estop
  • Send CLEAR_ESTOP; confirm estop clears when disarmed
  • Send SET_PID; confirm bal.kp/ki/kd update
  • Verify STATUS frames arrive at 10 Hz on Jetson side
  • Confirm heartbeat timeout detection after 500 ms silence

Closes #629

## Summary - Implements binary UART command protocol on **UART5** (PC12/PD2) at 115200 baud for Jetson→STM32 communication - Frame format: `STX(0x02) + LEN + CMD + PAYLOAD + CRC8-SMBUS + ETX(0x03)` - DMA1_Stream0_Channel4 circular 256-byte RX ring; TX polled (frames <20 B) - Commands: `SET_VELOCITY` (RPM direct to CAN motors), `GET_STATUS`, `SET_PID`, `ESTOP`, `CLEAR_ESTOP` - STATUS frame pushed at 10 Hz: pitch, motor_cmd, vbat_mv, balance_state, estop_active - Heartbeat timeout: 500 ms (`UART_PROT_HB_TIMEOUT_MS`) - **Note:** Spec requested USART1 @ 115200; USART1 occupied by JLink @ 921600 — implemented on UART5 instead ## Files - `include/uart_protocol.h` — frame constants, command/response IDs, `uart_prot_status_t`, `UartProtState`, API - `src/uart_protocol.c` — UART5 + DMA init, CRC8, parser state machine, dispatcher, TX helpers - `include/config.h` — `UART_PROT_BAUD`, `UART_PROT_HB_TIMEOUT_MS` - `src/main.c` — `uart_protocol_init()`, `uart_protocol_process()`, command dispatch, 10 Hz STATUS TX ## Test plan - [ ] Verify UART5 pinout PC12/PD2 on hardware schematic - [ ] Send SET_VELOCITY from Jetson; confirm CAN velocity commands update - [ ] Send ESTOP; confirm balance disarm + motor estop - [ ] Send CLEAR_ESTOP; confirm estop clears when disarmed - [ ] Send SET_PID; confirm bal.kp/ki/kd update - [ ] Verify STATUS frames arrive at 10 Hz on Jetson side - [ ] Confirm heartbeat timeout detection after 500 ms silence Closes #629
sl-webui added 1 commit 2026-03-15 14:41:24 -04:00
Implements binary command protocol on UART5 (PC12/PD2) at 115200 baud
for Jetson→STM32 communication. Frame: STX+LEN+CMD+PAYLOAD+CRC8+ETX.

Commands: SET_VELOCITY (RPM direct to CAN), GET_STATUS, SET_PID, ESTOP,
CLEAR_ESTOP. DMA1_Stream0_Channel4 circular 256-byte RX ring. ACK/NACK
inline; STATUS pushed at 10 Hz. Heartbeat timeout 500 ms (UART_PROT_HB_TIMEOUT_MS).

NOTE: Spec requested USART1 @ 115200; USART1 occupied by JLink @ 921600.
Implemented on UART5 instead; note in code comments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
sl-jetson merged commit 45332f1a8b into main 2026-03-15 16:30:10 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: seb/saltylab-firmware#639
No description provided.