76 lines
1.8 KiB
C
76 lines
1.8 KiB
C
#ifndef _UART_H_
|
|
#define _UART_H_
|
|
|
|
#include "apt32f102.h"
|
|
#include "apt32f102_uart.h"
|
|
|
|
#define Recv_2400_TimeOut 20 //ms
|
|
#define Recv_9600_TimeOut 10 //ms
|
|
#define Recv_115200_TimeOut 3 //ms
|
|
|
|
#define USART_BUFFER_NUM 3
|
|
#define USART_BUFFER_SIZE 100
|
|
|
|
#define UART_SEND_BUFFER_NUM 10
|
|
#define UART_SEND_BUFFER_SIZE 20
|
|
|
|
/*调试信息相关定义*/
|
|
#ifndef DBG_LOG_EN
|
|
#define DBG_LOG_EN 0 //DEBUG LOG 输出总开关
|
|
#endif
|
|
|
|
/*调试信息初始状态*/
|
|
#define DBG_OPT_Debug_STATUS 0 //临时调试信息打印开关
|
|
#define DBG_OPT_DEVICE_STATUS 0 //设备驱动层打印调试信息打印开关
|
|
#define DBG_OPT_SYS_STATUS 0 //系统调试信息打印开关
|
|
|
|
/*调试信息输出控制位*/
|
|
#define DBG_BIT_Debug_STATUS 2
|
|
#define DBG_BIT_DEVICE_STATUS 1
|
|
#define DBG_BIT_SYS_STATUS 0
|
|
|
|
#if DBG_LOG_EN
|
|
#define DBG_Printf(data,len) UARTTransmit(UART1,data,len)
|
|
#else
|
|
#define DBG_Printf
|
|
#endif
|
|
|
|
typedef U8_T (*Uart_prt)(U8_T *,U16_T);
|
|
|
|
typedef enum
|
|
{
|
|
UART_0,
|
|
UART_1,
|
|
UART_2,
|
|
UART_3,
|
|
UART_MAX,
|
|
}UART_IDX;
|
|
|
|
typedef struct{
|
|
U8_T RecvBuffer[USART_BUFFER_SIZE];
|
|
U8_T DealBuff[USART_BUFFER_SIZE];
|
|
U8_T Receiving;
|
|
|
|
U16_T RecvLen;
|
|
U16_T DealLen;
|
|
|
|
U32_T RecvTimeout;
|
|
U32_T RecvIdleTiming;
|
|
|
|
Uart_prt processing_cf; //处理函数指针
|
|
}UART_t;
|
|
|
|
extern U32_T Dbg_Switch;
|
|
|
|
void UARTx_Init(UART_IDX uart_id, Uart_prt prt_cf);
|
|
void UART1_RecvINT_Processing(char data);
|
|
void UART1_TASK(void);
|
|
|
|
void Dbg_NoTick_Println(int DbgOptBit, const char *cmd, ...);
|
|
void Dbg_Print(int DbgOptBit, const char *cmd, ...);
|
|
void Dbg_Println(int DbgOptBit, const char *cmd, ...);
|
|
void Dbg_Print_Buff(int DbgOptBit, const char *cmd, U8_T *buff,U16_T len);
|
|
|
|
|
|
#endif
|