1 /*
2  * Copyright (c) 2016-2020, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*!****************************************************************************
33 @file   RFCC26X2.h
34 @brief  Radio Frequency (RF) Core Driver for the CC13X2 and CC26X2 device
35         family.
36 
37 To use the RF driver, ensure that the correct driver library for your device
38 is linked in and include the top-level header file as follows:
39 
40 @code
41 #include <ti/drivers/rf/RF.h>
42 @endcode
43 
44 <hr>
45 @anchor rf_overview
46 Overview
47 ========
48 
49 The RF driver provides access to the radio core on the CC13x2/CC26x2 device
50 family. It offers a high-level interface for command execution and to the
51 radio timer (RAT). The RF driver ensures the lowest possible power consumption
52 by providing automatic power management that is fully transparent for the
53 application.
54 
55 @note This document describes the features and usage of the RF driver API. For a
56 detailed explanation of the RF core, please refer to the
57 <a href='../../proprietary-rf/technical-reference-manual.html'><b>Technical
58 Reference Manual</b></a> or the
59 <a href='../../proprietary-rf/proprietary-rf-users-guide.html'><b>Proprietary
60 RF User Guide</b></a>.
61 
62 <b>Key features are:</b>
63 
64 @li @ref rf_command_execution "Synchronous execution of direct and immediate radio commands"
65 @li @ref rf_command_execution "Synchronous and asynchronous execution of radio operation commands"
66 @li Various @ref rf_event_callbacks "event hooks" to interact with RF commands and the RF driver
67 @li Automatic @ref rf_power_management "power management"
68 @li @ref rf_scheduling "Preemptive scheduler for RF operations" of different RF driver instances
69 @li Convenient @ref rf_rat "Access to the radio timer" (RAT)
70 @li @ref rf_tx_power "Programming the TX power level"
71 
72 @anchor rf_setup_and_configuration
73 Setup and configuration
74 =======================
75 
76 The RF driver can be configured at 4 different places:
77 
78 1. In the build configuration by choosing either the single-client or
79    multi-client driver version.
80 
81 2. At compile-time by setting hardware and software interrupt priorities
82    in the board support file.
83 
84 3. During run-time initialization by setting #RF_Params when calling
85    #RF_open().
86 
87 4. At run-time via #RF_control().
88 
89 
90 Build configuration
91 -------------------
92 
93 The RF driver comes in two versions: single-client and multi-client. The
94 single-client version allows only one driver instance to access the RF core at
95 a time. The multi-client driver version allows concurrent access to the RF
96 core with different RF settings. The multi-client driver has a slightly larger
97 footprint and is not needed for many proprietary applications. The driver
98 version can be selected in the build configuration by linking against a
99 RFCC26X2_multiMode pre-built library. The multi-client driver is the default
100 configuration in the SimpleLink SDKs.
101 
102 
103 Board configuration
104 -------------------
105 
106 The RF driver handles RF core hardware interrupts and uses software interrupts
107 for its internal state machine. For managing the interrupt priorities, it
108 expects the existence of a global #RFCC26XX_HWAttrsV2 object. This is
109 usually defined in the board support file, for example `CC2652RB_LAUNCHXL.c`,
110 but when developing on custom boards, it might be kept anywhere in the
111 application. By default, the priorities are set to the lowest possible value:
112 
113 @code
114 const RFCC26XX_HWAttrsV2 RFCC26XX_hwAttrs = {
115     .hwiPriority        = INT_PRI_LEVEL7,  // Lowest HWI priority:  INT_PRI_LEVEL7
116                                            // Highest HWI priority: INT_PRI_LEVEL1
117 
118     .swiPriority        = 0,               // Lowest SWI priority:  0
119                                            // Highest SWI priority: Swi.numPriorities - 1
120 
121     .xoscHfAlwaysNeeded = true             // Power driver always starts XOSC-HF:       true
122                                            // RF driver will request XOSC-HF if needed: false
123 };
124 @endcode
125 
126 
127 Initialization
128 --------------
129 
130 When initiating an RF driver instance, the function #RF_open() accepts a
131 pointer to a #RF_Params object which might set several driver parameters. In
132 addition, it expects an #RF_Mode object and a setup command which is usually
133 generated by SmartRF Studio:
134 
135 @code
136 RF_Params rfParams;
137 RF_Params_init(&rfParams);
138 rfParams.nInactivityTimeout = 2000;
139 
140 RF_Handle rfHandle = RF_open(&rfObject, &RF_prop,
141         (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
142 @endcode
143 
144 The function #RF_open() returns a driver handle that is used for accessing the
145 correct driver instance. Please note that the first RF operation command
146 before an RX or TX operation command must be a `CMD_FS` to set the synthesizer
147 frequency. The RF driver caches both, the pointer to the setup command and the
148 physical `CMD_FS` for automatic power management.
149 
150 
151 Run-time configuration
152 ----------------------
153 
154 While a driver instance is opened, it can be re-configured with the function
155 #RF_control(). Various configuration parameters @ref RF_CTRL are available.
156 Example:
157 
158 @code
159 uint32_t timeoutUs = 2000;
160 RF_control(rfHandle, RF_CTRL_SET_INACTIVITY_TIMEOUT, &timeoutUs);
161 @endcode
162 
163 <hr>
164 @anchor rf_command_execution
165 Command execution
166 =================
167 
168 The RF core supports 3 different kinds of commands:
169 
170 1. Direct commands
171 2. Immediate commands
172 3. Radio operation commands
173 
174 Direct and immediate commands are dispatched via #RF_runDirectCmd() and
175 #RF_runImmediateCmd() respectively. These functions block until the command
176 has completed and return a status code of the type #RF_Stat when done.
177 
178 @code
179 #include <ti/devices/${DEVICE_FAMILY}/driverlib/rf_common_cmd.h>
180 
181 RF_Stat status = RF_runDirectCmd(rfHandle, CMD_ABORT);
182 assert(status == RF_StatCmdDoneSuccess);
183 @endcode
184 
185 Radio operation commands are potentially long-running commands and support
186 different triggers as well as conditional execution. Only one command can be
187 executed at a time, but the RF driver provides an internal queue that stores
188 commands until the RF core is free. Two interfaces are provided for radio
189 operation commands:
190 
191 1. Asynchronous: #RF_postCmd() and #RF_pendCmd()
192 2. Synchronous: #RF_runCmd()
193 
194 The asynchronous function #RF_postCmd() posts a radio operation into the
195 driver's internal command queue and returns a command handle of the type
196 #RF_CmdHandle which is an index in the command queue. The command is
197 dispatched as soon as the RF core has completed any previous radio operation
198 command.
199 
200 @code
201 #include <ti/devices/${DEVICE_FAMILY}/driverlib/rf_common_cmd.h>
202 
203 RF_Callback callback = NULL;
204 RF_EventMask subscribedEvents = 0;
205 RF_CmdHandle rxCommandHandle = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdRx,
206         RF_PriorityNormal, callback, subscribedEvents);
207 
208 assert(rxCommandHandle != RF_ALLOC_ERROR); // The command queue is full.
209 @endcode
210 
211 Command execution happens in background. The calling task may proceed with
212 other work or execute direct and immediate commands to interact with the
213 posted radio operation. But beware that the posted command might not have
214 started, yet. By calling the function #RF_pendCmd() and subscribing events of
215 the type #RF_EventMask, it is possible to re-synchronize to a posted command:
216 
217 @code
218 // RF_EventRxEntryDone must have been subscribed in RF_postCmd().
219 RF_EventMask events = RF_pendCmd(rfHandle, rxCommandHandle,
220         RF_EventRxEntryDone);
221 
222 // Program proceeds after RF_EventRxEntryDone or after a termination event.
223 @endcode
224 
225 The function #RF_runCmd() is a combination of both, #RF_postCmd() and
226 #RF_pendCmd() and allows synchronous execution.
227 
228 A pending or already running command might be aborted at any time by calling
229 the function #RF_cancelCmd() or #RF_flushCmd(). These functions take command
230 handles as parameters, but can also just abort anything in the RF driver's
231 queue:
232 
233 @code
234 uint8_t abortGraceful = 1;
235 
236 // Abort a single command
237 RF_cancelCmd(rfHandle, rxCommandHandle, abortGraceful);
238 
239 // Abort anything
240 RF_flushCmd(rfHandle, RF_CMDHANDLE_FLUSH_ALL, abortGraceful);
241 @endcode
242 
243 When aborting a command, the return value of #RF_runCmd() or #RF_pendCmd()
244 will contain the termination reason in form of event flags. If the command is
245 in the RF driver queue, but has not yet start, the #RF_EventCmdCancelled event is
246 raised.
247 
248 <hr>
249 @anchor rf_event_callbacks
250 Event callbacks
251 ===============
252 
253 The RF core generates multiple interrupts during command execution. The RF
254 driver maps these interrupts 1:1 to callback events of the type #RF_EventMask.
255 Hence, it is unnecessary to implement own interrupt handlers. Callback events
256 are divided into 3 groups:
257 
258 - Command-specific events, documented for each radio operation command. An example
259   is the #RF_EventRxEntryDone for the `CMD_PROP_RX`.
260 
261 - Generic events, defined for all radio operations and originating on the RF core.
262   These are for instance #RF_EventCmdDone and #RF_EventLastCmdDone. Both events
263   indicate the termination of one or more RF operations.
264 
265 - Generic events, defined for all radio operations and originating in the RF driver,
266   for instance #RF_EventCmdCancelled.
267 
268 @sa @ref RF_Core_Events, @ref RF_Driver_Events.
269 
270 How callback events are subscribed was shown in the previous section. The
271 following snippet shows a typical event handler callback for a proprietary RX
272 operation:
273 
274 @code
275 void rxCallback(RF_Handle handle, RF_CmdHandle command, RF_EventMask events)
276 {
277     if (events & RF_EventRxEntryDone)
278     {
279         Semaphore_post(rxPacketSemaphore);
280     }
281     if (events & RF_EventLastCmdDone)
282     {
283         // ...
284     }
285 }
286 @endcode
287 
288 In addition, the RF driver can generate error and power-up events that do not
289 relate directly to the execution of a radio command. Such events can be
290 subscribed by specifying the callback function pointers #RF_Params::pErrCb and
291 #RF_Params::pPowerCb.
292 
293 All callback functions run in software interrupt (SWI) context. Therefore,
294 only a minimum amount of code should be executed. When using absolute timed
295 commands with tight timing constraints, then it is recommended to set the RF
296 driver SWIs to a high priority.
297 See @ref rf_setup_and_configuration "Setup and configuration" for more details.
298 
299 <hr>
300 @anchor rf_power_management
301 Power management
302 ================
303 
304 The RF core is a hardware peripheral and can be switched on and off. The RF
305 driver handles that automatically and provides the following power
306 optimization features:
307 
308 - Lazy power-up and radio setup caching
309 - Power-down on inactivity
310 - Deferred dispatching of commands with absolute timing
311 
312 
313 Lazy power-up and radio setup caching
314 -------------------------------------
315 
316 The RF core optimizes the power consumption by enabling the RF core as late as
317 possible. For instance does #RF_open() not power up the RF core immediately.
318 Instead, it waits until the first radio operation command is dispatched by
319 #RF_postCmd() or #RF_runCmd().
320 
321 The function #RF_open() takes a radio setup command as parameter and expects a
322 `CMD_FS` command to follow. The pointer to the radio setup command and the
323 whole `CMD_FS` command are cached internally in the RF driver. They will be
324 used for every proceeding power-up procedure. Whenever the client re-runs a
325 setup command or a `CMD_FS` command, the driver updates its internal cache
326 with the new settings.
327 
328 By default, the RF driver measures the time that it needs for the power-up
329 procedure and uses that as an estimate for the next power cycle. On the
330 CC13x0/CC26x0 devices, power-up takes usually 1.6 ms. Automatic measurement
331 can be suppressed by specifying a custom power-up time with
332 #RF_Params::nPowerUpDuration. In addition, the client might set
333 #RF_Params::nPowerUpDurationMargin to cover any uncertainty when doing
334 automatic measurements. This is necessary in applications with a high hardware
335 interrupt load which can delay the RF driver's internal state machine
336 execution.
337 
338 
339 Power-down on inactivity
340 ------------------------
341 
342 Whenever a radio operation completes and there is no other radio operation in
343 the queue, the RF core might be powered down. There are two options in the RF
344 driver:
345 
346 - **Automatic power-down** by setting the parameter
347   #RF_Params::nInactivityTimeout. The RF core will then start a timer after
348   the last command in the queue has completed. The default timeout is "forever"
349   and this feature is disabled.
350 
351 - **Manual power-down** by calling #RF_yield(). The client should do this
352   whenever it knows that no further radio operation will be executed for a
353   couple of milliseconds.
354 
355 During the power-down procedure the RF driver stops the radio timer and saves
356 a synchronization timestamp for the next power-up. This keeps the radio timer
357 virtually in sync with the RTC even though it is not running all the time. The
358 synchronization is done in hardware.
359 
360 
361 Deferred dispatching of commands with absolute timing
362 -----------------------------------------------------
363 
364 When dispatching a radio operation command with an absolute start trigger that
365 is ahead in the future, the RF driver defers the execution and powers the RF
366 core down until the command is due. It does that only, when:
367 
368 1. `cmd.startTrigger.triggerType` is set to `TRIG_ABSTIME`
369 
370 2. The difference between #RF_getCurrentTime() and `cmd.startTime`
371    is at not more than 3/4 of a full RAT cycle. Otherwise the driver assumes
372    that `cmd.startTime` is in the past.
373 
374 3. There is enough time to run a full power cycle before `cmd.startTime` is
375    due. That includes:
376 
377    - the power-down time (fixed value, 1 ms) if the RF core is already
378      powered up,
379 
380    - the measured power-up duration or the value specified by
381      #RF_Params::nPowerUpDuration,
382 
383    - the power-up safety margin #RF_Params::nPowerUpDurationMargin
384      (the default is 282 microseconds).
385 
386 If one of the conditions are not fulfilled, the RF core is kept up and
387 running and the command is dispatched immediately. This ensures, that the
388 command will execute on-time and not miss the configured start trigger.
389 
390 <hr>
391 @anchor rf_scheduling
392 Preemptive scheduling of RF commands in multi-client applications
393 =================================================================
394 
395 Schedule BLE and proprietary radio commands.
396 
397 @code
398 RF_Object rfObject_ble;
399 RF_Object rfObject_prop;
400 
401 RF_Handle rfHandle_ble, rfHandle_prop;
402 RF_Params rfParams_ble, rfParams_prop;
403 RF_ScheduleCmdParams schParams_ble, schParams_prop;
404 
405 RF_Mode rfMode_ble =
406 {
407   .rfMode      = RF_MODE_MULTIPLE,  // rfMode for dual mode
408   .cpePatchFxn = &rf_patch_cpe_ble,
409   .mcePatchFxn = 0,
410   .rfePatchFxn = &rf_patch_rfe_ble,
411 };
412 
413 RF_Mode rfMode_prop =
414 {
415   .rfMode      = RF_MODE_MULTIPLE,  // rfMode for dual mode
416   .cpePatchFxn = &rf_patch_cpe_genfsk,
417   .mcePatchFxn = 0,
418   .rfePatchFxn = 0,
419 };
420 
421 // Init RF and specify non-default parameters
422 RF_Params_init(&rfParams_ble);
423 rfParams_ble.nInactivityTimeout = 200;     // 200us
424 
425 RF_Params_init(&rfParams_prop);
426 rfParams_prop.nInactivityTimeout = 200;    // 200us
427 
428 // Configure RF schedule command parameters directly.
429 schParams_ble.priority    = RF_PriorityNormal;
430 schParams_ble.endTime     = 0;
431 schParams_ble.allowDelay  = RF_AllowDelayAny;
432 
433 // Alternatively, use the helper function to configure the default behavior
434 RF_ScheduleCmdParams_init(&schParams_prop);
435 
436 // Open BLE and proprietary RF handles
437 rfHandle_ble  = RF_open(rfObj_ble,  &rfMode_ble,  (RF_RadioSetup*)&RF_cmdRadioSetup,        &rfParams_ble);
438 rfHandle_prop = RF_open(rfObj_prop, &rfMode_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams_prop);
439 
440 // Run a proprietary Fs command
441 RF_runCmd(rfHandle_pro, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, NULL);
442 
443 // Schedule a proprietary RX command
444 RF_scheduleCmd(rfHandle_pro, (RF_Op*)&RF_cmdPropRx, &schParams_prop, &prop_callback, RF_EventRxOk);
445 
446 // Schedule a BLE advertiser command
447 RF_scheduleCmd(rfHandle_ble, (RF_Op*)&RF_cmdBleAdv, &schParams_ble, &ble_callback,
448              (RF_EventLastCmdDone | RF_EventRxEntryDone | RF_EventTxEntryDone));
449 
450 @endcode
451 
452 <hr>
453 @anchor rf_rat
454 Accessing the Radio Timer (RAT)
455 ==============================
456 
457 The Radio Timer on the RF core is an independent 32 bit timer running at a
458 tick rate of 4 ticks per microsecond. It is only physically active while the
459 RF core is on. But because the RF driver resynchronizes the RAT to the RTC on
460 every power-up, it appears to the application as the timer is always running.
461 The RAT accuracy depends on the system HF clock while the RF core is active
462 and on the LF clock while the RF core is powered down.
463 
464 The current RAT time stamp can be obtained by #RF_getCurrentTime():
465 
466 @code
467 uint32_t now = RF_getCurrentTime();
468 @endcode
469 
470 The RAT has 8 independent channels that can be set up in capture and compare
471 mode by #RF_ratCapture() and #RF_ratCompare() respectively. Three of these
472 channels are accessible by the RF driver. Each channel may be connected to
473 physical hardware signals for input and output or may trigger a callback
474 function.
475 
476 In order to allocate a RAT channel and trigger a callback function at a
477 certain time stamp, use #RF_ratCompare():
478 
479 @code
480 RF_Handle rfDriver;
481 RF_RatConfigCompare config;
482 RF_RatConfigCompare_init(&config);
483 config.callback = &onRatTriggered;
484 config.channel = RF_RatChannelAny;
485 config.timeout = RF_getCurrentTime() + RF_convertMsToRatTicks(1701);
486 
487 RF_RatHandle ratHandle = RF_ratCompare(rfDriver, &config, nullptr);
488 assert(ratHandle != RF_ALLOC_ERROR);
489 
490 void onRatTriggered(RF_Handle h, RF_RatHandle rh, RF_EventMask e, uint32_t compareCaptureTime)
491 {
492     if (e & RF_EventError)
493     {
494         // RF driver failed to trigger the callback on time.
495     }
496     printf("RAT has triggered at %u.", compareCaptureTime);
497 
498     // Trigger precisely with the same period again
499     config.timeout = compareCaptureTime + RF_convertMsToRatTicks(1701);
500     ratHandle = RF_ratCompare(rfDriver, &config, nullptr);
501     assert(ratHandle != RF_ALLOC_ERROR);
502 }
503 @endcode
504 
505 The RAT may be used to capture a time stamp on an edge of a physical pin. This
506 can be achieved with #RF_ratCapture().
507 
508 @code
509 #include <ti/drivers/pin/PINCC26XX.h>
510 // Map IO 26 to RFC_GPI0
511 PINCC26XX_setMux(pinHandle, IOID_26, PINCC26XX_MUX_RFC_GPI0);
512 
513 RF_Handle rfDriver;
514 RF_RatConfigCapture config;
515 RF_RatConfigCapture_init(&config);
516 config.callback = &onSignalTriggered;
517 config.channel = RF_RatChannelAny;
518 config.source = RF_RatCaptureSourceRfcGpi0;
519 config.captureMode = RF_RatCaptureModeRising;
520 config.repeat = RF_RatCaptureRepeat;
521 
522 RF_RatHandle ratHandle = RF_ratCapture(rfDriver, &config, nullptr);
523 assert(ratHandle != RF_ALLOC_ERROR);
524 
525 void onSignalTriggered(RF_Handle h, RF_RatHandle rh, RF_EventMask e, uint32_t compareCaptureTime)
526 {
527     if (e & RF_EventError)
528     {
529         // An internal error has occurred
530     }
531     printf("Rising edge detected on IO 26 at %u.", compareCaptureTime);
532 }
533 @endcode
534 
535 In both cases, the RAT may generate an output signal when being triggered. The
536 signal can be routed to a physical IO pin:
537 
538 @code
539 // Generate a pulse on an internal RAT output signal
540 RF_RatConfigOutput output;
541 RF_RatConfigOutput_init(&output);
542 output.mode = RF_RatOutputModePulse;
543 output.select = RF_RatOutputSelectRatGpo3;
544 RF_ratCompare(...);
545 
546 // Map RatGpo3 to one of four intermediate doorbell signals.
547 // This has to be done in the override list in order to take permanent effect.
548 // The override list can be found in the RF settings .c file exported from
549 // SmartRF Studio.
550 // Attention: This will change the default mapping of the PA and LNA signal as well.
551 #include <ti/devices/[DEVICE_FAMILY]/inc/hw_rfc_dbell.h>
552 static uint32_t pOverrides[] =
553 {
554     HW_REG_OVERRIDE(0x1110, RFC_DBELL_SYSGPOCTL_GPOCTL2_RATGPO3),
555     // ...
556 }
557 
558 // Finally, route the intermediate doorbell signal to a physical pin.
559 #include <ti/drivers/pin/PINCC26XX.h>
560 PINCC26XX_setMux(pinHandle, IOID_17, PINCC26XX_MUX_RFC_GPO2);
561 @endcode
562 
563 <hr>
564 @anchor rf_tx_power
565 Programming the TX power level
566 ==============================
567 
568 The application can program a TX power level for each RF client with the function
569 #RF_setTxPower(). The new value takes immediate effect if the RF core is up and
570 running. Otherwise, it is stored in the RF driver client configuration.
571 
572 TX power may be stored in a lookup table in ascending order. This table is usually
573 generated and exported from SmartRF Studio together with the rest of the PHY configuration.
574 A typical power table my look as follows:
575 @code
576 RF_TxPowerTable_Entry txPowerTable[] = {
577     { .power = 11,  .value = { 0x1233, RF_TxPowerTable_DefaultPA }},
578     { .power = 13,  .value = { 0x1234, RF_TxPowerTable_DefaultPA }},
579     // ...
580     RF_TxPowerTable_TERMINATION_ENTRY
581 };
582 @endcode
583 
584 @note Some devices offer a high-power PA in addition to the default PA.
585 A client must not mix configuration values in the same power table and must
586 not hop from a default PA configuration to a high-power PA configuration unless it
587 can guarantee that the RF setup command is re-executed in between.
588 
589 Given this power table format, the application may program a new power level in multiple
590 ways. It can use convenience functions to search a certain power level
591 in the power table or may access the table index-based:
592 @code
593 // Set a certain power level. Search a matching level.
594 RF_setTxPower(h, RF_TxPowerTable_findValue(txPowerTable, 17));
595 
596 // Set a certain power level with a known level.
597 RF_setTxPower(h, txPowerTable[3].value);
598 
599 // Set a certain power without using a human readable level.
600 RF_setTxPower(h, value);
601 
602 // Set maximum power. Search the value.
603 RF_setTxPower(h, RF_TxPowerTable_findValue(txPowerTable, RF_TxPowerTable_MAX_DBM));
604 
605 // Set minimum power without searching.
606 RF_setTxPower(h, txPowerTable[0].value);
607 
608 // Set minimum power. Search the value.
609 RF_setTxPower(h, RF_TxPowerTable_findValue(txPowerTable, RF_TxPowerTable_MIN_DBM));
610 
611 // Set maximum power without searching.
612 int32_t lastIndex = sizeof(txPowerTable) / sizeof(RF_TxPowerTable_Entry) - 2;
613 RF_setTxPower(h, txPowerTable[lastIndex].value);
614 @endcode
615 
616 The current configured power level for a client can be retrieved by #RF_getTxPower().
617 @code
618 // Get the current configured power level.
619 int8_t power = RF_TxPowerTable_findPowerLevel(txPowerTable, RF_getTxPower(h));
620 @endcode
621 
622 <hr>
623 @anchor rf_convenience_features
624 Convenience features
625 ====================
626 
627 The RF driver simplifies often needed tasks and provides additional functions.
628 For instance, it can read the RSSI while the RF core is in RX mode using the
629 function :tidrivers_api:`RF_getRssi`:
630 
631 @code
632 int8_t rssi = RF_getRssi(rfHandle);
633 assert (rssi != RF_GET_RSSI_ERROR_VAL); // Could not read the RSSI
634 @endcode
635 
636 <hr>
637  ******************************************************************************
638  */
639 
640 //*****************************************************************************
641 //
642 //! \addtogroup rf_driver
643 //! @{
644 //! \addtogroup rf_driver_cc13x2_cc26x2
645 //! @{
646 //
647 //*****************************************************************************
648 
649 #ifndef ti_drivers_rfcc26x2__include
650 #define ti_drivers_rfcc26x2__include
651 
652 #ifdef __cplusplus
653 extern "C" {
654 #endif
655 
656 #include <stdint.h>
657 #include <stdbool.h>
658 
659 #include <ti/drivers/dpl/ClockP.h>
660 #include <ti/drivers/dpl/SemaphoreP.h>
661 #include <ti/drivers/utils/List.h>
662 
663 #include <ti/devices/DeviceFamily.h>
664 #include DeviceFamily_constructPath(driverlib/rf_common_cmd.h)
665 #include DeviceFamily_constructPath(driverlib/rf_prop_cmd.h)
666 #include DeviceFamily_constructPath(driverlib/rf_ble_cmd.h)
667 
668 /**
669  *  @name RF Core Events
670  *  @anchor RF_Core_Events
671  *
672  *  Events originating on the RF core and caused during command execution.
673  *  They are aliases for the corresponding interrupt flags.
674  *  RF Core Events are command-specific and are explained in the Technical Reference Manual.
675  *
676  *  @sa RF_postCmd(), RF_pendCmd(), RF_runCmd()
677  *  @{
678  */
679 #define   RF_EventCmdDone             (1 << 0)   ///< A radio operation command in a chain finished.
680 #define   RF_EventLastCmdDone         (1 << 1)   ///< A stand-alone radio operation command or the last radio operation command in a chain finished.
681 #define   RF_EventFGCmdDone           (1 << 2)   ///< A IEEE-mode radio operation command in a chain finished.
682 #define   RF_EventLastFGCmdDone       (1 << 3)   ///< A stand-alone IEEE-mode radio operation command or the last command in a chain finished.
683 #define   RF_EventTxDone              (1 << 4)   ///< Packet transmitted
684 #define   RF_EventTXAck               (1 << 5)   ///< ACK packet transmitted
685 #define   RF_EventTxCtrl              (1 << 6)   ///< Control packet transmitted
686 #define   RF_EventTxCtrlAck           (1 << 7)   ///< Acknowledgement received on a transmitted control packet
687 #define   RF_EventTxCtrlAckAck        (1 << 8)   ///< Acknowledgement received on a transmitted control packet, and acknowledgement transmitted for that packet
688 #define   RF_EventTxRetrans           (1 << 9)   ///< Packet retransmitted
689 #define   RF_EventTxEntryDone         (1 << 10)  ///< Tx queue data entry state changed to Finished
690 #define   RF_EventTxBufferChange      (1 << 11)  ///< A buffer change is complete
691 #define   RF_EventPaChanged           (1 << 14)  ///< The PA was reconfigured on the fly.
692 #define   RF_EventRxOk                (1 << 16)  ///< Packet received with CRC OK, payload, and not to be ignored
693 #define   RF_EventRxNOk               (1 << 17)  ///< Packet received with CRC error
694 #define   RF_EventRxIgnored           (1 << 18)  ///< Packet received with CRC OK, but to be ignored
695 #define   RF_EventRxEmpty             (1 << 19)  ///< Packet received with CRC OK, not to be ignored, no payload
696 #define   RF_EventRxCtrl              (1 << 20)  ///< Control packet received with CRC OK, not to be ignored
697 #define   RF_EventRxCtrlAck           (1 << 21)  ///< Control packet received with CRC OK, not to be ignored, then ACK sent
698 #define   RF_EventRxBufFull           (1 << 22)  ///< Packet received that did not fit in the Rx queue
699 #define   RF_EventRxEntryDone         (1 << 23)  ///< Rx queue data entry changing state to Finished
700 #define   RF_EventDataWritten         (1 << 24)  ///< Data written to partial read Rx buffer
701 #define   RF_EventNDataWritten        (1 << 25)  ///< Specified number of bytes written to partial read Rx buffer
702 #define   RF_EventRxAborted           (1 << 26)  ///< Packet reception stopped before packet was done
703 #define   RF_EventRxCollisionDetected (1 << 27)  ///< A collision was indicated during packet reception
704 #define   RF_EventModulesUnlocked     (1 << 29)  ///< As part of the boot process, the CM0 has opened access to RF core modules and memories
705 #define   RF_EventInternalError       (uint32_t)(1 << 31) ///< Internal error observed
706 #define   RF_EventMdmSoft             0x0000002000000000  ///< Synchronization word detected (MDMSOFT interrupt flag)
707 /** @}*/
708 
709 /**
710  *  @name RF Driver Events
711  *  @anchor RF_Driver_Events
712  *
713  *  Event flags generated by the RF Driver.
714  *  @{
715  */
716 #define   RF_EventCmdCancelled        0x1000000000000000  ///< Command canceled before it was started.
717 #define   RF_EventCmdAborted          0x2000000000000000  ///< Abrupt command termination caused by RF_cancelCmd() or RF_flushCmd().
718 #define   RF_EventCmdStopped          0x4000000000000000  ///< Graceful command termination caused by RF_cancelCmd() or RF_flushCmd().
719 #define   RF_EventRatCh               0x0800000000000000  ///< A user-programmable RAT channel triggered an event.
720 #define   RF_EventPowerUp             0x0400000000000000  ///< RF power up event. \deprecated This event is deprecated. Use #RF_ClientEventPowerUpFinished instead.
721 #define   RF_EventError               0x0200000000000000  ///< Event flag used for error callback functions to indicate an error. See RF_Params::pErrCb.
722 #define   RF_EventCmdPreempted        0x0100000000000000  ///< Command preempted by another command with higher priority. Applies only to multi-client applications.
723 /** @}*/
724 
725 /**
726  *  @name Control codes for driver configuration
727  *  @anchor RF_CTRL
728  *
729  *  Control codes are used in RF_control().
730  *
731  *  @{
732  */
733 
734 /*!
735  * @brief Control code used by RF_control to set inactivity timeout
736  *
737  * Setting this control allows RF to power down the radio upon completion of a radio
738  * command after a specified timeout period (in us)
739  * With this control code @b arg is a pointer to the timeout variable and returns RF_StatSuccess.
740  */
741 #define RF_CTRL_SET_INACTIVITY_TIMEOUT            0
742 /*!
743  * @brief Control code used by RF_control to update setup command
744  *
745  * Setting this control notifies RF that the setup command is to be updated, so that RF will take
746  * proper actions when executing the next setup command.
747  * Note the updated setup command will take effect in the next power up cycle when RF executes the
748  * setup command. Prior to updating the setup command, user should make sure all pending commands
749  * have completed.
750  */
751 #define RF_CTRL_UPDATE_SETUP_CMD                  1
752 /*!
753  * @brief Control code used by RF_control to set powerup duration margin
754  *
755  * Setting this control updates the powerup duration margin. Default is RF_DEFAULT_POWER_UP_MARGIN.
756  */
757 #define RF_CTRL_SET_POWERUP_DURATION_MARGIN       2
758 /*!
759  * @brief Control code used by RF_control to set the phy switching margin
760  *
761  * Setting this control updates the phy switching duration margin, which is used to calculate when
762  * run-time conflicts shall be evaluated in case of colliding radio operations issued from two
763  * different clients. Default is RF_DEFAULT_PHY_SWITCHING_MARGIN.
764  */
765 #define RF_CTRL_SET_PHYSWITCHING_DURATION_MARGIN  3
766 /*!
767  * @brief Control code used by RF_control to set max error tolerance for RAT/RTC
768  *
769  * Setting this control updates the error tol for how frequently the CMD_RAT_SYNC_STOP is sent.
770  * Default is RF_DEFAULT_RAT_RTC_ERR_TOL_IN_US (5 us)
771  * Client is recommeneded to change this setting before sending any commands.
772  */
773 #define RF_CTRL_SET_RAT_RTC_ERR_TOL_VAL           4
774 /*!
775  * @brief Control code used by RF_control to set power management
776  *
777  * Setting this control configures RF driver to enable or disable power management.
778  * By default power management is enabled.
779  * If disabled, once RF core wakes up, RF driver will not go to standby and will not power down RF core.
780  * To configure power management, use this control to pass a parameter value of 0 to disable power management,
781  * and pass a parameter value of 1 to re-enable power management.
782  * This control is valid for dual-mode code only. Setting this control when using single-mode code has no effect
783  * (power management always enabled).
784  */
785 #define RF_CTRL_SET_POWER_MGMT                    5
786 /*!
787  * @brief Control code used by RF_control to set the hardware interrupt priority level of the RF driver.
788  *
789  * This control code sets the hardware interrupt priority level that is used by the RF driver. Valid
790  * values are INT_PRI_LEVEL1 (highest) until INT_PRI_LEVEL7 (lowest). The default interrupt priority is
791  * set in the board support file. The default value is -1 which means "lowest possible priority".
792  *
793  * When using the TI-RTOS kernel, INT_PRI_LEVEL0 is reserved for zero-latency interrupts and must not be used.
794  *
795  * Execute this control code only while the RF core is powered down and the RF driver command queue is empty.
796  * This is usually the case after calling RF_open(). Changing the interrupt priority level while the RF driver
797  * is active will result in RF_StatBusyError being returned.
798  *
799  * Example:
800  * @code
801  * #include DeviceFamily_constructPath(driverlib/interrupt.h)
802  *
803  * int32_t hwiPriority = INT_PRI_LEVEL5;
804  * RF_control(rfHandle, RF_CTRL_SET_HWI_PRIORITY, &hwiPriority);
805  * @endcode
806  */
807 #define RF_CTRL_SET_HWI_PRIORITY                  6
808 /*!
809  * @brief Control code used by RF_control to set the software interrupt priority level of the RF driver.
810  *
811  * This control code sets the software interrupt priority level that is used by the RF driver. Valid
812  * values are integers starting at 0 (lowest) until <tt>Swi_numPriorities - 1</tt> (highest). The default
813  * interrupt priority is set in the board support file. The default value is 0 which means means
814  * "lowest possible priority".
815  *
816  * Execute this control code only while the RF core is powered down and the RF driver command queue is empty.
817  * This is usually the case after calling RF_open(). Changing the interrupt priority level while the RF driver
818  * is active will result in RF_StatBusyError being returned.
819  *
820  * Example:
821  * @code
822  * #include <ti/sysbios/knl/Swi.h>
823  *
824  * // Set highest possible priority
825  * uint32_t swiPriority = ~0;
826  * RF_control(rfHandle, RF_CTRL_SET_SWI_PRIORITY, &swiPriority);
827  * @endcode
828  */
829 #define RF_CTRL_SET_SWI_PRIORITY                  7
830 /*!
831  * @brief Control code used by RF_control to mask the available RAT channels manually.
832  *
833  * This control code can be used to manually disallow/allow access to certain RAT channels from the RAT APIs.
834  * A typical use case is when a RAT channel is programmed through chained radio operations, and hence is
835  * used outside the scope of the RF driver. By disallowing access to this channel one can prevent collision
836  * between the automatic channel allocation through #RF_ratCompare()/#RF_ratCapture() and the direct
837  * configuration through #RF_postCmd().
838  */
839 #define RF_CTRL_SET_AVAILABLE_RAT_CHANNELS_MASK   8
840 /*!
841  * @brief Control code used by RF_control to enable or disable the coexistence feature at runtime
842  *
843  * This control code can be used to manually override the statically configured setting for global enable/disable
844  * of the coexistence feature. It will have no effect if coexistence is not originally enabled and included
845  * in the compiled project.
846  *
847  * Example:
848  * @code
849  * // Disable the CoEx feature
850  * uint32_t coexEnabled = 0;
851  * RF_control(rfHandle, RF_CTRL_COEX_CONTROL, &coexEnabled);
852  * @endcode
853  */
854 #define RF_CTRL_COEX_CONTROL  9
855 /** @}*/
856 
857 /**
858  * @name TX Power Table defines
859  * @{
860  */
861 
862 /**
863  * Refers to the the minimum available power in dBm when accessing a power
864  * table.
865  *
866  * \sa #RF_TxPowerTable_findValue()
867  */
868 #define RF_TxPowerTable_MIN_DBM   -128
869 
870 /**
871  * Refers to the the maximum available power in dBm when accessing a power
872  * table.
873  *
874  * \sa #RF_TxPowerTable_findValue()
875  */
876 #define RF_TxPowerTable_MAX_DBM   126
877 
878 /**
879  * Refers to an invalid power level in a TX power table.
880  *
881  * \sa #RF_TxPowerTable_findPowerLevel()
882  */
883 #define RF_TxPowerTable_INVALID_DBM   127
884 
885 /**
886  * Refers to an invalid power value in a TX power table.
887  *
888  * This is the raw value part of a TX power configuration. In order to check
889  * whether a given power configuration is valid, do:
890  *
891  * @code
892  * RF_TxPowerTable_Value value = ...;
893  * if (value.rawValue == RF_TxPowerTable_INVALID_VALUE) {
894  *     // error, value not valid
895  * }
896  * @endcode
897  *
898  * A TX power table is always terminated by an invalid power configuration.
899  *
900  * \sa #RF_getTxPower(), RF_TxPowerTable_findValue
901  */
902 #define RF_TxPowerTable_INVALID_VALUE 0x3fffff
903 
904 /**
905  * Marks the last entry in a TX power table.
906  *
907  * In order to use #RF_TxPowerTable_findValue() and #RF_TxPowerTable_findPowerLevel(),
908  * every power table must be terminated by a %RF_TxPowerTable_TERMINATION_ENTRY:
909  *
910  * @code
911  * RF_TxPowerTable_Entry txPowerTable[] =
912  * {
913  *     { 20,  RF_TxPowerTable_HIGH_PA_ENTRY(1, 2, 3) },
914  *     // ... ,
915  *     RF_TxPowerTable_TERMINATION_ENTRY
916  * };
917  * @endcode
918  */
919 #define RF_TxPowerTable_TERMINATION_ENTRY \
920         { .power = RF_TxPowerTable_INVALID_DBM, .value = { .rawValue = RF_TxPowerTable_INVALID_VALUE, .paType = RF_TxPowerTable_DefaultPA } }
921 
922 /**
923  * Creates a TX power table entry for the default PA.
924  *
925  * The values for \a bias, \a gain, \a boost and \a coefficient are usually measured by Texas Instruments
926  * for a specific front-end configuration. They can then be obtained from SmartRFStudio.
927  */
928 #define RF_TxPowerTable_DEFAULT_PA_ENTRY(bias, gain, boost, coefficient) \
929         { .rawValue = ((bias) << 0) | ((gain) << 6) | ((boost) << 8) | ((coefficient) << 9), .paType = RF_TxPowerTable_DefaultPA }
930 
931 /**
932  * Creates a TX power table entry for the High-power PA.
933  *
934  * The values for \a bias, \a ibboost, \a boost, \a coefficient and \a ldoTrim are usually measured by Texas Instruments
935  * for a specific front-end configuration. They can then be obtained from SmartRFStudio.
936  */
937 #define RF_TxPowerTable_HIGH_PA_ENTRY(bias, ibboost, boost, coefficient, ldotrim) \
938         { .rawValue = ((bias) << 0) | ((ibboost) << 6) | ((boost) << 8) | ((coefficient) << 9) | ((ldotrim) << 16), .paType = RF_TxPowerTable_HighPA }
939 
940 
941 /** @} */
942 
943 /**
944  * @name Other defines
945  * @{
946  */
947 #define RF_GET_RSSI_ERROR_VAL                   (-128)   ///< Error return value for RF_getRssi()
948 #define RF_CMDHANDLE_FLUSH_ALL                  (-1)     ///< RF command handle to flush all RF commands
949 #define RF_ALLOC_ERROR                          (-2)     ///< RF command or RAT channel allocation error
950 #define RF_SCHEDULE_CMD_ERROR                   (-3)     ///< RF command schedule error
951 #define RF_ERROR_RAT_PROG                       (-255)   ///< A rat channel could not be programmed.
952 #define RF_ERROR_INVALID_RFMODE                 (-256)   ///< Invalid RF_Mode. Used in error callback.
953 #define RF_ERROR_CMDFS_SYNTH_PROG               (-257)   ///< Synthesizer error with CMD_FS. Used in error callback. If this error occurred in error callback, user needs to resend CMD_FS to recover. See the device's errata for more details.
954 
955 #define RF_NUM_SCHEDULE_ACCESS_ENTRIES          2        ///< Number of access request entries
956 #define RF_NUM_SCHEDULE_COMMAND_ENTRIES         8        ///< Number of scheduled command entries
957 #define RF_NUM_SCHEDULE_MAP_ENTRIES             (RF_NUM_SCHEDULE_ACCESS_ENTRIES + RF_NUM_SCHEDULE_COMMAND_ENTRIES) ///< Number of schedule map entries. This is the sum of access request and scheduled command entries
958 #define RF_SCH_MAP_CURRENT_CMD_OFFSET           RF_NUM_SCHEDULE_ACCESS_ENTRIES      ///< Offset of the current command entry in the schedule map
959 #define RF_SCH_MAP_PENDING_CMD_OFFSET           (RF_SCH_MAP_CURRENT_CMD_OFFSET + 2) ///< Offset of the first pending command entry in the schedule map
960 
961 #define RF_ABORT_PREEMPTION                     (1<<2)   ///< Used with RF_cancelCmd() to provoke subscription to RadioFreeCallback
962 #define RF_ABORT_GRACEFULLY                     (1<<0)   ///< Used with RF_cancelCmd() for graceful command termination
963 
964 #define RF_SCH_CMD_EXECUTION_TIME_UNKNOWN       0        ///< For unknown execution time for RF scheduler
965 
966 #define RF_RAT_ANY_CHANNEL                      (-1)     ///< To be used within the channel configuration structure. Allocate any of the available channels.
967 #define RF_RAT_TICKS_PER_US                     4        ///< Radio timer (RAT) ticks per microsecond.
968 
969 #define RF_LODIVIDER_MASK                       0x7F     ///< Mask to be used to determine the effective value of the setup command's loDivider field.
970 
971 /**
972  *  @name Stack ID defines
973  *  @anchor RF_Stack_ID
974  *
975  *  Reserved values to identify which stack owns an RF_Handle h (stored as h->clientConfig.nID)
976  *  @{
977  */
978 #define RF_STACK_ID_DEFAULT                     0x00000000  ///< No value is set.
979 #define RF_STACK_ID_154                         0x8000F154  ///< ID for TI 15.4 Stack
980 #define RF_STACK_ID_BLE                         0x8000FB1E  ///< ID for TI BLE Stack
981 #define RF_STACK_ID_EASYLINK                    0x8000FEA2  ///< ID for TI EasyLink Stack
982 #define RF_STACK_ID_THREAD                      0x8000FEAD  ///< ID for TI Thread Stack
983 #define RF_STACK_ID_TOF                         0x8000F00F  ///< ID for TI TOF Stack
984 #define RF_STACK_ID_CUSTOM                      0x0000FC00  ///< ID for Custom Stack
985 /** @} */
986 
987 /*!
988 \brief Converts a duration given in \a microseconds into radio timer (RAT) ticks.
989 */
990 #define RF_convertUsToRatTicks(microseconds) \
991     ((microseconds) * (RF_RAT_TICKS_PER_US))
992 
993 /*!
994 \brief Converts a duration given in \a milliseconds into radio timer (RAT) ticks.
995 */
996 #define RF_convertMsToRatTicks(milliseconds) \
997     ((milliseconds) * 1000 * (RF_RAT_TICKS_PER_US))
998 
999 /*!
1000 \brief Converts a duration given in radio timer (RAT) \a ticks into microseconds.
1001 */
1002 #define RF_convertRatTicksToUs(ticks) \
1003     ((ticks) / (RF_RAT_TICKS_PER_US))
1004 
1005 /*!
1006 \brief Converts a duration given in radio timer (RAT) \a ticks into milliseconds.
1007 */
1008 #define RF_convertRatTicksToMs(ticks) \
1009     ((ticks) / (1000 * (RF_RAT_TICKS_PER_US)))
1010 
1011 
1012 /** @}*/
1013 
1014 
1015 /**
1016  * \brief PA configuration value for a certain power level.
1017  *
1018  * A %RF_TxPowerTable_Value contains the power amplifier (PA) configuration for a certain power level.
1019  * It encodes the PA type as well as a raw configuration value for the RF core hardware.
1020  *
1021  * \sa #RF_getTxPower(), #RF_setTxPower(), #RF_TxPowerTable_Entry, #RF_TxPowerTable_PAType.
1022  */
1023 typedef struct {
1024     uint32_t rawValue:22;      ///< Hardware configuration value.
1025                                ///<
1026                                ///< - \c [15:0] used for default PA,
1027                                ///< - \c [21:0] used for High-power PA
1028     uint32_t __dummy:9;
1029     uint32_t paType:1;         ///< Selects the PA type to be used.
1030                                ///<
1031                                ///< - 0: #RF_TxPowerTable_DefaultPA
1032                                ///< - 1: #RF_TxPowerTable_HighPA
1033 } RF_TxPowerTable_Value;
1034 
1035 /**
1036  * \brief TX power configuration entry in a TX power table.
1037  *
1038  * A %RF_TxPowerTable_Entry defines an entry in a lookup table. Each entry contains a
1039  * human-readable power level \a power as key and a hardware configuration \a value.
1040  *
1041  * Example of a typical power table:
1042  * \code
1043  * RF_TxPowerTable_Entry txPowerTable[] = {
1044  *    { .power = 20,  .value = { .rawValue = 0x1234, .paType = RF_TxPowerTable_HighPA }},
1045  *    { .power = 19,  .value = { .rawValue = 0x1233, .paType = RF_TxPowerTable_HighPA }},
1046  *    // ...
1047  *    RF_TxPowerTable_TERMINATION_ENTRY
1048  * };
1049  * \endcode
1050  *
1051  * \sa #RF_TxPowerTable_findPowerLevel(), #RF_TxPowerTable_findPowerLevel()
1052  */
1053 typedef struct
1054 {
1055     int8_t power;                 ///< Human readable power value representing
1056                                   ///< the output in dBm.
1057 
1058     RF_TxPowerTable_Value value;  ///< PA hardware configuration for that power level.
1059 } __attribute__((packed)) RF_TxPowerTable_Entry;
1060 
1061 
1062 /**
1063  * \brief Selects a power amplifier path in a TX power value.
1064  *
1065  * %RF_TxPowerTable_PAType selects one of the available power amplifiers
1066  * on the RF core. It is usually included in a #RF_TxPowerTable_Value.
1067  */
1068 typedef enum {
1069     RF_TxPowerTable_DefaultPA = 0, ///< Default PA
1070     RF_TxPowerTable_HighPA = 1,    ///< High-power PA
1071 } RF_TxPowerTable_PAType;
1072 
1073 
1074 /** @brief Base type for all radio operation commands.
1075  *
1076  *  All radio operation commands share a common part.
1077  *  That includes the command id, a status field, chaining properties
1078  *  and a start trigger.
1079  *  Whenever an RF operation command is used with the RF driver, it needs
1080  *  to be casted to an RF_Op.
1081  *
1082  *  More information about RF operation commands can be found in the Proprietary RF
1083  *  User's Guide.
1084  *
1085  *  @sa RF_runCmd(), RF_postCmd(), RF_pendCmd()
1086  */
1087 typedef rfc_radioOp_t RF_Op;
1088 
1089 
1090 /** @brief Specifies a RF core firmware configuration.
1091  *
1092  *  %RF_Mode selects a mode of operation and points to firmware patches for the RF core.
1093  *  There exists one instance per radio PHY configuration, usually generated by
1094  *  SmartRF Studio.
1095  *  After assigning %RF_Mode configuration to the RF driver via RF_open(), the
1096  *  driver caches the containing information and re-uses it on every power-up.
1097  */
1098 typedef struct {
1099     uint8_t rfMode;             ///< Specifies which PHY modes should be activated. Must be set to RF_MODE_MULTIPLE for dual-mode operation.
1100     void (*cpePatchFxn)(void);  ///< Pointer to CPE patch function
1101     void (*mcePatchFxn)(void);  ///< Pointer to MCE patch function
1102     void (*rfePatchFxn)(void);  ///< Pointer to RFE patch function
1103 } RF_Mode;
1104 
1105 /** @brief Scheduling priority of RF operation commands.
1106  *
1107  *  When multiple RF driver instances are used at the same time,
1108  *  commands from different clients may overlap.
1109  *  If an RF operation with a higher priority than the currently
1110  *  running operation is scheduled by RF_scheduleCmd(), then the
1111  *  running operation is interrupted.
1112  *
1113  *  In single-client applications, %RF_PriorityNormal should be used.
1114  */
1115 typedef enum {
1116     RF_PriorityHighest = 2, ///< Highest priority. Only use this for urgent commands.
1117     RF_PriorityHigh    = 1, ///< High priority. Use this for time-critical commands in synchronous protocols.
1118     RF_PriorityNormal  = 0, ///< Default priority. Use this in single-client applications.
1119 } RF_Priority;
1120 
1121 /**
1122  *  @brief Priority level for coexistence priority signal.
1123  *
1124  *  When the RF driver is configured for three-wire coexistence mode, one of the
1125  *  output wires will signal the priority level of the coexistence request. When
1126  *  RF operations are scheduled with RF_scheduleCmd(), the scheduler can be configured
1127  *  to override the default coexistence priority level for the RF operation.
1128  *
1129  *  The coexistence priority level is binary because it translates to a high/low output signal.
1130  */
1131 typedef enum {
1132     RF_PriorityCoexDefault  = 0,  ///< Default priority. Use value configured by setup command.
1133     RF_PriorityCoexLow      = 1,  ///< Low priority. Override default value configured by setup command.
1134     RF_PriorityCoexHigh     = 2,  ///< High priority. Override default value configured by setup command.
1135 } RF_PriorityCoex;
1136 
1137 /**
1138  *  @brief Behavior for coexistence request signal.
1139  *
1140  *  When the RF driver is configured for three-wire coexistence mode, one of the
1141  *  output wires will signal the request level of the coexistence request. When
1142  *  RF operations are scheduled with RF_scheduleCmd(), the scheduler can be configured
1143  *  to override the default coexistence request line behavior for the RF operation in RX.
1144  *
1145  *  This override will be ignored if the option to set request for an entire chain is active.
1146  */
1147 typedef enum {
1148     RF_RequestCoexDefault     = 0, ///< Default request line behavior. Use value configured by setup command.
1149     RF_RequestCoexAssertRx    = 1, ///< Assert REQUEST in RX. Override default value configured by setup command.
1150     RF_RequestCoexNoAssertRx  = 2, ///< Do not assert REQUEST in RX. Override default value configured by setup command.
1151 } RF_RequestCoex;
1152 
1153 /**
1154  *  @brief Runtime coexistence override parameters
1155  *
1156  *  When  RF operations are scheduled with RF_scheduleCmd(), the scheduler can be configured
1157  *  to override the default coexistence behavior. This structure encapsulates the available parameters.
1158  */
1159 typedef struct {
1160     RF_PriorityCoex   priority;   ///< Priority level for coexistence priority signal.
1161     RF_RequestCoex    request;    ///< Behavior for coexistence request signal.
1162 } RF_CoexOverride;
1163 
1164 /**
1165  *  @brief Coexistence override settings for BLE5 application scenarios
1166  *
1167  *  This configuration is provided to the BLE Stack to override the default coexistence configuration
1168  *  depending on the current application and stack states.
1169  */
1170 typedef struct {
1171     RF_CoexOverride    bleInitiator;
1172     RF_CoexOverride    bleConnected;
1173     RF_CoexOverride    bleBroadcaster;
1174     RF_CoexOverride    bleObserver;
1175 } RF_CoexOverride_BLEUseCases;
1176 
1177 /** @brief Status codes for various RF driver functions.
1178  *
1179  *  RF_Stat is reported as return value for RF driver functions which
1180  *  execute direct and immediate commands.
1181  *  Such commands are executed by RF_runDirectCmd() and RF_runImmediateCmd() in the
1182  *  first place, but also by some convenience functions like RF_cancelCmd(),
1183  *  RF_flushCmd(), RF_getInfo() and others.
1184  */
1185 typedef enum {
1186     RF_StatBusyError,          ///< Command not executed because RF driver is busy.
1187     RF_StatRadioInactiveError, ///< Command not executed because RF core is powered down.
1188     RF_StatCmdDoneError,       ///< Command finished with an error.
1189     RF_StatInvalidParamsError, ///< Function was called with an invalid parameter.
1190     RF_StatCmdEnded,           ///< Cmd is found in the pool but was already ended.
1191     RF_StatError   = 0x80,     ///< General error specifier.
1192     RF_StatCmdDoneSuccess,     ///< Command finished with success.
1193     RF_StatCmdSch,             ///< Command successfully scheduled for execution.
1194     RF_StatSuccess             ///< Function finished with success.
1195 } RF_Stat;
1196 
1197 /** @brief Data type for events during command execution.
1198  *
1199  *  Possible event flags are listed in @ref RF_Core_Events and @ref RF_Driver_Events.
1200  */
1201 typedef uint64_t RF_EventMask;
1202 
1203 /** @brief A unified type for radio setup commands of different PHYs.
1204  *
1205  *  Radio setup commands are used to initialize a PHY on the RF core.
1206  *  Various partially similar commands exist, each one represented
1207  *  by a different data type.
1208  *  RF_RadioSetup is a generic container for all types.
1209  *  A specific setup command is usually exported from SmartRF Studio
1210  *  and then passed to the RF driver in RF_open().
1211  */
1212 typedef union {
1213     rfc_command_t                      commandId;   ///< Generic command identifier. This is the first field
1214                                                     ///< in every radio operation command.
1215     rfc_CMD_RADIO_SETUP_t              common;      ///< Radio setup command for BLE and IEEE modes
1216     rfc_CMD_BLE5_RADIO_SETUP_t         ble5;        ///< Radio setup command for BLE5 mode
1217     rfc_CMD_PROP_RADIO_SETUP_t         prop;        ///< Radio setup command for PROPRIETARY mode on 2.4 GHz
1218     rfc_CMD_PROP_RADIO_DIV_SETUP_t     prop_div;    ///< Radio setup command for PROPRIETARY mode on Sub-1 Ghz
1219     rfc_CMD_RADIO_SETUP_PA_t           common_pa;   ///< Radio setup command for BLE and IEEE modes with High Gain PA
1220     rfc_CMD_BLE5_RADIO_SETUP_PA_t      ble5_pa;     ///< Radio setup command for BLE5 mode with High Gain PA
1221     rfc_CMD_PROP_RADIO_SETUP_PA_t      prop_pa;     ///< Radio setup command for PROPRIETARY mode on 2.4 GHz with High Gain PA
1222     rfc_CMD_PROP_RADIO_DIV_SETUP_PA_t  prop_div_pa; ///< Radio setup command for PROPRIETARY mode on Sub-1 Ghz with High Gain PA
1223 } RF_RadioSetup;
1224 
1225 /** @brief Client-related RF driver events.
1226  *
1227  *  Events originating in the RF driver but not directly related to a specific radio command,
1228  *  are called client events.
1229  *  Clients may subscribe to these events by specifying a callback function RF_Params::pClientEventCb.
1230  *  Events are activated by specifying a bitmask RF_Params::nClientEventMask.
1231  *  The callback is called separately for every event providing an optional argument.
1232  *
1233  *  @code
1234  *  void onClientEvent(RF_Handle h, RF_ClientEvent event, void* arg)
1235  *  {
1236  *      switch (event)
1237  *      {
1238  *      case RF_ClientEventPowerUpFinished:
1239  *          // Set output port
1240  *          break;
1241  *      default:
1242  *          // Unsubscribed events must not be issued.
1243  *          assert(false);
1244  *      }
1245  *  }
1246  *
1247  *  RF_Params params;
1248  *  params.pClientEventCb = &onClientEvent;
1249  *  params.nClientEventMask = RF_ClientEventPowerUpFinished;
1250  *  RF_open(...);
1251  *  @endcode
1252  */
1253 typedef enum {
1254     RF_ClientEventPowerUpFinished     = (1 << 0),   ///< The RF core has been powered up the radio setup has been finished.
1255     RF_ClientEventRadioFree           = (1 << 1),   ///< Radio becomes free after a command has been preempted by a high-priority command of another client.
1256                                                     ///< This event is only triggered on a client that has been preempted.
1257                                                     ///< Clients may use this event to retry running their low-priority RF operation.
1258 
1259     RF_ClientEventSwitchClientEntered = (1 << 2)    ///< Signals the client that the RF driver is about to switch over from another client.
1260 } RF_ClientEvent;
1261 
1262 /** @brief Global RF driver events.
1263  *
1264  *  The RF driver provides an interface through the global \c RFCC26XX_hwAttrs
1265  *  struct to register a global, client independent callback. This callback is
1266  *  typically used to control board related configurations such as antenna
1267  *  switches.
1268  *
1269  *  @code
1270  *  void globalCallback(RF_Handle h, RF_GlobalEvent event, void* arg)
1271  *  {
1272  *      switch (event)
1273  *      {
1274  *      case RF_GlobalEventRadioSetup:
1275  *      {
1276  *          RF_RadioSetup* setupCommand = (RF_RadioSetup*)arg;
1277  *          // Select antenna path
1278  *          if (setupCommand->common.commandNo == CMD_PROP_RADIO_DIV_SETUP) {
1279  *              // Sub-1 GHz ...
1280  *          } else {
1281  *              // 2.4 GHz ...
1282  *          }
1283  *      }
1284  *          break;
1285  *
1286  *      case RF_GlobalEventRadioPowerDown:
1287  *          // Disable antenna switch
1288  *          break;
1289  *
1290  *      default:
1291  *          // Unsubscribed events must not be issued.
1292  *          assert(false);
1293  *      }
1294  *  }
1295  *  @endcode
1296  *
1297  *  For the coexistence (coex) feature, some of the events are used to handle
1298  *  the I/O muxing of the GPIO signals for REQUEST, PRIORITY and GRANT.
1299  *
1300  *  @code
1301  *  void globalCallback(RF_Handle h, RF_GlobalEvent event, void* arg)
1302  *  {
1303  *      RF_Cmd* pCurrentCmd = (RF_Cmd*)arg;
1304  *
1305  *      if (event & RF_GlobalEventInit) {
1306  *          // Initialize and mux coex I/O pins to RF Core I/O signals
1307  *      }
1308  *      else if (event & RF_GlobalEventCmdStart) {
1309  *          if (pCurrentCmd->coexPriority != RF_PriorityCoexDefault){
1310  *              // Release PRIORITY pin from RF Core and set it to value of coexPriority
1311  *          }
1312  *      }
1313  *      else if (event & RF_GlobalEventCmdStop) {
1314  *          if (pCurrentCmd->coexPriority != RF_PriorityCoexDefault) {
1315  *              // Mux PRIORITY pin to RF Core signal to return to default priority level
1316  *          }
1317  *      }
1318  *  }
1319  *  @endcode
1320  *
1321  * \sa #RF_GlobalCallback
1322  */
1323 typedef enum {
1324     RF_GlobalEventRadioSetup     = (1 << 0),             ///< The RF core is being reconfigured through a setup command.
1325                                                          ///< The \a arg argument is a pointer to the setup command.
1326                                                          ///< HWI context.
1327 
1328     RF_GlobalEventRadioPowerDown = (1 << 1),             ///< The RF core is being powered down.
1329                                                          ///< The \a arg argument is empty.
1330                                                          ///< SWI context.
1331 
1332     RF_GlobalEventInit           = (1 << 2),             ///< RF_open() is called for the first time (number of registered clients changes from 0 to 1).
1333                                                          ///< The \a arg argument is empty.
1334                                                          ///< Task context.
1335 
1336     RF_GlobalEventCmdStart       = (1 << 3),             ///< A command chain is being dispatched to the radio.
1337                                                          ///< The \a arg argument is a pointer to the current command.
1338                                                          ///< HWI context.
1339 
1340     RF_GlobalEventCmdStop        = (1 << 4),             ///< Command termination event is handled.
1341                                                          ///< The \a arg argument is a pointer to the current command.
1342                                                          ///< HWI context.
1343 
1344     RF_GlobalEventCoexControl    = (1 << 5),             ///< Change to coex configuration is requested
1345                                                          ///< The \a arg argument is pointer to at least 8-bit wide int with value 1=enable, or 0=disable
1346                                                          ///< Task/HWI context.
1347 } RF_GlobalEvent;
1348 
1349 
1350 /** @brief Event mask for combining #RF_ClientEvent event flags in #RF_Params::nClientEventMask.
1351  *
1352  */
1353 typedef uint32_t RF_ClientEventMask;
1354 
1355 /** @brief Event mask for combining #RF_GlobalEvent event flags in #RFCC26XX_HWAttrsV2::globalEventMask.
1356  *
1357  */
1358 typedef uint32_t RF_GlobalEventMask;
1359 
1360 /** @brief Command handle that is returned by RF_postCmd().
1361  *
1362  *  A command handle is an integer number greater equals zero and identifies
1363  *  a command container in the RF driver's internal command queue. A client
1364  *  can dispatch a command with RF_postCmd() and use the command handle
1365  *  later on to make the RF driver interact with the command.
1366  *
1367  *  A negative value has either a special meaning or indicates an error.
1368  *
1369  *  @sa RF_pendCmd(), RF_flushCmd(), RF_cancelCmd(), ::RF_ALLOC_ERROR,
1370  *      ::RF_CMDHANDLE_FLUSH_ALL
1371  */
1372 typedef int16_t RF_CmdHandle;
1373 
1374 /** @struct RF_Object
1375  *  @brief Stores the client's internal configuration and states.
1376  *
1377  *  Before RF_open() can be called, an instance of RF_Object must be created where
1378  *  the RF driver can store its internal configuration and states.
1379  *  This object must remain persistent throughout application run-time and must not be
1380  *  modified by the application.
1381  *
1382  *  The size of #RF_Object can be optimized for single-mode applications by providing a
1383  *  `RF_SINGLEMODE` symbol at compilation time. The pre-built single-mode archive was generated
1384  *  with this symbol defined, hence any project using this archive must also define `RF_SINGLEMODE`
1385  *  on project level.
1386  *
1387  *  @note Except configuration fields before call to RF_open(), modification of
1388  *        any field in %RF_Object is forbidden.
1389  */
1390 
1391 
1392 /** @cond */
1393 
1394 typedef struct RF_ObjectMultiMode RF_Object;
1395 
1396 /** Definition of the RF_Object structure for multi mode applications.
1397  *  It is applicable with the multi mode RF driver through the #RF_Object common type.
1398  */
1399 struct RF_ObjectMultiMode{
1400     /// Configuration
1401     struct {
1402         uint32_t            nInactivityTimeout;          ///< Inactivity timeout in us.
1403         RF_Mode*            pRfMode;                     ///< Mode of operation.
1404         RF_RadioSetup*      pRadioSetup;                 ///< Pointer to the setup command to be executed at power up.
1405         uint32_t            nPhySwitchingDuration;       ///< Radio reconfiguration time to this client's phy and protocol.
1406         uint32_t            nPowerUpDuration;            ///< Radio power up time to be used to calculate future wake-up events.
1407         bool                bMeasurePowerUpDuration;     ///< Indicates if nPowerUpDuration holds a fix value or being measured and updated at every power up.
1408         bool                bUpdateSetup;                ///< Indicates if an analog configuration update should be performed at the next setup command execution.
1409         uint16_t            nPowerUpDurationMargin;      ///< Power up duration margin in us.
1410         void*               pPowerCb;                    ///< \deprecated Power up callback, will go away in future versions, see clientConfig::pClienteventCb instead
1411         void*               pErrCb;                      ///< Error callback.
1412         void*               pClientEventCb;              ///< Client event callback.
1413         RF_ClientEventMask  nClientEventMask;            ///< Client event mask to activate client event callback.
1414         uint16_t            nPhySwitchingDurationMargin; ///< Phy switching duration margin in us. It is used to calculate when run-time conflicts shall be resolved.
1415         uint32_t            nID;                         ///< RF handle identifier.
1416     } clientConfig;
1417     /// State & variables
1418     struct {
1419         struct {
1420             rfc_CMD_FS_t        cmdFs;              ///< FS command to be executed when the radio is powered up.
1421         } mode_state;                               ///< (Mode-specific) state structure
1422         SemaphoreP_Struct       semSync;            ///< Semaphore used by RF_runCmd(), RF_pendCmd() and power down sequence.
1423         RF_EventMask volatile   eventSync;          ///< Event mask/value used by RF_runCmd() and RF_pendCmd().
1424         void*                   pCbSync;            ///< Internal storage of user callbacks when RF_runCmd() is used.
1425         RF_EventMask            unpendCause;        ///< Internal storage of the return value of RF_pendCmd().
1426         ClockP_Struct           clkReqAccess;       ///< Clock used for request access timeout.
1427         bool                    bYielded;           ///< Flag indicates that the radio can be powered down at the earliest convenience.
1428     } state;
1429 };
1430 
1431 /** @endcond */
1432 
1433 /** @brief A handle that is returned by to RF_open().
1434  *
1435  *  %RF_Handle is used for further RF client interaction with the RF driver.
1436  *  An invalid handle has the value NULL.
1437  */
1438 typedef RF_Object* RF_Handle;
1439 
1440 
1441 /** @brief RAT handle that is returned by RF_ratCompare() or RF_ratCapture().
1442  *
1443  *  An %RF_RatHandle is an integer number with value greater than or equal to zero and identifies
1444  *  a Radio Timer Channel in the RF driver's internal RAT module. A client can interact with the
1445  *  RAT module through the RF_ratCompare(), RF_ratCapture() or RF_ratDisableChannel() APIs.
1446  *
1447  *  A negative value indicates an error. A typical example when RF_ratCompare() returns with RF_ALLOC_ERROR.
1448  */
1449 typedef int8_t RF_RatHandle;
1450 
1451 /** @brief Selects the entry of interest in RF_getInfo().
1452  *
1453  */
1454 typedef enum {
1455     RF_GET_CURR_CMD,                              ///< Retrieve a command handle of the current command.
1456     RF_GET_AVAIL_RAT_CH,                          ///< Create a bitmask showing available RAT channels.
1457     RF_GET_RADIO_STATE,                           ///< Show the current RF core power state. 0: Radio OFF, 1: Radio ON.
1458     RF_GET_SCHEDULE_MAP,                          ///< Deprecated. Not supported.
1459     RF_GET_CLIENT_LIST,                           ///< Provide the client list.
1460     RF_GET_CLIENT_SWITCHING_TIME,                 ///< Provide the client to client switching times
1461 } RF_InfoType;
1462 
1463 /** @brief Stores output parameters for RF_getInfo().
1464  *
1465  *  This union structure holds one out of multiple data types.
1466  *  The contained value is selected by #RF_InfoType.
1467  */
1468 typedef union {
1469     RF_CmdHandle ch;                              ///< Command handle (#RF_GET_CURR_CMD).
1470     uint16_t     availRatCh;                      ///< Available RAT channels (RF_GET_AVAIL_RAT_CH).
1471     bool         bRadioState;                     ///< Current RF core power state (#RF_GET_RADIO_STATE).
1472     RF_Handle    pClientList[2];                  ///< Client pointer list, [0]: client 1, [1]: client 2.
1473     uint32_t     phySwitchingTimeInUs[2];         ///< Phy switching time 0: client 1 -> 2, 1 : client 2 -> 1.
1474     void         *pScheduleMap;                   ///< Deprecated. Not supported.
1475 } RF_InfoVal;
1476 
1477 /** @brief RF schedule map entry structure.
1478  *
1479  */
1480 typedef struct {
1481     RF_CmdHandle ch;                               ///< Command handle
1482     RF_Handle    pClient;                          ///< Pointer to client object
1483     uint32_t     startTime;                        ///< Start time (in RAT tick) of the command or access request
1484     uint32_t     endTime;                          ///< End time (in RAT tick) of the command or access request
1485     RF_Priority  priority;                         ///< Priority of the command or access request
1486 } RF_ScheduleMapElement;
1487 
1488 /** @brief RF schedule map structure.
1489  *
1490  */
1491 typedef struct {
1492     RF_ScheduleMapElement  accessMap[RF_NUM_SCHEDULE_ACCESS_ENTRIES];    ///< Access request schedule map
1493     RF_ScheduleMapElement  commandMap[RF_NUM_SCHEDULE_COMMAND_ENTRIES];  ///< Command schedule map
1494 } RF_ScheduleMap;
1495 
1496 /** @brief Handles events related to RF command execution.
1497  *
1498  *  RF command callbacks notify the application of any events happening during RF command execution.
1499  *  Events may either refer to RF core interrupts (@ref RF_Core_Events) or may be generated by the RF driver
1500  *  (@ref RF_Driver_Events).
1501  *
1502  *  RF command callbacks are set up as parameter to RF_postCmd() or RF_runCmd() and provide:
1503  *
1504  *  - the relevant driver client handle \a h which was returned by RF_open(),
1505  *  - the relevant radio operation command handle \a ch,
1506  *  - an event mask \a e containing the occurred events.
1507  *
1508  *  RF command callbacks are executed in Software Interrupt (SWI) context and must not perform any
1509  *  blocking operation.
1510  *  The priority is configurable via #RFCC26XX_HWAttrsV2 in the board file or #RF_CTRL_SET_SWI_PRIORITY in RF_control().
1511  *
1512  *  The %RF_Callback function type is also used for signaling power events and
1513  *  errors.
1514  *  These are set in #RF_Params::pPowerCb and #RF_Params::pErrCb respectively.
1515  *  In case of a power event, \a ch can be ignored and \a e has #RF_EventPowerUp set.
1516  *  In case of an error callback, \a ch contains an error code instead of a command handle and
1517  *  \a e has the #RF_EventError flag set.
1518  *
1519  *  @note Error and power callbacks will be replaced by #RF_ClientCallback in future releases.
1520  */
1521 typedef void (*RF_Callback)(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
1522 
1523 /** @brief Handles events related to the Radio Timer (RAT).
1524  *
1525  *  The RF driver provides an interface to the Radio Timer through RF_ratCompare(), RF_ratCapture() and
1526  *  RF_ratDisableChannel() APIs. Each API call receives an optional input argument of the type
1527  *  RF_RatCallback. When a timer event occurs (compare, capture or error events), the registered
1528  *  callback is invoked.
1529  *
1530  *  The RF_RatCallback provides the following argument:
1531  *  - the relevant driver client handle \a h which was returned by RF_open(),
1532  *  - the relevant rat timer handle \a rh which the event is caused by,
1533  *  - an event mask \a e containing the occurred event (RF_EventRatCh or RF_EventError)
1534  *  - the captured value or the compare time \a compareCaptureTime read from the Radio Timer channel.
1535  */
1536 typedef void (*RF_RatCallback)(RF_Handle h, RF_RatHandle rh, RF_EventMask e, uint32_t compareCaptureTime);
1537 
1538 /**
1539  *  @brief Handles events related to a driver instance.
1540  *
1541  *  The RF driver produces additional events that are not directly related to the execution of a certain command, but
1542  *  happen during general RF driver operations.
1543  *  This includes power-up events, client switching events and others.
1544  *
1545  *  A client callback provides the following arguments:
1546  *  - the relevant driver client handle \a h which was returned by RF_open(),
1547  *  - an event identifier \a event,
1548  *  - an optional argument \a arg depending on the event.
1549  *
1550  *  RF client callbacks are executed in Software Interrupt (SWI) context and must not perform any blocking operation.
1551  *  The priority is configurable via #RFCC26XX_HWAttrsV2 in the board file or #RF_CTRL_SET_SWI_PRIORITY in RF_control().
1552  */
1553 typedef void (*RF_ClientCallback)(RF_Handle h, RF_ClientEvent event, void* arg);
1554 
1555 /**
1556  *  @brief Handles global events as part of PHY configuration.
1557  *
1558  *  The RF driver serves additional global, client independent events by invoking the #RF_GlobalCallback function
1559  *  registered through #RFCC26XX_HWAttrsV2::globalCallback in the board file. The function can subscribe to
1560  *  particular events through the #RFCC26XX_HWAttrsV2::globalEventMask, and receives the following arguments:
1561  *  - the relevant driver client handle \a h which was returned by RF_open(),
1562  *  - an event identifier \a event,
1563  *  - an optional argument \a arg depending on the event.
1564  *
1565  *  If multiple events happen at the same time, the callback is always invoked separately for each event.
1566  *  Depending on the event, the callback might be invoked in SWI or HWI context.
1567  */
1568 typedef void (*RF_GlobalCallback)(RF_Handle h, RF_GlobalEvent event, void* arg);
1569 
1570 /** @brief RF driver configuration parameters.
1571  *
1572  *  %RF_Params is used for initial RF driver configuration.
1573  *  It is initialized by RF_Params_init() and used by RF_open().
1574  *  Each client has its own set of parameters.
1575  *  They are reconfigured on a client switch.
1576  *  Some of the parameters can be changed during run-time using RF_control().
1577  */
1578 typedef struct {
1579     uint32_t            nInactivityTimeout;      ///< Inactivity timeout in microseconds.
1580                                                  ///< The default value is 0xFFFFFFFF (infinite).
1581 
1582     uint32_t            nPowerUpDuration;        ///< A custom power-up duration in microseconds.
1583                                                  ///< If 0, the RF driver will start with a conservative value and measure the actual time during the first power-up.
1584                                                  ///< The default value is 0.
1585 
1586     RF_Callback         pPowerCb;                ///< \deprecated Power up callback, will be removed future versions, see RF_Params::pClienteventCb instead.
1587                                                  ///< The default value is NULL.
1588 
1589     RF_Callback         pErrCb;                  ///< \deprecated Callback function for driver error events.
1590 
1591     uint16_t            nPowerUpDurationMargin;  ///< An additional safety margin to be added to #RF_Params::nPowerUpDuration.
1592                                                  ///< This is necessary because of other hardware and software interrupts
1593                                                  ///< preempting the RF driver interrupt handlers and state machine.
1594                                                  ///< The default value is platform-dependent.
1595 
1596     uint16_t            nPhySwitchingDurationMargin; ///< An additional safety margin to be used to calculate when conflicts shall be evaluated run-time.
1597 
1598     RF_ClientCallback   pClientEventCb;          ///< Callback function for client-related events.
1599                                                  ///< The default value is NULL.
1600 
1601     RF_ClientEventMask  nClientEventMask;        ///< Event mask used to subscribe certain client events.
1602                                                  ///< The purpose is to keep the number of callback executions small.
1603 
1604     uint32_t            nID;                     ///< RF handle identifier.
1605 } RF_Params;
1606 
1607 /** @brief Controls the behavior of the RF_scheduleCmd() API.
1608  *
1609  */
1610 typedef enum {
1611     RF_StartNotSpecified = 0,
1612     RF_StartAbs          = 1,
1613 } RF_StartType;
1614 
1615 /** @brief Controls the behavior of the RF_scheduleCmd() API.
1616  *
1617  */
1618 typedef enum {
1619     RF_EndNotSpecified = 0,
1620     RF_EndAbs          = 1,
1621     RF_EndRel          = 2,
1622     RF_EndInfinit      = 3,
1623  } RF_EndType;
1624 
1625 /* RF command. */
1626 typedef struct RF_Cmd_s RF_Cmd;
1627 
1628 /* RF command . */
1629 struct RF_Cmd_s {
1630     List_Elem            _elem;       /* Pointer to next and previous elements. */
1631     RF_Callback volatile pCb;         /* Pointer to callback function */
1632     RF_Op*               pOp;         /* Pointer to (chain of) RF operations(s) */
1633     RF_Object*           pClient;     /* Pointer to client */
1634     RF_EventMask         bmEvent;     /* Enable mask for interrupts from the command */
1635     RF_EventMask         pastifg;     /* Accumulated value of events happened within a command chain */
1636     RF_EventMask         rfifg;       /* Return value for callback 0:31 - RF_CPE0_INT, 32:63 - RF_HW_INT */
1637     RF_CmdHandle         ch;          /* Command handle */
1638     RF_Priority          ePri;        /* Priority of RF command */
1639     uint8_t volatile     flags;       /* [0: Aborted, 1: Stopped, 2: canceled] */
1640     uint32_t             startTime;   /* Command start time (in RAT ticks) */
1641     RF_StartType         startType;   /* Command start time type */
1642     uint32_t             allowDelay;  /* Delay allowed if the start time cannot be met. */
1643     uint32_t             endTime;     /* Command end time (in RAT ticks) */
1644     RF_EndType           endType;     /* Command end type */
1645     uint32_t             duration;    /* Command duration (in RAT ticks) */
1646     uint32_t             activityInfo; /* General value supported by user */
1647     RF_PriorityCoex      coexPriority; /* Command priority to use for coexistence request. */
1648     RF_RequestCoex       coexRequest; /* Command REQUEST line behavior to use for coexistence request. */
1649 };
1650 
1651 /** @brief RF Hardware attributes.
1652  *
1653  *  This data structure contains platform-specific driver configuration.
1654  *  It is usually defined globally in a board support file.
1655  */
1656 typedef struct {
1657     uint8_t             hwiPriority;        ///< Priority for HWIs belong to the RF driver.
1658     uint8_t             swiPriority;        ///< Priority for SWIs belong to the RF driver.
1659     bool                xoscHfAlwaysNeeded; ///< Indicate that the XOSC HF should be turned on by the power driver
1660     RF_GlobalCallback   globalCallback;     ///< Pointer to a callback function serving client independent events listed in #RF_GlobalEvent.
1661     RF_GlobalEventMask  globalEventMask;    ///< Event mask which the globalCallback is invoked upon.
1662 } RFCC26XX_HWAttrsV2;
1663 
1664 /** @brief Controls the behavior of the state machine of the RF driver when a conflict is identified
1665  *         run-time between the commands waiting on the pend queue and the commands being actively executed
1666  *         by the radio.
1667  */
1668 typedef enum
1669 {
1670     RF_ConflictNone   = 0,
1671     RF_ConflictReject = 1,
1672     RF_ConflictAbort  = 2,
1673 } RF_Conflict;
1674 
1675 /** @brief Describes the location within the pend queue where the new command was inserted by the scheduler.
1676  */
1677 typedef enum
1678 {
1679     RF_ScheduleStatusError   = -3,
1680     RF_ScheduleStatusNone    = 0,
1681     RF_ScheduleStatusTop     = 1,
1682     RF_ScheduleStatusMiddle  = 2,
1683     RF_ScheduleStatusTail    = 4,
1684     RF_ScheduleStatusPreempt = 8
1685 } RF_ScheduleStatus;
1686 
1687 /**
1688  *  @brief Handles the queue sorting algorithm when a new command is submitted to the driver from any of
1689  *         the active clients.
1690  *
1691  *  The function is invoked within the RF_scheduleCmd API.
1692  *
1693  *  The default algorithm is subscribed through the #RFCC26XX_SchedulerPolicy::submitHook and implemented
1694  *  in the RF driver. The arguments are:
1695  *      - \a pCmdNew points to the command to be submitted.
1696  *      - \a pCmdBg is the running background command.
1697  *      - \a pCmdFg is the running foreground command.
1698  *      - \a pPendQueue points to the head structure of pend queue.
1699  *      - \a pDoneQueue points to the head structure of done queue.
1700  *
1701  *  In case the radio APIs do not distinguish between background and foreground contexts, the active operation
1702  *  will be returned within the pCmdBg pointer. If there are no commands being executed, both the
1703  *  pCmdBg and pCmdFg pointers are returned as NULL.
1704  */
1705 typedef RF_ScheduleStatus (*RF_SubmitHook)(RF_Cmd* pCmdNew, RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue);
1706 
1707 /**
1708  *  @brief Defines the conflict resolution in runtime.
1709  *
1710  *  The function is invoked if a conflict is identified before the start-time of the next radio command in
1711  *  the pending queue. The return value of type #RF_Conflict determines the policy to be followed by the RF driver.
1712  *
1713  *  The arguments are:
1714  *      - \a pCmdBg is the running background command.
1715  *      - \a pCmdFg is the running foreground command.
1716  *      - \a pPendQueue points to the head structure of pend queue.
1717  *      - \a pDoneQueue points to the head structure of done queue.
1718  */
1719 typedef RF_Conflict (*RF_ConflictHook)(RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue);
1720 
1721 /** @brief RF scheduler policy.
1722  *
1723  *  This data structure contains function hooks which implements the scheduling
1724  *  algorithm used to inter-align one or more independent protocol stacks.
1725  */
1726 typedef struct {
1727   RF_SubmitHook   submitHook;   ///< Function hook implements the scheduling policy to be executed at the time of RF_scheduleCmd API call.
1728   RF_ConflictHook conflictHook; ///< Function hook implements the runtime conflict resolution, if any identified at the start time of next command.
1729 } RFCC26XX_SchedulerPolicy;
1730 
1731 /** @brief Controls the behavior of the RF_scheduleCmd() API.
1732  *
1733  */
1734 typedef enum {
1735     RF_AllowDelayNone = 0,
1736     RF_AllowDelayAny  = UINT32_MAX
1737 } RF_AllowDelay;
1738 
1739 /* @brief RF schedule command parameter struct
1740  *
1741  * RF schedule command parameters are used with the RF_scheduleCmd() call.
1742  */
1743 typedef struct {
1744     uint32_t            startTime;          ///< Start time in RAT Ticks for the radio command
1745     RF_StartType        startType;          ///< Start type for the start time
1746     uint32_t            allowDelay;         ///< Control word to define the policy of the scheduler if the timing of a command cannot be met.
1747                                             ///< Only applicable on CC13x2 and CC26x2 devices.
1748                                             ///<  RF_AllowDelayNone: Reject the command.
1749                                             ///<  RF_AllowDelayAny:  Append the command to the end of the queue.
1750    uint32_t            endTime;             ///< End time in RAT Ticks for the radio command
1751    RF_EndType          endType;             ///< End type for the end time
1752    uint32_t            duration;            ///< Duration in RAT Ticks for the radio command
1753    uint32_t            activityInfo;        ///< Activity info provided by user
1754    RF_PriorityCoex     coexPriority;        ///< Priority to use for coexistence request.
1755    RF_RequestCoex      coexRequest;         ///< REQUEST line behavior to use for coexistence request.
1756 } RF_ScheduleCmdParams;
1757 
1758 /** @brief RF request access parameter struct
1759  *
1760  *  RF request access command parameters are used with the RF_requestAccess() call.
1761  */
1762 typedef struct {
1763     uint32_t            duration;           ///< Radio access duration in RAT Ticks requested by the client
1764     uint32_t            startTime;          ///< Start time window in RAT Time for radio access
1765     RF_Priority         priority;           ///< Access priority
1766 } RF_AccessParams;
1767 
1768 /** @brief Select the preferred RAT channel through the configuration of #RF_ratCompare() or #RF_ratCapture().
1769  *
1770  *  If RF_RatChannelAny is provided within the channel configuration (default), the API will
1771  *  allocate the first available channel. Otherwise, it tries to allocate the requested channel,
1772  *  and if it is not available, returns with #RF_ALLOC_ERROR.
1773  */
1774 typedef enum {
1775     RF_RatChannelAny = -1,                  ///< Chose the first available channel.
1776     RF_RatChannel0   =  0,                  ///< Use RAT user channel 0.
1777     RF_RatChannel1   =  1,                  ///< Use RAT user channel 1.
1778     RF_RatChannel2   =  2,                  ///< Use RAT user channel 2.
1779 } RF_RatSelectChannel;
1780 
1781 /** @brief Selects the source signal for #RF_ratCapture().
1782  *
1783  *  The source of a capture event can be selected through the source field of the
1784  *  #RF_RatConfigCapture configuration structure.
1785  */
1786 typedef enum {
1787       RF_RatCaptureSourceRtcUpdate    = 20, ///< Selects the RTC update signal source.
1788       RF_RatCaptureSourceEventGeneric = 21, ///< Selects the Generic event of Event Fabric as source.
1789       RF_RatCaptureSourceRfcGpi0      = 22, ///< Selects the RFC_GPI[0] as source. This can be used i.e.
1790                                             ///< to capture events on a GPIO. This requires that the GPIO
1791                                             ///< is connected to RFC_GPO[0] from the GPIO driver.
1792       RF_RatCaptureSourceRfcGpi1      = 23  ///< Selects the RFC_GPO[1] as source. This can be used i.e.
1793                                             ///< to capture events on a GPIO. This requires that the GPIO
1794                                             ///< is connected to RFC_GPO[1] from the GPIO driver.
1795 } RF_RatCaptureSource;
1796 
1797 /** @brief Selects the mode of #RF_ratCapture().
1798  *
1799  *  The trigger mode of a capture event can be selected through the mode field of
1800  *  #RF_RatConfigCapture configuration structure.
1801  */
1802 typedef enum {
1803     RF_RatCaptureModeRising       = 0,      ///< Rising edge of the selected source will trigger a capture event.
1804     RF_RatCaptureModeFalling      = 1,      ///< Falling edge of the selected source will trigger a capture event.
1805     RF_RatCaptureModeBoth         = 2       ///< Both rising and falling edges of the selected source will generate
1806                                             ///< capture events.
1807 } RF_RatCaptureMode;
1808 
1809 /** @brief Selects the repetition of #RF_ratCapture().
1810  *
1811  *  The configuration of a capture channel also defines whether the channel should be
1812  *  freed or automatically rearmed after a capture event occurred. In the latter case, the
1813  *  user needs to free the channel manually through the #RF_ratDisableChannel() API.
1814  */
1815 typedef enum {
1816     RF_RatCaptureSingle           = 0,      ///< Free the channel after the first capture event.
1817     RF_RatCaptureRepeat           = 1       ///< Rearm the channel after each capture events.
1818 } RF_RatCaptureRepetition;
1819 
1820 /** @brief Selects the mode of the RAT_GPO[x] for #RF_ratCompare() or #RF_ratCapture().
1821  *
1822  *  In case of compare mode, the channel can generate an output signal of the selected
1823  *  mode on the configured RAT_GPO[x] interface, and can be interconnected with
1824  *  other subsystems through the RFC_GPO[x] or Event Fabric. An example use case is
1825  *  to generate a pulse on a GPIO.
1826  *
1827  *  In case of capture mode, the channel can also generate an output signal of the
1828  *  selected mode on the configured RAT_GPO[x] interface. Note that the configuration
1829  *  of this output event is independent of the source signal of the capture event.
1830  *  An example use case is to generate a pulse on a GPIO on each raising edge of another
1831  *  GPIO source.
1832  *
1833  */
1834 typedef enum {
1835     RF_RatOutputModePulse         = 0,      ///< Generates a one-clock period width pulse.
1836     RF_RatOutputModeSet           = 1,      ///< Sets the output high on a RAT event.
1837     RF_RatOutputModeClear         = 2,      ///< Sets the output low on a RAT event.
1838     RF_RatOutputModeToggle        = 3,      ///< Inverts the polarity of the output.
1839     RF_RatOutputModeAlwaysZero    = 4,      ///< Sets the output low independently of any RAT events.
1840     RF_RatOutputModeAlwaysOne     = 5,      ///< Sets the output high independently of any RAT events.
1841 } RF_RatOutputMode;
1842 
1843 /** @brief Selects GPO to be used with #RF_ratCompare() or #RF_ratCapture().
1844  *
1845  *  RAT_GPO[0]   - Reserved by the RF core. User shall not modify the configuration,
1846  *                 but can observe the signal through any of RFC_GPO[0:3].
1847  *  RAT_GPO[1]   - Reserved by the RF core only if sync word detection is enabled.
1848  *                 Otherwise can be used through RFC_GPO[0:3].
1849  *  RAT_GPO[2:3] - Available and can be used through any of the RFC_GPO[0:3].
1850  *  RAT_GPO[4:7] - Available and can be used through the Event fabric.
1851  */
1852 typedef enum {
1853     RF_RatOutputSelectRatGpo1     = 1,      ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[1]
1854     RF_RatOutputSelectRatGpo2     = 2,      ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[2]
1855     RF_RatOutputSelectRatGpo3     = 3,      ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[3]
1856     RF_RatOutputSelectRatGpo4     = 4,      ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[4]
1857     RF_RatOutputSelectRatGpo5     = 5,      ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[5]
1858     RF_RatOutputSelectRatGpo6     = 6,      ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[6]
1859     RF_RatOutputSelectRatGpo7     = 7,      ///< Configure RAT_CHANNEL[x] to interface with RAT_GPO[7]
1860 } RF_RatOutputSelect;
1861 
1862 /** @brief RF_ratCapture parameter structure.
1863  *
1864  *  %RF_RatCapture parameters are used with the #RF_ratCapture() call.
1865  */
1866 typedef struct {
1867     RF_RatCallback            callback;         ///< Callback function to be invoked upon a capture event (optional).
1868     RF_RatHandle              channel;          ///< RF_RatHandle identifies the channel to be allocated.
1869     RF_RatCaptureSource       source;           ///< Configuration of the event source to cause a capture event.
1870     RF_RatCaptureMode         captureMode;      ///< Configuration of the mode of event to cause a capture event.
1871     RF_RatCaptureRepetition   repeat;           ///< Configuration of the channel to be used in single or repeated mode.
1872 } RF_RatConfigCapture;
1873 
1874 /** @brief RF_ratCompare parameter structure.
1875  *
1876  *  %RF_RatCompare parameters are used with the #RF_ratCompare() call.
1877  */
1878 typedef struct {
1879     RF_RatCallback            callback;         ///< Callback function to be invoked upon a capture event (optional).
1880     RF_RatHandle              channel;          ///< RF_RatHandle identifies the channel to be allocated.
1881     uint32_t                  timeout;          ///< Timeout value in RAT ticks to be programmed in the timer as the
1882                                                 ///< trigger of compare event.
1883 } RF_RatConfigCompare;
1884 
1885 /** @brief RAT related IO parameter structure.
1886  *
1887  *  These parameters are used with the #RF_ratCompare() or #RF_ratCapture() calls.
1888  */
1889 typedef struct {
1890     RF_RatOutputMode          mode;            ///< The mode the GPO should operate in.
1891     RF_RatOutputSelect        select;          ///< The signal which shall be connected to the GPO.
1892 } RF_RatConfigOutput;
1893 
1894 /** @brief Creates a a new client instance of the RF driver.
1895  *
1896  *  This function initializes an RF driver client instance using \a pObj as storage.
1897  *  It does not power up the RF core.
1898  *  Once the client starts the first RF operation command later in the application,
1899  *  the RF core is powered up and set into a PHY mode specified by \a pRfMode.
1900  *  The chosen PHY is then configured by a radio setup command \a pRadioSetup.
1901  *  Whenever the RF core is powered up, the RF driver re-executes the radio setup command \a pRadioSetup.
1902  *  Additional driver behavior may be set by an optional \a params.
1903  *
1904  *  @code
1905  *  // Define parameters
1906  *  RF_Params rfParams;
1907  *  rfParams.nInactivityTimeout = 4;
1908  *  RF_Params_init(&rfParams);
1909  *  rfParams.nInactivityTimeout = 1701; // microseconds
1910  *
1911  *  RF_Handle rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
1912  *  @endcode
1913  *
1914  *  @note Calling context : Task
1915  *
1916  *  @param pObj         Pointer to a #RF_Object that will hold the state for this
1917  *                      RF client. The object must be in persistent and writable
1918  *                      memory.
1919  *  @param pRfMode      Pointer to a #RF_Mode struct holding PHY information
1920  *  @param pRadioSetup  Pointer to the radio setup command used for this client.
1921  *                      This is re-executed by the RF Driver on each power-up.
1922  *  @param params       Pointer to an RF_Params object with the desired driver configuration.
1923  *                      A NULL pointer results in the default configuration being loaded.
1924  *  @return             A handle for further RF driver calls on success. Otherwise NULL.
1925  */
1926 extern RF_Handle RF_open(RF_Object *pObj, RF_Mode *pRfMode, RF_RadioSetup *pRadioSetup, RF_Params *params);
1927 
1928 /**
1929  *  @brief  Close client connection to RF driver
1930  *
1931  *  Allows a RF client (high-level driver or application) to close its connection
1932  *  to the RF driver.
1933  *
1934  *  @note Calling context : Task
1935  *
1936  *  @param h  Handle previously returned by RF_open()
1937  */
1938 extern void RF_close(RF_Handle h);
1939 
1940 /**
1941  *  @brief  Return current radio timer value
1942  *
1943  *  If the radio is powered returns the current radio timer value, if not returns
1944  *  a conservative estimate of the current radio timer value
1945  *
1946  *  @note Calling context : Task/SWI/HWI
1947  *
1948  *  @return     Current radio timer value
1949  */
1950 extern uint32_t RF_getCurrentTime(void);
1951 
1952 /**
1953  *  @brief  Appends RF operation commands to the driver's command queue and returns a
1954  *          command handle.
1955  *
1956  *  The RF operation \a pOp may either represent a single operation or may be the first
1957  *  operation in a chain.
1958  *  If the command queue is empty, the \a pCmd is dispatched immediately. If there are
1959  *  other operations pending, then \a pCmd is processed after all other commands have been
1960  *  finished.
1961  *  The RF operation command must be compatible to the RF_Mode selected by RF_open(), e.g.
1962  *  proprietary commands can only be used when the RF core is configured for proprietary mode.
1963  *
1964  *  The returned command handle is an identifier that can be used to control command execution
1965  *  later on, for instance with RF_pendCmd() or RF_cancelCmd().
1966  *  It is a 16 Bit signed integer value, incremented on every new command.
1967  *  If the RF driver runs out of command containers, RF_ALLOC_ERROR is returned.
1968  *
1969  *  The priority \a ePri is only relevant in multi-client applications where commands of distinct
1970  *  clients may interrupt each other.
1971  *  Only commands started by RF_scheduleCmd() can preempt
1972  *  running commands. #RF_postCmd() or RF_runCmd() do never interrupt a running command.
1973  *  In single-client applications, \a ePri is ignored and should be set to ::RF_PriorityNormal.
1974  *
1975  *  A callback function \a pCb might be specified to get notified about events during command
1976  *  execution. Events are subscribed by the bit mask \a bmEvent.
1977  *  Valid event flags are specified in @ref RF_Core_Events and @ref RF_Driver_Events.
1978  *  If no callback is set, RF_pendCmd() can be used to synchronize the current task to command
1979  *  execution. For this it is necessary to subscribe all relevant events.
1980  *  The termination events ::RF_EventLastCmdDone, ::RF_EventCmdCancelled, ::RF_EventCmdAborted and
1981  *  ::RF_EventCmdStopped are always implicitly subscribed.
1982  *
1983  *  The following limitations apply to the execution of command chains:
1984  *
1985  *  - If TRIG_ABSTIME is used as a start trigger for the first command, TRIG_REL_FIRST_START
1986  *    can not be used for any other command. This is because the RF driver may insert a
1987  *    frequency-select command (CMD_FS) at the front of the chain when it performs an
1988  *    automatic power-up.
1989  *  - Having more than one CMD_FS in a chain may lead to unexpected behavior.
1990  *    If a chain contains a CMD_FS and the command can be reached by iterating over the pNextOp
1991  *    field, then RF driver will always update the cached CMD_FS with the new settings. On the
1992  *    next automatic power-up, the RF driver will use the updated frequency.
1993  *
1994  *  @note Calling context : Task/SWI
1995  *
1996  *  @sa RF_pendCmd(), RF_runCmd(), RF_scheduleCmd(), RF_RF_cancelCmd(), RF_flushCmd(), RF_getCmdOp()
1997  *
1998  *  @param h         Driver handle previously returned by RF_open()
1999  *  @param pOp       Pointer to the RF operation command.
2000  *  @param ePri      Priority of this RF command (used for arbitration in multi-client systems)
2001  *  @param pCb       Callback function called during command execution and upon completion.
2002  *                   If RF_postCmd() fails, no callback is made.
2003  *  @param bmEvent   Bitmask of events that will trigger the callback or that can be pended on.
2004  *  @return          A handle to the RF command. Return value of RF_ALLOC_ERROR indicates error.
2005  */
2006 extern RF_CmdHandle RF_postCmd(RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
2007 
2008 /**
2009  *  @brief  Sorts and adds commands to the RF driver internal command queue.
2010  *
2011  *  @param pCmdNew    Pointer to the command to be submitted.
2012  *  @param pCmdBg     Running background command.
2013  *  @param pCmdFg     Running foreground command.
2014  *  @param pPendQueue Pointer to the head structure of pend queue.
2015  *  @param pDoneQueue Pointer to the head structure of done queue..
2016  *  @return           RF_defaultSubmitPolicy identifies the success or failure of queuing.
2017  */
2018 extern RF_ScheduleStatus RF_defaultSubmitPolicy(RF_Cmd* pCmdNew, RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue);
2019 
2020 /**
2021  *  @brief  Makes a final decision when a conflict in run-time is identified.
2022  *
2023  *  @param pCmdBg     Running background command.
2024  *  @param pCmdFg     Running foreground command.
2025  *  @param pPendQueue Pointer to the head structure of pend queue.
2026  *  @param pDoneQueue Pointer to the head structure of done queue..
2027  *  @return           RF_defaultSubmitPolicy identifies the success or failure of queuing.
2028  */
2029 extern RF_Conflict RF_defaultConflictPolicy(RF_Cmd* pCmdBg, RF_Cmd* pCmdFg, List_List* pPendQueue, List_List* pDoneQueue);
2030 
2031 
2032 /**
2033  *  @brief  Initialize the configuration structure to default values to be used with the RF_scheduleCmd() API.
2034  *
2035  *  @note Calling context : Task/SWI/HWI
2036  *
2037  *  @param  pSchParams Pointer to the configuration structure.
2038  *  @return none
2039  */
2040 extern void RF_ScheduleCmdParams_init(RF_ScheduleCmdParams *pSchParams);
2041 
2042 /**
2043  *  @brief  Schedule an RF operation (chain) to the command queue.
2044  *
2045  *  Schedule an #RF_Op to the RF command queue of the client with handle h. <br>
2046  *  The command can be the first in a chain of RF operations or a standalone RF operation.
2047  *  If a chain of operations are posted they are treated atomically, i.e. either all
2048  *  or none of the chained operations are run. <br>
2049  *  All operations must be posted in strictly increasing chronological order. Function returns
2050  *  immediately. <br>
2051  *
2052  *  Limitations apply to the operations posted:
2053  *  - The operation must be in the set supported in the chosen radio mode when
2054  *    RF_open() was called
2055  *  - Only a subset of radio operations are supported
2056  *  - Only some of the trigger modes are supported with potential power saving (TRIG_NOW, TRIG_ABSTIME)
2057  *
2058  *  @note Calling context : Task/SWI
2059  *
2060  *  @param h         Handle previously returned by RF_open()
2061  *  @param pOp       Pointer to the #RF_Op. Must normally be in persistent and writable memory
2062  *  @param pSchParams Pointer to the schedule command parameter structure
2063  *  @param pCb       Callback function called upon command completion (and some other events).
2064  *                   If RF_scheduleCmd() fails no callback is made
2065  *  @param bmEvent   Bitmask of events that will trigger the callback.
2066  *  @return          A handle to the RF command. Return value of RF_ALLOC_ERROR indicates error.
2067  */
2068 extern RF_CmdHandle RF_scheduleCmd(RF_Handle h, RF_Op *pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent);
2069 
2070 /**
2071  *  @brief  Synchronizes the calling task to an RF operation command \a ch and
2072  *          returns accumulated event flags.
2073  *
2074  *  After having dispatched an RF operation represented by \a ch with RF_postCmd(), the
2075  *  command is running in parallel on the RF core. Thus, it might be desirable to synchronize
2076  *  the calling task to the execution of the command.
2077  *  With #RF_pendCmd(), the application can block until one of the events specified in
2078  *  \a bmEvent occurs or until the command finishes.
2079  *  The function consumes and returns all accumulated event flags that occurred during
2080  *  execution if they have been previously subscribed by RF_postCmd().
2081  *  Possible events are specified in @ref RF_Core_Events and @ref RF_Driver_Events.
2082  *  The termination events ::RF_EventLastCmdDone, ::RF_EventCmdCancelled,
2083  *  ::RF_EventCmdAborted and ::RF_EventCmdStopped are always implicitly subscribed and
2084  *  can not be masked.
2085  *
2086  *  #RF_pendCmd() may be called multiple times for the same command.
2087  *
2088  *  If #RF_pendCmd() is called for a command handle representing a finished command,
2089  *  then only the ::RF_EventLastCmdDone flag is returned, regardless of how the command
2090  *  finished.
2091  *
2092  *  If the command has also a callback set, the callback is executed before #RF_pendCmd()
2093  *  returns.
2094  *
2095  *  Example:
2096  *  @code
2097  *  // Dispatch a command to the RF driver's command queue
2098  *  RF_CmdHandle ch = RF_postCmd(driver, (RF_Op*)&CMD_PROP_RX, RF_PriorityNormal, NULL, RF_EventRxEntryDone);
2099  *  assert(ch != RF_ALLOC_ERROR);
2100  *
2101  *  bool finished = false;
2102  *  while (finished == false)
2103  *  {
2104  *      // Synchronize to events during command execution.
2105  *      uint32_t events = RF_pendCmd(driver, ch, RF_EventRxEntryDone);
2106  *      // Check events that happen during execution
2107  *      if (events & RF_EventRxEntryDone)
2108  *      {
2109  *          // Process packet
2110  *      }
2111  *      if (events & (RF_EventLastCmdDone | RF_EventCmdStopped | RF_EventCmdAborted | RF_EventCmdCancelled))
2112  *      {
2113  *          finished = true;
2114  *      }
2115  *      // ...
2116  *  }
2117  *  @endcode
2118  *
2119  *  @note Calling context : Task
2120  *
2121  *  @param h        Driver handle previously returned by RF_open()
2122  *  @param ch       Command handle previously returned by RF_postCmd().
2123  *  @param bmEvent  Bitmask of events that make RF_pendCmd() return. Termination events
2124  *                  are always implicitly subscribed.
2125  *  @return         Event flags accumulated during command execution.
2126  *
2127  *  @sa RF_postCmd()
2128  */
2129 extern RF_EventMask RF_pendCmd(RF_Handle h, RF_CmdHandle ch, RF_EventMask bmEvent);
2130 
2131 /**
2132  *  @brief  Runs synchronously an RF operation command or a chain of commands and returns
2133  *          the termination reason.
2134  *
2135  *  This function appends an RF operation command or a chain of commands to the RF driver's
2136  *  command queue and then waits for it to complete.
2137  *  A command is completed if one of the termination events ::RF_EventLastCmdDone,
2138  *  ::RF_EventCmdCancelled, ::RF_EventCmdAborted, ::RF_EventCmdStopped occurred.
2139  *
2140  *  This function is a combination of RF_postCmd() and RF_pendCmd().
2141  *  All options and limitations for RF_postCmd() apply here as well.
2142  *
2143  *  An application should always ensure that the command completed in the expected way and
2144  *  with an expected status code.
2145  *
2146  *  @note Calling context : Task
2147  *
2148  *  @param h         Driver handle previously returned by RF_open()
2149  *  @param pOp       Pointer to the RF operation command.
2150  *  @param ePri      Priority of this RF command (used for arbitration in multi-client systems)
2151  *  @param pCb       Callback function called during command execution and upon completion.
2152  *                   If RF_runCmd() fails, no callback is made.
2153  *  @param bmEvent   Bitmask of events that will trigger the callback or that can be pended on.
2154  *  @return          The relevant termination event.
2155  *
2156  *  @sa RF_postCmd(), RF_pendCmd(), RF_cancelCmd(), RF_flushCmd()
2157  */
2158 extern RF_EventMask RF_runCmd(RF_Handle h, RF_Op *pOp, RF_Priority ePri, RF_Callback pCb, RF_EventMask bmEvent);
2159 
2160 /**
2161  *  @brief  Runs synchronously a (chain of) RF operation(s) for dual or single-mode.
2162  *
2163  *  Allows a (chain of) operation(s) to be scheduled to the command queue and then waits
2164  *  for it to complete. <br> A command is completed if one of the RF_EventLastCmdDone,
2165  *  RF_EventCmdCancelled, RF_EventCmdAborted, RF_EventCmdStopped occurred.
2166  *
2167  *  @note Calling context : Task
2168  *  @note Only one call to RF_pendCmd() or RF_runScheduleCmd() can be made at a time for
2169  *        each client
2170  *
2171  *  @param h         Handle previously returned by RF_open()
2172  *  @param pOp       Pointer to the #RF_Op. Must normally be in persistent and writable memory
2173  *  @param pSchParams Pointer to the schedule command parameter structure
2174  *  @param pCb       Callback function called upon command completion (and some other events).
2175  *                   If RF_runScheduleCmd() fails, no callback is made.
2176  *  @param bmEvent   Bitmask of events that will trigger the callback.
2177  *  @return          The relevant command completed event.
2178  */
2179 extern RF_EventMask RF_runScheduleCmd(RF_Handle h, RF_Op *pOp, RF_ScheduleCmdParams *pSchParams, RF_Callback pCb, RF_EventMask bmEvent);
2180 
2181 /**
2182  *  @brief  Abort/stop/cancel single command in command queue.
2183  *
2184  *  If command is running, aborts/stops it and posts callback for the
2185  *  aborted/stopped command. <br>
2186  *  If command has not yet run, cancels it it and posts callback for the
2187  *  canceled command. <br>
2188  *  If command has already run or been aborted/stopped/canceled, has no effect.<br>
2189  *  If RF_cancelCmd is called from a Swi context with same or higher priority
2190  *  than RF Driver Swi, when the RF core is powered OFF -> the cancel callback will be delayed
2191  *  until the next power-up cycle.<br>
2192  *
2193  *  @note Calling context : Task/SWI
2194  *
2195  *  @param h            Handle previously returned by RF_open()
2196  *  @param ch           Command handle previously returned by RF_postCmd().
2197  *  @param mode         1: Stop gracefully, 0: abort abruptly
2198  *  @return             RF_Stat indicates if command was successfully completed
2199  */
2200 extern RF_Stat RF_cancelCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
2201 
2202 /**
2203  *  @brief  Abort/stop/cancel command and any subsequent commands in command queue.
2204  *
2205  *  If command is running, aborts/stops it and then cancels all later commands in queue.<br>
2206  *  If command has not yet run, cancels it and all later commands in queue.<br>
2207  *  If command has already run or been aborted/stopped/canceled, has no effect.<br>
2208  *  The callbacks for all canceled commands are issued in chronological order.<br>
2209  *  If RF_flushCmd is called from a Swi context with same or higher priority
2210  *  than RF Driver Swi, when the RF core is powered OFF -> the cancel callback will be delayed
2211  *  until the next power-up cycle.<br>
2212  *
2213  *  @note Calling context : Task/SWI
2214  *
2215  *  @param h            Handle previously returned by RF_open()
2216  *  @param ch           Command handle previously returned by RF_postCmd().
2217  *  @param mode         1: Stop gracefully, 0: abort abruptly
2218  *  @return             RF_Stat indicates if command was successfully completed
2219  */
2220 extern RF_Stat RF_flushCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode);
2221 
2222 /**
2223  *  @brief Send any Immediate command. <br>
2224  *
2225  *  Immediate Command is send to RDBELL, if radio is active and the RF_Handle points
2226  *  to the current client. <br>
2227  *  In other appropriate RF_Stat values are returned. <br>
2228  *
2229  *  @note Calling context : Task/SWI/HWI
2230  *
2231  *  @param h            Handle previously returned by RF_open()
2232  *  @param pCmdStruct   Pointer to the immediate command structure
2233  *  @return             RF_Stat indicates if command was successfully completed
2234  */
2235 extern RF_Stat RF_runImmediateCmd(RF_Handle h, uint32_t *pCmdStruct);
2236 
2237 /**
2238  *  @brief Send any Direct command. <br>
2239  *
2240  *  Direct Command value is send to RDBELL immediately, if radio is active and
2241  *  the RF_Handle point to the current client. <br>
2242  *  In other appropriate RF_Stat values are returned. <br>
2243  *
2244  *  @note Calling context : Task/SWI/HWI
2245  *
2246  *  @param h            Handle previously returned by RF_open()
2247  *  @param cmd          Direct command value.
2248  *  @return             RF_Stat indicates if command was successfully completed.
2249  */
2250 extern RF_Stat RF_runDirectCmd(RF_Handle h, uint32_t cmd);
2251 
2252 /**
2253  *  @brief  Signal that radio client is not going to issue more commands in a while. <br>
2254  *
2255  *  Hint to RF driver that, irrespective of inactivity timeout, no new further
2256  *  commands will be issued for a while and thus the radio can be powered down at
2257  *  the earliest convenience. In case the RF_yield() is called within a callback,
2258  *  the callback will need to finish and return before the power down sequence is
2259  *  initiated. Posting new commands to the queue will cancel any pending RF_yield()
2260  *  request. <br>
2261  *
2262  *  @note Calling context : Task
2263  *
2264  *  @param h       Handle previously returned by RF_open()
2265  */
2266 extern void RF_yield(RF_Handle h);
2267 
2268 /**
2269  *  @brief  Function to initialize the RF_Params struct to its defaults.
2270  *
2271  *  @param  params      An pointer to RF_Params structure for
2272  *                      initialization
2273  *
2274  *  Defaults values are:
2275  *      nInactivityTimeout = BIOS_WAIT_FOREVER
2276  *      nPowerUpDuration   = RF_DEFAULT_POWER_UP_TIME
2277  */
2278 extern void RF_Params_init(RF_Params *params);
2279 
2280 /**
2281  *  @brief Get value for some RF driver parameters. <br>
2282  *
2283  *  @note Calling context : Task/SWI/HWI
2284  *
2285  *  @param h            Handle previously returned by RF_open()
2286  *  @param type         Request value parameter defined by RF_InfoType
2287  *  @param pValue       Pointer to return parameter values specified by RF_InfoVal
2288  *  @return             RF_Stat indicates if command was successfully completed
2289  */
2290 extern RF_Stat RF_getInfo(RF_Handle h, RF_InfoType type, RF_InfoVal *pValue);
2291 
2292 /**
2293  *  @brief Get RSSI value.
2294  *
2295  *  @note Calling context : Task/SWI/HWI
2296  *
2297  *  @param  h            Handle previously returned by RF_open()
2298  *  @return              RSSI value. Return value of RF_GET_RSSI_ERROR_VAL indicates error case.
2299  */
2300 extern int8_t RF_getRssi(RF_Handle h);
2301 
2302 /**
2303  *  @brief  Get command structure pointer.
2304  *
2305  *  @note Calling context : Task/SWI/HWI
2306  *
2307  *  @param h            Handle previously returned by RF_open()
2308  *  @param cmdHnd       Command handle returned by RF_postCmd()
2309  *  @return             Pointer to the command structure.
2310  */
2311 extern RF_Op* RF_getCmdOp(RF_Handle h, RF_CmdHandle cmdHnd);
2312 
2313 /**
2314  *  @brief  Initialize the configuration structure to be used to set up a RAT compare event.
2315  *
2316  *  @note Calling context : Task/SWI/HWI
2317  *
2318  *  @param  channelConfig Pointer to the compare configuration structure.
2319  *  @return none
2320  */
2321 extern void RF_RatConfigCompare_init(RF_RatConfigCompare* channelConfig);
2322 
2323 /**
2324  *  @brief  Initialize the configuration structure to be used to set up a RAT capture event.
2325  *
2326  *  @note Calling context : Task/SWI/HWI
2327  *
2328  *  @param  channelConfig Pointer to the capture configuration structure.
2329  *  @return none
2330  */
2331 extern void RF_RatConfigCapture_init(RF_RatConfigCapture* channelConfig);
2332 
2333 /**
2334  *  @brief  Initialize the configuration structure to be used to set up a RAT IO.
2335  *
2336  *  @note Calling context : Task/SWI/HWI
2337  *
2338  *  @param  ioConfig Pointer to the IO configuration structure.
2339  *  @return none
2340  */
2341 extern void RF_RatConfigOutput_init(RF_RatConfigOutput* ioConfig);
2342 
2343 /**
2344  *  @brief  Setup a Radio Timer (RAT) channel in compare mode.
2345  *
2346  *  The %RF_ratCompare() API sets up one of the three available RAT channels in compare mode.
2347  *  When the compare event happens at the given compare time, the registered callback
2348  *  is invoked.
2349  *
2350  *  The RF driver handles power management. If the provided compare time is far into the future
2351  *  (and there is no other constraint set i.e. due to radio command execution), the RF core will be
2352  *  powered OFF and the device will enter the lowest possible power state. The RF core will be
2353  *  automatically powered ON just before the registered compare event. The callback function is
2354  *  served upon expiration of the allocated channel. The function is invoked with event type
2355  *  #RF_EventRatCh and runs in SWI context.
2356  *
2357  *  The API generates a "one-shot" compare event. Since the channel is automatically freed before
2358  *  the callback is served, the same channel can be reallocated from the callback itself through a
2359  *  new API call.
2360  *
2361  *  In case there were no available channels at the time of API call, the function returns with
2362  *  #RF_ALLOC_ERROR and no callback is invoked.
2363  *
2364  *  In case a runtime error occurs after the API successfully allocated a channel, the registered
2365  *  callback is invoked with event type #RF_EventError. A typical example is when the provided compare
2366  *  time is in the past and rejected by the RF core itself.
2367  *
2368  *  The events issued by the RAT timer can be output from the timer module through the RAT_GPO
2369  *  interface, and can be interconnected with other parts of the system through the RFC_GPO or
2370  *  the Event Fabric. The mapping between the allocated RAT channel and the selected RAT_GPO
2371  *  can be controlled through the optional ioConfig argument of %RF_ratCompare(). The possible
2372  *  RAT_GPO[x] are defined in #RF_RatOutputSelect.
2373  *
2374  *  @note Calling context : Task/SWI
2375  *
2376  *  @param rfHandle      Handle previously returned by RF_open().
2377  *  @param channelConfig Pointer to configuration structure needed to set up a channel in compare mode.
2378  *  @param ioConfig      Pointer to a configuration structure to set up the RAT_GPOs for the allocated
2379  *                       channel (optional).
2380  *  @return              Allocated RAT channel. If allocation fails, #RF_ALLOC_ERROR is returned.
2381  *
2382  *  \sa #RF_RatConfigCompare_init(), #RF_RatConfigOutput_init(), #RF_ratDisableChannel(), #RF_ratCapture()
2383  */
2384 extern RF_RatHandle RF_ratCompare(RF_Handle rfHandle, RF_RatConfigCompare* channelConfig, RF_RatConfigOutput* ioConfig);
2385 
2386 /**
2387  *  @brief  Setup a Radio Timer (RAT) channel in capture mode.
2388  *
2389  *  The %RF_ratCapture() API sets up one of the three available RAT channels in capture mode.
2390  *  The registered callback is invoked on the capture event.
2391  *
2392  *  The RF driver handles power management. If the RF core is OFF when the %RF_ratCapture() is called,
2393  *  it will be powered ON immediately and the RAT channel will be configured to capture mode. As long as
2394  *  at least one of the three RAT channels are in capture mode, the RF core will be kept ON. The callback
2395  *  function is served upon a capture event occurs. The function is invoked with event type RF_EventRatCh
2396  *  and runs in SWI context.
2397  *
2398  *  In case the channel is configured into single capture mode, the channel is automatically freed before
2399  *  the callback is called. In repeated capture mode, the channel remains allocated and automatically rearmed.
2400  *
2401  *  In case there were no available channels at the time of API call, the function returns with
2402  *  #RF_ALLOC_ERROR and no callback is invoked.
2403  *
2404  *  In case a runtime error occurs after the API successfully allocated a channel, the registered
2405  *  callback is invoked with event type #RF_EventError. A typical example is when the provided compare
2406  *  time is in the past and rejected by the RF core itself.
2407  *
2408  *  The events issued by the RAT timer can be output from the timer module through the RAT_GPO
2409  *  interface, and can be interconnected with other parts of the system through the RFC_GPO or
2410  *  the Event Fabric. The mapping between the allocated RAT channel and the selected RAT_GPO
2411  *  can be controlled through the optional ioConfig argument of %RF_ratCapture(). The possible
2412  *  RAT_GPO[x] are defined in #RF_RatOutputSelect. Note that this configuration is independent of
2413  *  the source signal of the capture event.
2414  *
2415  *  @note Calling context : Task/SWI
2416  *
2417  *  @param rfHandle      Handle previously returned by RF_open().
2418  *  @param channelConfig Pointer to configuration structure needed to set up a channel in compare mode.
2419  *  @param ioConfig      Pointer to a configuration structure to set up the RAT_GPO for the allocated
2420  *                       channel (optional).
2421  *  @return              Allocated RAT channel. If allocation fails, #RF_ALLOC_ERROR is returned.
2422  *
2423  *  \sa #RF_RatConfigCapture_init(), #RF_RatConfigOutput_init() , #RF_ratDisableChannel(), #RF_ratCompare()
2424  */
2425 extern RF_RatHandle RF_ratCapture(RF_Handle rfHandle, RF_RatConfigCapture* channelConfig, RF_RatConfigOutput* ioConfig);
2426 
2427 /**
2428  *  @brief  Disable a RAT channel.
2429  *
2430  *  The #RF_RatHandle returned by the #RF_ratCompare() or #RF_ratCapture() APIs can be used for further interaction with the
2431  *  Radio Timer. Passing the handle to %RF_ratDisableChannel() will abort a compare/capture event, and the provided channel
2432  *  is deallocated. No callback is invoked. This API can be called both if the RF core is ON or OFF. After the channel is
2433  *  freed, the next radio event will be rescheduled. A typical use case if a channel is configured in repeated capture mode,
2434  *  and the application decides to abort this operation.
2435  *
2436  *  @note Calling context : Task/SWI
2437  *
2438  *  @param rfHandle      Handle previously returned by RF_open().
2439  *  @param ratHandle     #RF_RatHandle returned by #RF_ratCompare() or #RF_ratCapture().
2440  *  @return              #RF_Stat indicates if command was successfully completed.
2441  *
2442  *  \sa #RF_ratCompare(), #RF_ratCapture()
2443  */
2444 extern RF_Stat RF_ratDisableChannel(RF_Handle rfHandle, RF_RatHandle ratHandle);
2445 
2446 /**
2447  *  @brief  Set RF control parameters.
2448  *
2449  *  @note Calling context : Task
2450  *
2451  *  @param h             Handle previously returned by RF_open()
2452  *  @param ctrl          Control codes
2453  *  @param args          Pointer to control arguments
2454  *  @return              RF_Stat indicates if API call was successfully completed.
2455  */
2456 extern RF_Stat RF_control(RF_Handle h, int8_t ctrl, void *args);
2457 
2458 /**
2459  *  @brief  Request radio access. <br>
2460  *
2461  *  Scope:
2462  *  1. Only supports request access which start immediately.<br>
2463  *  2. The #RF_AccessParams duration should be less than a pre-defined value
2464  *     RF_REQ_ACCESS_MAX_DUR_US in RFCC26X2_multiMode.c.<br>
2465  *  3. The #RF_AccessParams priority should be set RF_PriorityHighest.<br>
2466  *  4. Single request for a client at anytime.<br>
2467  *  5. Command from different client are blocked until the radio access
2468  *     period is completed.<br>
2469  *
2470  *  @note Calling context : Task
2471  *
2472  *  @param h             Handle previously returned by RF_open()
2473  *  @param pParams       Pointer to RF_AccessRequest parameters
2474  *  @return              RF_Stat indicates if API call was successfully completed.
2475  */
2476 extern RF_Stat RF_requestAccess(RF_Handle h, RF_AccessParams *pParams);
2477 
2478 /**
2479  * @brief Returns the currently configured transmit power configuration.
2480  *
2481  * This function returns the currently configured transmit power configuration under the assumption
2482  * that it has been previously set by #RF_setTxPower(). The value might be used for reverse
2483  * lookup in a TX power table. If no power has been programmed, it returns an invalid value.
2484  *
2485  * @code
2486  * RF_TxPowerTable_Value value = RF_getTxPower(handle);
2487  * if (value.rawValue == RF_TxPowerTable_INVALID_VALUE) {
2488  *     // error, value not valid
2489  * }
2490  * @endcode
2491  *
2492  * @param h         Handle previously returned by #RF_open()
2493  * @return          PA configuration struct
2494  *
2495  * @sa #RF_setTxPower(), #RF_TxPowerTable_findPowerLevel()
2496  */
2497 extern RF_TxPowerTable_Value RF_getTxPower(RF_Handle h);
2498 
2499 /**
2500  * @brief Updates the transmit power configuration of the RF core.
2501  *
2502  * This function programs a new TX power \a value and returns a status code. The API will return
2503  * with RF_StatBusyError if there are still pending commands in the internal queue. In case of
2504  * success, RF_StatSuccess is returned and the new configuration becomes effective from the next
2505  * radio operation.
2506  *
2507  * Some devices provide an integrated high-power PA in addition to the Default PA. On these devices
2508  * the API accepts configurations for both, and if \a value selects a different PA, the
2509  * \a globalCallback is invoked. The implementation of \a globalCallback is board specific and can
2510  * be used to reconfigure the external RF switches (if any).
2511  *
2512  * @param h         Handle previously returned by #RF_open()
2513  * @param value     TX power configuration value.
2514  * @return          #RF_StatSuccess on success, otherwise an error code.
2515  *
2516  * @sa #RF_getTxPower(), #RF_TxPowerTable_Value, #RF_TxPowerTable_findValue()
2517  */
2518 extern RF_Stat RF_setTxPower(RF_Handle h, RF_TxPowerTable_Value value);
2519 
2520 /**
2521  * @brief Retrieves a power level in dBm for a given power configuration value.
2522  *
2523  * \c %RF_TxPowerTable_findPowerLevel() searches in a lookup \a table for a given transmit power
2524  * configuration \a value and returns the power level in dBm if a matching configuration is found.
2525  * If \a value can not be found, #RF_TxPowerTable_INVALID_DBM is returned.
2526  *
2527  * This function does a reverse lookup compared to #RF_TxPowerTable_findValue() and has
2528  * O(n). It is assumed that \a table is terminated by a #RF_TxPowerTable_TERMINATION_ENTRY.
2529  *
2530  * @param table         List of #RF_TxPowerTable_Entry entries,
2531  *                      terminated by #RF_TxPowerTable_TERMINATION_ENTRY.
2532  *
2533  * @param value         Power configuration value.
2534  *
2535  * @return              Human readable power level in dBm on success,
2536  *                      otherwise #RF_TxPowerTable_INVALID_DBM.
2537  */
2538 extern int8_t RF_TxPowerTable_findPowerLevel(RF_TxPowerTable_Entry table[], RF_TxPowerTable_Value value);
2539 
2540 /**
2541  * @brief Retrieves a power configuration value for a given power level in dBm.
2542  *
2543  * \c %RF_TxPowerTable_findValue() searches in a lookup \a table for a given transmit power level
2544  * \a powerLevel in dBm and returns a matching power configuration. If \a powerLevel can not be
2545  * found, #RF_TxPowerTable_INVALID_VALUE is returned.
2546  *
2547  * This function performs a linear search in \a table and has O(n).
2548  * It is assumed that \a table is defined in ascending order and is terminated by a
2549  * #RF_TxPowerTable_TERMINATION_ENTRY.
2550  *
2551  * The following special values for \a powerLevel are also accepted:
2552  *
2553  * - #RF_TxPowerTable_MIN_DBM which returns always the lowest power value in the table
2554  * - #RF_TxPowerTable_MAX_DBM which returns always the highest power value in the table
2555  *
2556  * @param table         List of #RF_TxPowerTable_Entry entries,
2557  *                      terminated by #RF_TxPowerTable_TERMINATION_ENTRY.
2558  *
2559  * @param powerLevel    Human-readable power level in dBm.
2560  *
2561  * @return              PA configuration value on success.
2562  *                      otherwise #RF_TxPowerTable_INVALID_VALUE.
2563  */
2564 extern RF_TxPowerTable_Value RF_TxPowerTable_findValue(RF_TxPowerTable_Entry table[], int8_t powerLevel);
2565 
2566 
2567 /**
2568  * @brief Enables temperature monitoring and temperature based drift compensation
2569  *
2570  */
2571 extern void RF_enableHPOSCTemperatureCompensation(void);
2572 
2573 #ifdef __cplusplus
2574 }
2575 #endif
2576 
2577 #endif /* ti_drivers_rfcc26x2__include */
2578 
2579 //*****************************************************************************
2580 //
2581 //! Close the Doxygen group.
2582 //! @}
2583 //! @}
2584 //
2585 //*****************************************************************************
2586 
2587