MT_RPC.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /**************************************************************************************************
  2. Filename: mt_rpc.h
  3. Revised: $Date: 2010-10-07 04:00:42 -0700 (Thu, 07 Oct 2010) $
  4. Revision: $Revision: 24055 $
  5. Description: Public interface file for the RPC Transport Protocol Design.
  6. Copyright 2007-2010 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_RPC_H
  34. #define MT_RPC_H
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38. /***************************************************************************************************
  39. * INCLUDES
  40. ***************************************************************************************************/
  41. #include "hal_types.h"
  42. /***************************************************************************************************
  43. * CONSTANTS
  44. ***************************************************************************************************/
  45. /* 1st byte is the length of the data field, 2nd/3rd bytes are command field. */
  46. #define MT_RPC_FRAME_HDR_SZ 3
  47. /* Maximum length of data in the general frame format. The upper limit is 255 because of the
  48. * 1-byte length protocol. But the operation limit is lower for code size and ram savings so that
  49. * the uart driver can use 256 byte rx/tx queues and so
  50. * (MT_RPC_DATA_MAX + MT_RPC_FRAME_HDR_SZ + MT_UART_FRAME_OVHD) < 256
  51. */
  52. #define MT_RPC_DATA_MAX 250
  53. /* The 3 MSB's of the 1st command field byte are for command type. */
  54. #define MT_RPC_CMD_TYPE_MASK 0xE0
  55. /* The 5 LSB's of the 1st command field byte are for the subsystem. */
  56. #define MT_RPC_SUBSYSTEM_MASK 0x1F
  57. /* position of fields in the general format frame */
  58. #define MT_RPC_POS_LEN 0
  59. #define MT_RPC_POS_CMD0 1
  60. #define MT_RPC_POS_CMD1 2
  61. #define MT_RPC_POS_DAT0 3
  62. /* Error codes */
  63. #define MT_RPC_SUCCESS 0 /* success */
  64. #define MT_RPC_ERR_SUBSYSTEM 1 /* invalid subsystem */
  65. #define MT_RPC_ERR_COMMAND_ID 2 /* invalid command ID */
  66. #define MT_RPC_ERR_PARAMETER 3 /* invalid parameter */
  67. #define MT_RPC_ERR_LENGTH 4 /* invalid length */
  68. /***************************************************************************************************
  69. * TYPEDEF
  70. ***************************************************************************************************/
  71. typedef enum {
  72. MT_RPC_CMD_POLL = 0x00,
  73. MT_RPC_CMD_SREQ = 0x20,
  74. MT_RPC_CMD_AREQ = 0x40,
  75. MT_RPC_CMD_SRSP = 0x60,
  76. MT_RPC_CMD_RES4 = 0x80,
  77. MT_RPC_CMD_RES5 = 0xA0,
  78. MT_RPC_CMD_RES6 = 0xC0,
  79. MT_RPC_CMD_RES7 = 0xE0
  80. } mtRpcCmdType_t;
  81. typedef enum {
  82. MT_RPC_SYS_RES0, /* Reserved. */
  83. MT_RPC_SYS_SYS,
  84. MT_RPC_SYS_MAC,
  85. MT_RPC_SYS_NWK,
  86. MT_RPC_SYS_AF,
  87. MT_RPC_SYS_ZDO,
  88. MT_RPC_SYS_SAPI, /* Simple API. */
  89. MT_RPC_SYS_UTIL,
  90. MT_RPC_SYS_DBG,
  91. MT_RPC_SYS_APP,
  92. MT_RPC_SYS_OTA,
  93. MT_RPC_SYS_MAX /* Maximum value, must be last */
  94. /* 10-32 available, not yet assigned. */
  95. } mtRpcSysType_t;
  96. typedef struct
  97. {
  98. uint8 *(*alloc)(mtRpcCmdType_t type, uint8 len);
  99. void (*send)(uint8 *pBuf);
  100. } mtTransport_t;
  101. typedef uint8 (*mtProcessMsg_t)(uint8 *pBuf);
  102. /***************************************************************************************************
  103. ***************************************************************************************************/
  104. #ifdef __cplusplus
  105. };
  106. #endif
  107. #endif /* MT_RPC_H */