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>
77 lines
2.2 KiB
C
77 lines
2.2 KiB
C
/*
|
|
* face_uart.h — UART Command Interface for Face Animations
|
|
*
|
|
* Receives emotion commands from Jetson Orin via UART (USART3 by default).
|
|
* Parses simple text commands and updates face animation state.
|
|
*
|
|
* PROTOCOL:
|
|
* Text-based commands (newline-terminated):
|
|
* HAPPY — Set emotion to happy
|
|
* SAD — Set emotion to sad
|
|
* CURIOUS — Set emotion to curious
|
|
* ANGRY — Set emotion to angry
|
|
* SLEEP — Set emotion to sleeping
|
|
* NEUTRAL — Set emotion to neutral
|
|
* BLINK — Trigger immediate blink
|
|
* STATUS — Echo current emotion + animation state
|
|
*
|
|
* Example:
|
|
* > HAPPY\n
|
|
* < OK: HAPPY\n
|
|
*
|
|
* INTERFACE:
|
|
* - UART3 (PB10=TX, PB11=RX) at 115200 baud
|
|
* - RX ISR pushes bytes into ring buffer
|
|
* - face_uart_process() checks for complete commands (polling)
|
|
* - Case-insensitive command parsing
|
|
* - Echoes command results to TX for debugging
|
|
*
|
|
* API:
|
|
* - face_uart_init() — Configure UART3 @ 115200
|
|
* - face_uart_process() — Parse and execute commands (call from main loop)
|
|
* - face_uart_rx_isr() — Called by UART3 RX interrupt
|
|
* - face_uart_send() — Send response string (used internally)
|
|
*/
|
|
|
|
#ifndef FACE_UART_H
|
|
#define FACE_UART_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
/* === Configuration === */
|
|
#define FACE_UART_INSTANCE USART3 /* USART3 (PB10=TX, PB11=RX) */
|
|
#define FACE_UART_BAUD 115200 /* 115200 baud */
|
|
#define FACE_UART_RX_BUF_SZ 128 /* RX ring buffer size */
|
|
|
|
/* === Public API === */
|
|
|
|
/**
|
|
* Initialize UART for face commands.
|
|
* Configures USART3 @ 115200, enables RX interrupt.
|
|
*/
|
|
void face_uart_init(void);
|
|
|
|
/**
|
|
* Process any pending RX data and execute commands.
|
|
* Should be called periodically from main loop (or low-priority task).
|
|
* Returns immediately if no complete command available.
|
|
*/
|
|
void face_uart_process(void);
|
|
|
|
/**
|
|
* UART3 RX interrupt handler.
|
|
* Called by HAL when a byte is received.
|
|
* Pushes byte into ring buffer.
|
|
*/
|
|
void face_uart_rx_isr(uint8_t byte);
|
|
|
|
/**
|
|
* Send a response string to UART3 TX.
|
|
* Used for echoing status/ack messages.
|
|
* Non-blocking (pushes to TX queue).
|
|
*/
|
|
void face_uart_send(const char *str);
|
|
|
|
#endif // FACE_UART_H
|