MT_UART.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /***************************************************************************************************
  2. Filename: MT_UART.h
  3. Revised: $Date: 2009-07-02 15:24:39 -0700 (Thu, 02 Jul 2009) $
  4. Revision: $Revision: 20269 $
  5. Description: This header describes the functions that handle the serial port.
  6. Copyright 2007 Texas Instruments Incorporated. All rights reserved.
  7. IMPORTANT: Your use of this Software is limited to those specific rights
  8. granted under the terms of a software license agreement between the user
  9. who downloaded the software, his/her employer (which must be your employer)
  10. and Texas Instruments Incorporated (the "License"). You may not use this
  11. Software unless you agree to abide by the terms of the License. The License
  12. limits your use, and you acknowledge, that the Software may not be modified,
  13. copied or distributed unless embedded on a Texas Instruments microcontroller
  14. or used solely and exclusively in conjunction with a Texas Instruments radio
  15. frequency transceiver, which is integrated into your product. Other than for
  16. the foregoing purpose, you may not use, reproduce, copy, prepare derivative
  17. works of, modify, distribute, perform, display or sell this Software and/or
  18. its documentation for any purpose.
  19. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  20. PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  21. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  22. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  23. TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
  24. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  25. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  26. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  27. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  28. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  29. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  30. Should you have any questions regarding your right to use this Software,
  31. contact Texas Instruments Incorporated at www.TI.com.
  32. ***************************************************************************************************/
  33. #ifndef MT_UART_H
  34. #define MT_UART_H
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. /***************************************************************************************************
  40. * INCLUDES
  41. ***************************************************************************************************/
  42. #include "Onboard.h"
  43. #include "OSAL.h"
  44. /***************************************************************************************************
  45. * CONSTANTS
  46. ***************************************************************************************************/
  47. /* Start-of-frame delimiter for UART transport */
  48. #define MT_UART_SOF 0xFE
  49. /* UART frame overhead for SOF and FCS bytes */
  50. #define MT_UART_FRAME_OVHD 2
  51. /* Default values */
  52. #if defined (ZTOOL_P1) || defined (ZTOOL_P2)
  53. #define MT_UART_DEFAULT_PORT ZTOOL_PORT
  54. #elif defined (ZAPP_P1) || defined (ZAPP_P2)
  55. #define MT_UART_DEFAULT_PORT ZAPP_PORT
  56. #endif
  57. #if !defined( MT_UART_DEFAULT_OVERFLOW )
  58. #define MT_UART_DEFAULT_OVERFLOW TRUE
  59. #endif
  60. #if !defined MT_UART_DEFAULT_BAUDRATE
  61. #define MT_UART_DEFAULT_BAUDRATE HAL_UART_BR_38400
  62. #endif
  63. #define MT_UART_DEFAULT_THRESHOLD MT_UART_THRESHOLD
  64. #define MT_UART_DEFAULT_MAX_RX_BUFF MT_UART_RX_BUFF_MAX
  65. #if !defined( MT_UART_DEFAULT_MAX_TX_BUFF )
  66. #define MT_UART_DEFAULT_MAX_TX_BUFF MT_UART_TX_BUFF_MAX
  67. #endif
  68. #define MT_UART_DEFAULT_IDLE_TIMEOUT MT_UART_IDLE_TIMEOUT
  69. /* Application Flow Control */
  70. #define MT_UART_ZAPP_RX_NOT_READY 0x00
  71. #define MT_UART_ZAPP_RX_READY 0x01
  72. typedef struct
  73. {
  74. osal_event_hdr_t hdr;
  75. uint8 *msg;
  76. } mtOSALSerialData_t;
  77. /*
  78. * Initialization
  79. */
  80. extern void MT_UartInit (void);
  81. /*
  82. * Process ZTool Rx Data
  83. */
  84. void MT_UartProcessZToolData ( uint8 port, uint8 taskId );
  85. /*
  86. * Process ZApp Rx Data
  87. */
  88. void MT_UartProcessZAppData ( uint8 port, uint8 event );
  89. /*
  90. * Calculate the check sum
  91. */
  92. extern uint8 MT_UartCalcFCS( uint8 *msg_ptr, uint8 length );
  93. /*
  94. * Register TaskID for the application
  95. */
  96. extern void MT_UartRegisterTaskID( uint8 taskID );
  97. /*
  98. * Register max length that application can take
  99. */
  100. extern void MT_UartZAppBufferLengthRegister ( uint16 maxLen );
  101. /*
  102. * Turn Application flow control ON/OFF
  103. */
  104. extern void MT_UartAppFlowControl ( uint8 status );
  105. /***************************************************************************************************
  106. ***************************************************************************************************/
  107. #endif /* MT_UART_H */