sl-firmware fa75c442a7 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 09:00:38 -04:00

62 lines
1.9 KiB
C

#ifndef HW_BUTTON_H
#define HW_BUTTON_H
#include <stdint.h>
#include <stdbool.h>
/*
* hw_button — hardware button debounce + gesture detection (Issue #682).
*
* Debounce FSM:
* IDLE → (raw press detected) → DEBOUNCING
* DEBOUNCING → (still pressed after BTN_DEBOUNCE_MS) → HELD
* HELD → (released) → classify press type, back to IDLE
*
* Press types:
* SHORT held < BTN_LONG_MIN_MS from confirmed start
* LONG held >= BTN_LONG_MIN_MS
*
* Sequence detection:
* [SHORT, SHORT, LONG] -> BTN_EVENT_REARM_COMBO (fires on LONG release)
* [SHORT] + BTN_COMMIT_MS quiet timeout -> BTN_EVENT_PARK
*
* Config constants (can be overridden in config.h):
* BTN_DEBOUNCE_MS 20 ms debounce window
* BTN_LONG_MIN_MS 1500 ms threshold for LONG press
* BTN_COMMIT_MS 500 ms quiet after lone SHORT -> PARK
* BTN_SEQ_TIMEOUT_MS 3000 ms sequence window; expired sequence is abandoned
* BTN_PORT GPIOC
* BTN_PIN GPIO_PIN_2
*/
typedef enum {
BTN_EVENT_NONE = 0,
BTN_EVENT_PARK = 1, /* single short press + quiet */
BTN_EVENT_REARM_COMBO = 2, /* SHORT + SHORT + LONG */
} hw_btn_event_t;
/*
* hw_button_init() — configure GPIO (active-low pull-up), zero FSM state.
* Call once at startup.
*/
void hw_button_init(void);
/*
* hw_button_tick(now_ms) — advance debounce FSM and sequence detector.
* Call every ms from the main loop. Returns BTN_EVENT_NONE unless a
* complete gesture was recognised this tick.
*/
hw_btn_event_t hw_button_tick(uint32_t now_ms);
/*
* hw_button_is_pressed() — true while button is confirmed held (post-debounce).
*/
bool hw_button_is_pressed(void);
#ifdef TEST_HOST
/* Inject a simulated raw pin state for host-side unit tests. */
void hw_button_inject(bool pressed);
#endif
#endif /* HW_BUTTON_H */