Files
2026-04-15 09:55:17 +08:00

56 lines
1.4 KiB
C

/**
* @file uart_cmd.h
* @brief UART command interface via PB5(RX) / PB3(TX)
*/
#ifndef __uart_cmd_H__
#define __uart_cmd_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "hal_device.h"
#include <stdbool.h>
#include <stdint.h>
//=============================================================================
// Constant Definition
//=============================================================================
#define UART_CMD_BAUD_RATE 115200
#define UART_CMD_RX_BUF_SIZE 128
#define FW_VERSION "0.0.1"
//=============================================================================
// Global Data Definition
//=============================================================================
extern volatile char g_uart_rx_buf[UART_CMD_RX_BUF_SIZE];
extern volatile uint16_t g_uart_rx_idx;
extern volatile bool g_uart_rx_complete;
//=============================================================================
// Public Function Definition
//=============================================================================
/**
* @brief Initialize UART0 with PB3(TX) PB5(RX), enable RX interrupt
*/
void uart_cmd_init(void);
/**
* @brief Process received command (call in main loop when g_uart_rx_complete is set)
*/
void uart_cmd_process(void);
/**
* @brief Send a null-terminated string via UART0 TX
*/
void uart_cmd_send_str(const char *str);
#ifdef __cplusplus
}
#endif
#endif