SmartCar-V1/Code/bsp/inc/bsp_usart.h

58 lines
1.6 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __BSP_USART_H__
#define __BSP_USART_H__
#include "stdint.h"
#include "stm32f10x.h"
#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);
void bsp_usart_debug_init(void);
void bsp_usart_IrController_init(void);
// void bsp_usart_send_data(usart_type_Enum e_usart_type, uint16_t us_tx_data);
// uint16_t bsp_usart_receive_data(usart_type_Enum e_usart_type);
#endif