/* * 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 #include /* === 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