2024-11-30 10:27:03 +08:00
|
|
|
|
#ifndef __BSP_USART_H__
|
|
|
|
|
#define __BSP_USART_H__
|
|
|
|
|
|
|
|
|
|
#include "stdint.h"
|
2025-05-08 23:18:49 +08:00
|
|
|
|
#include "stm32f10x.h"
|
2024-11-30 10:27:03 +08:00
|
|
|
|
|
2025-05-08 23:18:49 +08:00
|
|
|
|
#define UART1_FIFO_EN 0
|
|
|
|
|
#define UART2_FIFO_EN 1
|
|
|
|
|
#define UART3_FIFO_EN 0
|
|
|
|
|
|
|
|
|
|
#if UART1_FIFO_EN == 1
|
|
|
|
|
#define UART1_TX_BUF_SIZE 1*1024
|
|
|
|
|
#define UART1_RX_BUF_SIZE 1*1024
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if UART2_FIFO_EN == 1
|
|
|
|
|
#define UART2_TX_BUF_SIZE 1*1024
|
|
|
|
|
#define UART2_RX_BUF_SIZE 1*1024
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if UART3_FIFO_EN == 1
|
|
|
|
|
#define UART3_TX_BUF_SIZE 1*1024
|
|
|
|
|
#define UART3_RX_BUF_SIZE 1*1024
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* 串口设备结构体 */
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
USART_TypeDef *uart; /* STM32内部串口设备指针 */
|
|
|
|
|
uint8_t *pTxBuf; /* 发送缓冲区 */
|
|
|
|
|
uint8_t *pRxBuf; /* 接收缓冲区 */
|
|
|
|
|
uint16_t usTxBufSize; /* 发送缓冲区大小 */
|
|
|
|
|
uint16_t usRxBufSize; /* 接收缓冲区大小 */
|
|
|
|
|
uint16_t usTxWrite; /* 发送缓冲区写指针 */
|
|
|
|
|
uint16_t usTxRead; /* 发送缓冲区读指针 */
|
|
|
|
|
uint16_t usTxCount; /* 等待发送的数据个数 */
|
|
|
|
|
|
|
|
|
|
uint16_t usRxWrite; /* 接收缓冲区写指针 */
|
|
|
|
|
uint16_t usRxRead; /* 接收缓冲区读指针 */
|
|
|
|
|
uint16_t usRxCount; /* 还未读取的新数据个数 */
|
|
|
|
|
|
|
|
|
|
void (*SendBefor)(void); /* 开始发送之前的回调函数指针(主要用于RS485切换到发送模式) */
|
|
|
|
|
void (*SendOver)(void); /* 发送完毕的回调函数指针(主要用于RS485将发送模式切换为接收模式) */
|
|
|
|
|
void (*ReciveNew)(uint8_t _byte); /* 串口收到数据的回调函数指针 */
|
|
|
|
|
}UART_T;
|
|
|
|
|
|
|
|
|
|
void bsp_usartTotalInit(void);
|
2024-11-30 10:27:03 +08:00
|
|
|
|
|
2025-05-05 22:37:13 +08:00
|
|
|
|
void bsp_usart_debug_init(void);
|
2024-11-30 10:27:03 +08:00
|
|
|
|
|
2025-05-08 23:18:49 +08:00
|
|
|
|
void bsp_usart_IrController_init(void);
|
2025-05-05 22:37:13 +08:00
|
|
|
|
// void bsp_usart_send_data(usart_type_Enum e_usart_type, uint16_t us_tx_data);
|
2024-11-30 10:27:03 +08:00
|
|
|
|
|
2025-05-05 22:37:13 +08:00
|
|
|
|
// uint16_t bsp_usart_receive_data(usart_type_Enum e_usart_type);
|
2024-11-30 10:27:03 +08:00
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|