Serial.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #if UART1_TX_USE_DMA==0
  19. #define UART1_TX_BUFFER_SIZE 1 //UART1 USE FOR PC
  20. #else
  21. #define UART1_TX_BUFFER_SIZE 200 //UART1 USE FOR PC
  22. #endif
  23. #define UART1_RX_BUFFER_SIZE 200
  24. #define UART3_TX_BUFFER_SIZE 1 //UART2 USE FOR GPS
  25. #define UART3_RX_BUFFER_SIZE 300 //(IAP_RX_BUF+20)//+ZIPRECVU:1,256,xxx
  26. #if UART2_TX_USE_DMA==0
  27. #define UART2_TX_BUFFER_SIZE 1 //UART3 USE FOR MODEM
  28. #else
  29. #define UART2_TX_BUFFER_SIZE 200 //UART3 USE FOR MODEM 200
  30. #endif
  31. #define UART2_RX_BUFFER_SIZE 1024+256 //(IAP_RX_BUF+20)//+ZIPRECVU:1,256,xxx
  32. extern unsigned char RxBuffer1[];
  33. extern unsigned char TxBuffer1[];
  34. extern unsigned short g_usUart1RecvLen;
  35. extern unsigned char RxBuffer3[];
  36. extern unsigned char TxBuffer3[];
  37. extern unsigned short g_usUart3RecvLen;
  38. extern unsigned char RxBuffer2[];
  39. extern unsigned char TxBuffer2[];
  40. extern unsigned short g_usRx2Len;
  41. extern unsigned char g_ucUARTSel;
  42. extern unsigned short rx1_ct;
  43. void Uart1Init();
  44. void Uart2Init(void);
  45. void Uart3Init(void);
  46. void UART1RxTxISRHandler(void);//串口1中断中回调此函数
  47. void UART3RxTxISRHandler(void);//串口2中断中回调此函数
  48. void UART2RxTxISRHandler(void);//串口3中断中回调此函数
  49. void SlwTrace(TRACE_TYPE type,char *buf,char needEnd);
  50. void ComSelect(unsigned char sel);
  51. void Uart1Send(char *txbuf,int len);
  52. void Uart2Send(unsigned char *txbuf,unsigned short len);
  53. void Uart1RxEnable(int en);
  54. void Uart1RxEnable2(int en);
  55. void Uart1RecvProcess(void);
  56. void Uart2RecvProcess(void);
  57. //通过DMA发送
  58. void USART1_Send(char *pbuffer, unsigned short size);
  59. void USART1_SendOK_IQ(void);
  60. void USART1_SendWaitCompleted(void);
  61. void USART2_Send(char *pbuffer, unsigned short size);
  62. void USART2_SendOK_IQ(void);
  63. void USART3_SendWaitCompleted(void);
  64. /***************************************************************************/
  65. #endif