Serial.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /********************************************************************************
  2. * File Name: Serial.h
  3. * Function Describe: Header file for Serial.c
  4. * Explain:
  5. * Writer: ShiLiangWen
  6. * Date: 2015-1-30
  7. *******************************************************************************/
  8. #ifndef _Serial_H__
  9. #define _Serial_H__
  10. /***************************************************************************/
  11. #include <rtl.h>
  12. #define COM_SEL_MCU 0
  13. #define COM_SEL_GPS 1
  14. #define COM_SEL_MODEM 2
  15. typedef enum {INF = 0, DEBUG =1} TRACE_TYPE;
  16. #define UART1_TX_USE_DMA 0
  17. #define UART2_TX_USE_DMA 0
  18. #define UART3_TX_USE_DMA 0
  19. #define RS485_DIR_PIN GPIO_Pin_8
  20. #define RS485_DIR_PORT GPIOA
  21. #define RS485_DIR_HIGH RS485_DIR_PORT->BSRR = RS485_DIR_PIN
  22. #define RS485_DIR_LOW RS485_DIR_PORT->BRR = RS485_DIR_PIN
  23. #if UART1_TX_USE_DMA==0
  24. #define UART1_TX_BUFFER_SIZE 10 //UART1 USE FOR PC
  25. #else
  26. #define UART1_TX_BUFFER_SIZE 200 //UART1 USE FOR PC
  27. #endif
  28. #if UART2_TX_USE_DMA==0
  29. #define UART2_TX_BUFFER_SIZE 1 //UART1 USE FOR PC
  30. #else
  31. #define UART2_TX_BUFFER_SIZE 260 //UART1 USE FOR PC
  32. #endif
  33. #if UART3_TX_USE_DMA==0
  34. #define UART3_TX_BUFFER_SIZE 1 //UART3 USE FOR MODEM
  35. #else
  36. #define UART3_TX_BUFFER_SIZE 300 //UART3 USE FOR MODEM
  37. #endif
  38. #define UART1_RX_BUFFER_SIZE 100
  39. #define UART2_RX_BUFFER_SIZE 230
  40. #define UART3_RX_BUFFER_SIZE 1200
  41. extern unsigned char RxBuffer1[UART1_RX_BUFFER_SIZE];
  42. extern unsigned char TxBuffer1[UART1_TX_BUFFER_SIZE];
  43. extern unsigned char ModbusBuf[UART1_RX_BUFFER_SIZE];
  44. extern unsigned char g_usUart1RecvLen;
  45. extern unsigned char RxBuffer2[UART2_RX_BUFFER_SIZE];
  46. extern unsigned char RxBuffer3[UART3_RX_BUFFER_SIZE];
  47. extern unsigned char TxBuffer3[UART3_TX_BUFFER_SIZE];
  48. extern unsigned short g_usRx2Len;
  49. extern unsigned char g_ucUARTSel;
  50. void Uart1Init(int mode);
  51. void Uart2Init(void);
  52. void Uart3Init(void);
  53. void UART1RxTxISRHandler(void);//串口1中断中回调此函数
  54. void UART2RxTxISRHandler(void);//串口2中断中回调此函数
  55. void UART3RxTxISRHandler(void);//串口3中断中回调此函数
  56. extern unsigned char g_ucDebugLog;//0--不打印DEBUG信息 1--打印DEBUG信息
  57. void SlwTrace(TRACE_TYPE type,char *buf);
  58. void ComSelect(unsigned char sel);
  59. void Uart1Send(char *txbuf,int len);
  60. void Uart2Send(char *txbuf,int len);
  61. void Uart3Send(char *txbuf,int len);
  62. void Uart3RecvProcess(void);
  63. //通过DMA发送
  64. void USART1_Send(char *pbuffer, unsigned short size);
  65. void USART1_SendOK_IQ(void);
  66. void USART1_SendWaitCompleted(void);
  67. //void USART3_Send(char *pbuffer, unsigned short size);
  68. //void USART3_SendOK_IQ(void);
  69. //void USART3_SendWaitCompleted(void);
  70. extern unsigned short g_usUSART_WordLength;
  71. extern unsigned char Uart1CheckPacket(unsigned char *pPackBuf,unsigned char **pData,unsigned char *pDataLen);
  72. /***************************************************************************/
  73. #endif