bcomdef.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /**************************************************************************************************
  2. Phyplus Microelectronics Limited confidential and proprietary.
  3. All rights reserved.
  4. IMPORTANT: All rights of this software belong to Phyplus Microelectronics
  5. Limited ("Phyplus"). Your use of this Software is limited to those
  6. specific rights granted under the terms of the business contract, the
  7. confidential agreement, the non-disclosure agreement and any other forms
  8. of agreements as a customer or a partner of Phyplus. You may not use this
  9. Software unless you agree to abide by the terms of these agreements.
  10. You acknowledge that the Software may not be modified, copied,
  11. distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
  12. (BLE) integrated circuit, either as a product or is integrated into your
  13. products. Other than for the aforementioned purposes, you may not use,
  14. reproduce, copy, prepare derivative works of, modify, distribute, perform,
  15. display or sell this Software and/or its documentation for any purposes.
  16. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  17. PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  18. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  19. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  20. PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
  21. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  22. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  23. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  24. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  25. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  26. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  27. **************************************************************************************************/
  28. /**
  29. @headerfile: bcomdef.h
  30. <!--
  31. Revised:
  32. Revision:
  33. Description: Type definitions and macros for BLE stack.
  34. -->
  35. **************************************************************************************************/
  36. #ifndef BCOMDEF_H
  37. #define BCOMDEF_H
  38. #ifdef __cplusplus
  39. extern "C"
  40. {
  41. #endif
  42. /*********************************************************************
  43. * INCLUDES
  44. */
  45. #include "comdef.h"
  46. //#include "EM_platform.h"
  47. //#define AT_LOG(...)
  48. //#define LOG(...)
  49. //#define OM_LOG(...)
  50. /*********************************************************************
  51. * CONSTANTS
  52. */
  53. #define CTRL_CONFIG ( ADV_NCONN_CFG | ADV_CONN_CFG | SCAN_CFG | INIT_CFG )
  54. //#if defined ( HOST_CONFIG )
  55. // // Set the Controller Configuration
  56. // #if ( HOST_CONFIG == ( CENTRAL_CFG | PERIPHERAL_CFG ) )
  57. // #define CTRL_CONFIG ( ADV_NCONN_CFG | ADV_CONN_CFG | SCAN_CFG | INIT_CFG )
  58. // #elif ( HOST_CONFIG == ( CENTRAL_CFG | BROADCASTER_CFG ) )
  59. // #define CTRL_CONFIG ( ADV_NCONN_CFG | SCAN_CFG | INIT_CFG )
  60. // #elif ( HOST_CONFIG == ( PERIPHERAL_CFG | OBSERVER_CFG ) )
  61. // #define CTRL_CONFIG ( ADV_NCONN_CFG | ADV_CONN_CFG | SCAN_CFG )
  62. // #elif ( HOST_CONFIG == ( BROADCASTER_CFG | OBSERVER_CFG ) )
  63. // #define CTRL_CONFIG ( ADV_NCONN_CFG | SCAN_CFG )
  64. // #elif ( HOST_CONFIG == CENTRAL_CFG )
  65. // #define CTRL_CONFIG ( SCAN_CFG | INIT_CFG )
  66. // #elif ( HOST_CONFIG == PERIPHERAL_CFG )
  67. // #define CTRL_CONFIG ( ADV_NCONN_CFG | ADV_CONN_CFG )
  68. // #elif ( HOST_CONFIG == OBSERVER_CFG )
  69. // #define CTRL_CONFIG SCAN_CFG
  70. // #elif ( HOST_CONFIG == BROADCASTER_CFG )
  71. // #define CTRL_CONFIG ADV_NCONN_CFG
  72. // #else
  73. // #error "Build Configuration Error: Invalid Host Role!"
  74. // #endif
  75. //#else
  76. // // Controller Sanity Check: Stop build when no configuration is defined.
  77. // #if !defined( CTRL_CONFIG ) || !( CTRL_CONFIG & ( ADV_NCONN_CFG | \
  78. // ADV_CONN_CFG | \
  79. // SCAN_CFG | \
  80. // INIT_CFG ) )
  81. // #error "Build Configuration Error: At least one Controller build component required!"
  82. // #endif // no Controller build components defined
  83. //#endif
  84. #if !defined ( MAX_NUM_LL_CONN )
  85. #if ( CTRL_CONFIG & INIT_CFG )
  86. #define MAX_NUM_LL_CONN 8
  87. #elif ( !( CTRL_CONFIG & INIT_CFG ) && ( CTRL_CONFIG & ADV_CONN_CFG ) )
  88. #define MAX_NUM_LL_CONN 1
  89. #else // no connection needed
  90. #define MAX_NUM_LL_CONN 0
  91. #endif // CTRL_CONFIG=INIT_CFG
  92. #endif // !MAX_NUM_LL_CONN
  93. #define MAX_NUM_LL_CONN_ROM_LIMT 16 //hard code for BBB ROM define
  94. #if (MAX_NUM_LL_CONN_ROM_LIMT<MAX_NUM_LL_CONN)
  95. #warning "MAX_NUM_LL_CONN > MAX_NUM_LL_CONN_ROM"
  96. #endif
  97. /** @defgroup BLE_COMMON_DEFINES BLE Common Defines
  98. * @{
  99. */
  100. //! Default Public and Random Address Length
  101. #define B_ADDR_LEN 6
  102. //! Default key length
  103. #define KEYLEN 16
  104. //! BLE Channel Map length
  105. #define B_CHANNEL_MAP_LEN 5
  106. //! BLE Event mask length
  107. #define B_EVENT_MASK_LEN 8
  108. //! BLE Local Name length
  109. #define B_LOCAL_NAME_LEN 248
  110. //! BLE Maximum Advertising Packet Length
  111. #define B_MAX_ADV_LEN 31
  112. #define B_MAX_EXT_ADV_LEN 229
  113. #define B_MAX_PERIOD_ADV_LEN 247
  114. // 2020-01-14 AOA/AOD IQ Sample LEN
  115. #define B_MAX_IQ_LEN 0x52
  116. //! BLE Random Number Size
  117. #define B_RANDOM_NUM_SIZE 8
  118. //! BLE Feature Supported length
  119. #define B_FEATURE_SUPPORT_LENGTH 8
  120. /** @defgroup BLE_STATUS_VALUES BLE Default BLE Status Values
  121. * returned as bStatus_t
  122. * @{
  123. */
  124. #define bleInvalidTaskID INVALID_TASK //!< Task ID isn't setup properly
  125. #define bleNotReady 0x10 //!< Not ready to perform task
  126. #define bleAlreadyInRequestedMode 0x11 //!< Already performing that task
  127. #define bleIncorrectMode 0x12 //!< Not setup properly to perform that task
  128. #define bleMemAllocError 0x13 //!< Memory allocation error occurred
  129. #define bleNotConnected 0x14 //!< Can't perform function when not in a connection
  130. #define bleNoResources 0x15 //!< There are no resource available
  131. #define blePending 0x16 //!< Waiting
  132. #define bleTimeout 0x17 //!< Timed out performing function
  133. #define bleInvalidRange 0x18 //!< A parameter is out of range
  134. #define bleLinkEncrypted 0x19 //!< The link is already encrypted
  135. #define bleProcedureComplete 0x1A //!< The Procedure is completed
  136. // GAP Status Return Values - returned as bStatus_t
  137. #define bleGAPUserCanceled 0x30 //!< The user canceled the task
  138. #define bleGAPConnNotAcceptable 0x31 //!< The connection was not accepted
  139. #define bleGAPBondRejected 0x32 //!< The bound information was rejected.
  140. // ATT Status Return Values - returned as bStatus_t
  141. #define bleInvalidPDU 0x40 //!< The attribute PDU is invalid
  142. #define bleInsufficientAuthen 0x41 //!< The attribute has insufficient authentication
  143. #define bleInsufficientEncrypt 0x42 //!< The attribute has insufficient encryption
  144. #define bleInsufficientKeySize 0x43 //!< The attribute has insufficient encryption key size
  145. // L2CAP Status Return Values - returned as bStatus_t
  146. #define INVALID_TASK_ID 0xFF //!< Task ID isn't setup properly
  147. /** @} End BLE_STATUS_VALUES */
  148. /** @defgroup BLE_NV_IDS BLE Non-volatile IDs
  149. * @{
  150. */
  151. // Device NV Items - Range 0 - 0x1F
  152. #define BLE_NVID_IRK 0x02 //!< The Device's IRK
  153. #define BLE_NVID_CSRK 0x03 //!< The Device's CSRK
  154. #define BLE_NVID_SIGNCOUNTER 0x04 //!< The Device's Sign Counter
  155. // Bonding NV Items - Range 0x20 - 0x5F - This allows for 10 bondings
  156. #define BLE_NVID_GAP_BOND_START 0x20 //!< Start of the GAP Bond Manager's NV IDs
  157. #define BLE_NVID_GAP_BOND_END 0x5f //!< End of the GAP Bond Manager's NV IDs Range
  158. // GATT Configuration NV Items - Range 0x70 - 0x79 - This must match the number of Bonding entries
  159. #define BLE_NVID_GATT_CFG_START 0x70 //!< Start of the GATT Configuration NV IDs
  160. #define BLE_NVID_GATT_CFG_END 0x79 //!< End of the GATT Configuration NV IDs
  161. /** @} End BLE_NV_IDS */
  162. /*********************************************************************
  163. * BLE OSAL GAP GLOBAL Events
  164. */
  165. #define GAP_EVENT_SIGN_COUNTER_CHANGED 0x4000 //!< The device level sign counter changed
  166. /** @defgroup BLE_MSG_IDS BLE OSAL Message ID Events
  167. * Reserved Message ID Event Values:<BR>
  168. * 0xC0 - Key Presses<BR>
  169. * 0xE0 to 0xFC - App<BR>
  170. * @{
  171. */
  172. // GAP - Messages IDs (0xD0 - 0xDF)
  173. #define GAP_MSG_EVENT 0xD0 //!< Incoming GAP message
  174. // SM - Messages IDs (0xC1 - 0xCF)
  175. #define SM_NEW_RAND_KEY_EVENT 0xC1 //!< New Rand Key Event message
  176. // GATT - Messages IDs (0xB0 - 0xBF)
  177. #define GATT_MSG_EVENT 0xB0 //!< Incoming GATT message
  178. #define GATT_SERV_MSG_EVENT 0xB1 //!< Incoming GATT Serv App message
  179. // L2CAP - Messages IDs (0xA0 - 0xAF)
  180. #define L2CAP_DATA_EVENT 0xA0 //!< Incoming data on a channel
  181. #define L2CAP_SIGNAL_EVENT 0xA2 //!< Incoming Signaling message
  182. // HCI - Messages IDs (0x90 - 0x9F)
  183. #define HCI_DATA_EVENT 0x90 //!< HCI Data Event message
  184. #define HCI_GAP_EVENT_EVENT 0x91 //!< GAP Event message
  185. #define HCI_SMP_EVENT_EVENT 0x92 //!< SMP Event message
  186. #define HCI_EXT_CMD_EVENT 0x93 //!< HCI Extended Command Event message
  187. /** @} End BLE_MSG_IDS */
  188. /*********************************************************************
  189. * TYPEDEFS
  190. */
  191. //! BLE Generic Status return: @ref BLE_STATUS_VALUES
  192. typedef Status_t bStatus_t;
  193. /** @} End GAP_MSG_EVENT_DEFINES */
  194. /*********************************************************************
  195. * System Events
  196. */
  197. /*********************************************************************
  198. * Global System Messages
  199. */
  200. /*********************************************************************
  201. * MACROS
  202. */
  203. #define TI_BASE_UUID_128( uuid ) 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, \
  204. 0x00, 0x40, 0x51, 0x04, LO_UINT16( uuid ), HI_UINT16( uuid ), 0x00, 0xF0
  205. /*********************************************************************
  206. * GLOBAL VARIABLES
  207. */
  208. /*********************************************************************
  209. * FUNCTIONS
  210. */
  211. /*********************************************************************
  212. *********************************************************************/
  213. #ifdef __cplusplus
  214. }
  215. #endif
  216. #endif /* BCOMDEF_H */