优化实现串口驱动,SPI驱动 W25QXX还需要初始化验证修复

This commit is contained in:
冯佳
2026-01-23 09:59:43 +08:00
parent 51e8d79f78
commit b166bee1a9
69 changed files with 6253 additions and 1178 deletions

View File

@ -38,10 +38,24 @@ typedef enum {
HAL_UART_DATABITS_9 = 1U
} hal_uart_databits_t;
/**
* @brief UART instance identifier definitions
*/
typedef enum {
HAL_UART_INSTANCE_1 = 0U,
HAL_UART_INSTANCE_2,
HAL_UART_INSTANCE_3,
HAL_UART_INSTANCE_4,
HAL_UART_INSTANCE_5,
HAL_UART_INSTANCE_6,
HAL_UART_INSTANCE_MAX
} hal_uart_instance_t;
/**
* @brief UART configuration structure
*/
typedef struct {
hal_uart_instance_t instance;
uint32_t baudrate;
hal_uart_parity_t parity;
hal_uart_stopbits_t stopbits;
@ -54,36 +68,40 @@ typedef struct {
void hal_uart_init(void);
/**
* @brief Configure UART parameters
* @brief Configure UART parameters for specific instance
* @param config: UART configuration structure
*/
void hal_uart_config(const hal_uart_config_t *config);
/**
* @brief Send data over UART
* @brief Send data over specific UART instance
* @param instance: UART instance identifier
* @param data: Pointer to data buffer
* @param length: Data length in bytes
*/
void hal_uart_send(const uint8_t *data, size_t length);
void hal_uart_send(hal_uart_instance_t instance, const uint8_t *data, size_t length);
/**
* @brief Receive data over UART
* @brief Receive data from specific UART instance
* @param instance: UART instance identifier
* @param data: Pointer to data buffer
* @param length: Data length to receive in bytes
* @retval Number of bytes received
*/
size_t hal_uart_receive(uint8_t *data, size_t length);
size_t hal_uart_receive(hal_uart_instance_t instance, uint8_t *data, size_t length);
/**
* @brief Check if UART is ready to send
* @brief Check if specific UART instance is ready to send
* @param instance: UART instance identifier
* @retval 1 if ready, 0 otherwise
*/
uint8_t hal_uart_is_tx_ready(void);
uint8_t hal_uart_is_tx_ready(hal_uart_instance_t instance);
/**
* @brief Check if UART has data to receive
* @brief Check if specific UART instance has data to receive
* @param instance: UART instance identifier
* @retval 1 if data available, 0 otherwise
*/
uint8_t hal_uart_is_rx_ready(void);
uint8_t hal_uart_is_rx_ready(hal_uart_instance_t instance);
#endif /* HAL_UART_H */