12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- /********************************************************************************
- * File Name: Serial.h
- * Function Describe: Header file for Serial.c
- * Explain:
- * Writer: ShiLiangWen
- * Date: 2015-1-30
- *******************************************************************************/
- #ifndef _Serial_H__
- #define _Serial_H__
- /***************************************************************************/
- #include <rtl.h>
- #define COM_SEL_MCU 0
- #define COM_SEL_GPS 1
- #define COM_SEL_MODEM 2
- typedef enum {INF = 0, DEBUG =1} TRACE_TYPE;
- #define UART1_TX_USE_DMA 0
- #define UART2_TX_USE_DMA 0
- #define UART3_TX_USE_DMA 0
- #define RS485_DIR_PIN GPIO_Pin_8
- #define RS485_DIR_PORT GPIOA
- #define RS485_DIR_HIGH RS485_DIR_PORT->BSRR = RS485_DIR_PIN
- #define RS485_DIR_LOW RS485_DIR_PORT->BRR = RS485_DIR_PIN
- #if UART1_TX_USE_DMA==0
- #define UART1_TX_BUFFER_SIZE 10 //UART1 USE FOR PC
- #else
- #define UART1_TX_BUFFER_SIZE 200 //UART1 USE FOR PC
- #endif
- #if UART2_TX_USE_DMA==0
- #define UART2_TX_BUFFER_SIZE 1 //UART1 USE FOR PC
- #else
- #define UART2_TX_BUFFER_SIZE 260 //UART1 USE FOR PC
- #endif
- #if UART3_TX_USE_DMA==0
- #define UART3_TX_BUFFER_SIZE 1 //UART3 USE FOR MODEM
- #else
- #define UART3_TX_BUFFER_SIZE 300 //UART3 USE FOR MODEM
- #endif
- #define UART1_RX_BUFFER_SIZE 100
- #define UART2_RX_BUFFER_SIZE 230
- #define UART3_RX_BUFFER_SIZE 1200
- extern unsigned char RxBuffer1[UART1_RX_BUFFER_SIZE];
- extern unsigned char TxBuffer1[UART1_TX_BUFFER_SIZE];
- extern unsigned char ModbusBuf[UART1_RX_BUFFER_SIZE];
- extern unsigned char g_usUart1RecvLen;
- extern unsigned char RxBuffer2[UART2_RX_BUFFER_SIZE];
- extern unsigned char RxBuffer3[UART3_RX_BUFFER_SIZE];
- extern unsigned char TxBuffer3[UART3_TX_BUFFER_SIZE];
- extern unsigned short g_usRx2Len;
- extern unsigned char g_ucUARTSel;
- void Uart1Init(int mode);
- void Uart2Init(void);
- void Uart3Init(void);
- void UART1RxTxISRHandler(void);//串口1中断中回调此函数
- void UART2RxTxISRHandler(void);//串口2中断中回调此函数
- void UART3RxTxISRHandler(void);//串口3中断中回调此函数
- extern unsigned char g_ucDebugLog;//0--不打印DEBUG信息 1--打印DEBUG信息
- void SlwTrace(TRACE_TYPE type,char *buf);
- void ComSelect(unsigned char sel);
- void Uart1Send(char *txbuf,int len);
- void Uart2Send(char *txbuf,int len);
- void Uart3Send(char *txbuf,int len);
- void Uart3RecvProcess(void);
- //通过DMA发送
- void USART1_Send(char *pbuffer, unsigned short size);
- void USART1_SendOK_IQ(void);
- void USART1_SendWaitCompleted(void);
- //void USART3_Send(char *pbuffer, unsigned short size);
- //void USART3_SendOK_IQ(void);
- //void USART3_SendWaitCompleted(void);
- extern unsigned short g_usUSART_WordLength;
- extern unsigned char Uart1CheckPacket(unsigned char *pPackBuf,unsigned char **pData,unsigned char *pDataLen);
- /***************************************************************************/
- #endif
|