Contiki-NG
Loading...
Searching...
No Matches
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#include <inttypes.h>
49
50/*---------------------------------------------------------------------------*/
51#include "sys/log.h"
52#define LOG_MODULE "BLE-RADIO"
53#define LOG_LEVEL LOG_LEVEL_MAIN
54/*---------------------------------------------------------------------------*/
55#define CMD_GET_STATUS(X) (((rfc_radioOp_t *)X)->status)
56/*---------------------------------------------------------------------------*/
57/* values for a selection of available TX powers (values from SmartRF Studio) */
58/*static uint16_t tx_power = 0x9330; / * +5 dBm * / */
59static uint16_t tx_power = 0x3161; /* 0 dBm */
60/*static uint16_t tx_power = 0x0CCB; / * -15 dBm * / */
61/*---------------------------------------------------------------------------*/
62/* BLE overrides */
63#if RADIO_CONF_BLE5
64uint32_t ble_overrides_common[] =
65{
66 /* 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.) */
67 ADI_HALFREG_OVERRIDE(0,4,0xF,0x8),
68 /* Rx: Set LNA IB offset used for automatic software compensation to 0 */
69 (uint32_t)0x00008883,
70 /* Synth: Use 24 MHz crystal, enable extra PLL filtering */
71 (uint32_t)0x02010403,
72 /* Synth: Set fine top and bottom code to 127 and 0 */
73 HW_REG_OVERRIDE(0x4020, 0x7F00),
74 /* Synth: Configure faster calibration */
75 HW32_ARRAY_OVERRIDE(0x4004, 1),
76 /* Synth: Configure faster calibration */
77 (uint32_t)0x1C0C0618,
78 /* Synth: Configure faster calibration */
79 (uint32_t)0xC00401A1,
80 /* Synth: Configure faster calibration */
81 (uint32_t)0x21010101,
82 /* Synth: Configure faster calibration */
83 (uint32_t)0xC0040141,
84 /* Synth: Configure faster calibration */
85 (uint32_t)0x00214AD3,
86 /* Synth: Decrease synth programming time-out by 90 us (0x0298 RAT ticks = 166 us) */
87 (uint32_t)0x02980243,
88 /* Bluetooth 5: Set correct total clock accuracy for received AuxPtr assuming local sleep clock of 50 ppm */
89 (uint32_t)0x0E490823,
90 /* override_frontend_id.xml */
91 (uint32_t)0xFFFFFFFF,
92};
93
94uint32_t ble_overrides_1Mbps[] =
95{
96 /* 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.) */
97 ADI_HALFREG_OVERRIDE(0,4,0xF,0x8),
98 /* Rx: Configure AGC to use gain table for improved performance */
99 HW_REG_OVERRIDE(0x6084, 0x05F8),
100 (uint32_t)0xFFFFFFFF,
101};
102
103uint32_t ble_overrides_2Mbps[] =
104{
105 /* 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.) */
106 ADI_HALFREG_OVERRIDE(0,4,0xF,0x8),
107 (uint32_t)0xFFFFFFFF,
108};
109
110uint32_t ble_overrides_coded[] =
111{
112 /* Rx: Set LNA IB trim to 0xF (maximum) */
113 ADI_HALFREG_OVERRIDE(0,4,0xF,0xF),
114 /* Rx: Override AGC target gain to improve performance */
115 HW_REG_OVERRIDE(0x6088, 0x0018),
116 (uint32_t)0xFFFFFFFF,
117};
118#else
119static uint32_t ble_overrides[] = {
120 0x00364038, /* Synth: Set RTRIM (POTAILRESTRIM) to 6 */
121 0x000784A3, /* Synth: Set FREF = 3.43 MHz (24 MHz / 7) */
122 0xA47E0583, /* Synth: Set loop bandwidth after lock to 80 kHz (K2) */
123 0xEAE00603, /* Synth: Set loop bandwidth after lock to 80 kHz (K3, LSB) */
124 0x00010623, /* Synth: Set loop bandwidth after lock to 80 kHz (K3, MSB) */
125 0x00456088, /* Adjust AGC reference level */
126 0x008F88B3, /* GPIO mode: https://e2e.ti.com/support/wireless_connectivity/proprietary_sub_1_ghz_simpliciti/f/156/t/488244?*/
127 0xFFFFFFFF, /* End of override list */
128};
129#endif
130/*---------------------------------------------------------------------------*/
131unsigned short
132rf_ble_cmd_send(uint8_t *command)
133{
134 uint32_t cmdsta;
135 rfc_radioOp_t *cmd = (rfc_radioOp_t *)command;
136
137 if(rf_core_send_cmd((uint32_t)cmd, &cmdsta) != RF_CORE_CMD_OK) {
138 LOG_ERR("rf_ble_cmd_send() could not send cmd. status: 0x%04X\n",
139 CMD_GET_STATUS(cmd));
140 return RF_BLE_CMD_ERROR;
141 }
142 return RF_BLE_CMD_OK;
143}
144/*---------------------------------------------------------------------------*/
145unsigned short
146rf_ble_cmd_wait(uint8_t *command)
147{
148 rfc_radioOp_t *cmd = (rfc_radioOp_t *)command;
149 if(rf_core_wait_cmd_done((void *)cmd) != RF_CORE_CMD_OK) {
150 LOG_ERR("rf_ble_cmd_wait() could not wait. status: 0x%04X\n",
151 CMD_GET_STATUS(cmd));
152 return RF_BLE_CMD_ERROR;
153 }
154 return RF_BLE_CMD_OK;
155}
156/*---------------------------------------------------------------------------*/
157unsigned short
159{
160#if RADIO_CONF_BLE5
161 rfc_CMD_BLE5_RADIO_SETUP_t cmd;
162
163 /* Create radio setup command */
164 rf_core_init_radio_op((rfc_radioOp_t *)&cmd, sizeof(cmd), CMD_BLE5_RADIO_SETUP);
165
166 cmd.startTrigger.bEnaCmd = 0;
167 cmd.defaultPhy.mainMode = 1;
168 cmd.defaultPhy.coding = 1;
169 cmd.pRegOverrideCommon = ble_overrides_common;
170 cmd.pRegOverride1Mbps = ble_overrides_1Mbps;
171 cmd.pRegOverride2Mbps = ble_overrides_2Mbps;
172 cmd.pRegOverrideCoded = ble_overrides_coded;
173#else
174 rfc_CMD_RADIO_SETUP_t cmd;
175
176 /* Create radio setup command */
177 rf_core_init_radio_op((rfc_radioOp_t *)&cmd, sizeof(cmd), CMD_RADIO_SETUP);
178
179 cmd.mode = 0;
180 cmd.pRegOverride = ble_overrides;
181#endif
182 cmd.txPower = tx_power;
183
184 /* Send Radio setup to RF Core */
185 if(rf_ble_cmd_send((uint8_t *)&cmd) != RF_BLE_CMD_OK) {
186 return RF_BLE_CMD_ERROR;
187 }
188
189 /* Wait until radio setup is done */
190 return rf_ble_cmd_wait((uint8_t *)&cmd);
191}
192/*---------------------------------------------------------------------------*/
193/* ADVERTISING functions */
194/*---------------------------------------------------------------------------*/
195void
196rf_ble_cmd_create_adv_cmd(uint8_t *command, uint8_t channel,
197 uint8_t *param, uint8_t *output)
198{
199#if RADIO_CONF_BLE5
200 rfc_CMD_BLE5_ADV_t *c = (rfc_CMD_BLE5_ADV_t *)command;
201
202 memset(c, 0x00, sizeof(rfc_CMD_BLE5_ADV_t));
203
204 c->commandNo = CMD_BLE5_ADV;
205 c->rangeDelay = 0;
206
207 c->txPower = tx_power;
208#else
209 rfc_CMD_BLE_ADV_t *c = (rfc_CMD_BLE_ADV_t *)command;
210
211 memset(c, 0x00, sizeof(rfc_CMD_BLE_ADV_t));
212 c->commandNo = CMD_BLE_ADV;
213#endif
214 c->condition.rule = COND_NEVER;
215 c->whitening.bOverride = 0;
216 c->channel = channel;
217 c->pParams = (rfc_bleAdvPar_t *)param;
218 c->startTrigger.triggerType = TRIG_NOW;
219 c->pOutput = (rfc_bleAdvOutput_t *)output;
220}
221/*---------------------------------------------------------------------------*/
222void
223rf_ble_cmd_create_adv_params(uint8_t *param, dataQueue_t *rx_queue,
224 uint8_t adv_data_len, uint8_t *adv_data,
225 uint8_t scan_resp_data_len, uint8_t *scan_resp_data,
226 ble_addr_type_t own_addr_type, uint8_t *own_addr)
227{
228 rfc_bleAdvPar_t *p = (rfc_bleAdvPar_t *)param;
229
230 memset(p, 0x00, sizeof(rfc_bleAdvPar_t));
231
232 p->pRxQ = rx_queue;
233 p->rxConfig.bAutoFlushIgnored = 1;
234 p->rxConfig.bAutoFlushCrcErr = 0;
235 p->rxConfig.bAutoFlushEmpty = 1;
236 p->rxConfig.bIncludeLenByte = 1;
237 p->rxConfig.bIncludeCrc = 0;
238 p->rxConfig.bAppendRssi = 1;
239 p->rxConfig.bAppendStatus = 1;
240 p->rxConfig.bAppendTimestamp = 1;
241 p->advConfig.advFilterPolicy = 0;
242 p->advConfig.bStrictLenFilter = 0;
243 p->advConfig.deviceAddrType = own_addr_type;
244 p->pDeviceAddress = (uint16_t *)own_addr;
245 p->advLen = adv_data_len;
246 p->scanRspLen = scan_resp_data_len;
247 p->pAdvData = adv_data;
248 p->pScanRspData = scan_resp_data;
249 p->endTrigger.triggerType = TRIG_NEVER;
250}
251/*---------------------------------------------------------------------------*/
252/* INITIATOR functions */
253/*---------------------------------------------------------------------------*/
254void
255rf_ble_cmd_create_initiator_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
256 uint8_t *output, uint32_t start_time)
257{
258#if RADIO_CONF_BLE5
259 rfc_CMD_BLE5_INITIATOR_t *c = (rfc_CMD_BLE5_INITIATOR_t *)cmd;
260
261 memset(c, 0x00, sizeof(rfc_CMD_BLE5_INITIATOR_t));
262
263 c->commandNo = CMD_BLE5_INITIATOR;
264 c->condition.rule = COND_NEVER;
265 c->whitening.bOverride = 0;
266 c->channel = channel;
267 c->pParams = (rfc_ble5InitiatorPar_t *)params;
268 c->startTrigger.triggerType = TRIG_ABSTIME;
269 c->startTime = start_time;
270 c->pOutput = (rfc_ble5ScanInitOutput_t *)output;
271
272 c->txPower = tx_power;
273 c->rangeDelay = 0;
274#else
275 rfc_CMD_BLE_INITIATOR_t *c = (rfc_CMD_BLE_INITIATOR_t *)cmd;
276
277 memset(c, 0x00, sizeof(rfc_CMD_BLE_INITIATOR_t));
278
279 c->commandNo = CMD_BLE_INITIATOR;
280 c->condition.rule = COND_NEVER;
281 c->whitening.bOverride = 0;
282 c->channel = channel;
283 c->pParams = (rfc_bleInitiatorPar_t *)params;
284 c->startTrigger.triggerType = TRIG_ABSTIME;
285 c->startTime = start_time;
286 c->pOutput = (rfc_bleInitiatorOutput_t *)output;
287#endif
288}
289/*---------------------------------------------------------------------------*/
290void
291rf_ble_cmd_create_initiator_params(uint8_t *param, dataQueue_t *rx_queue,
292 uint32_t initiator_time,
293 ble_addr_type_t own_addr_type, uint8_t *own_addr,
294 ble_addr_type_t peer_addr_type, uint8_t *peer_addr,
295 uint32_t connect_time, uint8_t *conn_req_data)
296{
297#if RADIO_CONF_BLE5
298 rfc_ble5InitiatorPar_t *p = (rfc_ble5InitiatorPar_t *)param;
299 p->backoffPar.bLastSucceeded = 0;
300 p->backoffPar.bLastFailed = 0;
301 p->maxWaitTimeForAuxCh = 0;
302 p->rxStartTime = 0;
303 p->rxListenTime = 0;
304#else
305 rfc_bleInitiatorPar_t *p = (rfc_bleInitiatorPar_t *)param;
306#endif
307 p->pRxQ = rx_queue;
308 p->rxConfig.bAutoFlushIgnored = 1;
309 p->rxConfig.bAutoFlushCrcErr = 0;
310 p->rxConfig.bAutoFlushEmpty = 1;
311 p->rxConfig.bIncludeLenByte = 1;
312 p->rxConfig.bIncludeCrc = 0;
313 p->rxConfig.bAppendRssi = 1;
314 p->rxConfig.bAppendStatus = 1;
315 p->rxConfig.bAppendTimestamp = 1;
316
317 /* p->initConfig.bUseWhiteList = 0; */
318 p->initConfig.bUseWhiteList = 1;
319 p->initConfig.bDynamicWinOffset = 0;
320 p->initConfig.deviceAddrType = own_addr_type;
321 p->initConfig.peerAddrType = peer_addr_type;
322 p->initConfig.bStrictLenFilter = 1;
323
324 p->connectReqLen = 22;
325 p->pConnectReqData = conn_req_data;
326 p->pDeviceAddress = (uint16_t *)own_addr;
327 p->pWhiteList = (rfc_bleWhiteListEntry_t *)peer_addr;
328 p->connectTime = connect_time;
329 p->timeoutTrigger.triggerType = TRIG_REL_START;
330 p->timeoutTime = initiator_time;
331 p->endTrigger.triggerType = TRIG_NEVER;
332}
333/*---------------------------------------------------------------------------*/
334/* CONNECTION slave functions */
335/*---------------------------------------------------------------------------*/
336void
337rf_ble_cmd_create_slave_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
338 uint8_t *output, uint32_t start_time)
339{
340#if RADIO_CONF_BLE5
341 rfc_CMD_BLE5_SLAVE_t *c = (rfc_CMD_BLE5_SLAVE_t *)cmd;
342
343 memset(c, 0x00, sizeof(rfc_CMD_BLE5_SLAVE_t));
344
345 c->commandNo = CMD_BLE5_SLAVE;
346 c->condition.rule = COND_NEVER;
347 c->whitening.bOverride = 0;
348 c->channel = channel;
349 c->pParams = (rfc_ble5SlavePar_t *)params;
350 c->startTrigger.triggerType = TRIG_ABSTIME;
351 c->startTime = start_time;
352 c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
353
354 c->phyMode.mainMode = 1;
355 c->phyMode.coding = 1;
356 c->txPower = tx_power;
357 c->rangeDelay = 0;
358#else
359 rfc_CMD_BLE_SLAVE_t *c = (rfc_CMD_BLE_SLAVE_t *)cmd;
360
361 memset(c, 0x00, sizeof(rfc_CMD_BLE_SLAVE_t));
362
363 c->commandNo = CMD_BLE_SLAVE;
364 c->condition.rule = COND_NEVER;
365 c->whitening.bOverride = 0;
366 c->channel = channel;
367 c->pParams = (rfc_bleSlavePar_t *)params;
368 c->startTrigger.triggerType = TRIG_ABSTIME;
369 c->startTrigger.pastTrig = 0;
370 c->startTime = start_time;
371 c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
372#endif
373}
374/*---------------------------------------------------------------------------*/
375void
376rf_ble_cmd_create_slave_params(uint8_t *params, dataQueue_t *rx_queue,
377 dataQueue_t *tx_queue, uint32_t access_address,
378 uint8_t crc_init_0, uint8_t crc_init_1,
379 uint8_t crc_init_2, uint32_t win_size,
380 uint32_t window_widening, uint8_t first_packet)
381{
382#if RADIO_CONF_BLE5
383 rfc_ble5SlavePar_t *p = (rfc_ble5SlavePar_t *)params;
384 p->maxRxPktLen = 255;
385 p->maxLenLowRate = 0;
386#else
387 rfc_bleSlavePar_t *p = (rfc_bleSlavePar_t *)params;
388#endif
389 p->pRxQ = rx_queue;
390 p->pTxQ = tx_queue;
391 p->rxConfig.bAutoFlushIgnored = 1;
392 p->rxConfig.bAutoFlushCrcErr = 1;
393 p->rxConfig.bAutoFlushEmpty = 1;
394 p->rxConfig.bIncludeLenByte = 1;
395 p->rxConfig.bIncludeCrc = 0;
396 p->rxConfig.bAppendRssi = 1;
397 p->rxConfig.bAppendStatus = 1;
398 p->rxConfig.bAppendTimestamp = 1;
399
400 if(first_packet) {
401 /* set parameters for first packet according to TI Technical Reference Manual */
402 p->seqStat.lastRxSn = 1;
403 p->seqStat.lastTxSn = 1;
404 p->seqStat.nextTxSn = 0;
405 p->seqStat.bFirstPkt = 1;
406 p->seqStat.bAutoEmpty = 0;
407 p->seqStat.bLlCtrlTx = 0;
408 p->seqStat.bLlCtrlAckRx = 0;
409 p->seqStat.bLlCtrlAckPending = 0;
410 }
411
412 p->maxNack = 0;
413 p->maxPkt = 0;
414 p->accessAddress = access_address;
415 p->crcInit0 = crc_init_0;
416 p->crcInit1 = crc_init_1;
417 p->crcInit2 = crc_init_2;
418 p->timeoutTrigger.triggerType = TRIG_REL_START;
419 if(first_packet) {
420 p->timeoutTime = (uint32_t)(10 * win_size);
421 } else {
422 p->timeoutTime = (uint32_t)(win_size + 2 * window_widening);
423 }
424 p->endTrigger.triggerType = TRIG_NEVER;
425}
426/*---------------------------------------------------------------------------*/
427/* CONNECTION master functions */
428/*---------------------------------------------------------------------------*/
429void
430rf_ble_cmd_create_master_cmd(uint8_t *cmd, uint8_t channel, uint8_t *params,
431 uint8_t *output, uint32_t start_time)
432{
433#if RADIO_CONF_BLE5
434 rfc_CMD_BLE5_MASTER_t *c = (rfc_CMD_BLE5_MASTER_t *)cmd;
435
436 memset(c, 0x00, sizeof(rfc_CMD_BLE5_MASTER_t));
437
438 c->commandNo = CMD_BLE5_MASTER;
439 c->condition.rule = COND_NEVER;
440 c->whitening.bOverride = 0;
441 c->channel = channel;
442 c->pParams = (rfc_ble5MasterPar_t *)params;
443 c->startTrigger.triggerType = TRIG_ABSTIME;
444 c->startTime = start_time;
445 c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
446
447 c->phyMode.mainMode = 1;
448 c->phyMode.coding = 1;
449 c->txPower = tx_power;
450 c->rangeDelay = 0;
451#else
452 rfc_CMD_BLE_MASTER_t *c = (rfc_CMD_BLE_MASTER_t *)cmd;
453
454 memset(c, 0x00, sizeof(rfc_CMD_BLE_MASTER_t));
455
456 c->commandNo = CMD_BLE_MASTER;
457 c->condition.rule = COND_NEVER;
458 c->whitening.bOverride = 0;
459 c->channel = channel;
460 c->pParams = (rfc_bleMasterPar_t *)params;
461 c->startTrigger.triggerType = TRIG_ABSTIME;
462 c->startTime = start_time;
463 c->pOutput = (rfc_bleMasterSlaveOutput_t *)output;
464#endif
465}
466/*---------------------------------------------------------------------------*/
467void
468rf_ble_cmd_create_master_params(uint8_t *params, dataQueue_t *rx_queue,
469 dataQueue_t *tx_queue, uint32_t access_address,
470 uint8_t crc_init_0, uint8_t crc_init_1,
471 uint8_t crc_init_2, uint8_t first_packet)
472{
473#if RADIO_CONF_BLE5
474 rfc_ble5MasterPar_t *p = (rfc_ble5MasterPar_t *)params;
475 p->maxRxPktLen = 255;
476 p->maxLenLowRate = 0;
477#else
478 rfc_bleMasterPar_t *p = (rfc_bleMasterPar_t *)params;
479#endif
480 p->pRxQ = rx_queue;
481 p->pTxQ = tx_queue;
482 p->rxConfig.bAutoFlushIgnored = 1;
483 p->rxConfig.bAutoFlushCrcErr = 1;
484 p->rxConfig.bAutoFlushEmpty = 1;
485 p->rxConfig.bIncludeLenByte = 1;
486 p->rxConfig.bIncludeCrc = 0;
487 p->rxConfig.bAppendRssi = 1;
488 p->rxConfig.bAppendStatus = 1;
489 p->rxConfig.bAppendTimestamp = 1;
490
491 if(first_packet) {
492 /* set parameters for first packet according to TI Technical Reference Manual */
493 p->seqStat.lastRxSn = 1;
494 p->seqStat.lastTxSn = 1;
495 p->seqStat.nextTxSn = 0;
496 p->seqStat.bFirstPkt = 1;
497 p->seqStat.bAutoEmpty = 0;
498 p->seqStat.bLlCtrlTx = 0;
499 p->seqStat.bLlCtrlAckRx = 0;
500 p->seqStat.bLlCtrlAckPending = 0;
501 }
502
503 p->maxPkt = 12;
504 p->accessAddress = access_address;
505 p->crcInit0 = crc_init_0;
506 p->crcInit1 = crc_init_1;
507 p->crcInit2 = crc_init_2;
508 p->endTrigger.triggerType = TRIG_REL_START;
509 p->endTime = (uint32_t)15 * 4000; /* a connection event must end after 10 ms */
510}
511/*---------------------------------------------------------------------------*/
512/* DATA queue functions */
513/*---------------------------------------------------------------------------*/
514unsigned short
515rf_ble_cmd_add_data_queue_entry(dataQueue_t *q, uint8_t *e)
516{
517 uint32_t cmdsta;
518
519 rfc_CMD_ADD_DATA_ENTRY_t cmd;
520 cmd.commandNo = CMD_ADD_DATA_ENTRY;
521 cmd.pQueue = q;
522 cmd.pEntry = e;
523
524 if(rf_core_send_cmd((uint32_t)&cmd, &cmdsta) != RF_CORE_CMD_OK) {
525 LOG_ERR("could not add entry to data queue. status: 0x%04" PRIX32 "\n", cmdsta);
526 return RF_BLE_CMD_ERROR;
527 }
528 return RF_BLE_CMD_OK;
529}
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:553
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
uint_fast8_t rf_core_wait_cmd_done(void *cmd)
Block and wait for a Radio op to complete.
Definition rf-core.c:226
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:196
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:376
unsigned short rf_ble_cmd_send(uint8_t *command)
Sends a BLE radio command to the radio.
Definition rf-ble-cmd.c:132
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:337
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:468
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:223
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:255
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:430
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:291
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:158
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:515
unsigned short rf_ble_cmd_wait(uint8_t *command)
Waits for a running BLE radio command to be finished.
Definition rf-ble-cmd.c:146
BLE commands for the TI CC26xx BLE radio.
Header file for the CC13xx/CC26xx RF core driver.