#ifndef API_UART_H #define API_UART_H #include "CH58x_common.h" #include "api-gpio.h" #include "fifo.h" #define RxSize (127) #define UART_NUMBER (2) typedef struct { __IO uint8_t MCR; __IO uint8_t IER; __IO uint8_t FCR; __IO uint8_t LCR; __IO uint8_t IIR; __IO uint8_t LSR; __IO uint8_t MSR; __IO uint8_t RBR; __IO uint8_t THR; __IO uint8_t RFC; __IO uint8_t TFC; __IO uint16_t DL; __IO uint8_t DIV; __IO uint8_t ADR; } UART_TypeDef; #define UARTDIS (0x400) #define Uart(x) ((UART_TypeDef *)(0x40003000 + (x) * UARTDIS)) typedef enum { DataBit_5 = 0, DataBit_6, DataBit_7, DataBit_8, } DataBits_t; typedef enum { StopBit_1 = 0, StopBit_2, } StopBits_t; typedef enum { Parity_None = 0, Parity_Odd,//奇校验 Parity_Even, } Parity_t; typedef struct { uint8_t Len; uint8_t RxBuff[RxSize];//串口接受缓存区 Fifo_t RxFifo; } Uart_t; #define println(fmt, ...) printf(fmt "\r\n", ##__VA_ARGS__) #define printHex(buf, size) do{for(int p__i=0;p__i