75 lines
1.5 KiB
C
75 lines
1.5 KiB
C
#ifndef _UART_BOARD_H
|
|
#define _UART_BOARD_H
|
|
#include <stdint.h>
|
|
|
|
typedef enum UartId_t
|
|
{
|
|
G0_LPUART1,
|
|
G0_LPUART2,
|
|
G0_UART1,
|
|
G0_UART2,
|
|
G0_UART3,
|
|
G0_UART4,
|
|
G0_UART5,
|
|
G0_UART6,
|
|
G0_UARTM
|
|
} UartId_t;
|
|
|
|
|
|
#define PARITY_EVEN_MASK 0X02
|
|
#define PARITY_ODD_MASK 0x04
|
|
#define PARITY_NONE_MASK 0x00
|
|
#define DATA8_MASK 0X00
|
|
#define DATA7_MASK 0X01
|
|
|
|
|
|
#define PARITY_DATA_8N1 (DATA8_MASK | PARITY_NONE_MASK) // 00H
|
|
#define PARITY_DATA_7N1 (DATA7_MASK | PARITY_NONE_MASK) // 01H
|
|
#define PARITY_DATA_8E1 (DATA8_MASK | PARITY_EVEN_MASK) // 02H
|
|
#define PARITY_DATA_7E1 (DATA7_MASK | PARITY_EVEN_MASK) // 03H
|
|
#define PARITY_DATA_8O1 (DATA8_MASK | PARITY_ODD_MASK) // 04H
|
|
#define PARITY_DATA_7O1 (DATA7_MASK | PARITY_ODD_MASK) // 05H
|
|
|
|
typedef struct UartDrv_t
|
|
{
|
|
UartId_t Id;// 串口号
|
|
uint32_t BaudRate;// 波特率
|
|
uint32_t DataParity; // 数据位
|
|
char * rx_buffer;
|
|
uint16_t rx_size;
|
|
void (*rxdone) (void); // 接受完成回调函数
|
|
uint32_t rx_timer;
|
|
} UartDrv_t;
|
|
|
|
|
|
|
|
extern UartDrv_t g_DebugDrv ;
|
|
extern UartDrv_t g_U4851Drv ;
|
|
extern UartDrv_t g_U4852Drv ;
|
|
extern UartDrv_t g_U4853Drv ;
|
|
extern UartDrv_t g_ViewDrv ;
|
|
extern UartDrv_t g_ETH1Drv ;
|
|
extern UartDrv_t g_ETH2Drv ;
|
|
extern UartDrv_t g_GSMDrv ;
|
|
extern UartDrv_t g_LoRaDrv ;
|
|
|
|
|
|
|
|
|
|
// function
|
|
|
|
|
|
extern void MX_UART_TickHandle (void);
|
|
extern void MX_UART_Init (UartDrv_t *drv);
|
|
extern void MX_UART_IRQHandle (void);
|
|
extern void MX_UART_Clear (UartDrv_t * drv);
|
|
extern void MX_UART_PutChar (UartDrv_t * drv, char ch);
|
|
extern void MX_UART_PutBuffer (UartDrv_t * drv, char *buff, int size);
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|