Adds VESC motor control over USART6 for the SaltyBot self-balancing robot. Motor1 driven directly via COMM_SET_CURRENT; Motor2 bridged via COMM_FORWARD_CAN (cmd 34) to CAN ID 68. balance_update() now sends current commands to both VESCs on every PID tick — 0 A on disarm/fault, scaled ±10 A when armed (configurable via VESC_CURRENT_MAX_A). - include/vesc_comm.h: common interface (init, send_current, send_duty) - src/vesc_uart.c: USART6 @ 115200, CRC16-CCITT, VESC FW 6.6 framing - src/vesc_can.c: phase-2 stub (TODO: bxCAN + SN65HVD230) - src/balance.c: wire vesc_comm_send_current() into PID output path Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
32 lines
978 B
C
32 lines
978 B
C
#ifndef VESC_COMM_H
|
|
#define VESC_COMM_H
|
|
|
|
/*
|
|
* VESC Communication Interface — Dual FSESC 6.7 Pro (FW 6.6)
|
|
*
|
|
* Motor1: connected directly to USART6 (PC6=TX, PC7=RX) @ 115200
|
|
* Motor2: bridged via COMM_FORWARD_CAN (cmd 34) to CAN ID 68 on motor1
|
|
*
|
|
* Transport implementations:
|
|
* src/vesc_uart.c — USART6 UART (active)
|
|
* src/vesc_can.c — STM32 CAN + SN65HVD230 (phase 2, stub)
|
|
*/
|
|
|
|
/* Initialise the VESC transport (USART6 GPIO + peripheral) */
|
|
void vesc_comm_init(void);
|
|
|
|
/*
|
|
* Send a current command to both VESCs.
|
|
* current_motor1/2 in Amperes (positive = forward, negative = reverse).
|
|
* Range limited by VESC motor configuration; typical max ±30 A for FSESC 6.7 Pro.
|
|
*/
|
|
void vesc_comm_send_current(float current_motor1, float current_motor2);
|
|
|
|
/*
|
|
* Send a duty-cycle command to both VESCs.
|
|
* duty_motor1/2 in range -1.0 .. +1.0 (full reverse / full forward).
|
|
*/
|
|
void vesc_comm_send_duty(float duty_motor1, float duty_motor2);
|
|
|
|
#endif /* VESC_COMM_H */
|