您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

107 行
3.0 KiB

  1. /*******************************************************************************
  2. * *
  3. * Copyright 2010 Rheinmetall Canada Inc. *
  4. * *
  5. * No part of this document may be reproduced, stored in *
  6. * a retrieval system, or transmitted, in any form or by any means, *
  7. * electronic, mechanical, photocopying, recording, or otherwise, *
  8. * without the prior written permission of Rheinmetall Canada Inc. *
  9. * *
  10. *******************************************************************************/
  11. /*
  12. Description:
  13. This is a template file for standard C header file.
  14. */
  15. /* ************************************************************************** */
  16. /* ¤Revision:
  17. 000 20100616 JFM,
  18. Original version.
  19. ### YYYYMMDD Initial, Bug Identification
  20. Change description.
  21. */
  22. #ifndef UART_H
  23. #define UART_H
  24. /* ************************************************************************** */
  25. /* Defines */
  26. #define UART_MAX_RX_BUFF_SIZE 512
  27. #define UART_MAX_TX_BUFF_SIZE 1024
  28. /* ************************************************************************** */
  29. /* Type definitions */
  30. //Handles to the Uart ports as mapped physically on the CU board.
  31. //in comment is the physical port assigned to each handle
  32. //
  33. enum eUartHandles
  34. {
  35. UART_1, //(232) internet Uart 2 - Lora IF
  36. UART_2, //(232) internal Uart 5 - SIM7080G LTE IF
  37. //UART_3, // !!!EXTERNAL!!! SPI daughter board...
  38. MAX_UART_HANDLE,
  39. INVALID_UART_HANDLE = 0xFF
  40. };
  41. extern const char *gUartStrings[MAX_UART_HANDLE];
  42. enum eUartStopBits
  43. {
  44. UART_ONE_STOP_BIT,
  45. UART_ONE_HALF_STOP_BIT,
  46. UART_TWO_STOP_BITS
  47. };
  48. enum eUartParity
  49. {
  50. UART_NO_PARITY,
  51. UART_EVEN_PARITY,
  52. UART_ODD_PARTIY
  53. };
  54. typedef struct
  55. {
  56. int iIsInternal;
  57. int iPhysicalUartPort;
  58. int iDataPending; //This flag is 0 when : TxPtr == RxPtr OR Uart is transmitting.
  59. char acTxCircularBuffer[UART_MAX_TX_BUFF_SIZE];
  60. char *pcTxInPtr;
  61. char *pcTxOutPtr;
  62. char acRxCircularBuffer[UART_MAX_RX_BUFF_SIZE];
  63. char *pcRxInDataPtr;
  64. char *pcRxOutDataPtr;
  65. int iNbRxFIFOPendingBytes;
  66. }stUartData;
  67. enum eUartReturnValues
  68. {
  69. UART_OK = 1,
  70. UART_PORT_BUSY,
  71. UART_PORT_NOT_OPENED,
  72. UART_BUFFER_FULL,
  73. UART_INVALID_HANDLE,
  74. UART_INVALID_PORT
  75. };
  76. /* ************************************************************************** */
  77. /* Prototypes */
  78. int UartTransmitData(int p_iUartHandle, char *p_pcBuffer, int p_iSize);
  79. int UartReceiveData(int p_iUartHandle, char *p_pcBuffer, int p_iSize);
  80. int DataSentNotification(int p_iUartHandle,int p_iDataSize);
  81. void InitUart(void);
  82. int UartOpenComPort(int p_iUartHandle, int p_iBaudRate, int p_iNbStopBits, int p_iParityEnable);
  83. int UartTick(void);
  84. void UartBlockAndTick(unsigned int TickCount);
  85. int UartBlockUntillBufEmpty(int iUartHandle);
  86. int UartGetPendingDataSize(int iUartHandle);
  87. int UartResetPort(int p_iUartHandle);
  88. #endif
  89. //EOF