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

80 lines
2.5 KiB
C

#ifndef ESC_BACKEND_H
#define ESC_BACKEND_H
#include <stdint.h>
#include <stdbool.h>
/*
* ESC Backend Abstraction Layer
*
* Provides a pluggable interface for different ESC implementations:
* - Hoverboard (EFeru FOC firmware, UART @ 115200)
* - VESC (via UART @ 921600, with balance mode) — future
*
* Allows motor_driver.c to remain ESC-agnostic. Backend selection
* via ESC_BACKEND compile-time define in config.h.
*
* Issue #388: ESC abstraction layer
* Blocks Issue #383: VESC integration
*/
/* Telemetry snapshot from ESC (polled on-demand) */
typedef struct {
int16_t speed; /* Motor speed (PWM duty or RPM, backend-dependent) */
int16_t steer; /* Steering position (0 = centered) */
uint16_t voltage_mv; /* Battery voltage in millivolts */
int16_t current_ma; /* Motor current in milliamps (signed: discharge/charge) */
int16_t temperature_c; /* ESC temperature in °C */
uint16_t fault; /* Fault code (backend-specific) */
} esc_telemetry_t;
/* Virtual function table for ESC backends */
typedef struct {
/* Initialize ESC hardware and UART (called once at startup) */
void (*init)(void);
/* Send motor command to ESC (called at ~50Hz from motor_driver_update)
* speed: -1000..+1000 (forward/reverse)
* steer: -1000..+1000 (left/right)
*/
void (*send)(int16_t speed, int16_t steer);
/* Emergency stop: send zero and disable output
* (called from safety or mode manager)
*/
void (*estop)(void);
/* Query current ESC state
* Returns latest telemetry snapshot (may be cached/stale on some backends).
* Safe to call from any context (non-blocking).
*/
void (*get_telemetry)(esc_telemetry_t *out);
/* Optional: resume from estop (not all backends use this) */
void (*resume)(void);
} esc_backend_t;
/*
* Register a backend implementation at runtime.
* Typically called during init sequence before motor_driver_init().
*/
void esc_backend_register(const esc_backend_t *backend);
/*
* Get the currently active backend.
* Returns pointer to vtable; nullptr if no backend registered.
*/
const esc_backend_t *esc_backend_get(void);
/*
* High-level convenience wrappers (match motor_driver.c interface).
* These call through the active backend if registered.
*/
void esc_init(void);
void esc_send(int16_t speed, int16_t steer);
void esc_estop(void);
void esc_resume(void);
void esc_get_telemetry(esc_telemetry_t *out);
#endif /* ESC_BACKEND_H */