Contiki-NG
rf-ble-cmd.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017, Graz University of Technology
3  * Copyright (c) 2018, University of Bristol - http://www.bristol.ac.uk/
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * 3. Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  * OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 
32 /**
33  * \file
34  * BLE commands for the TI CC26xx BLE radio.
35  * These functions are specific to the TI CC26xx and cannot be
36  * reused by other BLE radios.
37  *
38  * \author
39  * Michael Spoerk <michael.spoerk@tugraz.at>
40  * Jinyan BAI <onefreebjy@outlook.com>
41  */
42 /*---------------------------------------------------------------------------*/
43 #include "contiki.h"
44 
45 #include "rf_ble_cmd.h"
46 #include "rf-core/rf-core.h"
48 
49 /*---------------------------------------------------------------------------*/
50 #include "sys/log.h"
51 #define LOG_MODULE "BLE-RADIO"
52 #define LOG_LEVEL LOG_LEVEL_MAIN
53 /*---------------------------------------------------------------------------*/
54 #define CMD_GET_STATUS(X) (((rfc_radioOp_t *)X)->status)
55 /*---------------------------------------------------------------------------*/
56 /* values for a selection of available TX powers (values from SmartRF Studio) */
57 /*static uint16_t tx_power = 0x9330; / * +5 dBm * / */
58 static uint16_t tx_power = 0x3161; /* 0 dBm */
59 /*static uint16_t tx_power = 0x0CCB; / * -15 dBm * / */
60 /*---------------------------------------------------------------------------*/
61 /* BLE overrides */
62 #if RADIO_CONF_BLE5
63 uint32_t ble_overrides_common[] =
64 {
65  /* Rx: Set LNA IB trim value based on the selected defaultPhy.mainMode setting. (NOTE: The value 0x8 is a placeholder. The value to use should be set during run-time by radio driver function.) */
66  ADI_HALFREG_OVERRIDE(0,4,0xF,0x8),
67  /* Rx: Set LNA IB offset used for automatic software compensation to 0 */
68  (uint32_t)0x00008883,
69  /* Synth: Use 24 MHz crystal, enable extra PLL filtering */
70  (uint32_t)0x02010403,
71  /* Synth: Set fine top and bottom code to 127 and 0 */
72  HW_REG_OVERRIDE(0x4020, 0x7F00),
73  /* Synth: Configure faster calibration */
74  HW32_ARRAY_OVERRIDE(0x4004, 1),
75  /* Synth: Configure faster calibration */
76  (uint32_t)0x1C0C0618,
77  /* Synth: Configure faster calibration */
78  (uint32_t)0xC00401A1,
79  /* Synth: Configure faster calibration */
80  (uint32_t)0x21010101,
81  /* Synth: Configure faster calibration */
82  (uint32_t)0xC0040141,
83  /* Synth: Configure faster calibration */
84  (uint32_t)0x00214AD3,
85  /* Synth: Decrease synth programming time-out by 90 us (0x0298 RAT ticks = 166 us) */
86  (uint32_t)0x02980243,
87  /* Bluetooth 5: Set correct total clock accuracy for received AuxPtr assuming local sleep clock of 50 ppm */
88  (uint32_t)0x0E490823,
89  /* override_frontend_id.xml */
90  (uint32_t)0xFFFFFFFF,
91 };
92 
93 uint32_t ble_overrides_1Mbps[] =
94 {
95  /* Rx: Set LNA IB trim to normal trim value. (NOTE: The value 0x8 is a placeholder. The value to use should be set during run-time by radio driver function.) */
96  ADI_HALFREG_OVERRIDE(0,4,0xF,0x8),
97  /* Rx: Configure AGC to use gain table for improved performance */
98  HW_REG_OVERRIDE(0x6084, 0x05F8),
99  (uint32_t)0xFFFFFFFF,
100 };
101 
102 uint32_t ble_overrides_2Mbps[] =
103 {
104  /* Rx: Set LNA IB trim to normal trim value. (NOTE: The value 0x8 is a placeholder. The value to use should be set during run-time by radio driver function.) */
105  ADI_HALFREG_OVERRIDE(0,4,0xF,0x8),
106  (uint32_t)0xFFFFFFFF,
107 };
108 
109 uint32_t ble_overrides_coded[] =
110 {
111  /* Rx: Set LNA IB trim to 0xF (maximum) */
112  ADI_HALFREG_OVERRIDE(0,4,0xF,0xF),
113  /* Rx: Override AGC target gain to improve performance */
114  HW_REG_OVERRIDE(0x6088, 0x0018),
115  (uint32_t)0xFFFFFFFF,
116 };
117 #else
118 static uint32_t ble_overrides[] = {
119  0x00364038, /* Synth: Set RTRIM (POTAILRESTRIM) to 6 */
120  0x000784A3, /* Synth: Set FREF = 3.43 MHz (24 MHz / 7) */
121  0xA47E0583, /* Synth: Set loop bandwidth after lock to 80 kHz (K2) */
122  0xEAE00603, /* Synth: Set loop bandwidth after lock to 80 kHz (K3, LSB) */
123  0x00010623, /* Synth: Set loop bandwidth after lock to 80 kHz (K3, MSB) */
124  0x00456088, /* Adjust AGC reference level */
125  0x008F88B3, /* GPIO mode: https://e2e.ti.com/support/wireless_connectivity/proprietary_sub_1_ghz_simpliciti/f/156/t/488244?*/
126  0xFFFFFFFF, /* End of override list */
127 };
128 #endif
129 /*---------------------------------------------------------------------------*/
130 unsigned short
131 rf_ble_cmd_send(uint8_t *command)
132 {
133  uint32_t cmdsta;
134  rfc_radioOp_t *cmd = (rfc_radioOp_t *)command;
135 
136  if(rf_core_send_cmd((uint32_t)cmd, &cmdsta) != RF_CORE_CMD_OK) {
137  LOG_ERR("rf_ble_cmd_send() could not send cmd. status: 0x%04X\n",
138  CMD_GET_STATUS(cmd));
139  return RF_BLE_CMD_ERROR;
140  }
141  return RF_BLE_CMD_OK;
142 }
143 /*---------------------------------------------------------------------------*/
144 unsigned short
145 rf_ble_cmd_wait(uint8_t *command)
146 {
147  rfc_radioOp_t *cmd = (rfc_radioOp_t *)command;
148  if(rf_core_wait_cmd_done((void *)cmd) != RF_CORE_CMD_OK) {
149  LOG_ERR("rf_ble_cmd_wait() could not wait. status: 0x%04X\n",
150  CMD_GET_STATUS(cmd));
151  return RF_BLE_CMD_ERROR;
152  }
153  return RF_BLE_CMD_OK;
154 }
155 /*---------------------------------------------------------------------------*/
156 unsigned short
158 {
159 #if RADIO_CONF_BLE5
160  rfc_CMD_BLE5_RADIO_SETUP_t cmd;
161 
162  /* Create radio setup command */
163  rf_core_init_radio_op((rfc_radioOp_t *)&cmd, sizeof(cmd), CMD_BLE5_RADIO_SETUP);
164 
165  cmd.startTrigger.bEnaCmd = 0;
166  cmd.defaultPhy.mainMode = 1;
167  cmd.defaultPhy.coding = 1;
168  cmd.pRegOverrideCommon = ble_overrides_common;
169  cmd.pRegOverride1Mbps = ble_overrides_1Mbps;
170  cmd.pRegOverride2Mbps = ble_overrides_2Mbps;
171  cmd.pRegOverrideCoded = ble_overrides_coded;
172 #else
173  rfc_CMD_RADIO_SETUP_t cmd;
174 
175  /* Create radio setup command */
176  rf_core_init_radio_op((rfc_radioOp_t *)&cmd, sizeof(cmd), CMD_RADIO_SETUP);
177 
178  cmd.mode = 0;
179  cmd.pRegOverride = ble_overrides;
180 #endif
181  cmd.txPower = tx_power;
182 
183  /* Send Radio setup to RF Core */
184  if(rf_ble_cmd_send((uint8_t *)&cmd) != RF_BLE_CMD_OK) {
185  return RF_BLE_CMD_ERROR;
186  }
187 
188  /* Wait until radio setup is done */
189  return rf_ble_cmd_wait((uint8_t *)&cmd);
190 }
191 /*---------------------------------------------------------------------------*/
192 /* ADVERTISING functions */
193 /*---------------------------------------------------------------------------*/
194 void
195 rf_ble_cmd_create_adv_cmd(uint8_t *command, uint8_t channel,
196  uint8_t *param, uint8_t *output)
197 {
198 #if RADIO_CONF_BLE5
199  rfc_CMD_BLE5_ADV_t *c = (rfc_CMD_BLE5_ADV_t *)command;
200 
201  memset(c, 0x00, sizeof(rfc_CMD_BLE5_ADV_t));
202 
203  c->commandNo = CMD_BLE5_ADV;
204  c->rangeDelay = 0;
205 
206  c->txPower = tx_power;
207 #else
208  rfc_CMD_BLE_ADV_t *c = (rfc_CMD_BLE_ADV_t *)command;
209 
210  memset(c, 0x00, sizeof(rfc_CMD_BLE_ADV_t));
211  c->commandNo = CMD_BLE_ADV;
212 #endif
213  c->condition.rule = COND_NEVER;
214  c->whitening.bOverride = 0;
215  c->channel = channel;
216  c->pParams = (rfc_bleAdvPar_t *)param;
217  c->startTrigger.triggerType = TRIG_NOW;
218  c->pOutput = (rfc_bleAdvOutput_t *)output;
219 }
220 /*---------------------------------------------------------------------------*/
221 void
222 rf_ble_cmd_create_adv_params(uint8_t *param, dataQueue_t *rx_queue,
223  uint8_t adv_data_len, uint8_t *adv_data,
224  uint8_t scan_resp_data_len, uint8_t *scan_resp_data,
225  ble_addr_type_t own_addr_type, uint8_t *own_addr)
226 {
227  rfc_bleAdvPar_t *p = (rfc_bleAdvPar_t *)param;
228 
229  memset(p, 0x00, sizeof(rfc_bleAdvPar_t));
230 
231  p->pRxQ = rx_queue;
232  p->rxConfig.bAutoFlushIgnored = 1;
233  p->rxConfig.bAutoFlushCrcErr = 0;
234  p->rxConfig.bAutoFlushEmpty = 1;
235  p->rxConfig.bIncludeLenByte = 1;
236  p->rxConfig.bIncludeCrc = 0;
237  p->rxConfig.bAppendRssi = 1;
238  p->rxConfig.bAppendStatus = 1;
239  p->rxConfig.bAppendTimestamp = 1;
240  p->advConfig.advFilterPolicy = 0;
241  p->advConfig.bStrictLenFilter = 0;
242  p->advConfig.deviceAddrType = own_addr_type;
243  p->pDeviceAddress = (uint16_t *)own_addr;
244  p->advLen = adv_data_len;
245  p->scanRspLen = scan_resp_data_len;
246  p->pAdvData = adv_data;
247  p->pScanRspData = scan_resp_data;
248  p->endTrigger.triggerType = TRIG_NEVER;
249 }
250 /*---------------------------------------------------------------------------*/
251 /* INITIATOR functions */
252 /*---------------------------------------------------------------------------*/
253 void
254 rf_ble_cmd_create_initiator_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
255  uint8_t *output, uint32_t start_time)
256 {
257 #if RADIO_CONF_BLE5
258  rfc_CMD_BLE5_INITIATOR_t *c = (rfc_CMD_BLE5_INITIATOR_t *)cmd;
259 
260  memset(c, 0x00, sizeof(rfc_CMD_BLE5_INITIATOR_t));
261 
262  c->commandNo = CMD_BLE5_INITIATOR;
263  c->condition.rule = COND_NEVER;
264  c->whitening.bOverride = 0;
265  c->channel = channel;
266  c->pParams = (rfc_ble5InitiatorPar_t *)params;
267  c->startTrigger.triggerType = TRIG_ABSTIME;
268  c->startTime = start_time;
269  c->pOutput = (rfc_ble5ScanInitOutput_t *)output;
270 
271  c->txPower = tx_power;
272  c->rangeDelay = 0;
273 #else
274  rfc_CMD_BLE_INITIATOR_t *c = (rfc_CMD_BLE_INITIATOR_t *)cmd;
275 
276  memset(c, 0x00, sizeof(rfc_CMD_BLE_INITIATOR_t));
277 
278  c->commandNo = CMD_BLE_INITIATOR;
279  c->condition.rule = COND_NEVER;
280  c->whitening.bOverride = 0;
281  c->channel = channel;
282  c->pParams = (rfc_bleInitiatorPar_t *)params;
283  c->startTrigger.triggerType = TRIG_ABSTIME;
284  c->startTime = start_time;
285  c->pOutput = (rfc_bleInitiatorOutput_t *)output;
286 #endif
287 }
288 /*---------------------------------------------------------------------------*/
289 void
290 rf_ble_cmd_create_initiator_params(uint8_t *param, dataQueue_t *rx_queue,
291  uint32_t initiator_time,
292  ble_addr_type_t own_addr_type, uint8_t *own_addr,
293  ble_addr_type_t peer_addr_type, uint8_t *peer_addr,
294  uint32_t connect_time, uint8_t *conn_req_data)
295 {
296 #if RADIO_CONF_BLE5
297  rfc_ble5InitiatorPar_t *p = (rfc_ble5InitiatorPar_t *)param;
298  p->backoffPar.bLastSucceeded = 0;
299  p->backoffPar.bLastFailed = 0;
300  p->maxWaitTimeForAuxCh = 0;
301  p->rxStartTime = 0;
302  p->rxListenTime = 0;
303 #else
304  rfc_bleInitiatorPar_t *p = (rfc_bleInitiatorPar_t *)param;
305 #endif
306  p->pRxQ = rx_queue;
307  p->rxConfig.bAutoFlushIgnored = 1;
308  p->rxConfig.bAutoFlushCrcErr = 0;
309  p->rxConfig.bAutoFlushEmpty = 1;
310  p->rxConfig.bIncludeLenByte = 1;
311  p->rxConfig.bIncludeCrc = 0;
312  p->rxConfig.bAppendRssi = 1;
313  p->rxConfig.bAppendStatus = 1;
314  p->rxConfig.bAppendTimestamp = 1;
315 
316  /* p->initConfig.bUseWhiteList = 0; */
317  p->initConfig.bUseWhiteList = 1;
318  p->initConfig.bDynamicWinOffset = 0;
319  p->initConfig.deviceAddrType = own_addr_type;
320  p->initConfig.peerAddrType = peer_addr_type;
321  p->initConfig.bStrictLenFilter = 1;
322 
323  p->connectReqLen = 22;
324  p->pConnectReqData = conn_req_data;
325  p->pDeviceAddress = (uint16_t *)own_addr;
326  p->pWhiteList = (rfc_bleWhiteListEntry_t *)peer_addr;
327  p->connectTime = connect_time;
328  p->timeoutTrigger.triggerType = TRIG_REL_START;
329  p->timeoutTime = initiator_time;
330  p->endTrigger.triggerType = TRIG_NEVER;
331 }
332 /*---------------------------------------------------------------------------*/
333 /* CONNECTION slave functions */
334 /*---------------------------------------------------------------------------*/
335 void
336 rf_ble_cmd_create_slave_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
337  uint8_t *output, uint32_t start_time)
338 {
339 #if RADIO_CONF_BLE5
340  rfc_CMD_BLE5_SLAVE_t *c = (rfc_CMD_BLE5_SLAVE_t *)cmd;
341 
342  memset(c, 0x00, sizeof(rfc_CMD_BLE5_SLAVE_t));
343 
344  c->commandNo = CMD_BLE5_SLAVE;
345  c->condition.rule = COND_NEVER;
346  c->whitening.bOverride = 0;
347  c->channel = channel;
348  c->pParams = (rfc_ble5SlavePar_t *)params;
349  c->startTrigger.triggerType = TRIG_ABSTIME;
350  c->startTime = start_time;
351  c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
352 
353  c->phyMode.mainMode = 1;
354  c->phyMode.coding = 1;
355  c->txPower = tx_power;
356  c->rangeDelay = 0;
357 #else
358  rfc_CMD_BLE_SLAVE_t *c = (rfc_CMD_BLE_SLAVE_t *)cmd;
359 
360  memset(c, 0x00, sizeof(rfc_CMD_BLE_SLAVE_t));
361 
362  c->commandNo = CMD_BLE_SLAVE;
363  c->condition.rule = COND_NEVER;
364  c->whitening.bOverride = 0;
365  c->channel = channel;
366  c->pParams = (rfc_bleSlavePar_t *)params;
367  c->startTrigger.triggerType = TRIG_ABSTIME;
368  c->startTrigger.pastTrig = 0;
369  c->startTime = start_time;
370  c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
371 #endif
372 }
373 /*---------------------------------------------------------------------------*/
374 void
375 rf_ble_cmd_create_slave_params(uint8_t *params, dataQueue_t *rx_queue,
376  dataQueue_t *tx_queue, uint32_t access_address,
377  uint8_t crc_init_0, uint8_t crc_init_1,
378  uint8_t crc_init_2, uint32_t win_size,
379  uint32_t window_widening, uint8_t first_packet)
380 {
381 #if RADIO_CONF_BLE5
382  rfc_ble5SlavePar_t *p = (rfc_ble5SlavePar_t *)params;
383  p->maxRxPktLen = 255;
384  p->maxLenLowRate = 0;
385 #else
386  rfc_bleSlavePar_t *p = (rfc_bleSlavePar_t *)params;
387 #endif
388  p->pRxQ = rx_queue;
389  p->pTxQ = tx_queue;
390  p->rxConfig.bAutoFlushIgnored = 1;
391  p->rxConfig.bAutoFlushCrcErr = 1;
392  p->rxConfig.bAutoFlushEmpty = 1;
393  p->rxConfig.bIncludeLenByte = 1;
394  p->rxConfig.bIncludeCrc = 0;
395  p->rxConfig.bAppendRssi = 1;
396  p->rxConfig.bAppendStatus = 1;
397  p->rxConfig.bAppendTimestamp = 1;
398 
399  if(first_packet) {
400  /* set parameters for first packet according to TI Technical Reference Manual */
401  p->seqStat.lastRxSn = 1;
402  p->seqStat.lastTxSn = 1;
403  p->seqStat.nextTxSn = 0;
404  p->seqStat.bFirstPkt = 1;
405  p->seqStat.bAutoEmpty = 0;
406  p->seqStat.bLlCtrlTx = 0;
407  p->seqStat.bLlCtrlAckRx = 0;
408  p->seqStat.bLlCtrlAckPending = 0;
409  }
410 
411  p->maxNack = 0;
412  p->maxPkt = 0;
413  p->accessAddress = access_address;
414  p->crcInit0 = crc_init_0;
415  p->crcInit1 = crc_init_1;
416  p->crcInit2 = crc_init_2;
417  p->timeoutTrigger.triggerType = TRIG_REL_START;
418  if(first_packet) {
419  p->timeoutTime = (uint32_t)(10 * win_size);
420  } else {
421  p->timeoutTime = (uint32_t)(win_size + 2 * window_widening);
422  }
423  p->endTrigger.triggerType = TRIG_NEVER;
424 }
425 /*---------------------------------------------------------------------------*/
426 /* CONNECTION master functions */
427 /*---------------------------------------------------------------------------*/
428 void
429 rf_ble_cmd_create_master_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
430  uint8_t *output, uint32_t start_time)
431 {
432 #if RADIO_CONF_BLE5
433  rfc_CMD_BLE5_MASTER_t *c = (rfc_CMD_BLE5_MASTER_t *)cmd;
434 
435  memset(c, 0x00, sizeof(rfc_CMD_BLE5_MASTER_t));
436 
437  c->commandNo = CMD_BLE5_MASTER;
438  c->condition.rule = COND_NEVER;
439  c->whitening.bOverride = 0;
440  c->channel = channel;
441  c->pParams = (rfc_ble5MasterPar_t *)params;
442  c->startTrigger.triggerType = TRIG_ABSTIME;
443  c->startTime = start_time;
444  c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
445 
446  c->phyMode.mainMode = 1;
447  c->phyMode.coding = 1;
448  c->txPower = tx_power;
449  c->rangeDelay = 0;
450 #else
451  rfc_CMD_BLE_MASTER_t *c = (rfc_CMD_BLE_MASTER_t *)cmd;
452 
453  memset(c, 0x00, sizeof(rfc_CMD_BLE_MASTER_t));
454 
455  c->commandNo = CMD_BLE_MASTER;
456  c->condition.rule = COND_NEVER;
457  c->whitening.bOverride = 0;
458  c->channel = channel;
459  c->pParams = (rfc_bleMasterPar_t *)params;
460  c->startTrigger.triggerType = TRIG_ABSTIME;
461  c->startTime = start_time;
462  c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
463 #endif
464 }
465 /*---------------------------------------------------------------------------*/
466 void
467 rf_ble_cmd_create_master_params(uint8_t *params, dataQueue_t *rx_queue,
468  dataQueue_t *tx_queue, uint32_t access_address,
469  uint8_t crc_init_0, uint8_t crc_init_1,
470  uint8_t crc_init_2, uint8_t first_packet)
471 {
472 #if RADIO_CONF_BLE5
473  rfc_ble5MasterPar_t *p = (rfc_ble5MasterPar_t *)params;
474  p->maxRxPktLen = 255;
475  p->maxLenLowRate = 0;
476 #else
477  rfc_bleMasterPar_t *p = (rfc_bleMasterPar_t *)params;
478 #endif
479  p->pRxQ = rx_queue;
480  p->pTxQ = tx_queue;
481  p->rxConfig.bAutoFlushIgnored = 1;
482  p->rxConfig.bAutoFlushCrcErr = 1;
483  p->rxConfig.bAutoFlushEmpty = 1;
484  p->rxConfig.bIncludeLenByte = 1;
485  p->rxConfig.bIncludeCrc = 0;
486  p->rxConfig.bAppendRssi = 1;
487  p->rxConfig.bAppendStatus = 1;
488  p->rxConfig.bAppendTimestamp = 1;
489 
490  if(first_packet) {
491  /* set parameters for first packet according to TI Technical Reference Manual */
492  p->seqStat.lastRxSn = 1;
493  p->seqStat.lastTxSn = 1;
494  p->seqStat.nextTxSn = 0;
495  p->seqStat.bFirstPkt = 1;
496  p->seqStat.bAutoEmpty = 0;
497  p->seqStat.bLlCtrlTx = 0;
498  p->seqStat.bLlCtrlAckRx = 0;
499  p->seqStat.bLlCtrlAckPending = 0;
500  }
501 
502  p->maxPkt = 12;
503  p->accessAddress = access_address;
504  p->crcInit0 = crc_init_0;
505  p->crcInit1 = crc_init_1;
506  p->crcInit2 = crc_init_2;
507  p->endTrigger.triggerType = TRIG_REL_START;
508  p->endTime = (uint32_t)15 * 4000; /* a connection event must end after 10 ms */
509 }
510 /*---------------------------------------------------------------------------*/
511 /* DATA queue functions */
512 /*---------------------------------------------------------------------------*/
513 unsigned short
514 rf_ble_cmd_add_data_queue_entry(dataQueue_t *q, uint8_t *e)
515 {
516  uint32_t cmdsta;
517 
518  rfc_CMD_ADD_DATA_ENTRY_t cmd;
519  cmd.commandNo = CMD_ADD_DATA_ENTRY;
520  cmd.pQueue = q;
521  cmd.pEntry = e;
522 
523  if(rf_core_send_cmd((uint32_t)&cmd, &cmdsta) != RF_CORE_CMD_OK) {
524  LOG_ERR("could not add entry to data queue. status: 0x%04X\n",
525  CMD_GET_STATUS(&cmd));
526  return RF_BLE_CMD_ERROR;
527  }
528  return RF_BLE_CMD_OK;
529 }
void rf_ble_cmd_create_master_params(uint8_t *params, dataQueue_t *rx_queue, dataQueue_t *tx_queue, uint32_t access_address, uint8_t crc_init_0, uint8_t crc_init_1, uint8_t crc_init_2, uint8_t first_packet)
Creates BLE radio command parameters that are used to set up BLE connection event on the radio core...
Definition: rf-ble-cmd.c:467
void rf_ble_cmd_create_adv_params(uint8_t *param, dataQueue_t *rx_queue, uint8_t adv_data_len, uint8_t *adv_data, uint8_t scan_resp_data_len, uint8_t *scan_resp_data, ble_addr_type_t own_addr_type, uint8_t *own_addr)
Creates BLE radio command parameters that are used to enable BLE advertisement on the radio core...
Definition: rf-ble-cmd.c:222
void rf_ble_cmd_create_initiator_params(uint8_t *param, dataQueue_t *rx_queue, uint32_t initiator_time, ble_addr_type_t own_addr_type, uint8_t *own_addr, ble_addr_type_t peer_addr_type, uint8_t *peer_addr, uint32_t connect_time, uint8_t *conn_req_data)
Creates BLE radio command parameters that are used to set up BLE initiation event on the radio core...
Definition: rf-ble-cmd.c:290
unsigned short rf_ble_cmd_send(uint8_t *command)
Sends a BLE radio command to the radio.
Definition: rf-ble-cmd.c:131
Header file for the CC13xx/CC26xx RF core driver.
static uint8_t output(const linkaddr_t *localdest)
Take an IP packet and format it to be sent on an 802.15.4 network using 6lowpan.
Definition: sicslowpan.c:1565
BLE commands for the TI CC26xx BLE radio.
void rf_ble_cmd_create_initiator_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params, uint8_t *output, uint32_t start_time)
Creates a BLE radio command structure that sets up BLE initiation event when sent to the radio core...
Definition: rf-ble-cmd.c:254
unsigned short rf_ble_cmd_setup_ble_mode(void)
Initializes the radio core to be used as a BLE radio.
Definition: rf-ble-cmd.c:157
void rf_ble_cmd_create_slave_params(uint8_t *params, dataQueue_t *rx_queue, dataQueue_t *tx_queue, uint32_t access_address, uint8_t crc_init_0, uint8_t crc_init_1, uint8_t crc_init_2, uint32_t win_size, uint32_t window_widening, uint8_t first_packet)
Creates BLE radio command parameters that are used to setup a single BLE connection event on the radi...
Definition: rf-ble-cmd.c:375
void rf_core_init_radio_op(rfc_radioOp_t *op, uint16_t len, uint16_t command)
Prepare a buffer to host a Radio Op.
Definition: rf-core.c:540
unsigned short rf_ble_cmd_wait(uint8_t *command)
Waits for a running BLE radio command to be finished.
Definition: rf-ble-cmd.c:145
unsigned short rf_ble_cmd_add_data_queue_entry(dataQueue_t *q, uint8_t *e)
Adds a data buffer to a BLE transmission queue.
Definition: rf-ble-cmd.c:514
uint_fast8_t rf_core_send_cmd(uint32_t cmd, uint32_t *status)
Sends a command to the RF core.
Definition: rf-core.c:154
void rf_ble_cmd_create_slave_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params, uint8_t *output, uint32_t start_time)
Creates a BLE radio command structure that sets up a single BLE connection event when sent to the rad...
Definition: rf-ble-cmd.c:336
Header file for the logging system
void rf_ble_cmd_create_adv_cmd(uint8_t *command, uint8_t channel, uint8_t *param, uint8_t *output)
Creates a BLE radio command structure that enables BLE advertisement when sent to the radio core...
Definition: rf-ble-cmd.c:195
uint_fast8_t rf_core_wait_cmd_done(void *cmd)
Block and wait for a Radio op to complete.
Definition: rf-core.c:220
void rf_ble_cmd_create_master_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params, uint8_t *output, uint32_t start_time)
Creates a BLE radio command structure that sets up BLE connection event when sent to the radio core...
Definition: rf-ble-cmd.c:429