ll_def.h 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575
  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. #ifndef LL_DEF_H_
  29. #define LL_DEF_H_
  30. #include "types.h"
  31. #include "comdef.h"
  32. #include "bcomdef.h"
  33. #include "ll_buf.h"
  34. //#include "ll.h"
  35. #if (MAX_NUM_LL_CONN_ROM_LIMT > 1)
  36. #define MULTI_ROLE
  37. #endif
  38. #define MAX_NUM_LL_PRD_ADV_SYNC 2 // for periodic adv listener
  39. #define LL_INVALID_CONNECTION_ID 0xFF
  40. #define LL_PKT_PREAMBLE_LEN 1
  41. #define LL_PKT_SYNCH_LEN 4
  42. #define LL_PKT_LLID_LEN 1
  43. #define LL_PKT_HDR_LEN 2
  44. #define LL_PKT_MIC_LEN 4
  45. #define LL_PKT_CRC_LEN 3
  46. #define LL_DATA_PDU_HDR_LLID_RESERVED 0
  47. #define LL_DATA_PDU_HDR_LLID_DATA_PKT_NEXT 1
  48. #define LL_DATA_PDU_HDR_LLID_DATA_PKT_FIRST 2
  49. #define LL_DATA_PDU_HDR_LLID_CONTROL_PKT 3
  50. ///adv header shift and mask
  51. #define PDU_TYPE_SHIFT 0
  52. #define PDU_TYPE_MASK 0xf
  53. #define CHSEL_SHIFT 5
  54. #define CHSEL_MASK 0x20
  55. #define TX_ADD_SHIFT 6
  56. #define TX_ADD_MASK 0x40
  57. #define RX_ADD_SHIFT 7
  58. #define RX_ADD_MASK 0x80
  59. #define LENGTH_SHIFT 8
  60. #define LENGTH_MASK 0xFf00
  61. // macro for bit operations
  62. #define SET_BITS(p,f,l,m) p=(f<<l) | (p & (~m))
  63. #define GET_BITS(p,l,m) (p&m)>>l
  64. // Receive Flow Control
  65. #define LL_RX_FLOW_CONTROL_DISABLED 0
  66. #define LL_RX_FLOW_CONTROL_ENABLED 1
  67. //LL packet type
  68. #define ADV_IND 0 //Connectable Undirected Event
  69. #define ADV_DIRECT_IND 1 //Connectable Directed Event
  70. #define ADV_NONCONN_IND 2 //Non-connectable Undirected Event
  71. #define ADV_SCAN_REQ 3
  72. #define ADV_AUX_SCAN_REQ 3
  73. #define ADV_SCAN_RSP 4
  74. #define ADV_CONN_REQ 5
  75. #define ADV_AUX_CONN_REQ 5
  76. #define ADV_SCAN_IND 6 //Scannable Undirected Event
  77. #define ADV_EXT_TYPE 7
  78. #define ADV_AUX_CONN_RSP 8
  79. // LL state defines
  80. #define LL_STATE_IDLE 0x00
  81. #define LL_STATE_ADV_UNDIRECTED 0x01
  82. #define LL_STATE_ADV_DIRECTED 0x02
  83. #define LL_STATE_ADV_SCAN 0x03
  84. #define LL_STATE_ADV_NONCONN 0x04
  85. #define LL_STATE_SCAN 0x05
  86. #define LL_STATE_INIT 0x06
  87. #define LL_STATE_CONN_SLAVE 0x07
  88. #define LL_STATE_CONN_MASTER 0x08
  89. #define LL_STATE_DIRECT_TEST_MODE_TX 0x09
  90. #define LL_STATE_DIRECT_TEST_MODE_RX 0x0A
  91. #define LL_STATE_MODEM_TEST_TX 0x0B
  92. #define LL_STATE_MODEM_TEST_RX 0x0C
  93. #define LL_STATE_MODEM_TEST_TX_FREQ_HOPPING 0x0D
  94. #define LL_STATE_ADV_EXT 0x0E
  95. #define LL_STATE_ADV_PERIODIC 0x0F
  96. /*
  97. ** LL Buffers Supported
  98. */
  99. #define LL_MAX_NUM_DATA_BUFFERS 12
  100. #define LL_MAX_NUM_CMD_BUFFERS 1
  101. /*
  102. ** LL API Parameters
  103. */
  104. // LL Parameter Limits
  105. #define LL_ADV_CONN_INTERVAL_MIN 32 // 20ms in 625us
  106. #define LL_ADV_CONN_INTERVAL_MAX 16384 // 10.24s in 625us
  107. #define LL_ADV_NONCONN_INTERVAL_MIN 160 // 100ms in 625us
  108. #define LL_ADV_NONCONN_INTERVAL_MAX 16384 // 10.24s in 625us
  109. // temporary macro define : align to version 5.1 non-conn intv 20ms
  110. // affect function LL_SetAdvControl
  111. #define LL_ADV_V51_NONCONN_INTERVAL_MIN 32
  112. #define LL_ADV_DELAY_MIN 0 // in ms
  113. #define LL_ADV_DELAY_MAX 10 // in ms
  114. #define LL_SCAN_INTERVAL_MIN 4 // 2.5ms in 625us
  115. #define LL_SCAN_INTERVAL_MAX 16384 // 10.24s in 625us
  116. #define LL_SCAN_WINDOW_MIN 4 // 2.5ms in 625us
  117. #define LL_SCAN_WINDOW_MAX 16384 // 10.24s in 625us
  118. #define LL_CONN_INTERVAL_MIN 6 // 7.5ms in 1.25ms
  119. #define LL_CONN_INTERVAL_MAX 3200 // 4s in 1.25ms
  120. #define LL_CONN_TIMEOUT_MIN 10 // 100ms in 10ms
  121. #define LL_CONN_TIMEOUT_MAX 3200 // 32s in 10ms
  122. #define LL_SLAVE_LATENCY_MIN 0
  123. #define LL_SLAVE_LATENCY_MAX 499
  124. #define LL_HOP_LENGTH_MIN 5
  125. #define LL_HOP_LENGTH_MAX 16
  126. #define LL_INSTANT_NUMBER_MIN 6
  127. #define LL_ADV_INTERVAL_DEFAULT 160 // 100ms in 625us ticks
  128. #define LL_SCAN_INTERVAL_DEFAULT 640 // 400ms in 625us ticks
  129. // LL Advertiser Channels
  130. #define LL_ADV_CHAN_37 1
  131. #define LL_ADV_CHAN_38 2
  132. #define LL_ADV_CHAN_39 4
  133. #define LL_ADV_CHAN_ALL (LL_ADV_CHAN_37 | LL_ADV_CHAN_38 | LL_ADV_CHAN_39)
  134. #define LL_MAX_NUM_DATA_CHAN 37 // 0 - 36
  135. // Advertiser Synchronization Word
  136. #define ADV_SYNCH_WORD 0x8E89BED6 // Adv channel sync
  137. #define ADV_CRC_INIT_VALUE 0x00555555 // not needed; handled by NR hardware automatically
  138. // Packet Lengths
  139. #define LL_DEVICE_ADDR_LEN 6
  140. #define LL_MAX_ADV_DATA_LEN 31
  141. #define LL_MAX_ADV_PAYLOAD_LEN (LL_DEVICE_ADDR_LEN + LL_MAX_ADV_DATA_LEN)
  142. #define LL_MAX_SCAN_DATA_LEN 31
  143. #define LL_MAX_SCAN_PAYLOAD_LEN (LL_DEVICE_ADDR_LEN + LL_MAX_SCAN_DATA_LEN)
  144. #define LL_MAX_LINK_DATA_LEN 27 // ZQ 20181030 for DLE feature
  145. //replaced by g_llPduLen.local.MaxTxOctets
  146. // =============== add in A2 for simultaneous slave and adv/scan
  147. #define LL_SEC_STATE_IDLE 0x00
  148. #define LL_SEC_STATE_SCAN 0x01
  149. #define LL_SEC_STATE_ADV 0x02
  150. #define LL_SEC_STATE_SCAN_PENDING 0x03
  151. #define LL_SEC_STATE_ADV_PENDING 0x04
  152. #define LL_SEC_STATE_IDLE_PENDING 0x05
  153. #define LL_SEC_STATE_INIT 0x06
  154. #define LL_SEC_STATE_INIT_PENDING 0x07
  155. // ============= for multi-role
  156. #define LL_ROLE_SLAVE 0x01
  157. #define LL_ROLE_MASTER 0x02
  158. #define LL_ROLE_INVALID 0xFF
  159. #define LL_INVALID_TIME 0xFFFFFFFF
  160. #define LL_TASK_MASTER_DURATION 3000
  161. #define LL_TASK_SLAVE_DURATION 2700
  162. enum
  163. {
  164. LL_SCH_PRIO_LOW = 0,
  165. LL_SCH_PRIO_MED,
  166. LL_SCH_PRIO_HIGH,
  167. LL_SCH_PRIO_IMMED,
  168. LL_SCH_PRIO_LAST
  169. };
  170. // ===== A2 End
  171. // 2020-01-15 CTE Macro define
  172. #define LL_CTE_MAX_ANTENNA_LEN 8
  173. #define LL_CTE_MAX_ANT_ID (LL_CTE_MAX_ANTENNA_LEN - 1)
  174. #define LL_CTE_MAX_PATTERN_LEN 16
  175. #define LL_CTE_MIN_SUPP_LEN 0x2
  176. #define LL_CTE_MAX_SUPP_LEN 0x14 // CTE MAX Support length in 8us units( MAX 160us)
  177. #define LL_CTE_SUPP_LEN_UNIT 0x08
  178. #define LL_CTE_MAX_PA_INTV_CNT 0x10
  179. #define LL_CTE_MAX_IQ_SAMP_CNT 0x10
  180. #define LL_CTE_ENABLE 0x1
  181. #define LL_CTE_DISABLE 0x0
  182. #define LL_IQ_SAMP_ENABLE 0x1
  183. #define LL_IQ_SAMP_DISABLE 0x0
  184. #define LL_CONN_IQSAMP_ENABLE 0x1
  185. #define LL_CONN_IQSAMP_DISENABLE 0x0
  186. #define LL_CONN_IQTX_ENABLE 0x1
  187. #define LL_CONN_IQTX_DISENABLE 0x0
  188. #define LL_CONN_CTE_REQ_ENABLE 0x1
  189. #define LL_CONN_CTE_REQ_DISENABLE 0x0
  190. #define LL_CONN_CTE_RSP_ENABLE 0x1
  191. #define LL_CONN_CTE_RSP_DISENABLE 0x0
  192. #define LL_IQ_SW_SAMP_1US 0x1
  193. #define LL_IQ_SW_SAMP_2US 0x2
  194. #define LL_CONTROLLER_SUPP_1US_AOD_TX 0x1
  195. #define LL_CONTROLLER_SUPP_1US_AOD_SAMP 0x2
  196. #define LL_CONTROLLER_SUPP_1US_AOA_TX_SAMP 0x4
  197. // 2020-01-20 add for Extended advertising
  198. #define LL_SECOND_ADV_PHY_1M 0x1
  199. #define LL_SECOND_ADV_PHY_2M 0x2
  200. #define LL_SECOND_ADV_PHY_CODE 0x3
  201. #define LL_PHY_1M 0x1
  202. #define LL_PHY_2M 0x2
  203. #define LL_PHY_CODE 0x3
  204. //LL connecction control type
  205. #define LL_CONNECTION_UPDATE_REQ 0
  206. #define LL_CHANNEL_MAP_REQ 1
  207. #define LL_TERMINATE_IND 2
  208. #define LL_ENC_REQ 3
  209. #define LL_ENC_RSP 4
  210. #define LL_START_ENC_REQ 5
  211. #define LL_START_ENC_RSP 6
  212. #define LL_UNKNOWN_RSP 7
  213. #define LL_FEATURE_REQ 8
  214. #define LL_FEATURE_RSP 9
  215. #define LL_PAUSE_ENC_REQ 10
  216. #define LL_PAUSE_ENC_RSP 11
  217. #define LL_VERSION_IND 12
  218. #define LL_REJECT_IND 13
  219. #define LL_SLAVE_FEATURE_REQ 14
  220. #define LL_CONNECTION_PARAM_REQ 15
  221. #define LL_CONNECTION_PARAM_RSP 16
  222. #define LL_REJECT_IND_EXT 17
  223. #define LL_PING_REQ 18
  224. #define LL_PING_RSP 19
  225. #define LL_LENGTH_REQ 20
  226. #define LL_LENGTH_RSP 21
  227. #define LL_PHY_REQ 22
  228. #define LL_PHY_RSP 23
  229. #define LL_PHY_UPDATE_IND 24
  230. #define LL_CONNECT_REQ_PAYLOAD_LEN 18
  231. #define LL_CONN_UPDATE_REQ_PAYLOAD_LEN 12
  232. #define LL_CHAN_MAP_REQ_PAYLOAD_LEN 8
  233. #define LL_TERM_IND_PAYLOAD_LEN 2
  234. #define LL_ENC_REQ_PAYLOAD_LEN 23
  235. #define LL_ENC_RSP_PAYLOAD_LEN 13
  236. #define LL_START_ENC_REQ_PAYLOAD_LEN 1
  237. #define LL_START_ENC_RSP_PAYLOAD_LEN 1
  238. #define LL_PAUSE_ENC_REQ_PAYLOAD_LEN 1
  239. #define LL_PAUSE_ENC_RSP_PAYLOAD_LEN 1
  240. #define LL_REJECT_IND_PAYLOAD_LEN 2
  241. #define LL_REJECT_EXT_IND_PAYLOAD_LEN 3
  242. #define LL_FEATURE_REQ_PAYLOAD_LEN 9
  243. #define LL_FEATURE_RSP_PAYLOAD_LEN 9
  244. #define LL_VERSION_IND_PAYLOAD_LEN 6
  245. #define LL_UNKNOWN_RSP_PAYLOAD_LEN 2
  246. #define LL_LENGTH_REQ_PAYLOAD_LEN 9
  247. #define LL_LENGTH_RSP_PAYLOAD_LEN 9
  248. #define LL_PHY_REQ_PAYLOAD_LEN 3
  249. #define LL_PHY_RSP_PAYLOAD_LEN 3
  250. #define LL_PHY_UPDATE_IND_PAYLOAD_LEN 5
  251. // 2020-01-20 add for CTE
  252. #define LL_CTE_REQ_LEN 2
  253. #define LL_CTE_RSP_LEN 1
  254. #define LL_MAX_NUM_CTRL_PROC_PKTS 4
  255. #define LL_CTRL_UNDEFINED_PKT 0xFF
  256. // LL Events
  257. #define LL_EVT_POST_PROCESS_NR 0x0001
  258. #define LL_EVT_DIRECTED_ADV_FAILED 0x0002
  259. #define LL_EVT_SLAVE_CONN_CREATED 0x0004
  260. #define LL_EVT_NEXT_INTERVAL 0x0008
  261. #define LL_EVT_MASTER_CONN_CANCELLED 0x0010
  262. #define LL_EVT_TASK_TIMER_FENCE_EXPIRED 0x0020
  263. #define LL_EVT_SLAVE_CONN_CREATED_BAD_PARAM 0x0040
  264. #define LL_EVT_START_32KHZ_XOSC_DELAY 0x0080
  265. #define LL_EVT_32KHZ_XOSC_DELAY 0x0100
  266. #define LL_EVT_RESET_SYSTEM_HARD 0x0200
  267. #define LL_EVT_RESET_SYSTEM_SOFT 0x0400
  268. #define LL_EVT_MASTER_CONN_CREATED 0x0800
  269. #define LL_EVT_SECONDARY_SCAN 0x1000
  270. #define LL_EVT_SECONDARY_ADV 0x2000
  271. #define LL_EVT_SECONDARY_INIT 0x4000
  272. #define LL_EVT_RPA_TIMEOUT 0x8000
  273. #define LL_ADV_NONCONN_STATE 0x00
  274. #define LL_ADV_DISCOV_STATE 0x01
  275. #define LL_ADV_UNDIRECT_STATE 0x02
  276. #define LL_ADV_HDC_DIRECT_STATE 0x03
  277. #define LL_SCAN_PASSIVE_STATE 0x04
  278. #define LL_SCAN_ACTIVE_STATE 0x05
  279. #define LL_INIT_STATE 0x06 // connection state in master role also supported
  280. #define LL_SLAVE_STATE 0x07
  281. //
  282. #define LL_ADV_NONCONN_SCAN_PASSIVE_STATE 0x10
  283. #define LL_ADV_DISCOV_SCAN_PASSIVE_STATE 0x11
  284. #define LL_ADV_UNDIRECT_SCAN_PASSIVE_STATE 0x12
  285. #define LL_ADV_HDC_DIRECT_SCAN_PASSIVE_STATE 0x13
  286. #define LL_ADV_NONCONN_SCAN_ACTIVE_STATE 0x14
  287. #define LL_ADV_DISCOV_SCAN_ACTIVE_STATE 0x15
  288. #define LL_ADV_UNDIRECT_SCAN_ACTIVE_STATE 0x16
  289. #define LL_ADV_HDC_DIRECT_SCAN_ACTIVE_STATE 0x17
  290. //
  291. #define LL_ADV_NONCONN_INIT_STATE 0x20
  292. #define LL_ADV_DISCOV_INIT_STATE 0x21
  293. #define LL_ADV_NONCONN_MASTER_STATE 0x22
  294. #define LL_ADV_DISCOV_MASTER_STATE 0x23
  295. #define LL_ADV_NONCONN_SLAVE_STATE 0x24
  296. #define LL_ADV_DISCOV_SLAVE_STATE 0x25
  297. #define LL_SCAN_PASSIVE_INIT_STATE 0x26
  298. #define LL_SCAN_ACTIVE_INIT_STATE 0x27
  299. //
  300. #define LL_SCAN_PASSIVE_MASTER_STATE 0x30
  301. #define LL_SCAN_ACTIVE_MASTER_STATE 0x31
  302. #define LL_SCAN_PASSIVE_SLAVE_STATE 0x32
  303. #define LL_SCAN_ACTIVE_SLAVE_STATE 0x33
  304. #define LL_INIT_MASTER_STATE 0x34 // master role and master role combination also supported
  305. //
  306. #define LL_ADV_LDC_DIRECT_STATE 0x35
  307. #define LL_ADV_LDC_DIRECT_SCAN_PASSIVE_STATE 0x36
  308. #define LL_ADV_LDC_DIRECT_SCAN_ACTIVE_STATE 0x37
  309. #define HCI_RX_PKT_HDR_SIZE 5
  310. #define LL_NUM_BYTES_FOR_CHAN_MAP 5 //(LL_MAX_NUM_ADV_CHAN+LL_MAX_NUM_DATA_CHAN)/sizeof(uint8)
  311. #define LL_CTRL_PROC_STATUS_SUCCESS 0
  312. #define LL_CTRL_PROC_STATUS_TERMINATE 1
  313. // A2 multi-connection
  314. #define LL_PROC_LINK_KEEP 0
  315. #define LL_PROC_LINK_TERMINATE 1
  316. #define LL_TX_DATA_CONTEXT_POST_PROCESSING 2
  317. #define LL_TX_DATA_CONTEXT_SEND_DATA 0
  318. #define LL_LINK_SETUP_TIMEOUT 5 // 6 connection intervals (i.e. 0..5)
  319. // Setup Next Slave Procedure Actions
  320. #define LL_SETUP_NEXT_LINK_STATUS_SUCCESS 0
  321. #define LL_SETUP_NEXT_LINK_STATUS_TERMINATE 1
  322. // Data PDU Control Packet Types
  323. #define LL_CTRL_CONNECTION_UPDATE_REQ 0 // M
  324. #define LL_CTRL_CHANNEL_MAP_REQ 1 // M
  325. #define LL_CTRL_TERMINATE_IND 2 // M, S
  326. #define LL_CTRL_ENC_REQ 3 // M
  327. #define LL_CTRL_ENC_RSP 4 // , S
  328. #define LL_CTRL_START_ENC_REQ 5 // , S
  329. #define LL_CTRL_START_ENC_RSP 6 // M, S
  330. #define LL_CTRL_UNKNOWN_RSP 7 // M, S
  331. #define LL_CTRL_FEATURE_REQ 8 // M
  332. #define LL_CTRL_FEATURE_RSP 9 // , S , also could be M in ver4.2 ... HZF
  333. #define LL_CTRL_PAUSE_ENC_REQ 10 // M
  334. #define LL_CTRL_PAUSE_ENC_RSP 11 // , S
  335. #define LL_CTRL_VERSION_IND 12 // M, S
  336. #define LL_CTRL_REJECT_IND 13 // , S
  337. // BLE 4.2
  338. #define LL_CTRL_SLAVE_FEATURE_REQ 14
  339. #define LL_CTRL_CONNECTION_PARAM_REQ 15
  340. #define LL_CTRL_CONNECTION_PARAM_RSP 16
  341. #define LL_CTRL_REJECT_EXT_IND 17
  342. #define LL_CTRL_PING_REQ 18
  343. #define LL_CTRL_PING_RSP 19
  344. #define LL_CTRL_LENGTH_REQ 20
  345. #define LL_CTRL_LENGTH_RSP 21
  346. // BLE 5.0
  347. #define LL_CTRL_PHY_REQ 22
  348. #define LL_CTRL_PHY_RSP 23
  349. #define LL_CTRL_PHY_UPDATE_IND 24
  350. #define LL_CTRL_MIN_USED_CHANNELS_IND 25
  351. // TODO 2020-02-07 change , default: 26
  352. #define LL_CTRL_TERMINATE_RX_WAIT_FOR_TX_ACK 0xFE //26 // M (internal to LL only)
  353. // 2020-01-19 add for CTE
  354. #define LL_CTRL_CTE_REQ 0x1A
  355. #define LL_CTRL_CTE_RSP 0x1B
  356. // control procedure timeout in coarse timer ticks
  357. #define LL_MAX_CTRL_PROC_TIMEOUT 64000 // 40s
  358. // Encryption Related
  359. #define LL_ENC_RAND_LEN 8
  360. #define LL_ENC_EDIV_LEN 2
  361. #define LL_ENC_LTK_LEN 16
  362. #define LL_ENC_IRK_LEN 16
  363. #define LL_ENC_IV_M_LEN 4
  364. #define LL_ENC_IV_S_LEN 4
  365. #define LL_ENC_IV_LINK_LEN 4
  366. #define LL_ENC_IV_LEN (LL_ENC_IV_M_LEN + LL_ENC_IV_S_LEN)
  367. #define LL_ENC_SKD_M_LEN 8
  368. #define LL_ENC_SKD_S_LEN 8
  369. #define LL_ENC_SKD_LINK_LEN 8
  370. #define LL_ENC_SKD_LEN (LL_ENC_SKD_M_LEN + LL_ENC_SKD_S_LEN)
  371. #define LL_ENC_SK_LEN 16
  372. #define LL_ENC_NONCE_LEN 13
  373. #define LL_END_NONCE_IV_OFFSET 5
  374. #define LL_ENC_MIC_LEN LL_PKT_MIC_LEN
  375. //
  376. #define LL_ENC_IV_M_OFFSET LL_ENC_IV_S_LEN
  377. #define LL_ENC_IV_S_OFFSET 0
  378. #define LL_ENC_SKD_M_OFFSET LL_ENC_SKD_S_LEN
  379. #define LL_ENC_SKD_S_OFFSET 0
  380. //
  381. #define LL_ENC_BLOCK_LEN 16
  382. #define LL_ENC_CCM_BLOCK_LEN LL_ENC_BLOCK_LEN
  383. #define LL_ENC_BLOCK_B0_FLAGS 0x49
  384. #define LL_ENC_BLOCK_A0_FLAGS 0x01
  385. // Resolving Private Address list
  386. #define LEN_24BIT 3 // Number of bytes in a 24 bit number
  387. #define PRAND_SIZE LEN_24BIT // PRAND size in the Private Resolvable Address calculation
  388. // Address header bits
  389. #define RANDOM_ADDR_HDR 0xC0 // Used for LL RANDOM Address
  390. #define STATIC_ADDR_HDR 0xC0 // Host Static Address, same as RANDOM address
  391. #define PRIVATE_RESOLVE_ADDR_HDR 0x40
  392. // Extended advertiser setting
  393. #define LL_MAX_ADVERTISER_SET_LENGTH 0x672 // spec range: 0x1F ~ 0x672
  394. #define LL_INVALID_ADV_SET_HANDLE 0xFF
  395. //////////////////// for scan
  396. // Scanner Advertisment Channels
  397. #define LL_SCAN_ADV_CHAN_37 37
  398. #define LL_SCAN_ADV_CHAN_38 38
  399. #define LL_SCAN_ADV_CHAN_39 39
  400. // add by HZF for whitelist
  401. #define LL_WHITELIST_ENTRY_NUM 8
  402. // BBB ROM code: resolving list size
  403. #define LL_RESOLVINGLIST_ENTRY_NUM 8
  404. struct bd_addr{
  405. uint8_t addr[6];
  406. };
  407. typedef struct
  408. {
  409. uint8_t peerAddrType; // peer device address type of public or random
  410. uint8_t peerAddr[ 6 ]; // peer device address
  411. } peerInfo_t;
  412. // BBB ROM code add
  413. typedef struct
  414. {
  415. uint8_t localIrk[16];
  416. uint8_t peerIrk[16];
  417. uint8_t peerAddrType; // peer device address type of public or random
  418. uint8_t peerAddr[ 6 ]; // peer device address
  419. } resolvingListInfo_t;
  420. /// Advertising parameters
  421. typedef struct
  422. {
  423. uint8_t active;
  424. uint16_t advInterval; // the advertiser interval, based on advIntMin and advIntMax
  425. /// Advertising type
  426. uint16_t advMode; // flag to indicate if currently advertising
  427. uint8_t ownAddrType; // own device address type of public or random
  428. uint8_t ownAddr[LL_DEVICE_ADDR_LEN]; // own device address
  429. uint8_t advChanMap; // saved Adv channel map; note, only lower three bits used
  430. uint8_t advEvtType; //connectable directed, undirected, discoverable, or non-connectable
  431. uint8_t wlPolicy; // white list policy for Adv
  432. uint16_t scaValue; // Slave SCA in PPM
  433. uint8_t advDataLen; // advertiser data length
  434. // Scan Repsonse Parameters
  435. uint8_t scanRspLen; // scan response data length
  436. // add by HZF
  437. uint8 advNextChan;
  438. // multi-connection
  439. uint8 connId;
  440. }advInfo_t;
  441. /// Extended Advertising parameters
  442. typedef struct
  443. {
  444. // uint8_t advHandle; // range: 0x00 - 0xEF
  445. uint8_t advertisingSID; // range: 0x00 - 0x0F
  446. uint16_t advEventProperties; // adv event type
  447. uint32_t priAdvIntMin; // 3 octets, minimum primary adv interval
  448. uint32_t priAdvgIntMax; // 3 octets, maximum primary adv interval
  449. uint8_t priAdvChnMap;
  450. uint8_t ownAddrType; // own device address type of public or random
  451. uint8_t isOwnRandomAddressSet; // own random address type set flag. The address is set by HCI_LE_SET_ADVERTISING_SET_RANDOM_ADDRESS
  452. uint8_t ownRandomAddress[LL_DEVICE_ADDR_LEN];
  453. uint8_t peerAddrType;
  454. uint8_t peerAddress[LL_DEVICE_ADDR_LEN];
  455. uint8_t wlPolicy; // white list policy for Adv
  456. uint8_t advTxPower;
  457. uint8_t primaryAdvPHY;
  458. uint8_t secondaryAdvPHY;
  459. uint8_t secondaryAdvMaxSkip; // the maximum number of advertising events that can be skipped before the AUX_ADV_IND can be sent
  460. uint8_t scanReqNotificationEnable;
  461. }extAdvParameter_t;
  462. /// data of Advertising set or scan response data
  463. typedef struct
  464. {
  465. // uint8_t advHandle;
  466. uint8_t dataComplete; // all data of advert set received
  467. uint8 fragmentPreference;
  468. uint16 advertisingDataLength;
  469. uint8 *advertisingData;
  470. // LL generated
  471. uint16 DIDInfo; // 12bits
  472. }advSetData_t;
  473. /// extended adv parameters, include spec parameters & implemented-specific parameters
  474. typedef struct
  475. {
  476. uint8_t advHandle;
  477. extAdvParameter_t parameter;
  478. advSetData_t data; // only for extended adv
  479. uint16 scanRspMaxLength;
  480. uint8 *scanRspData;
  481. // ===================== advertisement enable info
  482. uint32_t duration; // unit us, note spec parameter is 10ms unit
  483. uint8_t maxExtAdvEvents;
  484. // ================= advertisement context parameters
  485. uint8_t isPeriodic; // is the adv parameters for periodic adv
  486. uint8_t active; // extended adv enable or not
  487. uint32_t primary_advertising_interval;
  488. uint16_t adv_event_counter; // counter for extend adv event
  489. uint32_t adv_event_duration; // duration of advertise
  490. uint8_t tx_power; // not setting now, reserve for TxPwr field
  491. uint8_t sendingAuxAdvInd;
  492. // below parameters only applicable to extended adv, not for periodic adv
  493. uint8_t currentChn; // current adv channel
  494. uint8_t auxChn; // 1st aux PDU channel No.
  495. uint16_t currentAdvOffset; // current read ptr of adv data set, for fill AUX_XXX_IND PDUs
  496. } extAdvInfo_t;
  497. typedef struct
  498. {
  499. uint16 syncPacketOffset : 13; // 13bits
  500. uint16 offsetUnit : 1; // 1 bit
  501. uint16 offsetAdj : 1; // 1 bit
  502. uint16 rfu : 1; // 1 bit
  503. } syncInfoOffset_t;
  504. typedef struct
  505. {
  506. uint8 chn_map : 5; // 5bits
  507. uint8 sca : 3; // 3 bit
  508. } chanMap4_t;
  509. typedef struct
  510. {
  511. syncInfoOffset_t offset;
  512. uint16 interval;
  513. uint8 chn_map[4];
  514. chanMap4_t chn_map4;
  515. uint8 AA[4];
  516. uint8 crcInit[3];
  517. uint16 event_counter;
  518. } syncInfo_t;
  519. /// data of periodic Advertising set
  520. typedef struct
  521. {
  522. uint8 dataComplete; // all data of advert set received
  523. uint16 advertisingDataLength;
  524. uint8 *advertisingData;
  525. }periodicAdvSetData_t;
  526. // 2020-01-15 add for connection & connectionless parameter
  527. typedef struct
  528. {
  529. // common
  530. // uint16 handle; // syncConnHandle for connectionless , connHandle for connection
  531. uint8 enable; //
  532. uint8 CTE_Length; // connectionless transmit CTE length or connection request and response CTE Length
  533. uint8 CTE_Type; // AOA, ADO 1us , AOD 2us
  534. uint8 CTE_Count; // number of CTE to transmit in each PA interval
  535. // IQ Sample:max number of CTE to sample and report in each PA interval
  536. uint8 CTE_Count_Idx; // record the number of times that the CTE send , max equal to CTE_Count
  537. uint8 pattern_LEN;
  538. uint8 AntID[LL_CTE_MAX_PATTERN_LEN];
  539. uint8 slot_Duration; // switching and sampling slot 1us or 2us
  540. // connectionless transmit param
  541. // uint8 advSet; // identify connectionless advertising set
  542. // CTEInfo_t merge to periodicAdvInfo_t , advSet not used
  543. // connection CTE request & response enable command
  544. uint16 CTE_Request_Intv;
  545. }CTEInfo_t;
  546. // periodic adv: data + parameters + enable flag
  547. // note that periodic adv also need extended adv parameters + enable
  548. typedef struct
  549. {
  550. uint8_t advHandle;
  551. periodicAdvSetData_t data;
  552. uint16 adv_interval_min;
  553. uint16 adv_interval_max;
  554. uint16_t adv_event_properties; // adv event type
  555. // ================= advertisement context parameters
  556. uint8_t active; // extended adv enable or not
  557. uint32_t adv_interval;
  558. uint8_t secondaryAdvPHY; // reserved, should we copy this setting from ext adv info? ext adv may be disabled while keep periodic adv alive
  559. uint8 chn_map[5]; // 37 bits
  560. uint8_t chanMapTable[LL_MAX_NUM_DATA_CHAN];
  561. uint8_t numUsedChans; // count of the number of usable data channels
  562. uint8 sca; // 3 bit
  563. uint32 AA;
  564. uint32 crcInit;
  565. uint8_t tx_power; // not setting now, reserve for TxPwr field
  566. uint16_t periodic_adv_event_counter; // counter for periodic adv event
  567. uint8 pa_current_chn; // current periodic adv channel
  568. uint8_t currentChn; // current adv channel
  569. uint16_t currentAdvOffset; // current read ptr of adv data set, for fill AUX_XXX_IND PDUs
  570. // 2020-01-15 CTE global variable
  571. CTEInfo_t PrdCTEInfo;
  572. } periodicAdvInfo_t;
  573. ///////////////////////////////////////////////////////////
  574. // Scanner Event Parameters
  575. typedef struct
  576. {
  577. // taskInfo_t *llTask; // pointer to associated task block
  578. uint8 ownAddrType; // own device address type of public or random
  579. uint8 ownAddr[ LL_DEVICE_ADDR_LEN ]; // own device address
  580. uint8 initPending; // flag to indicate if Scan needs to be initialized
  581. uint8 scanMode; // flag to indicate if currently scanning
  582. uint8 scanType; // passive or active scan
  583. uint16 scanInterval; // the interval between scan events
  584. uint16 scanWindow; // the duration of a scan event
  585. uint8 wlPolicy; // white list policy for Scan
  586. uint8 filterReports; // flag to indicate if duplicate Adv packet reports are to be filtered
  587. uint16 scanBackoffUL; // backoff upper limit count
  588. uint8 nextScanChan; // advertising channel to be used by scanner
  589. uint8 numSuccess; // for adjusting backoff count by tracking successive successes
  590. uint8 numFailure; // for adjusting backoff count by tracking successive failures
  591. uint16 currentBackoff; // current back off count, uint16 because the upper limit is 256
  592. } scanInfo_t;
  593. ///////////////////////////////////////////////////////////
  594. // Extended Scanner Parameters
  595. #define LL_MAX_EXTENDED_SCAN_PHYS 2
  596. #define LL_MAX_EXTENDED_INIT_PHYS 3
  597. #define LL_SCAN_PHY_1M_BITMASK 0x01
  598. #define LL_CONN_PHY_2M_BITMASK 0x02 // only for init
  599. #define LL_SCAN_PHY_CODED_BITMASK 0x04
  600. typedef struct
  601. {
  602. uint8 enable;
  603. uint8 ownAddrType; // own device address type of public or random
  604. uint8 ownAddr[ LL_DEVICE_ADDR_LEN ]; // own device address
  605. uint8 wlPolicy; // white list policy for Scan
  606. uint8 numOfScanPHY;
  607. uint8 scanPHYs[LL_MAX_EXTENDED_SCAN_PHYS]; // scan PHYs
  608. uint8 scanType[LL_MAX_EXTENDED_SCAN_PHYS]; // passive or active scan
  609. uint16 scanInterval[LL_MAX_EXTENDED_SCAN_PHYS]; // the interval between scan events
  610. uint16 scanWindow[LL_MAX_EXTENDED_SCAN_PHYS]; // the duration of a scan event
  611. uint8 filterDuplicate; // Duplicate filtering setting
  612. uint16 duration; // scan duration in a scan period
  613. uint16 period; // scan period
  614. // scan context
  615. uint8 current_index; // current scan parameter index, 0 or 1
  616. uint8 current_scan_PHY;
  617. uint8 current_chn;
  618. uint16 adv_data_offset; // offset of long adv data
  619. uint16 adv_data_buf_len; // adv data buffer size
  620. uint8 *adv_data;
  621. } extScanInfo_t;
  622. typedef struct
  623. {
  624. uint8 valid;
  625. uint8 options;
  626. uint8 advertising_SID;
  627. uint8 advertiser_Address_Type;
  628. uint8 advertiser_Address[LL_DEVICE_ADDR_LEN];
  629. uint16 skip;
  630. uint16 sync_Timeout;
  631. uint8 sync_CTE_Type;
  632. } scannerSyncInfo_t;
  633. typedef struct
  634. {
  635. uint8 header;
  636. uint8 advA[LL_DEVICE_ADDR_LEN];
  637. uint8 targetA[LL_DEVICE_ADDR_LEN];
  638. uint8 cteInfo;
  639. uint16 adi;
  640. struct
  641. {
  642. uint8 chn_idx;
  643. uint8 ca;
  644. uint8 offset_unit;
  645. uint16 aux_offset;
  646. uint8 aux_phy;
  647. } auxPtr;
  648. uint8 syncInfo[18];
  649. uint8 txPower;
  650. } extAdvHdr_t;
  651. /////////////////// Initiator Event Parameters
  652. typedef struct
  653. {
  654. uint8 ownAddrType; // own device address type of public or random
  655. uint8 ownAddr[ LL_DEVICE_ADDR_LEN ]; // own device address
  656. //
  657. uint8 initPending; // flag to indicate if Scan needs to be initialized
  658. uint8 scanMode; // flag to indicate if currently scanning
  659. uint16 scanInterval; // the interval between scan events
  660. uint16 scanWindow; // the duration of a scan event
  661. uint8 nextScanChan; // advertising channel to be used by scanner
  662. uint8 wlPolicy; // white list policy for Init
  663. uint8 connId; // allocated connection ID
  664. uint8 scaValue; // Master SCA as an ordinal value for PPM
  665. } initInfo_t;
  666. typedef struct
  667. {
  668. uint8 ownAddrType; // own device address type of public or random
  669. uint8 ownAddr[ LL_DEVICE_ADDR_LEN ]; // own device address
  670. uint8 wlPolicy; // white list policy for Init
  671. // uint8 initPending; // flag to indicate if Scan needs to be initialized
  672. uint8 scanMode; // flag to indicate if currently scanning
  673. uint8 numOfScanPHY;
  674. uint8 initPHYs[LL_MAX_EXTENDED_SCAN_PHYS]; // scan PHYs
  675. uint16 scanInterval[LL_MAX_EXTENDED_SCAN_PHYS]; // the interval between scan events
  676. uint16 scanWindow[LL_MAX_EXTENDED_SCAN_PHYS]; // the duration of a scan event
  677. uint16 conn_interval_min[LL_MAX_EXTENDED_SCAN_PHYS];
  678. uint16 conn_interval_max[LL_MAX_EXTENDED_SCAN_PHYS];
  679. uint16 conn_latency[LL_MAX_EXTENDED_SCAN_PHYS];
  680. uint16 supervision_timeout[LL_MAX_EXTENDED_SCAN_PHYS];
  681. uint16 minimum_CE_length[LL_MAX_EXTENDED_SCAN_PHYS];
  682. uint16 maximum_CE_length[LL_MAX_EXTENDED_SCAN_PHYS];
  683. // initiator parameters for 2Mbps PHY
  684. uint8 is_2M_parameter_present;
  685. uint16 conn_interval_min_2Mbps;
  686. uint16 conn_interval_max_2Mbps;
  687. uint16 conn_latency_2Mbps;
  688. uint16 supervision_timeout_2Mbps;
  689. uint16 minimum_CE_length_2Mbps;
  690. uint16 maximum_CE_length_2Mbps;
  691. // scan context
  692. uint8 current_index; // current scan parameter index, 0 or 1
  693. uint8 current_scan_PHY;
  694. uint8 current_chn;
  695. uint8 connId; // allocated connection ID
  696. uint8 scaValue; // Master SCA as an ordinal value for PPM
  697. } extInitInfo_t;
  698. /////////////////////////////////////////////////////////////////
  699. typedef struct
  700. {
  701. uint8_t winSize; // window size
  702. uint16_t winOffset; // window offset
  703. uint16_t connInterval; // connection interval
  704. uint16_t slaveLatency; // number of connection events the slave can ignore
  705. uint16_t connTimeout; // supervision connection timeout
  706. } connParam_t;
  707. typedef struct
  708. {
  709. uint8_t verNum; // controller spec version
  710. uint16_t comId; // company identifier
  711. uint16_t subverNum; // implementation version
  712. } verInfo_t;
  713. typedef struct
  714. {
  715. uint8_t connId; // connection ID
  716. uint8_t termIndRcvd; // indicates a TERMINATE_IND was received
  717. uint8_t reason; // reason code to return to Host when connection finally ends
  718. } termInfo_t;
  719. // TX Data
  720. typedef struct txData_t
  721. {
  722. struct txData_t *pNext; // pointer to next Tx data entry on queue
  723. } txData_t;
  724. // Data Packet Queue
  725. typedef struct
  726. {
  727. txData_t *head; // pointer to head of queue
  728. txData_t *tail; // pointer to tail of queue
  729. } llDataQ_t;
  730. // Version Information Exchange
  731. typedef struct
  732. {
  733. uint8_t peerInfoValid; // flag to indicate the peer's version information is valid
  734. uint8_t hostRequest; // flag to indicate the host has requested the peer's version information
  735. uint8_t verInfoSent; // flag to indicate this device's version information has been sent
  736. } verExchange_t;
  737. // Feature Set Data
  738. typedef struct
  739. {
  740. uint8_t featureRspRcved; // flag to indicate the Feature Request has been responded to
  741. uint8_t featureSet[ 8 ];
  742. } featureSet_t;
  743. // Channel Map
  744. typedef struct
  745. {
  746. uint8_t chanMap[ 5 ]; // bit map corresponding to the data channels 0..39
  747. } chanMap_t;
  748. // Control Procedure Information
  749. typedef struct
  750. {
  751. uint8_t ctrlPktActive; // flag that indicates a control packet is being processed
  752. uint8_t ctrlPkts[ LL_MAX_NUM_CTRL_PROC_PKTS ]; // queue of control packets to be processed
  753. uint8_t ctrlPktCount; // number of queued control packets
  754. uint16_t ctrlTimeoutVal; // timeout in CI events for control procedure for this connection
  755. uint16_t ctrlTimeout; // timeout counter in CI events for control procedure
  756. } ctrlPktInfo_t;
  757. typedef struct
  758. {
  759. uint16_t MaxTxOctets;
  760. uint16_t MaxTxTime;
  761. uint16_t MaxRxOctets;
  762. uint16_t MaxRxTime;
  763. }ll_pdu_length_ctrl_t;
  764. typedef struct
  765. {
  766. ll_pdu_length_ctrl_t local;
  767. ll_pdu_length_ctrl_t remote;
  768. ll_pdu_length_ctrl_t suggested; // global setting
  769. uint8_t isProcessingReq;
  770. uint8_t isWatingRsp;
  771. uint8_t isChanged;
  772. uint8_t dummy[1];
  773. }llPduLenManagment_t;
  774. typedef struct
  775. {
  776. uint8_t allPhy;
  777. uint8_t txPhy;
  778. uint8_t rxPhy;
  779. uint8_t dummy[1];
  780. }ll_phy_ctrl_t;
  781. typedef struct
  782. {
  783. uint8_t m2sPhy;
  784. uint8_t s2mPhy;
  785. uint16_t instant;
  786. }ll_phy_update_ind_t;
  787. typedef struct
  788. {
  789. ll_phy_ctrl_t def;
  790. ll_phy_ctrl_t local;
  791. ll_phy_ctrl_t req;
  792. ll_phy_ctrl_t rsp;
  793. uint16_t phyOptions;
  794. uint8_t isChanged;
  795. uint8_t isProcessingReq;
  796. uint8_t isWatingRsp;
  797. uint8_t status;
  798. uint8_t dummy[2];
  799. }llPhyModeManagment_t;
  800. // 2020-02-21 add for CTE req & rsp logic
  801. typedef struct
  802. {
  803. uint8_t isChanged;
  804. uint8_t isProcessingReq;
  805. uint8_t isWatingRsp; // wait other Ctrl command procedure
  806. uint8_t errorCode;
  807. }llCTEModeManagement_t;
  808. // for timer drift adjust
  809. typedef struct
  810. {
  811. uint32 coarse; // number of 625us ticks at SFD capture
  812. uint16 fine; // number of 31.25ns ticks at SFD capture
  813. } sysTime_t;
  814. // Encryption
  815. typedef struct
  816. {
  817. // Note: IV and SKD provide enough room for the full IV and SKD. When the
  818. // Master and Slave values are provided, the result is one combined
  819. // (concatenated) value.
  820. uint8 IV[ LL_ENC_IV_LEN ]; // combined master and slave IV values concatenated
  821. uint8 SKD [ LL_ENC_SKD_LEN ]; // combined master and slave SKD values concatenated
  822. uint8 RAND[ LL_ENC_RAND_LEN ]; // random vector from Master
  823. uint8 EDIV[ LL_ENC_EDIV_LEN ]; // encrypted diversifier from Master
  824. uint8 nonce[ LL_ENC_NONCE_LEN ]; // current nonce with current IV value
  825. uint8 SK[ LL_ENC_SK_LEN ]; // session key derived from LTK and SKD
  826. uint8 LTK[ LL_ENC_LTK_LEN ]; // Long Term Key from Host
  827. uint8 SKValid; // flag that indicates the Session Key is valid
  828. uint8 LTKValid; // Long Term Key is valid
  829. uint32 txPktCount; // used for nonce formation during encryption (Note: 39 bits!)??
  830. uint32 rxPktCount; // used for nonce formation during encryption (Note: 39 bits!)??
  831. uint8 encRestart; // flag to indicate if an encryption key change took place
  832. uint8 encRejectErrCode; // error code for rejecting encryption request
  833. // ALT: COULD USE ONE VARIABLE AND STATES FOR THESE FLAGS; IF SO, THE
  834. // CONTROL PROCEDURE WOULD NEED TO BE REWORKED.
  835. uint8 startEncRspRcved; // flag to indicate the Start Request has been responded to
  836. uint8 pauseEncRspRcved; // flag to indicate the Pause Request has been responded to
  837. uint8 encReqRcved; // flag to indicate an Enc Req was received in a Enc Pause procedure
  838. uint8 startEncReqRcved; // flag to indicate the Start Request has been responded to
  839. uint8 rejectIndRcved; // flag to indicate the Start Encryption needs to be aborted
  840. } encInfo_t;
  841. // Packet Error Rate Information - General
  842. typedef struct
  843. {
  844. uint16 numPkts; // total number of packets
  845. uint16 numCrcErr; // total number of packets with CRC error
  846. uint16 numEvents; // total number of connection events
  847. uint16 numMissedEvts; // total number of missed connection events
  848. } perInfo_t;
  849. typedef struct
  850. {
  851. // adv channel statistics
  852. int ll_send_undirect_adv_cnt;
  853. int ll_send_nonconn_adv_cnt;
  854. int ll_send_scan_adv_cnt;
  855. int ll_send_hdc_dir_adv_cnt;
  856. int ll_send_ldc_dir_adv_cnt;
  857. // adv in conn event
  858. int ll_send_conn_adv_cnt;
  859. int ll_conn_adv_pending_cnt;
  860. // scan in conn event
  861. int ll_conn_scan_pending_cnt;
  862. // slave counter
  863. int ll_recv_scan_req_cnt;
  864. int ll_send_scan_rsp_cnt;
  865. int ll_recv_conn_req_cnt;
  866. int ll_send_conn_rsp_cnt;
  867. // whitelist
  868. int ll_filter_scan_req_cnt;
  869. int ll_filter_conn_req_cnt;
  870. // scan
  871. int ll_recv_adv_pkt_cnt;
  872. int ll_send_scan_req_cnt;
  873. int ll_recv_scan_rsp_cnt;
  874. // connection event counters
  875. int ll_conn_succ_cnt; // LL accept connect, but not always sync succ
  876. int ll_link_lost_cnt;
  877. int ll_link_estab_fail_cnt;
  878. // connection packet statistics
  879. // int ll_recv_ctrl_pkt_cnt;
  880. // int ll_recv_data_pkt_cnt;
  881. // int ll_recv_invalid_pkt_cnt;
  882. //
  883. // int ll_recv_abnormal_cnt;
  884. //
  885. // int ll_send_data_pkt_cnt;
  886. //
  887. // int ll_conn_event_cnt;
  888. // int ll_recv_crcerr_event_cnt; // CRC error detected in the connection event
  889. // int ll_conn_event_timeout_cnt; // timeout connection event countt
  890. int ll_rx_peer_cnt; // scan/conn request counter, to consider whether we need it
  891. // LL <-> HCI packets statistics
  892. // int ll_to_hci_pkt_cnt;
  893. // int ll_hci_to_ll_pkt_cnt;
  894. //
  895. // int ll_hci_buffer_alloc_err_cnt;
  896. //ll_hw err cnt
  897. int ll_evt_shc_err;
  898. //ll_hw err cnt
  899. int ll_trigger_err;
  900. int ll_rfifo_rst_err;
  901. int ll_rfifo_rst_cnt;
  902. int ll_rfifo_read_err;
  903. // reserve counter
  904. int ll_tbd_cnt1;
  905. int ll_tbd_cnt2;
  906. int ll_tbd_cnt3;
  907. int ll_tbd_cnt4;
  908. int ll_tbd_cnt5;
  909. int ll_tbd_cnt6;
  910. int ll_tbd_cnt7;
  911. int ll_tbd_cnt8;
  912. } llGlobalStatistics_t;
  913. // ======= multi-connection
  914. typedef struct
  915. {
  916. // connection packet statistics
  917. uint32_t ll_recv_ctrl_pkt_cnt;
  918. uint32_t ll_recv_data_pkt_cnt;
  919. uint32_t ll_recv_invalid_pkt_cnt;
  920. uint32_t ll_recv_abnormal_cnt;
  921. uint32_t ll_send_data_pkt_cnt;
  922. uint32_t ll_conn_event_cnt;
  923. uint32_t ll_recv_crcerr_event_cnt; // CRC error detected in the connection event
  924. uint32_t ll_conn_event_timeout_cnt; // timeout connection event countt
  925. // LL <-> HCI packets statistics
  926. uint32_t ll_to_hci_pkt_cnt;
  927. uint32_t ll_hci_to_ll_pkt_cnt;
  928. uint32_t ll_hci_buffer_alloc_err_cnt;
  929. uint32_t ll_miss_master_evt_cnt;
  930. uint32_t ll_miss_slave_evt_cnt;
  931. // reserve counter
  932. uint32_t ll_tbd_cnt1;
  933. uint32_t ll_tbd_cnt2;
  934. uint32_t ll_tbd_cnt3;
  935. uint32_t ll_tbd_cnt4;
  936. } llLinkStatistics_t;
  937. typedef struct
  938. {
  939. uint8_t chanMap[5];
  940. uint16_t chanMapUpdateEvent; // event count to indicate when to apply pending chan map update
  941. uint8_t chanMapUpdated;
  942. } preChanMapUpdate_t;
  943. // Connection Data
  944. typedef struct
  945. {
  946. uint8_t rx_timeout; // ----- Phyplus
  947. uint8_t rx_crcok; // ----- Phyplus
  948. uint8_t allocConn; // flag to indicate if this connection is allocated
  949. uint8_t active; // flag to indicate if this connection is active
  950. uint8_t connId; // connection ID
  951. uint8_t firstPacket; // flag to indicate when the first packet has been received. 0 means TURE, 1 means FALSE
  952. uint16_t currentEvent; // current event number
  953. uint16_t nextEvent; // next active event number
  954. uint16_t lastCurrentEvent;
  955. uint16_t expirationEvent; // event at which the LSTO has expired
  956. uint16_t expirationValue; // number of events to a LSTO expiration
  957. uint16_t scaFactor; // SCA factor for timer drift calculation
  958. uint32_t timerDrift; // saved timer drift adjustment to avoid recalc
  959. uint32_t accuTimerDrift; // accumulate timer drift
  960. // Connection Parameters
  961. uint32_t lastTimeToNextEvt; // the time to next event from the previous connection event
  962. uint8_t slaveLatencyAllowed; // flag to indicate slave latency is permitted
  963. uint16_t slaveLatency; // current slave latency; 0 means inactive
  964. uint8_t lastSlaveLatency; // last slave latency value used
  965. uint16_t slaveLatencyValue; // current slave latency value (when enabled)
  966. uint32_t accessAddr; // saved synchronization word to be used by Slave
  967. uint32_t initCRC; // connection CRC initialization value (24 bits)
  968. uint8_t sleepClkAccuracy; // peer's sleep clock accurracy; used by own device to determine timer drift
  969. connParam_t curParam;
  970. // current connection parameters
  971. // Channel Map
  972. uint8_t nextChan; // the channel for the next active connection event
  973. uint8_t currentChan; // the channel for the currently completed connection event
  974. uint8_t lastCurrentChan; // the channel for the last currentChan for disable slavelatency usage
  975. uint8_t numUsedChans; // count of the number of usable data channels
  976. // uint8_t hopLength; // used for finding next data channel at next connection event
  977. uint8_t chanMapTable[LL_MAX_NUM_DATA_CHAN]; // current chan map table that is in use for this connection
  978. uint8_t chanMap[5];
  979. chanMap_t chanMapUpdate; // slave chanMapUpdate for different connId
  980. preChanMapUpdate_t preChanMapUpdate; // used for disable latency
  981. uint8_t hop;
  982. // TX Related
  983. uint8_t txDataEnabled; // flag that indicates whether data output is allowed
  984. llDataQ_t txDataQ; // queue of Tx Data packets
  985. // RX Related
  986. uint8_t rxDataEnabled; // flag that indicates whether data input is allowed
  987. uint8_t lastRssi; // last data packet RSSI received on this connection
  988. uint16_t foff; // A2 add, sync qualitiy indicator, estimated by rx BB
  989. uint8_t carrSens; // A2 add, estimated freq offset by rx BB ,foff-512-->[-512 511]KHz
  990. // Control Packet Information
  991. ctrlPktInfo_t ctrlPktInfo; // information for control procedure processing
  992. // Parameter Update Control Procedure
  993. uint8_t pendingParamUpdate; // flag to indicate connection parameter update is pending
  994. uint16_t paramUpdateEvent; // event count to indicate when to apply pending param update
  995. connParam_t paramUpdate; // update parameters
  996. // Channel Map Update Control Procedure
  997. uint8_t pendingChanUpdate; // flag to indicate connection channel map update is pending
  998. uint16 chanMapUpdateEvent; // event count to indicate when to apply pending chan map update
  999. // Encryption Data Control Procedure
  1000. uint8 encEnabled; // flag to indicate that encryption is enabled for this connection
  1001. encInfo_t encInfo; // structure that holds encryption related data
  1002. // Feature Set
  1003. featureSet_t featureSetInfo; // feature set for this connection
  1004. // Version Information
  1005. verExchange_t verExchange; // version information exchange
  1006. verInfo_t verInfo; // peer version information
  1007. // Termination Control Procedure
  1008. termInfo_t termInfo; // structure that holds connection termination data
  1009. // Unknnown Control Packet
  1010. uint8 unknownCtrlType; // value of unknown control type
  1011. // Packet Error Rate
  1012. perInfo_t perInfo; // PER
  1013. uint8_t isCollision;
  1014. uint8_t rejectOpCode;
  1015. ll_phy_update_ind_t phyUpdateInfo; // ll_phy update
  1016. // Parameter Update Control Procedure
  1017. uint8_t pendingPhyModeUpdate; // flag to indicate connection ll phy update is pending
  1018. uint16_t phyModeUpdateEvent;
  1019. uint8_t sn_nesn; // use to save last sn/nesn in new IC
  1020. // for new IC
  1021. uint8_t llMode; // for RTLP & TRLP loop, may need change the HW engine mode.
  1022. // =============== A2 multi connection
  1023. uint8_t ctrlDataIsProcess ; // seding a control packet or not
  1024. uint8_t ctrlDataIsPending ; // control packet is pending to be sent
  1025. // uint8_t dummy[2]; // for 4-bytes align
  1026. int anchor_point_base_time; // do we need it?
  1027. int anchor_point_fine_time; // do we need it?
  1028. int next_event_base_time; // do we need it?
  1029. int next_event_fine_time; // do we need it?
  1030. ctrl_packet_buf ctrlData;
  1031. llLinkBuf_t ll_buf;
  1032. // DLE
  1033. llPduLenManagment_t llPduLen;
  1034. llPhyModeManagment_t llPhyModeCtrl;
  1035. // add after BBB ROM release, PHY format
  1036. uint8_t llRfPhyPktFmt;
  1037. llLinkStatistics_t pmCounter;
  1038. // 2020-01-19 add for CTE
  1039. // llCTE_ReqFlag,llCTE_RspFlag only indicate CTE Request and Response enable or disable status
  1040. uint8 llCTE_ReqFlag;
  1041. uint8 llCTE_RspFlag;
  1042. // CTE REQ & RSP Control
  1043. llCTEModeManagement_t llCTEModeCtrl;
  1044. CTEInfo_t llConnCTE;
  1045. /*bug-fix for : multi-role SMP, When already master established,then as slave smp,
  1046. that smp shall relative with conn handle and role*/
  1047. uint8 connRole;
  1048. } llConnState_t;
  1049. typedef struct
  1050. {
  1051. uint8 rsc_idx; // connection ID, reserved for dynamic resource allocate
  1052. uint8 priority;
  1053. uint8 linkRole; // link role, slave(LL_ROLE_SLAVE) or master(LL_ROLE_MASTER)
  1054. uint32 task_period; // schedule period, calculate from connection interval, in us. required???
  1055. uint32 task_duration; // task duration
  1056. uint32 remainder; // remainder time
  1057. // uint32 lastTimerValue; // last timer configure value
  1058. } llScheduleInfo_t;
  1059. // Per BLE LL Connection (max number is BLE_LL_MAX_NUM_LL_CONNS)
  1060. typedef struct
  1061. {
  1062. uint8 numLLConns; // number of allocated connections
  1063. uint8 numLLMasterConns; // number of master, to check whether we need it
  1064. uint8 currentConn; // the LL connection currently in use
  1065. llScheduleInfo_t scheduleInfo[MAX_NUM_LL_CONN_ROM_LIMT]; // scheduler information
  1066. // ========== common link parameter for all master connection
  1067. uint16 connInterval; // connection interval
  1068. uint16 slaveLatency; // number of connection events the slave can ignore
  1069. uint16 connTimeout; // supervision connection timeout
  1070. uint32 per_slot_time; // delta T per resource slot
  1071. uint32 timerExpiryTick; // last LL timer expiry tick in 1s timer
  1072. uint32 current_timer; // LL timer initial load value
  1073. } llConns_t;
  1074. // for extended/periodic adv shceduler
  1075. typedef struct
  1076. {
  1077. // uint8 advInfoIdx; // index in the adv parameters array
  1078. // uint8 advSetIdx; // index in the adv parameters array
  1079. uint8 adv_handler;
  1080. extAdvInfo_t *pAdvInfo;
  1081. // uint8 eventType; // adv event type
  1082. // uint32 task_period; // schedule period, calculate from connection interval, in us. required???
  1083. // uint32 task_duration; // task duration
  1084. uint32 nextEventRemainder; // remainder time
  1085. uint32 auxPduRemainder; // remainder time
  1086. } llAdvScheduleInfo_t;
  1087. typedef struct
  1088. {
  1089. // uint8 advInfoIdx; // index in the adv parameters array
  1090. // uint8 advSetIdx; // index in the adv parameters array
  1091. uint8 adv_handler;
  1092. periodicAdvInfo_t *pAdvInfo_prd;
  1093. extAdvInfo_t *pAdvInfo;
  1094. // uint32 task_period; // schedule period, calculate from connection interval, in us. required???
  1095. // uint32 task_duration; // task duration
  1096. uint32 nextEventRemainder; // primary channel PDU remainder time
  1097. uint32 auxPduRemainder; // auxilary channel PDU remainder time
  1098. } llPeriodicAdvScheduleInfo_t;
  1099. // periodic scanner context
  1100. typedef struct
  1101. {
  1102. uint16 syncHandler;
  1103. uint8 valid;
  1104. uint8 syncEstOk;
  1105. uint8 event1stFlag; // indicate LL is searching AUX_SYNC_IND PDU
  1106. uint16 skip;
  1107. uint32 syncTimeout; // unit us, need *1250 when convert from HCI value
  1108. uint8 syncCteType;
  1109. // syncInfoOffset_t offset;
  1110. uint32 advInterval; // periodic adv event interval, unit us, need *1250 when convert from air interface PDU value
  1111. uint8 chnMap[5];
  1112. uint8_t chanMapTable[LL_MAX_NUM_DATA_CHAN];
  1113. uint8_t numUsedChans; // count of the number of usable data channels
  1114. uint8 sca;
  1115. uint8 accessAddress[4];
  1116. uint16 channelIdentifier;
  1117. uint8 crcInit[3];
  1118. uint8 advPhy;
  1119. uint8 current_channel; // current scan channel, for AUX_CHAIN_IND, it may different with 1st PDU channel
  1120. uint8 currentEventChannel; // current periodic adv event 1st PDU channel
  1121. uint16 eventCounter; // periodic adv event counter
  1122. uint16 syncLostTime;
  1123. uint32 nextEventRemainder; // next periodic advertisement event remainder time
  1124. // 2020-01-17 add for CTE Sampling
  1125. CTEInfo_t IQSampleInfo;
  1126. } llPeriodicScannerInfo_t;
  1127. // ===== BBB ROM code added
  1128. typedef struct
  1129. {
  1130. uint8 isTimer1RecoverRequired;
  1131. uint32 timer1Remainder;
  1132. // uint8 isTimer2RecoverRequired;
  1133. // uint32 timer2Remainder;
  1134. //
  1135. // uint8 isTimer3RecoverRequired;
  1136. // uint32 timer3Remainder;
  1137. uint8 isTimer4RecoverRequired;
  1138. uint32 timer4Remainder;
  1139. } llSleepContext;
  1140. typedef uint8 llStatus_t;
  1141. // Packet Error Rate Information By Channel
  1142. typedef struct
  1143. {
  1144. uint16 numPkts[ LL_MAX_NUM_DATA_CHAN ];
  1145. uint16 numCrcErr[ LL_MAX_NUM_DATA_CHAN ];
  1146. } perByChan_t;
  1147. typedef struct
  1148. {
  1149. uint16 rxNumPkts[ LL_MAX_NUM_DATA_CHAN ];
  1150. uint16 rxNumCrcErr[ LL_MAX_NUM_DATA_CHAN ];
  1151. uint16 txNumRetry[ LL_MAX_NUM_DATA_CHAN ];
  1152. uint16 TxNumAck[ LL_MAX_NUM_DATA_CHAN ];
  1153. uint16 rxToCnt[ LL_MAX_NUM_DATA_CHAN ];
  1154. uint16 connEvtCnt[ LL_MAX_NUM_DATA_CHAN ];
  1155. } perStatsByChan_t;
  1156. typedef struct
  1157. {
  1158. uint16 rxNumPkts;
  1159. uint16 rxNumCrcErr;
  1160. uint16 txNumRetry;
  1161. uint16 TxNumAck;
  1162. uint16 rxToCnt;
  1163. uint16 connEvtCnt;
  1164. } perStats_t;
  1165. typedef enum{
  1166. LE_1M_PHY= 0x01,
  1167. LE_2M_PHY= 0x02,
  1168. LE_CODED_PHY=0x04,
  1169. }PhyModeCtrl_e;
  1170. typedef uint8_t ( *LL_PLUS_AdvDataFilterCB_t )(void);
  1171. typedef uint8_t ( *LL_PLUS_ScanRequestFilterCB_t )(void);
  1172. // Counters
  1173. typedef struct
  1174. {
  1175. uint8 numTxDone; // TX pkts ACK'ed (auto-empty not counted)
  1176. uint8 numTxAck; // TX pkts ACK'ed (both auto-empty and TX FIFO packets)
  1177. uint8 numTxCtrlAck; // TX control pkts ACK'ed
  1178. uint8 numTxCtrl; // TX control pkts TX'ed
  1179. uint8 numTxRetrans; // retrans + auto-empty retrans
  1180. uint8 numTx; // trans (incl. auto-empty) + retrans (incl. auto-empty)
  1181. uint8 numRxOk; // non-empty correctly RX'ed and not ignored data and control pkts
  1182. uint8 numRxCtrl; // correctly RX'ed control pkts
  1183. uint8 numRxNotOk; // RX'ed with bad CRC
  1184. uint8 numRxIgnored; // correctly RX'ed, but ignored
  1185. uint8 numRxEmpty; // correctly RX'ed empty packets
  1186. uint8 numRxFifoFull; // correctly RX'ed but discarded due to full RX FIFO
  1187. } rfCounters_t;
  1188. // global variables
  1189. extern uint8_t LL_TaskID;
  1190. extern uint8_t llState;
  1191. extern peerInfo_t peerInfo;
  1192. extern advInfo_t adv_param;
  1193. extern scanInfo_t scanInfo; // scan data
  1194. extern initInfo_t initInfo; // Initiator info
  1195. extern extScanInfo_t extScanInfo; // extended Scanner info
  1196. extern extInitInfo_t extInitInfo; // extended Initiator info
  1197. extern chanMap_t chanMapUpdate;
  1198. extern featureSet_t deviceFeatureSet;
  1199. //extern preChanMapUpdate_t preChanMapUpdate[];
  1200. extern uint8 g_maxConnNum;
  1201. extern uint8 g_maxPktPerEventTx;
  1202. extern uint8 g_maxPktPerEventRx;
  1203. extern llConnState_t *conn_param;
  1204. extern uint8 numComplPkts;
  1205. extern uint8 numComplPktsLimit;
  1206. extern verInfo_t verInfo;
  1207. extern rfCounters_t rfCounters;
  1208. extern llConns_t g_ll_conn_ctx;
  1209. extern llGlobalStatistics_t g_pmCounters;
  1210. extern llPduLenManagment_t g_llPduLen;
  1211. //extern llPhyModeManagment_t g_llPhyModeCtrl;
  1212. extern peerInfo_t g_llWhitelist[];
  1213. // Resolving list
  1214. extern resolvingListInfo_t g_llResolvinglist[];
  1215. extern uint8 g_llRlEnable;
  1216. extern uint8 g_llRlDeviceNum; // current device number in resolving list, should not exceed LL_RESOLVINGLIST_ENTRY_NUM
  1217. extern uint16 g_llRlTimeout;
  1218. // extended advertiser
  1219. extern extAdvInfo_t *g_pExtendedAdvInfo;
  1220. extern periodicAdvInfo_t *g_pPeriodicAdvInfo;
  1221. extern uint8 g_extAdvNumber; // number of ext adv set
  1222. extern uint8 g_perioAdvNumber; // number of periodic adv set
  1223. extern uint16 g_advSetMaximumLen;
  1224. // extended adv scheduler context
  1225. extern llAdvScheduleInfo_t *g_pAdvSchInfo;
  1226. extern uint8 g_schExtAdvNum; // current schedule extended adv number
  1227. extern uint8 g_currentExtAdv; // current schedule extended adv index
  1228. // ==== periodic adv scheduler context
  1229. extern llPeriodicAdvScheduleInfo_t *g_pAdvSchInfo_periodic; // periodic adv scheduler info
  1230. extern uint8 g_schExtAdvNum_periodic; // current scheduler periodic adv number
  1231. extern uint8 g_currentExtAdv_periodic; // current scheduler periodic adv index
  1232. extern uint32 g_advPerSlotTick; // us
  1233. extern uint32 g_advSlotPeriodic; // us
  1234. extern uint32 g_currentAdvTimer; // us
  1235. extern uint32 g_timerExpiryTick; // us
  1236. extern uint8 g_currentTimerTask;
  1237. extern llSleepContext g_llSleepContext;
  1238. extern llPeriodicScannerInfo_t g_llPeriodAdvSyncInfo[];
  1239. // =========== BBB ROM code
  1240. #define LL_TASK_EXTENDED_ADV 0x01
  1241. #define LL_TASK_PERIODIC_ADV 0x02
  1242. #define LL_TASK_EXTENDED_SCAN 0x03
  1243. #define LL_TASK_EXTENDED_INIT 0x04
  1244. #define LL_TASK_PERIODIC_SCAN 0x05
  1245. //#define LL_TASK_SLAVE_CONN 0x03
  1246. //#define LL_TASK_MASTER_CONN 0x04
  1247. #define LL_TASK_OTHERS 0x10
  1248. #define LL_TASK_INVALID 0xFF
  1249. extern uint8 llTaskState;
  1250. extern extAdvHdr_t ext_adv_hdr;
  1251. // 2020-02-15 add for connectionless IQ Sample buffer
  1252. extern uint16 *g_pLLcteISample;
  1253. extern uint16 *g_pLLcteQSample;
  1254. #endif