Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 

103 рядки
3.1 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 INTERNAL_UART_H
  23. #define INTERNAL_UART_H
  24. /* ************************************************************************** */
  25. /* Includes */
  26. /* ************************************************************************** */
  27. /* Defines */
  28. #define INTERNAL_UART_BUFFER_DEPTH 1//4//16 //JFM 2012-08-27
  29. #define USE_TX_INTERNAL_BUFFER
  30. #define INTERNAL_UART1_TX_PIN_DIR TRISFbits.TRISF3
  31. #define INTERNAL_UART1_TX_PIN LATFbits.LATF3
  32. #define INTERNAL_UART2_TX_PIN_DIR TRISFbits.TRISF5
  33. #define INTERNAL_UART2_TX_PIN LATFbits.LATF5
  34. #define INTERNAL_UART5_TX_PIN_DIR TRISBbits.TRISB14
  35. #define INTERNAL_UART5_TX_PIN LATBbits.LATB14
  36. /* ************************************************************************** */
  37. /* Type definitions */
  38. typedef enum
  39. {
  40. INTERNAL_UART_PORT_1,
  41. INTERNAL_UART_PORT_2,
  42. INTERNAL_UART_PORT_5,
  43. MAX_INTERNAL_UART_PORT
  44. }eInternalUartPorts;
  45. typedef enum
  46. {
  47. INT_UART_NO_PARITY,
  48. INT_UART_EVEN_PARITY,
  49. INT_UART_ODD_PARITY
  50. }eIntUartParity;
  51. typedef enum
  52. {
  53. INT_UART_ONE_STOP_BIT,
  54. INT_UART_TWO_STOP_BITS
  55. }eIntUartStopBits;
  56. typedef enum
  57. {
  58. INT_UART_INTERRUPT_OFF,
  59. INT_UART_INTERRUPT_ON
  60. }eIntUartInterruptOnOff;
  61. typedef struct
  62. {
  63. char *pcTxDataPtr;
  64. char acIntUartTxFIFO[INTERNAL_UART_BUFFER_DEPTH];
  65. int iNbFIFOPendingBytes;
  66. int iTxDataSize;
  67. int iTxDataCounter;
  68. int iIsBusy;
  69. int iIsOpened;
  70. int iUartHandle;
  71. }stInternalUartData;
  72. /* ************************************************************************** */
  73. /* Prototypes */
  74. void InternalUartInit(void);
  75. int OpenInternalPort(int p_iUartPort,int p_iUartHandle,char *p_pcHeadPtr, char *p_pcTailPtr, int p_iBaudRate, int p_iNbStopBits, int p_iParityEnable);
  76. int SendInternalUartData(char *p_pcDataBuf, int p_iDataSize, int p_iUartPort, char *p_pcSourceBufferHead, char *p_pcSourceBufferTail);
  77. int SetIntalUartInterrupts(int p_iUartPort, int p_iRxInterrupt,int p_iTxInterrupt);
  78. int SendInternalUartDataBlocking(char *p_pcDataBuf, int p_iDataSize, int p_iUartPort);
  79. void TickInternalUart(void);
  80. void ResetUart1(void);
  81. void ResetUart2(void);
  82. void ResetUart5(void);
  83. #endif
  84. //EOF