sl-firmware 291dd689f8 feat: remove all STM32/Mamba/BlackPill references — ESP32-S3 only
Archive STM32 firmware to legacy/stm32/:
- src/, include/, lib/USB_CDC/, platformio.ini, test stubs, flash_firmware.py
- test/test_battery_adc.c, test_hw_button.c, test_pid_schedule.c, test_vesc_can.c, test_can_watchdog.c
- USB_CDC_BUG.md

Rename: stm32_protocol → esp32_protocol, mamba_protocol → balance_protocol,
  stm32_cmd_node → esp32_cmd_node, stm32_cmd_params → esp32_cmd_params,
  stm32_cmd.launch.py → esp32_cmd.launch.py,
  test_stm32_protocol → test_esp32_protocol, test_stm32_cmd_node → test_esp32_cmd_node

Content cleanup across all files:
- Mamba F722S → ESP32-S3 BALANCE
- BlackPill → ESP32-S3 IO
- STM32F722/F7xx → ESP32-S3
- stm32Mode/Version/Port → esp32Mode/Version/Port
- STM32 State/Mode labels → ESP32 State/Mode
- Jetson Nano → Jetson Orin Nano Super
- /dev/stm32 → /dev/esp32
- stm32_bridge → esp32_bridge
- STM32 HAL → ESP-IDF

docs/SALTYLAB.md:
- Update "Drone FC Details" to describe ESP32-S3 BALANCE board (Waveshare ESP32-S3 Touch LCD 1.28)
- Replace verbose "Self-Balancing Control" STM32 section with brief note pointing to SAUL-TEE-SYSTEM-REFERENCE.md

TEAM.md: Update Embedded Firmware Engineer role to ESP32-S3 / ESP-IDF

No new functionality — cleanup only.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-04 08:41:26 -04:00

55 lines
2.2 KiB
C

#ifndef CAN_DRIVER_H
#define CAN_DRIVER_H
#include <stdint.h>
#include <stdbool.h>
#define CAN_NUM_MOTORS 2u
#define CAN_NODE_LEFT 0u
#define CAN_NODE_RIGHT 1u
#define CAN_ID_VEL_CMD_BASE 0x100u
#define CAN_ID_ENABLE_CMD_BASE 0x110u
#define CAN_ID_FEEDBACK_BASE 0x200u
#define CAN_FILTER_STDID 0x200u
#define CAN_FILTER_MASK 0x7E0u
#define CAN_PRESCALER 6u
#define CAN_TX_RATE_HZ 100u
#define CAN_NODE_TIMEOUT_MS 100u
#define CAN_WDOG_RESTART_MS 200u
typedef struct { int16_t velocity_rpm; int16_t torque_x100; } can_cmd_t;
typedef struct {
int16_t velocity_rpm; int16_t current_ma; int16_t position_x100;
int8_t temperature_c; uint8_t fault; uint32_t last_rx_ms;
} can_feedback_t;
typedef struct {
uint32_t tx_count; uint32_t rx_count; uint16_t err_count;
uint8_t bus_off; uint8_t _pad;
} can_stats_t;
typedef enum {
CAN_ERR_NOMINAL = 0u, CAN_ERR_WARNING = 1u,
CAN_ERR_ERROR_PASSIVE = 2u, CAN_ERR_BUS_OFF = 3u,
} can_error_state_t;
typedef struct {
uint32_t restart_count; uint32_t busoff_count;
uint16_t errpassive_count; uint16_t errwarn_count;
can_error_state_t error_state; uint8_t tec; uint8_t rec; uint8_t busoff_pending;
uint32_t busoff_ms;
} can_wdog_t;
void can_driver_init(void);
void can_driver_send_cmd(uint8_t node_id, const can_cmd_t *cmd);
void can_driver_send_enable(uint8_t node_id, bool enable);
bool can_driver_get_feedback(uint8_t node_id, can_feedback_t *out);
bool can_driver_is_alive(uint8_t node_id, uint32_t now_ms);
void can_driver_get_stats(can_stats_t *out);
void can_driver_process(void);
can_error_state_t can_driver_watchdog_tick(uint32_t now_ms);
void can_driver_get_wdog(can_wdog_t *out);
#ifdef TEST_HOST
void can_driver_inject_esr(uint32_t esr_val);
#endif
typedef void (*can_ext_frame_cb_t)(uint32_t ext_id, const uint8_t *data, uint8_t len);
typedef void (*can_std_frame_cb_t)(uint16_t std_id, const uint8_t *data, uint8_t len);
void can_driver_set_ext_cb(can_ext_frame_cb_t cb);
void can_driver_set_std_cb(can_std_frame_cb_t cb);
void can_driver_send_ext(uint32_t ext_id, const uint8_t *data, uint8_t len);
void can_driver_send_std(uint16_t std_id, const uint8_t *data, uint8_t len);
#endif /* CAN_DRIVER_H */