1 /***************************************************************************//**
2  * @file
3  * @brief The main header file for the RAIL library. It describes the external
4  *   APIs available to a RAIL user
5  *******************************************************************************
6  * # License
7  * <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
8  *******************************************************************************
9  *
10  * SPDX-License-Identifier: Zlib
11  *
12  * The licensor of this software is Silicon Laboratories Inc.
13  *
14  * This software is provided 'as-is', without any express or implied
15  * warranty. In no event will the authors be held liable for any damages
16  * arising from the use of this software.
17  *
18  * Permission is granted to anyone to use this software for any purpose,
19  * including commercial applications, and to alter it and redistribute it
20  * freely, subject to the following restrictions:
21  *
22  * 1. The origin of this software must not be misrepresented; you must not
23  *    claim that you wrote the original software. If you use this software
24  *    in a product, an acknowledgment in the product documentation would be
25  *    appreciated but is not required.
26  * 2. Altered source versions must be plainly marked as such, and must not be
27  *    misrepresented as being the original software.
28  * 3. This notice may not be removed or altered from any source distribution.
29  *
30  ******************************************************************************/
31 
32 #ifndef __RAIL_H__
33 #define __RAIL_H__
34 
35 #include <string.h> // For memcpy()
36 
37 // Get the RAIL-specific structures and types
38 #include "rail_types.h"
39 #include "rail_assert_error_codes.h"
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
45 /**
46  * @addtogroup RAIL_API RAIL API
47  * @brief This is the primary API layer for the Radio Abstraction Interface
48  *   Layer (RAIL).
49  * @{
50  */
51 
52 /**
53  * @defgroup Chip_Specific Chip-Specific
54  * @brief Chip-Specific RAIL APIs, types, and information
55  */
56 
57 /**
58  * @defgroup Protocol_Specific Protocol-specific
59  * @brief Protocol-Specific RAIL APIs
60  */
61 
62 /******************************************************************************
63  * General Radio Operation
64  *****************************************************************************/
65 /**
66  * @addtogroup General
67  * @brief Basic APIs to set up and interact with the RAIL library
68  * @{
69  */
70 
71 /**
72  * Get the version information for the compiled RAIL library.
73  *
74  * @param[out] version A non-NULL pointer to \ref RAIL_Version_t structure to
75  *   populate with version information.
76  * @param[in] verbose Populate \ref RAIL_Version_t struct with verbose
77  *   information.
78  * @return Status code indicating success of the function call.
79  *
80  * The version information contains a major version number, a minor version
81  * number, and a rev (revision) number.
82  */
83 RAIL_Status_t RAIL_GetVersion(RAIL_Version_t *version, bool verbose);
84 
85 #ifndef DOXYGEN_SHOULD_SKIP_THIS
86 
87 /**
88  * A global pointer to the head of a linked list of state buffers
89  * \ref RAIL_Init() can use.
90  *
91  * RAIL internally provides one statically-allocated RAM state buffer
92  * for a single protocol and two for dynamic multiprotocol. If your
93  * application needs more, they can be provided via \ref
94  * RAIL_AddStateBuffer3() or \ref RAIL_AddStateBuffer4(), which use
95  * internal buffers, or the more general \ref RAIL_AddStateBuffer().
96  *
97  * This symbol is WEAK in the RAIL library in case an application wants
98  * to allocate and provide its own buffers. However, this use is highly
99  * discouraged.
100  */
101 extern RAIL_StateBufferEntry_t *RAIL_StateBufferHead;
102 
103 /**
104  * Get the run-time size of the radio's state buffer.
105  *
106  * @param[in] genericRailHandle A generic RAIL instance handle.
107  * @return Size, in bytes, of the radio's internal state buffer.
108  *   If the handle is invalid, 0 is returned.
109  *
110  * See \ref RAIL_STATE_BUFFER_BYTES for a compile-time estimated size
111  * definition, which may be larger than what this function returns.
112  */
113 uint32_t RAIL_GetStateBufferSize(RAIL_Handle_t genericRailHandle);
114 
115 /**
116  * Add an app-provided state buffer to the \ref RAIL_StateBufferHead list.
117  *
118  * @param[in] genericRailHandle A generic RAIL instance handle.
119  * @param[in] newEntry A pointer to a \ref RAIL_StateBufferEntry_t to
120  *   add to the liked list of state buffers headed by
121  *   \ref RAIL_StateBufferHead. Both the \ref RAIL_StateBufferEntry_t
122  *   to which this parameter points and the \ref
123  *   RAIL_StateBufferEntry_t::buffer to which that points must be
124  *   allocated in RAM and persist indefinitely beyond this call.
125  * @return Status code indicating success of the function call.
126  *   An error should be returned if the entry's
127  *   \ref RAIL_StateBufferEntry_t::bufferBytes is too small or
128  *   the RAIL_StateBufferEntry_t::buffer pointer seems invalid.
129  *
130  * RAIL's internal \ref RAIL_StateBufferHead should prove
131  * sufficient for most applications, providing one (single protocol)
132  * or two (dynamic multiprotocol) buffers preallocated in RAM for
133  * use by \ref RAIL_Init(). This function exists for dynamic
134  * multiprotocol applications that needs more than two protocols, or
135  * that prefer to dynamically allocate RAIL state buffers just prior
136  * to calling \ref RAIL_Init() rather than having them statically
137  * allocated in RAM.
138  */
139 RAIL_Status_t RAIL_AddStateBuffer(RAIL_Handle_t genericRailHandle,
140                                   RAIL_StateBufferEntry_t *newEntry);
141 
142 #endif//DOXYGEN_SHOULD_SKIP_THIS
143 
144 /**
145  * Add a 3rd multiprotocol internal state buffer for use by \ref RAIL_Init().
146  *
147  * @param[in] genericRailHandle A generic RAIL instance handle.
148  * @return Status code indicating success of the function call.
149  *   An error is returned if the 3rd state buffer was previously added
150  *   or this isn't the RAIL multiprotocol library.
151  */
152 RAIL_Status_t RAIL_AddStateBuffer3(RAIL_Handle_t genericRailHandle);
153 
154 /**
155  * Add a 4th multiprotocol internal state buffer for use by \ref RAIL_Init().
156  *
157  * @param[in] genericRailHandle A generic RAIL instance handle.
158  * @return Status code indicating success of the function call.
159  *   An error is returned if the 4th state buffer was previously added.
160  *   or this isn't the RAIL multiprotocol library.
161  */
162 RAIL_Status_t RAIL_AddStateBuffer4(RAIL_Handle_t genericRailHandle);
163 
164 /**
165  * Allocate a DMA channel for RAIL to work with.
166  *
167  * @param[in] channel The DMA channel to use when copying memory. If a value of
168  *   \ref RAIL_DMA_INVALID is passed, RAIL will stop using any DMA channel.
169  * @return Status code indicating success of the function call.
170  *
171  * To use this API, the application must initialize the DMA engine
172  * on the chip and allocate a DMA channel. This channel will be used
173  * periodically to copy memory more efficiently. Call this function
174  * before \ref RAIL_Init() to have the most benefit. If the application needs
175  * to take back control of the DMA channel that RAIL is using, this API may be
176  * called with a channel of \ref RAIL_DMA_INVALID to tell RAIL to stop using DMA.
177  *
178  * @warning To allocate and use a DMA channel for RAIL to work with when
179  *   TrustZone is enabled and LDMA is configured as secure peripheral, the
180  *   secure application must initialize the DMA engine and call this API. The
181  *   non-secure application must provide a non-NULL
182  *   \ref RAIL_TZ_Config_t::radioPerformM2mLdmaCallback to
183  *   \ref RAIL_TZ_InitNonSecure().
184  *   To take back control of the DMA channel when TrustZone is enabled and LDMA
185  *   is configured as secure peripheral, the secure application must call this
186  *   API with a channel of \ref RAIL_DMA_INVALID. The non-secure application
187  *   must provide a NULL \ref RAIL_TZ_Config_t::radioPerformM2mLdmaCallback to
188  *   \ref RAIL_TZ_InitNonSecure().
189  */
190 RAIL_Status_t RAIL_UseDma(uint8_t channel);
191 
192 #ifndef DOXYGEN_SHOULD_SKIP_THIS
193 
194 /**
195  * Load the first image \ref RAIL_SEQ_IMAGE_1 into the radio sequencer during
196  * RAIL initialization.
197  *
198  * @param[in] genericRailHandle A generic RAIL instance handle.
199  * @return Status code indicating success of the function call.
200  *
201  * This function must only be called from within the RAIL callback context of
202  * \ref RAILCb_RadioSequencerImageLoad(). Otherwise, the function returns \ref
203  * RAIL_STATUS_INVALID_STATE.
204  */
205 RAIL_Status_t RAIL_LoadSequencerImage1(RAIL_Handle_t genericRailHandle);
206 
207 /**
208  * Load the second image \ref RAIL_SEQ_IMAGE_2 into the radio sequencer during
209  * RAIL initialization.
210  *
211  * @param[in] genericRailHandle A generic RAIL instance handle.
212  * @return Status code indicating success of the function call.
213  *
214  * This function must only be called from within the RAIL callback context of
215  * \ref RAILCb_RadioSequencerImageLoad(). Otherwise, the function returns \ref
216  * RAIL_STATUS_INVALID_STATE. On platforms where \ref RAIL_SEQ_IMAGE_COUNT < 2,
217  * the function returns with \ref RAIL_STATUS_INVALID_CALL.
218  */
219 RAIL_Status_t RAIL_LoadSequencerImage2(RAIL_Handle_t genericRailHandle);
220 
221 /**
222  * Callback used to load the radio sequencer image during RAIL initialization.
223  * This function is optional to implement.
224  *
225  * @return Status code indicating success of the function call.
226  *
227  * This callback is used by RAIL to load a radio sequencer image during \ref
228  * RAIL_Init() via an API such as \ref RAIL_LoadSequencerImage1(). If this
229  * function is not implemented, a default image will be loaded. On some
230  * platforms, (in particular EFR32xG24), not implementing this function may
231  * result in a larger overall code size due to unused sequencer images not
232  * being dead stripped.
233  *
234  * @note If this function is implemented without a call to an image loading API
235  *   such as \ref RAIL_LoadSequencerImage1(), an assert will occur during
236  *   RAIL initialization. Similarly, if an image is loaded that is
237  *   unsupported by the platform, an assert will occur.
238  */
239 RAIL_Status_t RAILCb_RadioSequencerImageLoad(void);
240 
241 /**
242  * Load the OFDM and OQPSK image into the software modem (SFM) sequencer during
243  * RAIL initialization.
244  *
245  * @param[in] genericRailHandle A generic RAIL instance handle.
246  * @return Status code indicating success of the function call.
247  *
248  * This function must only be called from within the RAIL callback context of
249  * \ref RAILCb_LoadSfmSequencer(). Otherwise, the function returns \ref
250  * RAIL_STATUS_INVALID_STATE.
251  */
252 RAIL_Status_t RAIL_LoadSfmSunOfdmOqpsk(RAIL_Handle_t genericRailHandle);
253 
254 /**
255  * Load the OFDM image into the software modem (SFM) sequencer during
256  * RAIL initialization.
257  *
258  * @param[in] genericRailHandle A generic RAIL instance handle.
259  * @return Status code indicating success of the function call.
260  *
261  * This function must only be called from within the RAIL callback context of
262  * \ref RAILCb_LoadSfmSequencer(). Otherwise, the function returns \ref
263  * RAIL_STATUS_INVALID_STATE.
264  */
265 RAIL_Status_t RAIL_LoadSfmSunOfdm(RAIL_Handle_t genericRailHandle);
266 
267 /**
268  * Load the empty image into the software modem (SFM) sequencer during
269  * RAIL initialization.
270  *
271  * @param[in] genericRailHandle A generic RAIL instance handle.
272  * @return Status code indicating success of the function call.
273  *
274  * This function must only be called from within the RAIL callback context of
275  * \ref RAILCb_LoadSfmSequencer(). Otherwise, the function returns \ref
276  * RAIL_STATUS_INVALID_STATE.
277  */
278 RAIL_Status_t RAIL_LoadSfmEmpty(RAIL_Handle_t genericRailHandle);
279 
280 /**
281  * Callback used to load the software modem (SFM) sequencer image during RAIL
282  * initialization. This function is optional to implement.
283  *
284  * @return Status code indicating success of the function call.
285  *
286  * This callback is used by RAIL to load a software modem sequencer image
287  * during \ref RAIL_Init() via an API such as \ref RFHAL_LoadSfmSunOfdmOqpsk().
288  * If this function is not implemented, a default image including OFDM and
289  * OQPSK modulations will be loaded.
290  *
291  * @note If this function is implemented without a call to an image loading API
292  *   such as \ref RFHAL_LoadSfmSunOfdmOqpsk(), an assert will occur during RAIL
293  *   initialization. Similarly, if an image is loaded that is unsupported by
294  *   the platform, an assert will occur.
295  */
296 RAIL_Status_t RAILCb_LoadSfmSequencer(void);
297 
298 #endif //DOXYGEN_SHOULD_SKIP_THIS
299 
300 /**
301  * Reads out device specific data that may be needed by RAIL
302  * and populates appropriate data structures in the library.
303  *
304  * @param[in] genericRailHandle A generic RAIL instance handle.
305  * @return Status code indicating success of the function call.
306  *
307  * @note This function must be called before calling \ref RAIL_Init()
308  *   on any platforms that require this data
309  *   and should not be called inside a critical section.
310  *   This function does nothing on EFR32 Series 2 devices.
311  */
312 RAIL_Status_t RAIL_CopyDeviceInfo(RAIL_Handle_t genericRailHandle);
313 
314 /**
315  * Initialize RAIL.
316  *
317  * @param[in] railCfg The configuration for setting up the protocol.
318  * @param[in] cb A callback that notifies the application when the radio is
319  *   finished initializing and is ready for further configuration. This
320  *   callback is useful for potential transceiver products that require a
321  *   power up sequence before further configuration is available. After the
322  *   callback fires, the radio is ready for additional configuration before
323  *   transmit and receive operations.
324  * @return Handle for initialized rail instance or NULL if an
325  *   invalid value was passed in the railCfg.
326  *
327  * @note Call this function only once per protocol. If called
328  *   again, it will do nothing and return NULL. \ref RAIL_CopyDeviceInfo()
329  *   should be called once before calling this function for
330  *   Silicon Labs Series 3 devices.
331  */
332 RAIL_Handle_t RAIL_Init(const RAIL_Config_t *railCfg,
333                         RAIL_InitCompleteCallbackPtr_t cb);
334 
335 /**
336  * Get RAIL initialization status.
337  *
338  * @return true if the radio has finished initializing and
339  *   false otherwise.
340  *
341  * RAIL APIs, e.g., \ref RAIL_GetTime(), which work only if \ref RAIL_Init() has been called,
342  * can use \ref RAIL_IsInitialized() to determine whether RAIL has been initialized or not.
343  */
344 bool RAIL_IsInitialized(void);
345 
346 /**
347  * Collect entropy from the radio if available.
348  *
349  * @param[in] railHandle A RAIL instance handle.
350  * @param[out] buffer A non-NULL pointer to the buffer to write the collected entropy.
351  * @param[in] bytes The number of bytes to fill in the input buffer.
352  * @return The number of bytes of entropy collected. For
353  *   radios that don't support entropy collection, the function returns 0.
354  *   Values less than the requested amount may also be returned on platforms
355  *   that use entropy pools to collect random data periodically.
356  *
357  * Attempts to fill the provided buffer with the requested number of bytes of
358  * entropy. If the requested number of bytes can't be provided, as many
359  * bytes as possible will be filled and returned. For radios
360  * that do not support this function, 0 bytes are always returned. For
361  * information about the specific mechanism for gathering entropy, see
362  * documentation for the chip family.
363  */
364 uint16_t RAIL_GetRadioEntropy(RAIL_Handle_t railHandle,
365                               uint8_t *buffer,
366                               uint16_t bytes);
367 
368 /** @} */ // end of group General
369 
370 /******************************************************************************
371  * PTI
372  *****************************************************************************/
373 /**
374  * @addtogroup PTI PTI Packet Trace
375  * @brief Basic APIs to set up and interact with PTI settings
376  * @{
377  */
378 
379 /**
380  * Configure PTI pin locations, serial protocols, and baud rates.
381  *
382  * @param[in] railHandle A radio-generic or real RAIL instance handle.
383  * @param[in] ptiConfig A non-NULL pointer to the PTI configuration structure
384  *   to use.
385  * @return Status code indicating success of the function call.
386  *
387  * This method must be called before \ref RAIL_EnablePti() is called.
388  * There is only one PTI configuration that can be active on a
389  * radio, regardless of the number of protocols (unless the application
390  * updates the configuration upon a protocol switch -- RAIL does not
391  * save the configuration in a protocol RAIL instance).
392  *
393  * PTI should be configured only when the radio is off (idle).
394  *
395  * @note On EFR32 platforms GPIO configuration must be unlocked
396  *   (see GPIO->LOCK register) to configure or use PTI.
397  *
398  * @warning As this function relies on GPIO access and RAIL is meant to run in
399  *   TrustZone non-secure world, it is not supported if GPIO is configured as
400  *   secure peripheral and it will return \ref RAIL_STATUS_INVALID_CALL.
401  */
402 RAIL_Status_t RAIL_ConfigPti(RAIL_Handle_t railHandle,
403                              const RAIL_PtiConfig_t *ptiConfig);
404 
405 /**
406  * Get the currently-active PTI configuration.
407  *
408  * @param[in] railHandle A radio-generic or real RAIL instance handle.
409  * @param[out] ptiConfig A non-NULL pointer to the configuration structure
410  *   to be filled in with the active PTI configuration.
411  * @return RAIL status indicating success of the function call.
412  *
413  * Although most combinations of configurations can be set, it is safest
414  * to call this method after configuration to confirm which values were
415  * actually set. This function always returns the active PTI configuration
416  * on the radio regardless of the active protocol.
417  */
418 RAIL_Status_t RAIL_GetPtiConfig(RAIL_Handle_t railHandle,
419                                 RAIL_PtiConfig_t *ptiConfig);
420 
421 /**
422  * Enable Packet Trace Interface (PTI) output of packet data.
423  *
424  * @param[in] railHandle A radio-generic or real RAIL instance handle.
425  * @param[in] enable PTI is enabled if true; disabled if false.
426  * @return Status code indicating success of the function call.
427  *
428  * Similarly to having only one PTI configuration per radio,
429  * PTI can only be enabled or disabled for all protocols. It cannot
430  * be individually set to enabled and disabled per protocol
431  * (unless the application switches it when the protocol switches --
432  * RAIL does not save this state in a protocol RAIL instance).
433  *
434  * PTI should be enabled or disabled only when the radio is off (idle).
435  *
436  * @warning On EFR32 platforms GPIO configuration must be unlocked
437  *   (see GPIO->LOCK register) to configure or use PTI, otherwise a fault
438  *   or assert might occur.
439  *   If GPIO configuration locking is desired, PTI must be disabled
440  *   beforehand either with this function or with \ref RAIL_ConfigPti()
441  *   using \ref RAIL_PTI_MODE_DISABLED.
442  *
443  * @warning As this function relies on GPIO access and RAIL is meant to run in
444  *   TrustZone non-secure world, it is not supported if GPIO is configured as
445  *   secure peripheral and it will return \ref RAIL_STATUS_INVALID_CALL.
446  */
447 RAIL_Status_t RAIL_EnablePti(RAIL_Handle_t railHandle,
448                              bool enable);
449 
450 /**
451  * Set a protocol that RAIL outputs on PTI.
452  *
453  * @param[in] railHandle A RAIL instance handle.
454  * @param[in] protocol The enumeration representing which protocol the app is using.
455  * @return Status code indicating success of the function call.
456  *
457  * The protocol is output via PTI for each packet.
458  * Before any protocol is set, the default value is \ref
459  * RAIL_PTI_PROTOCOL_CUSTOM. Use one of the enumeration values so that
460  * the Network Analyzer can decode the packet.
461  *
462  * @note This function cannot be called unless the radio is currently in the
463  *   \ref RAIL_RF_STATE_IDLE or \ref RAIL_RF_STATE_INACTIVE states. For this
464  *   reason, call this function early on before starting radio
465  *   operations and not changed later.
466  */
467 RAIL_Status_t RAIL_SetPtiProtocol(RAIL_Handle_t railHandle,
468                                   RAIL_PtiProtocol_t protocol);
469 
470 /**
471  * Get the protocol that RAIL outputs on PTI.
472  *
473  * @param[in] railHandle A RAIL instance handle.
474  * @return PTI protocol in use.
475  */
476 RAIL_PtiProtocol_t RAIL_GetPtiProtocol(RAIL_Handle_t railHandle);
477 
478 /** @} */ // end of group PTI
479 
480 /******************************************************************************
481  * Antenna Control
482  *****************************************************************************/
483 /**
484  * @addtogroup Antenna_Control Antenna Control
485  * @brief Basic APIs to control the antenna functionality
486  * @{
487  */
488 /**
489  * Configure antenna path and pin locations.
490  *
491  * @warning This API must be called before any TX or RX occurs. Otherwise,
492  *   the antenna configurations for those functions will not take effect.
493  *
494  * @param[in] railHandle A radio-generic or real RAIL instance handle.
495  * @param[in] config A pointer to a configuration structure applied to the relevant Antenna
496  *   Configuration registers. A NULL configuration will produce undefined behavior.
497  * @return Status code indicating success of the function call.
498  *
499  * This function informs RAIL how to select each antenna, but not when.
500  * Antenna selection for receive is controlled by the
501  * \ref RAIL_RX_OPTION_ANTENNA0 and
502  * \ref RAIL_RX_OPTION_ANTENNA1 options
503  * (and the \ref RAIL_RX_OPTION_ANTENNA_AUTO combination).
504  * Antenna selection for transmit is controlled by the
505  * \ref RAIL_TX_OPTION_ANTENNA0 and
506  * \ref RAIL_TX_OPTION_ANTENNA1 options.
507  *
508  * There is only one antenna configuration can be active on a
509  * radio, regardless of the number of protocols (unless the application
510  * updates the configuration upon a protocol switch --
511  * RAIL does not save this configuration in a protocol RAIL instance).
512  */
513 RAIL_Status_t RAIL_ConfigAntenna(RAIL_Handle_t railHandle,
514                                  const RAIL_AntennaConfig_t *config);
515 
516 /**
517  * Get the default RF path.
518  *
519  * @param[in] railHandle A RAIL instance handle.
520  * @param[out] rfPath A pointer to RF path updated by the function.
521  * @return Status code indicating success of the function call.
522  *
523  * If multiple protocols are used, this function returns
524  * \ref RAIL_STATUS_INVALID_STATE if it is called and the given railHandle is
525  * not active. In that case, the caller must attempt to re-call this function later,
526  * for example when \ref RAIL_EVENT_CONFIG_SCHEDULED trigger.
527  */
528 RAIL_Status_t RAIL_GetRfPath(RAIL_Handle_t railHandle, RAIL_AntennaSel_t *rfPath);
529 
530 /** @} */ // end of group Antenna_Control
531 
532 /******************************************************************************
533  * Radio Configuration
534  *****************************************************************************/
535 /// @addtogroup Radio_Configuration Radio Configuration
536 /// @brief Routines for setting up and querying radio configuration information.
537 ///
538 /// These routines allow for runtime flexibility in the radio
539 /// configuration. Some of the parameters, however, are meant to be generated
540 /// from the radio calculator in Simplicity Studio. The basic code to configure
541 /// the radio from this calculator output looks like the example below.
542 /// @code{.c}
543 /// // Associate a specific channel configuration with a particular RAIL instance and
544 /// // load the settings that correspond to the first usable channel.
545 /// RAIL_ConfigChannels(railHandle, channelConfigs[0]);
546 /// @endcode
547 ///
548 /// For more information about the types of parameters that can be changed in
549 /// the other functions and how to use them, see their individual documentation.
550 ///
551 /// @{
552 
553 /**
554  * Load a static radio configuration.
555  *
556  * @param[in] railHandle A RAIL instance handle.
557  * @param[in] config A radio configuration array (pointer).
558  * @return Status code indicating success of the function call.
559  *
560  * The configuration passed into this function should be auto-generated
561  * and not manually created or edited. By default, do not call this function
562  * in RAIL 2.x and later unless instructed by Silicon Labs because it
563  * may bypass updating certain RAIL state. In RAIL 2.x and later, the
564  * RAIL_ConfigChannels function applies the default radio configuration
565  * automatically.
566  */
567 RAIL_Status_t RAIL_ConfigRadio(RAIL_Handle_t railHandle,
568                                RAIL_RadioConfig_t config);
569 
570 /**
571  * Modify the currently configured fixed frame length in bytes.
572  *
573  * @param[in] railHandle A RAIL instance handle.
574  * @param[in] length The expected fixed frame length. A value of 0 is infinite.
575  *   A value of \ref RAIL_SETFIXEDLENGTH_INVALID restores the frame's length back to
576  *   the length specified by the default frame type configuration.
577  * @return The new frame length configured into the hardware
578  *   for use: 0 if in infinite mode, or \ref RAIL_SETFIXEDLENGTH_INVALID if the frame
579  *   length has not yet been overridden by a valid value.
580  *
581  * Sets the fixed-length configuration for transmit and receive.
582  * Be careful when using this function in receive and transmit as this
583  * function changes the default frame configuration and remains in force until
584  * it is called again with an input value of \ref RAIL_SETFIXEDLENGTH_INVALID. This
585  * function will override any fixed or variable length settings from a radio
586  * configuration.
587  */
588 uint16_t RAIL_SetFixedLength(RAIL_Handle_t railHandle, uint16_t length);
589 
590 /**
591  * Configure the channels supported by this device.
592  *
593  * @param[in] railHandle A RAIL instance handle.
594  * @param[in] config A pointer to the channel configuration for your device.
595  *   This pointer will be cached in the library so it must
596  *   exist for the runtime of the application. Typically, this should be
597  *   what is stored in Flash by the configuration tool.
598  * @param[in] cb A pointer to a function called whenever a radio
599  *   configuration change occurs. May be NULL if do not need a callback.
600  * @return The first available channel in the configuration.
601  *
602  * When configuring channels on EFR32, the radio tuner is reconfigured
603  * based on the frequency and channel spacing in the channel configuration.
604  *
605  * @note config can be NULL to simply register or unregister the cb callback
606  *   function when using RAIL internal protocol-specific radio configuration
607  *   APIs for BLE, IEEE 802.15.4, or Z-Wave, which lack callback specification.
608  *   In this use case, 0 is returned.
609  */
610 uint16_t RAIL_ConfigChannels(RAIL_Handle_t railHandle,
611                              const RAIL_ChannelConfig_t *config,
612                              RAIL_RadioConfigChangedCallback_t cb);
613 
614 /**
615  * Configure the channels supported by this device.
616  *
617  * @param[in] railHandle A RAIL instance handle.
618  * @param[in] config A pointer to the channel configuration for your device.
619  *   This pointer will be cached in the library so it must
620  *   exist for the runtime of the application. Typically, this should be
621  *   what is stored in Flash by the configuration tool.
622  * @param[in] cb A pointer to a function called whenever a radio
623  *   configuration change occurs. May be NULL if do not need a callback.
624  * @return Status code indicating success of the function call.
625  *
626  * @note Unlike \ref RAIL_ConfigChannels(), this function only caches the
627  *   configuration and does not prepare any channel in the configuration. That
628  *   action is deferred to the next call to a RAIL API where channel is passed
629  *   as a parameter, namely
630  * \ref RAIL_PrepareChannel(), \ref RAIL_StartTx(),
631  * \ref RAIL_StartScheduledTx(), \ref RAIL_StartCcaCsmaTx(),
632  * \ref RAIL_StartCcaLbtTx(), \ref RAIL_StartScheduledCcaCsmaTx(),
633  * \ref RAIL_StartScheduledCcaLbtTx(), \ref RAIL_StartRx(),
634  * \ref RAIL_ScheduleRx(), \ref RAIL_StartAverageRssi(),
635  * \ref RAIL_StartTxStream().
636  *
637  * @note config can be NULL to simply register or unregister the cb callback
638  *   function when using RAIL internal protocol-specific radio configuration
639  *   APIs for BLE, IEEE 802.15.4, or Z-Wave, which lack callback specification.
640  */
641 RAIL_Status_t RAIL_ConfigChannelsAlt(RAIL_Handle_t railHandle,
642                                      const RAIL_ChannelConfig_t *config,
643                                      RAIL_RadioConfigChangedCallback_t cb);
644 
645 /**
646  * Get verbose listing of channel metadata for the current channel configuration.
647  *
648  * @param[in] railHandle A RAIL instance handle.
649  * @param[out] channelMetadata A pointer to an app-allocated array that
650  *   will be populated with channel metadata.
651  * @param[in,out] length A pointer to the number of entries available
652  *   in the channelMetadata array.
653  *   This value will be updated to the number of channels written to the array,
654  *   not to exceed the length number passed in.
655  * @param[in] minChannel Minimum channel number about which to collect data.
656  * @param[in] maxChannel Maximum channel number about which to collect data.
657  * @return Status code indicating success of the function call.
658  *   \ref RAIL_STATUS_INVALID_PARAMETER means that,
659  *   based on the currently active radio configuration, there are more
660  *   channels to write than there is space provided in the allocated
661  *   channelMetadata. However, the channel metadata that was written is valid.
662  *   \ref RAIL_STATUS_INVALID_STATE indicates that the channel configuration
663  *   has not been configured. \ref RAIL_STATUS_NO_ERROR indicates complete
664  *   success.
665  */
666 RAIL_Status_t RAIL_GetChannelMetadata(RAIL_Handle_t railHandle,
667                                       RAIL_ChannelMetadata_t *channelMetadata,
668                                       uint16_t *length,
669                                       uint16_t minChannel,
670                                       uint16_t maxChannel);
671 
672 /**
673  * Check whether the channel exists in the current RAIL channel configuration.
674  *
675  * @param[in] railHandle A RAIL instance handle.
676  * @param[in] channel A channel number to check.
677  * @return \ref RAIL_STATUS_NO_ERROR if channel exists or \ref
678  *   RAIL_STATUS_INVALID_PARAMETER if the given channel does not exist.
679  */
680 RAIL_Status_t RAIL_IsValidChannel(RAIL_Handle_t railHandle,
681                                   uint16_t channel);
682 
683 /**
684  * Cause radio settings associated with a particular channel to be applied to
685  * hardware.
686  *
687  * @param[in] railHandle A RAIL instance handle.
688  * @param[in] channel The channel to prepare for use.
689  * @return \ref RAIL_STATUS_NO_ERROR on success or
690  *   \ref RAIL_STATUS_INVALID_PARAMETER if the given channel does not have an
691  *   associated channel configuration entry.
692  *
693  * This function walks the current \ref RAIL_ChannelConfig_t::configs list
694  * and applies the configuration associated with the specified channel if
695  * found.
696  * This function manually changes channels without starting a TX or RX
697  * operation.
698  *
699  * When successful, the radio is idled.
700  * When unsuccessful, the radio state will not be altered.
701  */
702 RAIL_Status_t RAIL_PrepareChannel(RAIL_Handle_t railHandle, uint16_t channel);
703 
704 /**
705  * Return the most-recently requested RAIL channel.
706  *
707  * @param[in] railHandle A RAIL instance handle.
708  * @param[out] channel A pointer to the channel for which RAIL was
709  *   most-recently configured.
710  * @return \ref RAIL_STATUS_NO_ERROR on success or
711  *   \ref RAIL_STATUS_INVALID_CALL if the radio is not configured for any channel
712  *   or \ref RAIL_STATUS_INVALID_PARAMETER if channel parameter is NULL.
713  *
714  * This function returns the channel most recently specified in API calls that
715  * pass in a channel to tune to, namely \ref RAIL_PrepareChannel(),
716  * \ref RAIL_StartTx(), \ref RAIL_StartScheduledTx(), \ref RAIL_StartCcaCsmaTx(),
717  * \ref RAIL_StartCcaLbtTx(), \ref RAIL_StartScheduledCcaCsmaTx(),
718  * \ref RAIL_StartScheduledCcaLbtTx(), \ref RAIL_StartRx(), \ref RAIL_ScheduleRx(),
719  * \ref RAIL_StartAverageRssi(), \ref RAIL_StartTxStream(), \ref RAIL_StartTxStreamAlt().
720  * It doesn't follow changes RAIL performs implicitly during channel hopping
721  * and mode switch.
722  */
723 RAIL_Status_t RAIL_GetChannel(RAIL_Handle_t railHandle, uint16_t *channel);
724 
725 /**
726  * Return the RAIL channel to which the radio is currently tuned.
727  *
728  * @param[in] railHandle A RAIL instance handle.
729  * @param[out] channel A pointer to the currently-tuned channel.
730  * @return \ref RAIL_STATUS_NO_ERROR on success or
731  *   \ref RAIL_STATUS_INVALID_CALL if the radio is not configured for any channel
732  *   or \ref RAIL_STATUS_INVALID_PARAMETER if channel parameter is NULL.
733  *
734  * This function returns the channel to which the radio is currently tuned if
735  * the specified RAIL handle is active. It returns the channel to which it
736  * will be tuned during the next protocol switch if the handle is inactive.
737  * The channel returned may be different than what \ref RAIL_GetChannel
738  * returns when channel hopping or mode switch are involved.
739  */
740 RAIL_Status_t RAIL_GetChannelAlt(RAIL_Handle_t railHandle, uint16_t *channel);
741 
742 /**
743  * Return the symbol rate for the current PHY.
744  *
745  * @param[in] railHandle A RAIL instance handle.
746  * @return The symbol rate in symbols per second or 0.
747  *
748  * The symbol rate is the rate of symbol changes over the air. For non-DSSS
749  * PHYs, this is the same as the baudrate. For DSSS PHYs, it is the baudrate
750  * divided by the length of a chipping sequence. For more information,
751  * see the modem calculator documentation. If the rate cannot be
752  * calculated, this function returns 0.
753  */
754 uint32_t RAIL_GetSymbolRate(RAIL_Handle_t railHandle);
755 
756 #ifndef DOXYGEN_SHOULD_SKIP_THIS
757 /**
758  * Calculate the symbol rate for the current PHY.
759  *
760  * @param[in] railHandle A RAIL instance handle.
761  * @return The symbol rate in symbols per second or 0.
762  *
763  * This function calculates the symbol rate when the radio configuration does
764  * not include that information. In general, this function should be
765  * implemented automatically in the radio configuration as a stub.
766  */
767 uint32_t RAILCb_CalcSymbolRate(RAIL_Handle_t railHandle);
768 #endif//DOXYGEN_SHOULD_SKIP_THIS
769 
770 /**
771  * Return the bit rate for the current PHY.
772  *
773  * @param[in] railHandle A RAIL instance handle.
774  * @return The bit rate in bits per second or 0.
775  *
776  * The bit rate is the effective over-the-air data rate. It does not account
777  * for extra spreading for forward error correction, and so on, but
778  * accounts for modulation schemes, DSSS, and other configurations. For more
779  * information, see the modem calculator documentation. If the rate cannot be
780  * calculated, this function returns 0.
781  */
782 uint32_t RAIL_GetBitRate(RAIL_Handle_t railHandle);
783 
784 #ifndef DOXYGEN_SHOULD_SKIP_THIS
785 /**
786  * Calculate the bit rate for the current PHY.
787  *
788  * @param[in] railHandle A RAIL instance handle.
789  * @return The bit rate in bits per second or 0.
790  *
791  * This function calculates the bit rate when the radio configuration does
792  * not include that information. In general, this function should be
793  * implemented automatically in the radio configuration as a stub.
794  */
795 uint32_t RAILCb_CalcBitRate(RAIL_Handle_t railHandle);
796 #endif//DOXYGEN_SHOULD_SKIP_THIS
797 
798 /**
799  * Set the PA capacitor tune value for transmit and receive.
800  *
801  * @param[in] railHandle A RAIL instance handle.
802  * @param[in] txPaCtuneValue PA Ctune value for TX mode.
803  * @param[in] rxPaCtuneValue PA Ctune value for RX mode.
804  * @return Status code indicating success of the function call.
805  *
806  * Tunes the impedance of the transmit
807  * and receive modes by changing the amount of capacitance at
808  * the PA output.
809  * Changes made to the TX Power configuration, e.g., calling \ref RAIL_ConfigTxPower,
810  * will undo changes made to PA capacitor tune value for transmit and receive
811  * via \ref RAIL_SetPaCTune.
812  *
813  * @note This function does nothing on EFR32 Series 2 devices.
814  */
815 RAIL_Status_t RAIL_SetPaCTune(RAIL_Handle_t railHandle,
816                               uint8_t txPaCtuneValue,
817                               uint8_t rxPaCtuneValue);
818 
819 /**
820  * Get the sync words and their length.
821  *
822  * @param[in] railHandle A RAIL instance handle.
823  * @param[out] syncWordConfig An application-provided non-NULL pointer to store
824  *   \ref RAIL_SyncWordConfig_t sync word information.
825  * @return Status code indicating success of the function call.
826  **/
827 RAIL_Status_t RAIL_GetSyncWords(RAIL_Handle_t railHandle,
828                                 RAIL_SyncWordConfig_t *syncWordConfig);
829 
830 /**
831  * Set the selected sync words and their length.
832  *
833  * @param[in] railHandle A RAIL instance handle.
834  * @param[in] syncWordConfig A non-NULL pointer to \ref RAIL_SyncWordConfig_t
835  *   specifying the sync words and their length.
836  *   The desired length should be between 2 and 32 bits inclusive, however it is
837  *   recommended to not change the length below what the PHY sync word length is
838  *   configured to be. Changing the sync word length, especially to that which is
839  *   lower than the default length, may result in a decrease in packet reception
840  *   rate or may not work at all.
841  *   Other values will result in \ref RAIL_STATUS_INVALID_PARAMETER. The default
842  *   sync word continues to be valid.
843  * @return Status code indicating success of the function call.
844  *
845  * When the custom sync word(s) applied by this API are no longer needed, or to
846  * revert to default sync word, calling \ref RAIL_ConfigChannels() will re-establish
847  * the sync words specified in the radio configuration.
848  *
849  * This function will return \ref RAIL_STATUS_INVALID_STATE if called when BLE
850  * has been enabled for this railHandle. When changing sync words in BLE mode,
851  * use \ref RAIL_BLE_ConfigChannelRadioParams() instead.
852  **/
853 RAIL_Status_t RAIL_ConfigSyncWords(RAIL_Handle_t railHandle,
854                                    const RAIL_SyncWordConfig_t *syncWordConfig);
855 
856 /**
857  * Sets the whitening initialization value.
858  *
859  * @param[in] railHandle A RAIL instance handle.
860  * @return The whitening initialization value currently being used.
861  */
862 uint16_t RAIL_GetWhiteningInitVal(RAIL_Handle_t railHandle);
863 
864 /**
865  * Returns the CRC initialization value.
866  *
867  * @param[in] railHandle A RAIL instance handle.
868  * @return The CRC initialization value currently being used.
869  */
870 uint32_t RAIL_GetCrcInitVal(RAIL_Handle_t railHandle);
871 
872 /**
873  * Sets the whitening initialization value.
874  *
875  * @param[in] railHandle A RAIL instance handle.
876  * @param[in] whiteInit A whitening initialization value.
877  * @return Status code indicating success of the function call.
878  *
879  * Use this function to override the whitening initialization value
880  * defined by the current PHY's radio configuration. The new value
881  * will persist until this function is called again, \ref
882  * RAIL_ResetWhiteningInitVal() is called, or the PHY is
883  * changed.
884  *
885  * @note Overriding a PHY's whitening initialization value
886  *   will break communication with peers unless they effect
887  *   a similar change.
888  *
889  * @warning This API must not be used when either 802.15.4
890  *   or BLE modes are enabled.
891  */
892 RAIL_Status_t RAIL_SetWhiteningInitVal(RAIL_Handle_t railHandle,
893                                        uint16_t whiteInit);
894 
895 /**
896  * Sets the CRC initialization value.
897  *
898  * @param[in] railHandle A RAIL instance handle.
899  * @param[in] crcInit A CRC initialization value.
900  * @return Status code indicating success of the function call.
901  *
902  * Use this function to override the CRC initialization value
903  * defined by the current PHY's radio configuration. The new value
904  * will persist until this function is called again, \ref
905  * RAIL_ResetCrcInitVal() is called, or the PHY is changed.
906  *
907  * @note Overriding a PHY's CRC initialization value
908  *   will break communication with peers unless they effect
909  *   a similar change.
910  *
911  * @warning This API must not be used when either 802.15.4
912  *   or BLE modes are enabled.
913  */
914 RAIL_Status_t RAIL_SetCrcInitVal(RAIL_Handle_t railHandle,
915                                  uint32_t crcInit);
916 
917 /**
918  * Restores the whitening initialization value to its initial setting
919  * from the Radio Configurator.
920  *
921  * @param[in] railHandle A RAIL instance handle.
922  * @return Status code indicating success of the function call.
923  *
924  * Can use this function after using \ref RAIL_SetWhiteningInitVal().
925  */
926 RAIL_Status_t RAIL_ResetWhiteningInitVal(RAIL_Handle_t railHandle);
927 
928 /**
929  * Restores the CRC initialization value to its initial setting from
930  * the Radio Configurator.
931  *
932  * @param[in] railHandle A RAIL instance handle.
933  * @return Status code indicating success of the function call.
934  *
935  * Can use this function after using \ref RAIL_SetCrcInitVal().
936  */
937 RAIL_Status_t RAIL_ResetCrcInitVal(RAIL_Handle_t railHandle);
938 
939 /** @} */ // end of group Radio_Configuration
940 
941 /******************************************************************************
942  * Timing Information
943  *****************************************************************************/
944 /// @addtogroup System_Timing System Timing
945 /// @brief Functionality related to the RAIL timer and general system time.
946 ///
947 /// These functions can be used to get information about the current system time
948 /// or to manipulate the RAIL timer.
949 ///
950 /// The system time returned by \ref RAIL_GetTime() is in the same timebase that is
951 /// used throughout RAIL. Any callbacks or structures that provide a timestamp,
952 /// such as \ref RAIL_RxPacketDetails_t::timeReceived, will use the same timebase
953 /// as will any APIs that accept an absolute time for scheduling their action.
954 /// Throughout the documentation, the timebase is referred to as the RAIL
955 /// timebase. The timebase is currently a value in microseconds from \ref
956 /// RAIL_Init() time, which means that it will wrap every 1.19 hours.
957 /// (`(2^32 - 1) / (3600 sec/hr * 1000000 us/sec)`).
958 ///
959 /// The provided timer is hardware-backed and interrupt-driven. It can be used
960 /// for timing any event in the system, but is especially helpful for
961 /// timing protocol-based state machines and other systems that interact with
962 /// the radio. To avoid processing the expiration in interrupt
963 /// context, leave the cb parameter passed to \ref RAIL_SetTimer() as NULL and poll
964 /// for expiration with the \ref RAIL_IsTimerExpired() function. See below for an
965 /// example of the interrupt driven method of interacting with the timer.
966 /// @code{.c}
967 /// void timerCb(RAIL_Handle_t cbArg)
968 /// {
969 ///   // Timer callback action
970 /// }
971 ///
972 /// void main(void)
973 /// {
974 ///   // Initialize RAIL ...
975 ///
976 ///   // Set up a timer for 1 ms from now
977 ///   RAIL_SetTimer(railHandle, 1000, RAIL_TIME_RELATIVE, &timerCb);
978 ///
979 ///   // Run main loop
980 ///   while(1);
981 /// }
982 /// @endcode
983 ///
984 /// If multiple software timers are needed to be run off of the one available
985 /// hardware timer, enable a software multiplexing layer within RAIL
986 /// using the \ref RAIL_ConfigMultiTimer() function. This will allow you to
987 /// set up as many timers as you want using the RAIL_*MultiTimer() functions.
988 /// See the example below for using the multitimer functionality.
989 /// @code{.c}
990 /// // Declare timer structures in global space or somewhere that will exist
991 /// // until the callback has fired
992 /// RAIL_MultiTimer_t tmr1, tmr2;
993 ///
994 /// void timerCb(RAIL_MultiTimer_t *tmr,
995 ///              RAIL_Time_t expectedTimeOfEvent,
996 ///              void *cbArg)
997 /// {
998 ///   if (tmr == tmr1) {
999 ///     // Timer 1 action
1000 ///   } else {
1001 ///     // Timer 2 action
1002 ///   }
1003 /// }
1004 ///
1005 /// void main(void)
1006 /// {
1007 ///   // Initialize RAIL ...
1008 ///
1009 ///   RAIL_ConfigMultiTimer(true);
1010 ///
1011 ///   // Set up one timer for 1 ms from now and one at time 2000000 in the RAIL
1012 ///   // timebase
1013 ///   RAIL_SetMultiTimer(&tmr1, 1000, RAIL_TIME_RELATIVE, &timerCb, NULL);
1014 ///   RAIL_SetMultiTimer(&tmr2, 2000000, RAIL_TIME_ABSOLUTE, &timerCb, NULL);
1015 ///
1016 ///   // Run main loop
1017 ///   while(1);
1018 /// }
1019 /// @endcode
1020 ///
1021 /// @{
1022 
1023 /**
1024  * Get the current RAIL time.
1025  *
1026  * @return The RAIL time in microseconds. Note that this wraps
1027  *   after about 1.19 hours since it's stored in a 32 bit value.
1028  *
1029  * Returns the current time in the RAIL timebase (microseconds). It can be
1030  * used to compare with packet timestamps or to schedule transmits.
1031  */
1032 RAIL_Time_t RAIL_GetTime(void);
1033 
1034 /**
1035  * Set the current RAIL time.
1036  *
1037  * @param[in] time Set the RAIL timebase to this value in microseconds.
1038  * @return Status code indicating the success of the function call.
1039  *
1040  * @warning Use this API only for testing purposes or in
1041  *   very limited circumstances during RAIL Timer Synchronization.
1042  *   Undefined behavior can result by calling it in multiprotocol or
1043  *   when the radio is not idle or timed events are active. Applications
1044  *   using \ref RAIL_GetTime() may not be designed for discontinuous
1045  *   changes to the RAIL time base.
1046  */
1047 RAIL_Status_t RAIL_SetTime(RAIL_Time_t time);
1048 
1049 /**
1050  * Blocking delay routine for a specified number of microseconds.
1051  *
1052  * @param[in] microseconds Delay duration in microseconds.
1053  * @return Status code indicating success of the function call.
1054  *
1055  * Use this RAIL API only for short blocking delays because it has less overhead
1056  * than calling RAIL_GetTime() in a loop.
1057  *
1058  * @note Passing large delay values may give unpredictable results or trigger
1059  *   the Watchdog reset.
1060  *   \n Also, this function will start the clocks required for the RAIL timebase if they
1061  *   are not running, except between \ref RAIL_Sleep() and \ref RAIL_Wake()
1062  *   where the timer must remain stopped.
1063  *   \n Interrupts are not disabled during the delay, so the delay may be longer if an
1064  *   interrupt extends beyond the delay duration.
1065  */
1066 RAIL_Status_t RAIL_DelayUs(RAIL_Time_t microseconds);
1067 
1068 /**
1069  * Schedule a timer to expire using the RAIL timebase.
1070  *
1071  * @param[in] railHandle A RAIL instance handle.
1072  * @param[in] time The timer's expiration time in the RAIL timebase.
1073  * @param[in] mode Indicates whether the time argument is an absolute
1074  *   RAIL time or relative to the current RAIL time. Specifying mode
1075  *   \ref RAIL_TIME_DISABLED is the same as calling \ref RAIL_CancelTimer().
1076  * @param[in] cb A pointer to a callback function that RAIL will call
1077  *   when the timer expires. May be NULL if no callback is desired.
1078  * @return \ref RAIL_STATUS_NO_ERROR on success and
1079  *   \ref RAIL_STATUS_INVALID_PARAMETER if the timer can't be scheduled.
1080  *
1081  * Configures a timer to expire after a period in the RAIL timebase.
1082  * This timer can be used to implement low-level protocol features.
1083  *
1084  * @warning Attempting to schedule the timer when it is
1085  *   still running from a previous request is bad practice, unless the cb
1086  *   callback is identical to that used in the previous request, in which case
1087  *   the timer is rescheduled to the new time. Note that if the original timer
1088  *   expires as it is being rescheduled, the callback may or may not occur. It
1089  *   is generally good practice to cancel a running timer before rescheduling
1090  *   it to minimize ambiguity.
1091  */
1092 RAIL_Status_t RAIL_SetTimer(RAIL_Handle_t railHandle,
1093                             RAIL_Time_t time,
1094                             RAIL_TimeMode_t mode,
1095                             RAIL_TimerCallback_t cb);
1096 
1097 /**
1098  * Return the absolute time that the RAIL timer was configured to expire.
1099  *
1100  * @param[in] railHandle A RAIL instance handle.
1101  * @return The absolute time that this timer was set to expire.
1102  *
1103  * Provides the absolute time regardless of the \ref RAIL_TimeMode_t that
1104  * was passed into \ref RAIL_SetTimer(). Note that the time might be in the
1105  * past if the timer has already expired. The return value is undefined if the
1106  * timer was never set.
1107  */
1108 RAIL_Time_t RAIL_GetTimer(RAIL_Handle_t railHandle);
1109 
1110 /**
1111  * Stop the currently scheduled RAIL timer.
1112  *
1113  * @param[in] railHandle A RAIL instance handle.
1114  * @return \ref RAIL_STATUS_NO_ERROR on success and
1115  *   \ref RAIL_STATUS_INVALID_CALL if the timer is not running.
1116  *
1117  * Cancels the timer. If this function is called before the timer expires,
1118  * the cb callback specified in the earlier RAIL_SetTimer() call will never
1119  * be called.
1120  */
1121 RAIL_Status_t RAIL_CancelTimer(RAIL_Handle_t railHandle);
1122 
1123 /**
1124  * Check whether the RAIL timer has expired.
1125  *
1126  * @param[in] railHandle A RAIL instance handle.
1127  * @return true if the previously scheduled timer has expired and false
1128  *   otherwise.
1129  *
1130  * Polling with this function is an alternative to the callback.
1131  */
1132 bool RAIL_IsTimerExpired(RAIL_Handle_t railHandle);
1133 
1134 /**
1135  * Check whether the RAIL timer is currently running.
1136  *
1137  * @param[in] railHandle A RAIL instance handle.
1138  * @return true if the timer is running and false if
1139  *   the timer has expired or was never set.
1140  */
1141 bool RAIL_IsTimerRunning(RAIL_Handle_t railHandle);
1142 
1143 /**
1144  * Configure the RAIL software timer feature.
1145  *
1146  * @param[in] enable Enables/disables the RAIL multitimer.
1147  * @return true if the multitimer was successfully enabled/disabled, false
1148  *   otherwise.
1149  *
1150  * Turning this on will add a software timer layer above the physical RAIL timer
1151  * so that the user can have as many timers as desired. It is not necessary to
1152  * call this function if the MultiTimer APIs are not used.
1153  *
1154  * @note This function must be called before calling \ref RAIL_SetMultiTimer().
1155  *   This function is a no-op on multiprotocol as this layer is already used
1156  *   under the hood.
1157  *   Do not call this function while the RAIL timer is running.
1158  *   Call \ref RAIL_IsTimerRunning() before enabling/disabling the multitimer.
1159  *   If the multitimer is not needed, do not call this function to
1160  *   allow the multitimer code to be dead stripped. If the multitimer is
1161  *   enabled for use, the multitimer and timer APIs can both be used.
1162  *   However, no timer can be in use while this function is being called.
1163  */
1164 bool RAIL_ConfigMultiTimer(bool enable);
1165 
1166 /**
1167  * Start a multitimer instance.
1168  *
1169  * @param[in,out] tmr A pointer to the timer instance to start.
1170  * @param[in] expirationTime A time when the timer is set to expire.
1171  * @param[in] expirationMode Select mode of expirationTime. See \ref
1172  *   RAIL_TimeMode_t.
1173  * @param[in] callback A function to call on timer expiry. See \ref
1174  *   RAIL_MultiTimerCallback_t. May be NULL if no callback is desired.
1175  * @param[in] cbArg An extra callback function parameter for the user application.
1176  * @return
1177  *   \ref RAIL_STATUS_NO_ERROR on success.@n
1178  *   \ref RAIL_STATUS_INVALID_PARAMETER if tmr has an illegal value or if
1179  *   timeout is in the past.
1180  *
1181  * @note It is legal to start an already running timer. If this is done,
1182  *   the timer will first be stopped before the new configuration is applied.
1183  *   If expirationTime is 0, the callback is called immediately.
1184  */
1185 RAIL_Status_t RAIL_SetMultiTimer(RAIL_MultiTimer_t *tmr,
1186                                  RAIL_Time_t expirationTime,
1187                                  RAIL_TimeMode_t expirationMode,
1188                                  RAIL_MultiTimerCallback_t callback,
1189                                  void *cbArg);
1190 
1191 /**
1192  * Stop the currently scheduled RAIL multitimer.
1193  *
1194  * @param[in,out] tmr A pointer to a RAIL timer instance.
1195  * @return true if the timer was successfully canceled;
1196  *   false if the timer was not running.
1197  *
1198  * Cancels the timer. If this function is called before the timer expires,
1199  * the cb callback specified in the earlier \ref RAIL_SetTimer() call will never
1200  * be called.
1201  */
1202 bool RAIL_CancelMultiTimer(RAIL_MultiTimer_t *tmr);
1203 
1204 /**
1205  * Check if a given timer is running.
1206  *
1207  * @param[in] tmr A pointer to the timer instance.
1208  * @return true if the timer is running; false if the timer is not running
1209  *    or tmr is not a timer instance.
1210  */
1211 bool RAIL_IsMultiTimerRunning(RAIL_MultiTimer_t *tmr);
1212 
1213 /**
1214  * Check if a given timer has expired.
1215  *
1216  * @param[in] tmr A pointer to the timer instance.
1217  * @return true if the timer has expired or tmr is not a timer instance;
1218  *   false if the timer is running.
1219  */
1220 bool RAIL_IsMultiTimerExpired(RAIL_MultiTimer_t *tmr);
1221 
1222 /**
1223  * Get time left before a given timer instance expires.
1224  *
1225  * @param[in] tmr A pointer to the timer instance to query.
1226  * @param[in] timeMode Indicates how the function provides the time
1227  *   remaining. By choosing \ref
1228  *   RAIL_TimeMode_t::RAIL_TIME_ABSOLUTE, the function returns the
1229  *   absolute expiration time, and by choosing \ref
1230  *   RAIL_TimeMode_t::RAIL_TIME_DELAY, the function returns the
1231  *   amount of time remaining before the timer's expiration.
1232  * @return
1233  *   Time left expressed in RAIL's time units.
1234  *   0 if the timer is not running or has already expired.
1235  */
1236 RAIL_Time_t RAIL_GetMultiTimer(RAIL_MultiTimer_t *tmr,
1237                                RAIL_TimeMode_t timeMode);
1238 
1239 /** @} */ // end of group System_Timing
1240 
1241 /******************************************************************************
1242  * Sleep APIs
1243  *****************************************************************************/
1244 /// @addtogroup Sleep
1245 /// @brief These APIs help when putting the system to an EM2/EM3/EM4 sleep
1246 /// states where the high frequency clock is disabled.
1247 /// @{
1248 ///
1249 /// The RAIL library has its own timebase and the ability to schedule operations
1250 /// into the future. When going to any power mode that disables the HF clock
1251 /// used for the radio (EM2/EM3/EM4), it is important that this timebase is
1252 /// synchronized to a running LFCLK and the chip is set to wake up before the
1253 /// next scheduled event.
1254 /// If RAIL has not been configured to use the power manager,
1255 /// \ref RAIL_Sleep() and \ref RAIL_Wake() must be called for performing this
1256 /// synchronization.
1257 /// If RAIL has been configured to use the power manager,
1258 /// \ref RAIL_InitPowerManager(), it will automatically perform timer
1259 /// synchronization based on the selected \ref RAIL_TimerSyncConfig_t. Calls to
1260 /// \ref RAIL_Sleep() and \ref RAIL_Wake() are unsupported in such a scenario.
1261 ///
1262 /// Following example code snippets demonstrate synchronizing the timebase
1263 /// with and without timer synchronization:
1264 ///
1265 /// <b>Sleep with timer synchronization:</b>
1266 ///
1267 /// When sleeping with timer synchronization, you must first get the required
1268 /// LFCLK up and running and leave it running across sleep so that the high
1269 /// frequency clock that drives the RAIL time base can be synchronized to it.
1270 /// The \ref RAIL_Sleep() API will also set up a wake event on the timer to wake
1271 /// up wakeupProcessTime before the next timer event so that it can run successfully.
1272 /// See the \ref efr32_main sections on Low-Frequency Clocks and RAIL Timer
1273 /// Synchronization for more setup details.
1274 ///
1275 /// This is useful when maintaining packet timestamps
1276 /// across sleep or use the scheduled RX/TX APIs while sleeping in between. It
1277 /// does take more time and code to do the synchronization. If your
1278 /// application does not need this, it should be avoided.
1279 ///
1280 /// Example (without Power Manager):
1281 /// @code{.c}
1282 /// #include "rail.h"
1283 ///
1284 /// extern RAIL_Handle_t railHandle;
1285 /// // Wakeup time for your crystal/board/chip combination
1286 /// extern uint32_t wakeupProcessTime;
1287 ///
1288 /// void main(void)
1289 /// {
1290 ///   RAIL_Status_t status;
1291 ///   bool shouldSleep = false;
1292 ///
1293 ///   // This function depends on your board/chip but it must enable the LFCLK
1294 ///   // you intend to use for RTCC sync before we configure sleep as that function
1295 ///   // will attempt to auto detect the clock.
1296 ///   BoardSetupLFCLK()
1297 ///
1298 ///   // Configure sleep for timer synchronization
1299 ///   RAIL_TimerSyncConfig_t timerSyncConfig = RAIL_TIMER_SYNC_DEFAULT;
1300 ///   status = RAIL_ConfigSleepAlt(railHandle, &timerSyncConfig);
1301 ///   assert(status == RAIL_STATUS_NO_ERROR);
1302 ///
1303 ///   // Application main loop
1304 ///   while(1) {
1305 ///     // ... do normal app stuff and set shouldSleep to true when we want to
1306 ///     // sleep
1307 ///     if (shouldSleep) {
1308 ///       bool sleepAllowed = false;
1309 ///
1310 ///       // Go critical to assess sleep decisions
1311 ///       CORE_ENTER_CRITICAL();
1312 ///       if (RAIL_Sleep(wakeupProcessTime, &sleepAllowed) != RAIL_STATUS_NO_ERROR) {
1313 ///         printf("Error trying to go to sleep!");
1314 ///         CORE_EXIT_CRITICAL();
1315 ///         continue;
1316 ///       }
1317 ///       if (sleepAllowed) {
1318 ///         // Go to sleep
1319 ///       }
1320 ///       // Wakeup and sync the RAIL timebase back up
1321 ///       RAIL_Wake(0);
1322 ///       CORE_EXIT_CRITICAL();
1323 ///     }
1324 ///   }
1325 /// }
1326 /// @endcode
1327 ///
1328 /// Example (with Power Manager):
1329 /// @code{.c}
1330 /// #include "rail.h"
1331 /// #include "sl_power_manager.h"
1332 ///
1333 /// extern RAIL_Handle_t railHandle;
1334 ///
1335 /// void main(void)
1336 /// {
1337 ///   RAIL_Status_t status;
1338 ///   bool shouldSleep = false;
1339 ///
1340 ///   // This function depends on your board/chip but it must enable the LFCLK
1341 ///   // you intend to use for RTCC sync before we configure sleep as that function
1342 ///   // will attempt to auto detect the clock.
1343 ///   BoardSetupLFCLK();
1344 ///   // Configure sleep for timer synchronization
1345 ///   RAIL_TimerSyncConfig_t timerSyncConfig = RAIL_TIMER_SYNC_DEFAULT;
1346 ///   status = RAIL_ConfigSleepAlt(railHandle, &timerSyncConfig);
1347 ///   assert(status == RAIL_STATUS_NO_ERROR);
1348 ///   // Initialize application-level power manager service
1349 ///   sl_power_manager_init();
1350 ///   // Initialize RAIL library's use of the power manager
1351 ///   RAIL_InitPowerManager();
1352 ///
1353 ///   // Application main loop
1354 ///   while(1) {
1355 ///     // ... do normal app stuff and set shouldSleep to true when we want to
1356 ///     // sleep
1357 ///     if (shouldSleep) {
1358 ///       // Let the CPU go to sleep if the system allows it.
1359 ///       sl_power_manager_sleep();
1360 ///     }
1361 ///   }
1362 /// }
1363 /// @endcode
1364 ///
1365 /// RAIL APIs such as, \ref RAIL_StartScheduledTx(), \ref RAIL_ScheduleRx(),
1366 /// \ref RAIL_SetTimer(), \ref RAIL_SetMultiTimer() can be used to schedule periodic
1367 /// wakeups to perform a scheduled operation. The call to
1368 /// sl_power_manager_sleep() in the main loop ensures that the device sleeps
1369 /// until the scheduled operation is due.
1370 /// Upon completion, each instantaneous or scheduled RX/TX operation will
1371 /// indicate radio busy to the power manager to allow the application to
1372 /// service the RAIL event and perform subsequent operations before going to
1373 /// sleep. Therefore, it is important that the application idle the radio by either
1374 /// calling \ref RAIL_Idle() or \ref RAIL_YieldRadio().
1375 /// If the radio transitions to RX after an RX or TX operation,
1376 /// always call \ref RAIL_Idle() in order transition to a lower sleep state.
1377 /// If the radio transitions to idle after an RX or TX operation,
1378 /// \ref RAIL_YieldRadio() should suffice in indicating to the power manager
1379 /// that the radio is no longer busy and the device can sleep.
1380 ///
1381 /// The following example shows scheduling periodic TX on getting a TX completion
1382 /// event:
1383 /// @code{.c}
1384 /// void RAILCb_Event(RAIL_Handle_t railHandle, RAIL_Events_t events)
1385 /// {
1386 ///   // Omitting other event handlers
1387 ///   if (events & RAIL_EVENTS_TX_COMPLETION) {
1388 ///     // Schedule the next TX.
1389 ///     RAIL_ScheduleTxConfig_t config = {
1390 ///       .when = (RAIL_Time_t)parameters->startTime,
1391 ///       .mode = (RAIL_TimeMode_t)parameters->startTimeMode
1392 ///     };
1393 ///     (void)RAIL_StartScheduledTx(railHandle, channel, 0, &config, NULL);
1394 ///   }
1395 /// }
1396 /// @endcode
1397 ///
1398 /// @note The above code assumes that RAIL automatic state transitions after TX
1399 ///   are idle. Use \ref RAIL_SetTxTransitions() to ensure the right state
1400 ///   transitions are used. Radio must be idle for the device to enter EM2 or lower
1401 ///   energy mode.
1402 ///
1403 /// @note When using the power manager, usage of \ref RAIL_YieldRadio() in
1404 ///   single protocol RAIL is similar to its usage in multiprotocol RAIL.
1405 ///   See \ref rail_radio_scheduler_yield for more details.
1406 ///
1407 /// @note Back to back scheduled operations do not require an explicit call to
1408 ///   \ref RAIL_YieldRadio() if the radio transitions to idle.
1409 ///
1410 /// <b>Sleep without timer synchronization:</b>
1411 ///
1412 /// When sleeping without timer synchronization, you are free to enable only the
1413 /// LFCLKs and wake sources required by the application. RAIL will not attempt
1414 /// to configure any wake events and may miss anything that occurs over sleep.
1415 ///
1416 /// This is useful when your application does not care about
1417 /// packet timestamps or scheduling operations accurately over sleep.
1418 ///
1419 /// Example (without Power Manager):
1420 /// @code{.c}
1421 /// #include "rail.h"
1422 ///
1423 /// extern RAIL_Handle_t railHandle;
1424 ///
1425 /// void main(void)
1426 /// {
1427 ///   RAIL_Status_t status;
1428 ///   bool shouldSleep = false;
1429 ///
1430 ///   // Configure sleep for no timer synchronization
1431 ///   RAIL_TimerSyncConfig_t timerSyncConfig = {
1432 ///     .sleep = RAIL_SLEEP_CONFIG_TIMERSYNC_DISABLED,
1433 ///   };
1434 ///   status = RAIL_ConfigSleepAlt(railHandle, &timerSyncConfig);
1435 ///   assert(status == RAIL_STATUS_NO_ERROR);
1436 ///
1437 ///   // Application main loop
1438 ///   while(1) {
1439 ///     // ... do normal app stuff and set shouldSleep to true when we want to
1440 ///     // sleep
1441 ///     if (shouldSleep) {
1442 ///       bool sleepAllowed = false;
1443 ///       uint32_t sleepTime = 0;
1444 ///
1445 ///       // Go critical to assess sleep decisions
1446 ///       CORE_ENTER_CRITICAL();
1447 ///       if (RAIL_Sleep(0, &sleepAllowed) != RAIL_STATUS_NO_ERROR) {
1448 ///         printf("Error trying to go to sleep!");
1449 ///         CORE_EXIT_CRITICAL();
1450 ///         continue;
1451 ///       }
1452 ///       if (sleepAllowed) {
1453 ///         // Go to sleep and optionally update sleepTime to the correct value
1454 ///         // in microseconds
1455 ///       }
1456 ///       // Wakeup and sync the RAIL timebase back up
1457 ///       RAIL_Wake(sleepTime);
1458 ///       CORE_EXIT_CRITICAL();
1459 ///     }
1460 ///   }
1461 /// }
1462 /// @endcode
1463 ///
1464 /// Example (with Power Manager):
1465 /// @code{.c}
1466 /// #include "rail.h"
1467 /// #include "sl_power_manager.h"
1468 ///
1469 /// extern RAIL_Handle_t railHandle;
1470 ///
1471 /// void main(void)
1472 /// {
1473 ///   RAIL_Status_t status;
1474 ///   bool shouldSleep = false;
1475 ///
1476 ///   // This function depends on your board/chip but it must enable the LFCLK
1477 ///   // you intend to use for RTCC sync before we configure sleep as that function
1478 ///   // will attempt to auto detect the clock.
1479 ///   BoardSetupLFCLK();
1480 ///   // Configure sleep for no timer synchronization
1481 ///   RAIL_TimerSyncConfig_t timerSyncConfig = {
1482 ///     .sleep = RAIL_SLEEP_CONFIG_TIMERSYNC_DISABLED,
1483 ///   };
1484 ///   status = RAIL_ConfigSleepAlt(railHandle, &timerSyncConfig);
1485 ///   assert(status == RAIL_STATUS_NO_ERROR);
1486 ///   // Initialize application-level power manager service
1487 ///   sl_power_manager_init();
1488 ///   // Initialize RAIL library's use of the power manager
1489 ///   RAIL_InitPowerManager();
1490 ///
1491 ///   // Application main loop
1492 ///   while(1) {
1493 ///     // ... do normal app stuff and set shouldSleep to true when we want to
1494 ///     // sleep
1495 ///     if (shouldSleep) {
1496 ///       // Let the CPU go to sleep if the system allows it.
1497 ///       sl_power_manager_sleep();
1498 ///     }
1499 ///   }
1500 /// }
1501 /// @endcode
1502 /**
1503  * Configure RAIL timer synchronization. This function is optional to implement.
1504  *
1505  * @param[in,out] timerSyncConfig A pointer to the \ref RAIL_TimerSyncConfig_t
1506  *   structure containing the configuration parameters for timer sync. The
1507  *   \ref RAIL_TimerSyncConfig_t::sleep field is ignored in this call.
1508  *
1509  * This function is called during \ref RAIL_ConfigSleep() to allow an application
1510  * to configure the PRS and RTCC channels used for timer sync to values other
1511  * than their defaults. The default channels are populated in timerSyncConfig and
1512  * can be overwritten by the application. If this function is not implemented by the
1513  * application, a default implementation from within the RAIL library will be used
1514  * that simply maintains the default channel values in timerSyncConfig.
1515  * For example:
1516  * @code{.c}
1517  * void RAILCb_ConfigSleepTimerSync(RAIL_TimerSyncConfig_t *timerSyncConfig)
1518  * {
1519  *   timerSyncConfig->prsChannel = MY_TIMERSYNC_PRS_CHANNEL;
1520  *   timerSyncConfig->rtccChannel = MY_TIMERSYNC_RTCC_CHANNEL;
1521  * }
1522  * @endcode
1523  *
1524  * If an unsupported channel is selected by the application, \ref RAIL_ConfigSleep()
1525  * will return \ref RAIL_STATUS_INVALID_PARAMETER.
1526  */
1527 void RAILCb_ConfigSleepTimerSync(RAIL_TimerSyncConfig_t *timerSyncConfig);
1528 
1529 /**
1530  * Initialize RAIL timer synchronization.
1531  *
1532  * @param[in] railHandle A RAIL instance handle.
1533  * @param[in] sleepConfig A sleep configuration.
1534  * @return Status code indicating success of the function call.
1535  *
1536  * @warning As this function relies on PRS and SYSRTC access and RAIL is meant
1537  *   to run in TrustZone non-secure world, it is not supported if PRS or SYSRTC
1538  *   are configured as secure peripheral and sleepConfig is set to
1539  *   \ref RAIL_SleepConfig_t::RAIL_SLEEP_CONFIG_TIMERSYNC_ENABLED. It will
1540  *   return \ref RAIL_STATUS_INVALID_CALL.
1541  */
1542 RAIL_Status_t RAIL_ConfigSleep(RAIL_Handle_t railHandle,
1543                                RAIL_SleepConfig_t sleepConfig);
1544 
1545 /**
1546  * Initialize RAIL timer synchronization.
1547  *
1548  * @param[in] railHandle A RAIL instance handle.
1549  * @param[in] syncConfig A non-NULL pointer to the timer synchronization configuration.
1550  * @return Status code indicating success of the function call.
1551  *
1552  * The default structure used to enable timer synchronization across sleep is
1553  * \ref RAIL_TIMER_SYNC_DEFAULT.
1554  *
1555  * @warning As this function relies on PRS and SYSRTC access and RAIL is meant
1556  *   to run in TrustZone non-secure world, it is not supported if PRS or SYSRTC
1557  *   are configured as secure peripheral and syncConfig->sleep is set to
1558  *   \ref RAIL_SleepConfig_t::RAIL_SLEEP_CONFIG_TIMERSYNC_ENABLED. It will
1559  *   return \ref RAIL_STATUS_INVALID_CALL.
1560  */
1561 RAIL_Status_t RAIL_ConfigSleepAlt(RAIL_Handle_t railHandle,
1562                                   const RAIL_TimerSyncConfig_t *syncConfig);
1563 
1564 /**
1565  * Stop the RAIL timer(s) and prepare RAIL for sleep.
1566  *
1567  * @param[in] wakeupProcessTime Time in microseconds that the application
1568  *   and hardware need to recover from sleep state.
1569  * @param[out] deepSleepAllowed A pointer to boolean that will be set
1570  *   true if system can go to deep sleep or false if system must not go
1571  *   to deep sleep (EM2 or lower energy modes).
1572  * @return Status code indicating success of the function call.
1573  *
1574  * @warning The active RAIL configuration must be idle to enable sleep.
1575  *
1576  * @note This API must not be called if RAIL Power Manager is initialized.
1577  */
1578 RAIL_Status_t RAIL_Sleep(uint16_t wakeupProcessTime, bool *deepSleepAllowed);
1579 
1580 /**
1581  * Wake RAIL from sleep and restart the RAIL timer(s).
1582  *
1583  * @param[in] elapsedTime Add this sleep duration in microseconds
1584  *   to the RAIL timer(s) before restarting it(them).
1585  * @return Status code indicating success of the function call.
1586  *
1587  * If the timer sync was enabled by \ref RAIL_ConfigSleep(), synchronize the RAIL
1588  * timer(s) using an alternate timer. Otherwise, add elapsedTime to the RAIL
1589  * timer(s).
1590  *
1591  * @note This API must not be called if RAIL Power Manager is initialized.
1592  */
1593 RAIL_Status_t RAIL_Wake(RAIL_Time_t elapsedTime);
1594 
1595 /**
1596  * Initialize RAIL Power Manager.
1597  *
1598  * @return Status code indicating success of the function call.
1599  *
1600  * @note This function must be called only when the application is built
1601  *   and initialized with Power Manager plugin and when the radio is idle.
1602  *   RAIL will perform timer synchronization, upon transitioning from EM2 or
1603  *   lower to EM1 or higher energy mode or vice-versa, in the Power Manager EM
1604  *   transition callback.
1605  *
1606  * @warning Since EM transition callbacks are not called in a deterministic
1607  *   order, it is suggested to not call any RAIL time dependent APIs
1608  *   in an EM transition callback.
1609  *
1610  * @warning As this function relies on EMU access and RAIL is meant to run in
1611  *   TrustZone non-secure world, it is not supported if EMU is configured as
1612  *   secure peripheral and it will return \ref RAIL_STATUS_INVALID_CALL.
1613  */
1614 RAIL_Status_t RAIL_InitPowerManager(void);
1615 
1616 /**
1617  * Stop the RAIL Power Manager.
1618  *
1619  * @return Status code indicating success of the function call.
1620  *
1621  * @note The active RAIL configuration must be idle to disable radio
1622  *   power manager and there should be no outstanding requirements by
1623  *   radio power manager.
1624  */
1625 RAIL_Status_t RAIL_DeinitPowerManager(void);
1626 
1627 /** @} */ // end of group Sleep
1628 
1629 /******************************************************************************
1630  * Events
1631  *****************************************************************************/
1632 /**
1633  * @addtogroup Events
1634  * @brief APIs related to events
1635  * @{
1636  */
1637 
1638 /**
1639  * Configure radio events.
1640  *
1641  * @param[in] railHandle A RAIL instance handle.
1642  * @param[in] mask A bitmask of events to configure.
1643  * @param[in] events A bitmask of events to trigger \ref RAIL_Config_t::eventsCallback.
1644  * @return Status code indicating success of the function call.
1645  *
1646  * Sets up which radio interrupts generate a RAIL event. The full list of
1647  * events is in \ref RAIL_Events_t.
1648  */
1649 RAIL_Status_t RAIL_ConfigEvents(RAIL_Handle_t railHandle,
1650                                 RAIL_Events_t mask,
1651                                 RAIL_Events_t events);
1652 
1653 /** @} */ // end of group Events
1654 
1655 /******************************************************************************
1656  * Data Management
1657  *****************************************************************************/
1658 /// @addtogroup Data_Management Data Management
1659 /// @brief Data management functions
1660 ///
1661 /// These functions allow the application to choose how data is presented to
1662 /// the application. RAIL provides data in a packet-based method or in a
1663 /// FIFO-based method. As originally conceived,
1664 /// \ref RAIL_DataMethod_t::PACKET_MODE was designed for handling packets
1665 /// that fit within RAIL's FIFOs while \ref RAIL_DataMethod_t::FIFO_MODE
1666 /// was designed for handling packets larger than RAIL's FIFOs could hold.
1667 /// Conceptually it is still useful to think of these modes this way, but
1668 /// functionally their distinction has become blurred by improvements in
1669 /// RAIL's flexibility -- applications now have much more control over both
1670 /// receive and transmit FIFO sizes, and the FIFO-management and threshold
1671 /// APIs and related events are no longer restricted to \ref
1672 /// RAIL_DataMethod_t::FIFO_MODE operation but can be used in \ref
1673 /// RAIL_DataMethod_t::PACKET_MODE too.
1674 ///
1675 /// The application can configure RAIL data management through \ref
1676 /// RAIL_ConfigData(). This function allows the application to specify the type
1677 /// of radio data (\ref RAIL_TxDataSource_t and \ref RAIL_RxDataSource_t) and
1678 /// the method of interacting with data (\ref RAIL_DataMethod_t). By default,
1679 /// RAIL configures TX and RX both with packet data source and \ref
1680 /// RAIL_DataMethod_t::PACKET_MODE.
1681 ///
1682 /// For transmit, \ref RAIL_DataMethod_t::PACKET_MODE and \ref
1683 /// RAIL_DataMethod_t::FIFO_MODE are functionally the same:
1684 ///   - When not actively transmitting, load a packet's initial transmit
1685 ///     data using \ref RAIL_WriteTxFifo() with reset set to true. Alternatively
1686 ///     this data copying can be avoided by changing the transmit FIFO to an
1687 ///     already-loaded section of memory with \ref RAIL_SetTxFifo().
1688 ///   - When actively transmitting, load remaining transmit data with
1689 ///     \ref RAIL_WriteTxFifo() with reset set to false.
1690 ///   - If transmit packets exceed the FIFO size, set the transmit FIFO
1691 ///     threshold through \ref RAIL_SetTxFifoThreshold(). The \ref
1692 ///     RAIL_Config_t::eventsCallback with \ref RAIL_EVENT_TX_FIFO_ALMOST_EMPTY
1693 ///     will occur telling the application to load more TX packet data, if
1694 ///     needed, to prevent a \ref RAIL_EVENT_TX_UNDERFLOW event from occurring.
1695 ///     One can get how much space is available in the transmit FIFO for more
1696 ///     transmit data through \ref RAIL_GetTxFifoSpaceAvailable().
1697 ///   - After transmit completes, the transmit FIFO can be manually reset
1698 ///     with \ref RAIL_ResetFifo(), but this should rarely be necessary.
1699 ///
1700 /// The transmit FIFO is specified by the application and its size is
1701 /// the value returned from the most recent call to \ref RAIL_SetTxFifo().
1702 /// The transmit FIFO is edge-based in that it only provides the \ref
1703 /// RAIL_EVENT_TX_FIFO_ALMOST_EMPTY event once when the threshold is crossed
1704 /// in the emptying direction.
1705 ///
1706 /// For receive, the distinction between \ref RAIL_DataMethod_t::PACKET_MODE
1707 /// and \ref RAIL_DataMethod_t::FIFO_MODE basically boils down to how
1708 /// unsuccessfully-received packets are handled. In \ref
1709 /// RAIL_DataMethod_t::PACKET_MODE, data from such packets is automatically
1710 /// rolled back as if the packet was never received, while in \ref
1711 /// RAIL_DataMethod_t::FIFO_MODE, rollback does not occur putting more onus
1712 /// on the application to deal with that data.
1713 ///
1714 /// In receive \ref RAIL_DataMethod_t::PACKET_MODE data management:
1715 ///   - Packet lengths are determined from the Radio Configurator configuration
1716 ///     and can be read out at the end using \ref RAIL_GetRxPacketInfo().
1717 ///   - Received packet data is made available on successful packet completion
1718 ///     via \ref RAIL_Config_t::eventsCallback with \ref
1719 ///     RAIL_EVENT_RX_PACKET_RECEIVED which can then use \ref RAIL_GetRxPacketInfo()
1720 ///     and \ref RAIL_GetRxPacketDetailsAlt() to access packet information and
1721 ///     \ref RAIL_PeekRxPacket() to access packet data.
1722 ///   - FILTERED, ABORTED, or FRAMEERROR received packet data is automatically
1723 ///     rolled back (dropped) without the application needing to worry about
1724 ///     consuming it.
1725 ///     The application can choose to not even be bothered with the events
1726 ///     related to such packets: \ref RAIL_EVENT_RX_ADDRESS_FILTERED,
1727 ///     \ref RAIL_EVENT_RX_PACKET_ABORTED, or \ref RAIL_EVENT_RX_FRAME_ERROR.
1728 ///
1729 /// In receive \ref RAIL_DataMethod_t::FIFO_MODE data management:
1730 ///   - Packet Lengths are determined from the Radio Configurator configuration
1731 ///     or by application knowledge of packet payload structure.
1732 ///   - Received data can be retrieved prior to packet completion through
1733 ///     \ref RAIL_ReadRxFifo() and is never rolled back on FILTERED, ABORTED, or
1734 ///     FRAMEERROR packets. The application should enable and handle these
1735 ///     events so it can flush any packet data it's already retrieved.
1736 ///   - After packet completion, remaining packet data for FILTERED, ABORTED,
1737 ///     or FRAMEERROR packets remains in the FIFO and the appropriate event is
1738 ///     triggered to the user. This data may be consumed in the callback unlike
1739 ///     in packet mode where it is automatically rolled back. At the end of the
1740 ///     callback all remaining data in the FIFO will be cleaned up as usual.
1741 ///     Keep in mind that \ref RAIL_GetRxPacketDetailsAlt() provides full packet
1742 ///     detailed information only for successfully received packets.
1743 ///
1744 /// Common receive data management features:
1745 ///   - Set the receive FIFO threshold through \ref RAIL_SetRxFifoThreshold(). The
1746 ///     \ref RAIL_Config_t::eventsCallback with \ref RAIL_EVENT_RX_FIFO_ALMOST_FULL
1747 ///     will occur telling the application to consume some RX packet data to
1748 ///     prevent a \ref RAIL_EVENT_RX_FIFO_OVERFLOW event from occurring.
1749 ///   - Get receive FIFO count information through
1750 ///     \ref RAIL_GetRxPacketInfo(\ref RAIL_RX_PACKET_HANDLE_NEWEST)
1751 ///     (or \ref RAIL_GetRxFifoBytesAvailable()).
1752 ///   - After receive completes and all its data has been consumed, the receive
1753 ///     FIFO can be manually reset with \ref RAIL_ResetFifo(), though this should
1754 ///     rarely be necessary and should only be done with the radio idle.
1755 ///
1756 /// When trying to determine an appropriate threshold, the application needs
1757 /// to know the size of each FIFO. The default receive FIFO is internal to RAIL
1758 /// with a size of 512 bytes. This can be changed, however, using
1759 /// \ref RAIL_SetRxFifo() and the default may be removed entirely by calling
1760 /// this from the \ref RAILCb_SetupRxFifo() callback. The receive FIFO event is
1761 /// level-based in that the \ref RAIL_EVENT_RX_FIFO_ALMOST_FULL event will
1762 /// constantly pend if the threshold is exceeded. This normally means that
1763 /// inside this event's callback, the application should empty enough of the FIFO
1764 /// to go under the threshold. To defer reading the FIFO to main context, the
1765 /// application can disable or re-enable the receive FIFO threshold event using
1766 /// \ref RAIL_ConfigEvents() with the mask \ref RAIL_EVENT_RX_FIFO_ALMOST_FULL.
1767 ///
1768 /// The receive FIFO can store multiple packets and processing of a packet can
1769 /// be deferred from the RAIL event callback to main-loop processing
1770 /// by using \ref RAIL_HoldRxPacket() in the event callback and
1771 /// \ref RAIL_ReleaseRxPacket() in the main-loop.
1772 /// On some platforms, the receive FIFO is supplemented by an internal
1773 /// fixed-size packet metadata FIFO that limits the number of packets
1774 /// RAIL and applications can hold onto for deferred processing.
1775 /// See chip-specific documentation, such as \ref efr32_main, for more
1776 /// information.
1777 ///
1778 /// @note When using multiprotocol the receive FIFO is reset
1779 ///   prior to a protocol switch so held packets will be lost if not processed
1780 ///   before then.
1781 ///
1782 /// While \ref RAIL_EVENT_RX_FIFO_ALMOST_FULL occurs solely based on the
1783 /// state of the receive FIFO used for packet data, both
1784 /// \ref RAIL_EVENT_RX_FIFO_FULL and \ref RAIL_EVENT_RX_FIFO_OVERFLOW
1785 /// can occur coincident with packet completion when either that or the
1786 /// internal packet metadata FIFO fills or overflows.
1787 /// \ref RAIL_EVENT_RX_FIFO_FULL informs the application it should
1788 /// immediately process and free up the oldest packets/data to make room
1789 /// for new packets/data, reducing the possibility of packet/data loss
1790 /// and \ref RAIL_EVENT_RX_FIFO_OVERFLOW.
1791 ///
1792 /// Before a packet is fully received you can always use \ref
1793 /// RAIL_PeekRxPacket() to look at the contents. In FIFO mode, you may also
1794 /// consume its data with \ref RAIL_ReadRxFifo(). Remember that none of these
1795 /// APIs will read across a packet boundary (even in FIFO mode) so you will
1796 /// need to handle each received packet individually.
1797 ///
1798 /// While RAIL defaults to \ref RAIL_DataMethod_t::PACKET_MODE, the
1799 /// application can explicitly initialize RAIL for \ref
1800 /// RAIL_DataMethod_t::PACKET_MODE in the following manner:
1801 /// @code{.c}
1802 /// extern RAIL_Handle_t railHandle;
1803 ///
1804 /// void configRailForPacketModeOperation(void)
1805 /// {
1806 ///   RAIL_DataConfig_t railDataConfig = {
1807 ///     .txSource = TX_PACKET_DATA,
1808 ///     .rxSource = RX_PACKET_DATA,
1809 ///     .txMethod = PACKET_MODE,
1810 ///     .rxMethod = PACKET_MODE,
1811 ///   };
1812 ///
1813 ///   (void) RAIL_ConfigData(railHandle, &railDataConfig);
1814 ///
1815 ///   // Events that can occur in Packet Mode:
1816 ///   //    RAIL_EVENT_TX_PACKET_SENT
1817 ///   //    RAIL_EVENT_RX_PACKET_RECEIVED
1818 ///   // and optionally (packet data automatically dropped):
1819 ///   //    RAIL_EVENT_RX_ADDRESS_FILTERED
1820 ///   //    RAIL_EVENT_RX_PACKET_ABORTED
1821 ///   //    RAIL_EVENT_RX_FRAME_ERROR
1822 ///   // and if enabled:
1823 ///   //   RAIL_EVENT_TX_UNDERFLOW
1824 ///   //   RAIL_EVENT_TXACK_UNDERFLOW
1825 ///   //   RAIL_EVENT_TX_FIFO_ALMOST_EMPTY
1826 ///   //   RAIL_EVENT_RX_FIFO_ALMOST_FULL
1827 /// }
1828 /// @endcode
1829 ///
1830 /// Initializing RAIL for \ref RAIL_DataMethod_t::FIFO_MODE requires a few
1831 /// more function calls:
1832 /// @code{.c}
1833 /// extern RAIL_Handle_t railHandle;
1834 ///
1835 /// void config_rail_for_fifo_mode_operation(void)
1836 /// {
1837 ///   RAIL_DataConfig_t railDataConfig = {
1838 ///     .txSource = TX_PACKET_DATA,
1839 ///     .rxSource = RX_PACKET_DATA,
1840 ///     .txMethod = FIFO_MODE,
1841 ///     .rxMethod = FIFO_MODE,
1842 ///   };
1843 ///
1844 ///   (void) RAIL_ConfigData(railHandle, &railDataConfig);
1845 ///
1846 ///   // Gets the size of the FIFOs.
1847 ///   // Assume that the transmit and receive FIFOs are the same size
1848 ///   uint16_t fifoSize = RAIL_GetTxFifoSpaceAvailable(railHandle);
1849 ///
1850 ///   // Sets the transmit and receive FIFO thresholds.
1851 ///   // For this example, set the threshold in the middle of each FIFO.
1852 ///   (void) RAIL_SetRxFifoThreshold(railHandle, fifoSize / 2);
1853 ///   (void) RAIL_SetTxFifoThreshold(railHandle, fifoSize / 2);
1854 ///
1855 ///   // Events that can occur in FIFO mode:
1856 ///   //   RAIL_EVENT_TX_FIFO_ALMOST_EMPTY
1857 ///   //   RAIL_EVENT_TX_UNDERFLOW
1858 ///   //   RAIL_EVENT_TXACK_UNDERFLOW
1859 ///   //   RAIL_EVENT_TX_PACKET_SENT
1860 ///   //   RAIL_EVENT_RX_FIFO_ALMOST_FULL
1861 ///   //   RAIL_EVENT_RX_FIFO_OVERFLOW
1862 ///   //   RAIL_EVENT_RX_ADDRESS_FILTERED
1863 ///   //   RAIL_EVENT_RX_PACKET_ABORTED
1864 ///   //   RAIL_EVENT_RX_FRAME_ERROR
1865 ///   //   RAIL_EVENT_RX_PACKET_RECEIVED
1866 /// }
1867 /// @endcode
1868 ///
1869 /// On receive, an application can use a different \ref RAIL_RxDataSource_t that
1870 /// is only compatible with \ref RAIL_DataMethod_t::FIFO_MODE. All that differs
1871 /// from the FIFO mode example above is the RAIL_DataConfig_t::rxSource setting.
1872 /// IQ data samples are taken at the hardware's oversample rate and the amount
1873 /// of data can easily overwhelm the CPU processing time. The sample rate
1874 /// depends on the chosen PHY, as determined by the data rate and the decimation
1875 /// chain. It is <b>not</b> recommended to use the IQ data source with sample
1876 /// rates above 300 k samples/second because the CPU might not be able to keep up
1877 /// with the data stream. Depending on the application and the needed CPU
1878 /// bandwidth, slower data rates may be required. On EFR32xG22 and later
1879 /// platforms, it is recommended to reset the RX buffer before initiating a
1880 /// receive for all modes except \ref RAIL_RxDataSource_t::RX_PACKET_DATA since
1881 /// the RX buffer has to be 32-bit aligned. If the buffer is <b>not</b> reset
1882 /// but is 32-bit aligned, capture is performed on the remaining space available.
1883 /// If the buffer is <b>not</b> reset and is <b>not</b> 32-bit aligned, then
1884 /// RAIL_ConfigData() returns \ref RAIL_STATUS_INVALID_STATE.
1885 /// @code{.c}
1886 /// // Reset RX buffer (EFR32xG22 and later platforms)
1887 /// RAIL_ResetFifo(railHandle, false, true);
1888 ///
1889 /// // IQ data is provided into the receive FIFO.
1890 /// RAIL_DataConfig_t railDataConfig = {
1891 ///   .txSource = TX_PACKET_DATA,
1892 ///   .rxSource = RX_IQDATA_FILTLSB,
1893 ///   .txMethod = FIFO_MODE,
1894 ///   .rxMethod = FIFO_MODE,
1895 /// };
1896 ///
1897 /// // IQ data comes in the following format when reading out of the FIFO:
1898 /// //------------------------------------
1899 /// // I[LSB] | I[MSB] | Q[LSB] | Q[MSB] |
1900 /// //------------------------------------
1901 /// @endcode
1902 ///
1903 /// @{
1904 
1905 /**
1906  * RAIL data management configuration
1907  *
1908  * @param[in] railHandle A RAIL instance handle.
1909  * @param[in] dataConfig A pointer to a non-NULL RAIL data configuration structure.
1910  * @return Status code indicating success of the function call.
1911  *
1912  * This function configures how RAIL manages data. The application can
1913  * configure RAIL to receive data in a packet-based or FIFO-based manner.
1914  * \ref RAIL_DataMethod_t::FIFO_MODE is necessary to receive packets larger
1915  * than the radio's receive FIFO. It is also required for receive data
1916  * sources other than \ref RAIL_RxDataSource_t::RX_PACKET_DATA.
1917  *
1918  * Generally with \ref RAIL_DataMethod_t::FIFO_MODE, the application sets
1919  * appropriate FIFO thresholds via \ref RAIL_SetTxFifoThreshold() and
1920  * \ref RAIL_SetRxFifoThreshold() and then enables and handles the
1921  * \ref RAIL_EVENT_TX_FIFO_ALMOST_EMPTY event callback (to feed more packet
1922  * data via \ref RAIL_WriteTxFifo() before the FIFO underflows) and the \ref
1923  * RAIL_EVENT_RX_FIFO_ALMOST_FULL event callback (to consume packet data
1924  * via \ref RAIL_ReadRxFifo() before the receive FIFO overflows).
1925  *
1926  * When configuring TX for \ref RAIL_DataMethod_t::FIFO_MODE, this
1927  * function resets the transmit FIFO. When configuring TX or RX for
1928  * \ref RAIL_DataMethod_t::PACKET_MODE, this function will reset
1929  * the corresponding FIFO thresholds such that they won't trigger the
1930  * \ref RAIL_EVENT_RX_FIFO_ALMOST_FULL or \ref RAIL_EVENT_TX_FIFO_ALMOST_EMPTY
1931  * events.
1932  *
1933  * When \ref RAIL_DataConfig_t::rxMethod is set to \ref
1934  * RAIL_DataMethod_t::FIFO_MODE, the radio won't drop packet data of
1935  * aborted or CRC error packets, but will present it to the application
1936  * to deal with accordingly. On completion of erroneous packets, the
1937  * \ref RAIL_Config_t::eventsCallback with \ref RAIL_EVENT_RX_PACKET_ABORTED,
1938  * \ref RAIL_EVENT_RX_FRAME_ERROR, or \ref RAIL_EVENT_RX_ADDRESS_FILTERED will
1939  * tell the application it can drop any data it read via \ref RAIL_ReadRxFifo() during reception.
1940  * For CRC error packets when the \ref RAIL_RX_OPTION_IGNORE_CRC_ERRORS
1941  * RX option is in effect, the application should check for that from the
1942  * \ref RAIL_RxPacketStatus_t obtained by calling \ref RAIL_GetRxPacketInfo().
1943  * RAIL will automatically flush any remaining packet data after reporting
1944  * one of these packet completion events or the application can explicitly
1945  * flush it by calling \ref RAIL_ReleaseRxPacket().
1946  *
1947  * When \ref RAIL_DataConfig_t::rxMethod is set to \ref
1948  * RAIL_DataMethod_t::PACKET_MODE, the radio will roll back (drop) all packet
1949  * data associated with aborted packets including those with CRC errors
1950  * (unless configured to ignore CRC errors via the
1951  * \ref RAIL_RX_OPTION_IGNORE_CRC_ERRORS RX option). The application will
1952  * never have to deal with packet data from these packets.
1953  * In either mode, the application can set RX options as needed.
1954  *
1955  * When \ref RAIL_DataConfig_t::rxSource is set to a value other than
1956  * \ref RX_PACKET_DATA and \ref RAIL_Config_t::eventsCallback
1957  * \ref RAIL_EVENT_RX_FIFO_OVERFLOW is enabled RX will be terminated
1958  * if a RX FIFO overflow occurs. If \ref RAIL_EVENT_RX_FIFO_OVERFLOW
1959  * is not enabled, data will be discarded until the overflow condition
1960  * is resolved. To continue capturing data RX must be restarted using
1961  * \ref RAIL_StartRx().
1962  *
1963  */
1964 RAIL_Status_t RAIL_ConfigData(RAIL_Handle_t railHandle,
1965                               const RAIL_DataConfig_t *dataConfig);
1966 
1967 /**
1968  * Write data to the transmit FIFO previously established by RAIL_SetTxFifo().
1969  *
1970  * @param[in] railHandle A RAIL instance handle.
1971  * @param[in] dataPtr A pointer to transmit data.
1972  * @param[in] writeLength A number of bytes to write to the transmit FIFO.
1973  * @param[in] reset If true, resets transmit FIFO before writing the data.
1974  * @return The number of bytes written to the transmit FIFO.
1975  *
1976  * This function copies writeLength bytes of data from the provided dataPtr into the
1977  * transmit FIFO previously established by \ref RAIL_SetTxFifo() or \ref RAIL_Init().
1978  * If the requested writeLength exceeds the current number of bytes open
1979  * in the transmit FIFO, the function only writes until the transmit FIFO
1980  * is full. The function returns the number of bytes written to the transmit
1981  * FIFO or returns zero if railHandle is NULL or if the transmit FIFO is full.
1982  *
1983  * @note The protocol's packet configuration, as set up by the radio
1984  *   configurator or via \ref RAIL_SetFixedLength(), determines how many
1985  *   bytes of data are consumed from the transmit FIFO for a successful transmit
1986  *   operation, not the writeLength value passed in. If not enough data has
1987  *   been put into the transmit FIFO, a \ref RAIL_EVENT_TX_UNDERFLOW event will
1988  *   occur. If too much data is put into the transmit FIFO, the extra data will
1989  *   either become the first bytes
1990  *   sent in a subsequent packet, or will be thrown away if the FIFO gets
1991  *   reset prior to the next transmit. In general, the proper number of
1992  *   packet bytes to put into the transmit FIFO are all payload bytes except
1993  *   for any CRC bytes, which the packet configuration causes to be sent
1994  *   automatically.
1995  *
1996  * @note This function does not utilize a critical section but, depending on the
1997  *   application, calling it within a critical section could be appropriate.
1998  */
1999 uint16_t RAIL_WriteTxFifo(RAIL_Handle_t railHandle,
2000                           const uint8_t *dataPtr,
2001                           uint16_t writeLength,
2002                           bool reset);
2003 
2004 /**
2005  * Set the address of the transmit FIFO, a circular buffer used for TX data,
2006  * possibly pre-populated with transmit data.
2007  *
2008  * @param[in] railHandle A RAIL instance handle.
2009  * @param[in,out] addr An appropriately-aligned (see below) pointer to a read-write memory
2010  *   location in RAM used as the transmit FIFO. This memory must persist until the next
2011  *   call to this function or \ref RAIL_SetTxFifoAlt.
2012  * @param[in] initLength A number of initial bytes already in the transmit FIFO.
2013  * @param[in] size A desired size of the transmit FIFO in bytes.
2014  * @return The transmit FIFO size in bytes, 0 if an error occurs.
2015  *
2016  * This function sets the memory location for the transmit FIFO. \ref RAIL_SetTxFifo or
2017  * \ref RAIL_SetTxFifoAlt must be called at least once before any transmit operations occur.
2018  *
2019  * FIFO size can be determined by the return value of this function. The
2020  * chosen size is determined based on the available FIFO sizes supported by the
2021  * hardware. Similarly, some hardware has stricter FIFO alignment requirements;
2022  * 32-bit alignment provides the maximum portability across all RAIL platforms.
2023  * For more on supported FIFO sizes and alignments, see chip-specific
2024  * documentation, such as \ref efr32_main. The returned FIFO size will be the
2025  * closest allowed size less than or equal to the passed in size parameter,
2026  * unless the size parameter is smaller than the minimum FIFO size, in that case
2027  * 0 is returned. If the initLength parameter is larger than the returned
2028  * size, the FIFO will be filled up to its size.
2029  *
2030  * A user may write to the custom memory location directly before calling this
2031  * function, or use \ref RAIL_WriteTxFifo() to write to the memory location after
2032  * calling this function. Users must specify the initLength for
2033  * previously-written memory to be set in the transmit FIFO.
2034  *
2035  * This function reserves the block of RAM starting at addr with a length of the
2036  * returned FIFO size, which is used internally as a circular buffer for the
2037  * transmit FIFO. It must be able to hold the entire FIFO size. The caller must
2038  * guarantee that the custom FIFO remains intact and unchanged (except via calls
2039  * to \ref RAIL_WriteTxFifo()) until the next call to this function.
2040  *
2041  * @note The protocol's packet configuration, as set up by the radio
2042  *   configurator or via RAIL_SetFixedLength(), determines how many
2043  *   bytes of data are consumed from the transmit FIFO for a successful transmit
2044  *   operation, not the initLength value passed in. If not enough data has
2045  *   been put into the transmit FIFO, a \ref RAIL_EVENT_TX_UNDERFLOW event will
2046  *   occur. If too much data is put into the transmit FIFO, the extra data
2047  *   will either become the first bytes
2048  *   sent in a subsequent packet, or will be thrown away if the FIFO gets
2049  *   reset prior to the next transmit. In general, the proper number of
2050  *   packet bytes to put into the transmit FIFO are all payload bytes except
2051  *   for any CRC bytes which the packet configuration causes to be sent
2052  *   automatically.
2053  */
2054 uint16_t RAIL_SetTxFifo(RAIL_Handle_t railHandle,
2055                         uint8_t *addr,
2056                         uint16_t initLength,
2057                         uint16_t size);
2058 
2059 /**
2060  * Set the address of the transmit FIFO, a circular buffer used for TX data which
2061  * can start at offset distance from the FIFO base address.
2062  *
2063  * @param[in] railHandle A RAIL instance handle.
2064  * @param[in,out] addr An appropriately-aligned (see \ref RAIL_SetTxFifo description)
2065  *   pointer to a read-write memory location in RAM used as the transmit FIFO. This memory
2066  *   must persist until the next call to this function or \ref RAIL_SetTxFifo.
2067  * @param[in] startOffset A number of bytes defining the start position of the TX data
2068  *   from the transmit FIFO base address, only valid if initLength is not 0.
2069  * @param[in] initLength The number of valid bytes already in the transmit FIFO after startOffset.
2070  * @param[in] size A desired size of the transmit FIFO in bytes.
2071  * @return The transmit FIFO size in bytes, 0 if an error occurs.
2072  *
2073  * This function is similar to \ref RAIL_SetTxFifo except a startOffset can be specified
2074  * to indicate where the transmit packet data starts. This allows an application to
2075  * place unaligned initial packet data within the aligned transmit FIFO (initLength > 0).
2076  * Specifying a startOffset will not reduce the FIFO threshold or affect
2077  * \ref RAIL_GetTxFifoSpaceAvailable().
2078  * \ref RAIL_SetTxFifo or \ref RAIL_SetTxFifoAlt must be called at least once before any transmit
2079  * operations occur.
2080  * FIFO size handling is quite same as \ref RAIL_SetTxFifo. Only difference is that if the
2081  * initLength plus startOffset parameters are larger than the returned size, the FIFO
2082  * will be filled up to its size from startOffset.
2083  * Note that the startOffset is essentially forgotten after the next transmit --
2084  * i.e. it applies onto to the next transmit operation, and is not re-established when
2085  * the transmit FIFO is reset.
2086  */
2087 uint16_t RAIL_SetTxFifoAlt(RAIL_Handle_t railHandle,
2088                            uint8_t *addr,
2089                            uint16_t startOffset,
2090                            uint16_t initLength,
2091                            uint16_t size);
2092 
2093 /**
2094  * Set the address of the receive FIFO, a circular buffer used for receive data.
2095  *
2096  * @param[in] railHandle A RAIL instance handle.
2097  * @param[in,out] addr A pointer to a read-write memory location in RAM used as
2098  *   the receive FIFO. This memory must persist until the next call to this
2099  *   function.
2100  * @param[in,out] size A pointer to the desired size of the receive
2101  *   FIFO in bytes. This will be updated with the actual size during the
2102  *   function call.
2103  * @return Status code indicating success of the function call.
2104  *
2105  * This function sets the memory location for the receive FIFO. It
2106  * must be called at least once before any receive operations occur.
2107  *
2108  * @note After it is called, any prior receive FIFO is orphaned. To avoid
2109  *   orphaning the default internal 512-byte receive FIFO so it does
2110  *   not unnecessarily consume RAM resources in your application,
2111  *   implement \ref RAILCb_SetupRxFifo() to call this function.
2112  *
2113  * FIFO size can be determined by the return value of this function. The
2114  * chosen size is determined based on the available FIFO sizes supported by the
2115  * hardware. Similarly, some hardware has stricter FIFO alignment requirements;
2116  * 32-bit alignment provides the maximum portability across all RAIL platforms.
2117  * For more on supported FIFO sizes and alignments, see chip-specific
2118  * documentation, such as \ref efr32_main. The returned FIFO size will be the
2119  * closest allowed size less than or equal to the passed in size parameter,
2120  * unless the size parameter is smaller than the minimum FIFO size.
2121  *
2122  * This function reserves the block of RAM starting at addr with a length
2123  * of size, which is used internally as a circular buffer for the receive FIFO.
2124  * It must be able to hold the entire FIFO size. The caller must guarantee that
2125  * the custom FIFO remains intact and unchanged (except via incoming packet data
2126  * being written) until the next call to this function.
2127  *
2128  * In multiprotocol, RAIL currently shares one receive FIFO across all
2129  * protocols. This function will return \ref RAIL_STATUS_INVALID_STATE if the
2130  * requested \ref RAIL_Handle_t is not active.
2131  */
2132 RAIL_Status_t RAIL_SetRxFifo(RAIL_Handle_t railHandle,
2133                              uint8_t *addr,
2134                              uint16_t *size);
2135 
2136 /// Set up the receive FIFO to use. This function is optional to implement.
2137 ///
2138 /// @param[in] railHandle A RAIL instance handle.
2139 /// @return Status code indicating success of the function call.
2140 ///
2141 /// This callback is called during the \ref RAIL_Init() process to set up the FIFO
2142 /// to use for received packets. If not implemented by the application,
2143 /// a default implementation from within the RAIL library will be used to
2144 /// initialize an internal default 512-byte receive FIFO.
2145 ///
2146 /// If this function returns an error, the RAIL_Init() process will fail.
2147 ///
2148 /// During this function, the application should generally call
2149 /// \ref RAIL_SetRxFifo(). If that does not happen, the application needs to
2150 /// set up the receive FIFO via a call to \ref RAIL_SetRxFifo() before attempting
2151 /// to receive any packets. An example implementation may look like the following:
2152 /// @code{.c}
2153 /// #define RX_FIFO_BYTES 1024
2154 /// static __ALIGNED(RAIL_FIFO_ALIGNMENT) uint8_t rxFifo[RX_FIFO_BYTES];
2155 ///
2156 /// RAIL_Status_t RAILCb_SetupRxFifo(RAIL_Handle_t railHandle)
2157 /// {
2158 ///   uint16_t rxFifoBytes = RX_FIFO_BYTES;
2159 ///   RAIL_Status_t status = RAIL_SetRxFifo(railHandle, &rxFifo[0], &rxFifoBytes);
2160 ///   if (rxFifoBytes != RX_FIFO_BYTES) {
2161 ///     // We set up an incorrect FIFO size
2162 ///     return RAIL_STATUS_INVALID_PARAMETER;
2163 ///   }
2164 ///   if (status == RAIL_STATUS_INVALID_STATE) {
2165 ///     // Allow failures due to multiprotocol
2166 ///     return RAIL_STATUS_NO_ERROR;
2167 ///   }
2168 ///   return status;
2169 /// }
2170 /// @endcode
2171 RAIL_Status_t RAILCb_SetupRxFifo(RAIL_Handle_t railHandle);
2172 
2173 /**
2174  * Read packet data from RAIL's receive FIFO.
2175  *
2176  * @param[in] railHandle A RAIL instance handle.
2177  * @param[out] dataPtr An application-provided pointer to store data.
2178  *   If NULL, the data is thrown away rather than copied out.
2179  * @param[in] readLength A number of packet bytes to read from the FIFO.
2180  * @return The number of packet bytes read from the receive FIFO.
2181  *
2182  * This function reads packet data from the head of receive FIFO and
2183  * writes it to the provided dataPtr. It does not permit reading more
2184  * data than is available in the FIFO, nor does it permit reading more
2185  * data than remains in the oldest unreleased packet.
2186  *
2187  * Because this function does not have a critical section, use it
2188  * only in one context or make sure function calls are protected to prevent
2189  * buffer corruption.
2190  *
2191  * @warning This function is intended for use only with \ref
2192  *   RAIL_DataMethod_t::FIFO_MODE and should never be called in \ref
2193  *   RAIL_DataMethod_t::PACKET_MODE where it could lead to receive FIFO
2194  *   corruption.
2195  *
2196  * @note When reading data from an arriving packet that is not yet complete,
2197  *   keep in mind its data is highly suspect because it has not yet passed
2198  *   any CRC integrity checking. Also note that the packet could be aborted,
2199  *   canceled, or fail momentarily, invalidating its data in Packet mode.
2200  *   Furthermore, there is a small chance towards the end of packet reception
2201  *   that the receive FIFO could include not only packet data received so far,
2202  *   but also some raw radio-appended info detail bytes that RAIL's
2203  *   packet-completion processing will subsequently deal with. It's up to the
2204  *   application to know its packet format well enough to avoid reading this
2205  *   info because it will corrupt the packet's details and possibly corrupt the
2206  *   receive FIFO.
2207  */
2208 uint16_t RAIL_ReadRxFifo(RAIL_Handle_t railHandle,
2209                          uint8_t *dataPtr,
2210                          uint16_t readLength);
2211 
2212 /**
2213  * Configure the RAIL transmit FIFO almost empty threshold.
2214  *
2215  * @param[in] railHandle A RAIL instance handle.
2216  * @param[in] txThreshold The threshold below which the
2217  *   \ref RAIL_EVENT_TX_FIFO_ALMOST_EMPTY event will fire.
2218  * @return Configured transmit FIFO threshold value.
2219  *
2220  * This function configures the threshold for the transmit FIFO. When the
2221  * number of bytes in the transmit FIFO falls below the configured threshold,
2222  * \ref RAIL_Config_t::eventsCallback will fire with \ref
2223  * RAIL_EVENT_TX_FIFO_ALMOST_EMPTY set.
2224  * The txThreshold value should be smaller than or equal to the transmit
2225  * FIFO size; higher values will be pegged to the FIFO size.
2226  * A value of 0 or \ref RAIL_FIFO_THRESHOLD_DISABLED will disable the
2227  * threshold, returning \ref RAIL_FIFO_THRESHOLD_DISABLED.
2228  */
2229 uint16_t RAIL_SetTxFifoThreshold(RAIL_Handle_t railHandle,
2230                                  uint16_t txThreshold);
2231 
2232 /**
2233  * Configure the RAIL receive FIFO almost full threshold.
2234  *
2235  * @param[in] railHandle A RAIL instance handle.
2236  * @param[in] rxThreshold The threshold above which the
2237  *   \ref RAIL_EVENT_RX_FIFO_ALMOST_FULL event will fire.
2238  * @return Configured receive FIFO threshold value.
2239  *
2240  * This function configures the threshold for the receive FIFO. When the
2241  * number of bytes of packet data in the receive FIFO exceeds the
2242  * configured threshold, \ref RAIL_Config_t::eventsCallback will keep
2243  * firing with \ref RAIL_EVENT_RX_FIFO_ALMOST_FULL set as long as the
2244  * number of bytes in the receive FIFO exceeds the configured threshold
2245  * value. The rxThreshold value should be smaller than the receive FIFO
2246  * size; anything else, including a value of
2247  * \ref RAIL_FIFO_THRESHOLD_DISABLED, will disable the threshold,
2248  * returning \ref RAIL_FIFO_THRESHOLD_DISABLED.
2249  *
2250  * @note To avoid sticking in the event handler (even in idle state):
2251  *   1. Disable the event (via the config events API or the
2252  *      \ref RAIL_FIFO_THRESHOLD_DISABLED parameter).
2253  *   2. Increase FIFO threshold.
2254  *   3. Read the FIFO (that's not an option in
2255  *      \ref RAIL_DataMethod_t::PACKET_MODE) in the event handler.
2256  */
2257 uint16_t RAIL_SetRxFifoThreshold(RAIL_Handle_t railHandle,
2258                                  uint16_t rxThreshold);
2259 
2260 /**
2261  * Get the RAIL transmit FIFO almost empty threshold value.
2262  *
2263  * @param[in] railHandle A RAIL instance handle.
2264  * @return Configured TX Threshold value in bytes.
2265  *
2266  * Retrieves the configured TX threshold value.
2267  */
2268 uint16_t RAIL_GetTxFifoThreshold(RAIL_Handle_t railHandle);
2269 
2270 /**
2271  * Get the RAIL receive FIFO almost full threshold value.
2272  *
2273  * @param[in] railHandle A RAIL instance handle.
2274  * @return Configured RX Threshold value in bytes.
2275  *
2276  * Retrieves the configured RX threshold value.
2277  */
2278 uint16_t RAIL_GetRxFifoThreshold(RAIL_Handle_t railHandle);
2279 
2280 /**
2281  * Reset the RAIL transmit and/or receive FIFOs.
2282  *
2283  * @param[in] railHandle A RAIL instance handle.
2284  * @param[in] txFifo If true, reset the transmit FIFO.
2285  * @param[in] rxFifo If true, reset the receive FIFO and its internal metadata FIFO.
2286  * @return Status code indicating success of the function call.
2287  *
2288  * This function can reset each FIFO independently.
2289  * The application should not reset the receive FIFO while receiving a frame,
2290  * nor should it reset the transmit FIFO while transmitting a frame.
2291  */
2292 RAIL_Status_t RAIL_ResetFifo(RAIL_Handle_t railHandle, bool txFifo, bool rxFifo);
2293 
2294 /**
2295  * Get the number of bytes used in the receive FIFO.
2296  * Only use this function in RX \ref RAIL_DataMethod_t::FIFO_MODE.
2297  * Apps should use \ref RAIL_GetRxPacketInfo() instead.
2298  *
2299  * @param[in] railHandle A RAIL instance handle.
2300  * @return Number of bytes used in the receive FIFO.
2301  *
2302  * This function indicates how much packet-related data exists in the receive
2303  * FIFO that could be read.
2304  *
2305  * @note The number of bytes returned may not just reflect the current
2306  *   packet's data but could also include raw appended info bytes added
2307  *   after successful packet reception and bytes from subsequently received
2308  *   packets. It is up to the app to never try to consume more than the
2309  *   packet's actual data when using the value returned here in a subsequent
2310  *   call to \ref RAIL_ReadRxFifo(), otherwise the receive FIFO will be corrupted.
2311  */
2312 uint16_t RAIL_GetRxFifoBytesAvailable(RAIL_Handle_t railHandle);
2313 
2314 /**
2315  * Get the number of bytes unused in the transmit FIFO.
2316  *
2317  * @param[in] railHandle A RAIL instance handle.
2318  * @return Number of bytes unused in the transmit FIFO.
2319  *
2320  * This function indicates how much space is available in the transmit FIFO
2321  * for writing additional packet data.
2322  */
2323 uint16_t RAIL_GetTxFifoSpaceAvailable(RAIL_Handle_t railHandle);
2324 
2325 /** @} */ // end of group Data_Management
2326 
2327 /******************************************************************************
2328  * State Transitions
2329  *****************************************************************************/
2330 /**
2331  * @addtogroup State_Transitions State Transitions
2332  * @{
2333  */
2334 
2335 /**
2336  * Configure RAIL automatic state transitions after RX.
2337  *
2338  * @param[in] railHandle A RAIL instance handle.
2339  * @param[in] transitions A pointer to the state transitions to apply after reception.
2340  * @return Status code indicating success of the function call.
2341  *
2342  * This function fails if unsupported transitions are passed in or if the
2343  * radio is currently in the RX state. Success can transition to TX, RX, or
2344  * IDLE, while error can transition to RX or IDLE. The timings of state
2345  * transitions from the RX state are not guaranteed when packets are longer
2346  * than 16 seconds on-air.
2347  */
2348 RAIL_Status_t RAIL_SetRxTransitions(RAIL_Handle_t railHandle,
2349                                     const RAIL_StateTransitions_t *transitions);
2350 
2351 /**
2352  * Get the current RAIL automatic state transitions after RX.
2353  *
2354  * @param[in] railHandle A RAIL instance handle.
2355  * @param[out] transitions A pointer to the state transitions that RAIL applies after receive.
2356  * @return Status code indicating a success of the function call.
2357  *
2358  * Retrieves the current state transitions after RX and stores them in the
2359  * transitions argument.
2360  */
2361 RAIL_Status_t RAIL_GetRxTransitions(RAIL_Handle_t railHandle,
2362                                     RAIL_StateTransitions_t *transitions);
2363 
2364 /**
2365  * Configure RAIL automatic state transitions after TX.
2366  *
2367  * @param[in] railHandle A RAIL instance handle.
2368  * @param[in] transitions A pointer to the state transitions to apply after transmission.
2369  * @return Status code indicating a success of the function call.
2370  *
2371  * This function fails if unsupported transitions are passed in or if the
2372  * radio is currently in the TX state. Success and error can each transition
2373  * to RX or IDLE only, not TX. For the ability to run repeated transmits, see
2374  * \ref RAIL_SetNextTxRepeat(). Calling this function will clear any repeated
2375  * transmissions set up by \ref RAIL_SetNextTxRepeat().
2376  */
2377 RAIL_Status_t RAIL_SetTxTransitions(RAIL_Handle_t railHandle,
2378                                     const RAIL_StateTransitions_t *transitions);
2379 
2380 /**
2381  * Get the current RAIL automatic state transitions after TX.
2382  *
2383  * @param[in] railHandle A RAIL instance handle.
2384  * @param[out] transitions A pointer to the state transitions that RAIL applies after transmission.
2385  * @return Status code indicating a success of the function call.
2386  *
2387  * Retrieves the current state transitions after TX and stores them in the
2388  * transitions argument.
2389  */
2390 RAIL_Status_t RAIL_GetTxTransitions(RAIL_Handle_t railHandle,
2391                                     RAIL_StateTransitions_t *transitions);
2392 
2393 /**
2394  * Set up automatic repeated transmits after the next transmit.
2395  *
2396  * @param[in] railHandle A RAIL instance handle.
2397  * @param[in] repeatConfig A pointer to the configuration structure for repeated transmits.
2398  * @return Status code indicating a success of the function call.
2399  *
2400  * Repeated transmits will occur after an application-initiated transmit caused
2401  * by calling one of the \ref Packet_TX APIs. The repetition will only occur
2402  * after the first application-initiated transmit after this function is
2403  * called. Future repeated transmits must be requested by calling this function
2404  * again.
2405  *
2406  * Each repeated transmit that occurs will have full \ref PTI information, and
2407  * will receive events such as \ref RAIL_EVENT_TX_PACKET_SENT as normal.
2408  *
2409  * If a TX error occurs during the repetition, the process will abort and the
2410  * TX error transition from \ref RAIL_SetTxTransitions() will be used. If the
2411  * repetition completes successfully, then the TX success transition from
2412  * \ref RAIL_SetTxTransitions() will be used.
2413  *
2414  * Use \ref RAIL_GetTxPacketsRemaining() if need to know how many transmit
2415  * completion events are expected before the repeating sequence is done, or
2416  * how many were not performed due to a transmit error.
2417  *
2418  * Any call to \ref RAIL_Idle(), \ref RAIL_StopTx(), or \ref
2419  * RAIL_SetTxTransitions() will clear the pending
2420  * repeated transmits. The state will also be cleared by another call to this
2421  * function. A DMP switch will clear this
2422  * state only if the initial transmit triggering the repeated transmits has
2423  * started.
2424  *
2425  * One can change the repeated transmit configuration by re-calling
2426  * this function with new parameters as long as that occurs prior to
2427  * calling a \ref Packet_TX API. Passing a \ref
2428  * RAIL_TxRepeatConfig_t::iterations count of 0 will prevent the next
2429  * transmit from repeating.
2430  *
2431  * The application is responsible for populating the transmit data to be used
2432  * by the repeated transmits via \ref RAIL_SetTxFifo() or \ref RAIL_WriteTxFifo().
2433  * Data will be transmitted from the transmit FIFO. If the transmit FIFO does
2434  * not have sufficient data to transmit, a TX error will be caused and a \ref
2435  * RAIL_EVENT_TX_UNDERFLOW will occur. In order to avoid an underflow, the
2436  * application should queue data to be transmitted as early as possible.
2437  * Consider using \ref RAIL_TX_OPTION_RESEND if the same packet data is to
2438  * be repeated: then the transmit FIFO only needs to be set/written once.
2439  *
2440  * Do not call this function after starting a transmit operation via a \ref
2441  * Packet_TX API call or
2442  * before processing the final transmit completion event of a prior transmit.
2443  * This function will fail to (re)configure the repetition if a transmit of any
2444  * kind is ongoing, including during the time between an initial transmit and
2445  * the end of a previously-configured repetition.
2446  *
2447  * @note Use the compile time symbol \ref RAIL_SUPPORTS_TX_TO_TX or the runtime
2448  *   call \ref RAIL_SupportsTxToTx() to check whether the platform supports
2449  *   this feature.
2450  */
2451 RAIL_Status_t RAIL_SetNextTxRepeat(RAIL_Handle_t railHandle,
2452                                    const RAIL_TxRepeatConfig_t *repeatConfig);
2453 
2454 /**
2455  * Get the number of transmits remaining in a repeat operation.
2456  * Must only be called from within event callback context when handling
2457  * one of the \ref RAIL_EVENTS_TX_COMPLETION events.
2458  *
2459  * @param[in] railHandle A RAIL instance handle.
2460  * @return transmits remaining as described below.
2461  *
2462  * If the TX completion event is \ref RAIL_EVENT_TX_PACKET_SENT the
2463  * returned value indicates how many more such events are expected
2464  * before the repeat transmit operation is done. Due to interrupt
2465  * latency and timing, this may be an overcount if greater than 0
2466  * but is guaranteed to be accurate when 0.
2467  *
2468  * If the TX completion event is an error, the returned value indicates
2469  * the number of requested transmits that were not performed. For
2470  * \ref RAIL_EVENT_TX_ABORTED and \ref RAIL_EVENT_TX_UNDERFLOW the
2471  * count does not include the failing transmit itself. For the other
2472  * errors where a transmit never started or was blocked, the count
2473  * would include the failing transmit, which may be one higher than
2474  * the configured \ref RAIL_TxRepeatConfig_t::iterations if it was
2475  * the original transmit that was blocked.
2476  *
2477  * If an infinite repeat was configured, this will return \ref
2478  * RAIL_TX_REPEAT_INFINITE_ITERATIONS.
2479  */
2480 uint16_t RAIL_GetTxPacketsRemaining(RAIL_Handle_t railHandle);
2481 
2482 /**
2483  * Configure RAIL automatic state transition timing.
2484  *
2485  * @param[in] railHandle A RAIL instance handle.
2486  * @param[in,out] timings A pointer to the timings used to configure the RAIL state
2487  *   machine. This structure is updated with the actual times that were
2488  *   set, if an input timing is invalid.
2489  * @return Status code indicating a success of the function call.
2490  *
2491  * The timings given are close to the actual transition time. However,
2492  * a still uncharacterized software overhead occurs. Also, timings are not
2493  * always adhered to when using an automatic transition after an error, due to
2494  * the cleanup required to recover from the error.
2495  */
2496 RAIL_Status_t RAIL_SetStateTiming(RAIL_Handle_t railHandle,
2497                                   RAIL_StateTiming_t *timings);
2498 
2499 /**
2500  * Place the radio into an idle state.
2501  *
2502  * @param[in] railHandle A RAIL instance handle.
2503  * @param[in] mode The method for shutting down the radio.
2504  * @param[in] wait Whether this function should wait for the radio to reach
2505  *   idle before returning.
2506  * @return \ref RAIL_STATUS_NO_ERROR if the radio has idled by the time this
2507  *   function returns, or \ref RAIL_STATUS_SUSPENDED if it is still in the
2508  *   process of idling.
2509  *
2510  * This function is used to remove the radio from TX and RX states. How these
2511  * states are left is defined by the mode parameter.
2512  *
2513  * In multiprotocol, this API will also cause the radio to be yielded so that
2514  * other tasks can be run. See \ref rail_radio_scheduler_yield for more details.
2515  */
2516 RAIL_Status_t RAIL_Idle(RAIL_Handle_t railHandle,
2517                         RAIL_IdleMode_t mode,
2518                         bool wait);
2519 
2520 /**
2521  * Get the current radio state.
2522  *
2523  * @param[in] railHandle A RAIL instance handle.
2524  * @return An enumeration for the current radio state.
2525  *
2526  * Returns the state of the radio as a bitmask containing:
2527  * \ref RAIL_RF_STATE_IDLE, \ref RAIL_RF_STATE_RX, \ref RAIL_RF_STATE_TX,
2528  * and \ref RAIL_RF_STATE_ACTIVE. \ref RAIL_RF_STATE_IDLE, \ref
2529  * RAIL_RF_STATE_RX, and \ref RAIL_RF_STATE_TX bits are mutually exclusive.
2530  * The radio can transition through intermediate states,
2531  * which are not reported but are instead considered part of the state
2532  * most closely associated. For example, when the radio is warming up
2533  * or shutting down the transmitter or receiver, this function returns
2534  * \ref RAIL_RF_STATE_TX or \ref RAIL_RF_STATE_RX, respectively.
2535  * When transitioning directly from RX to TX or vice-versa, this function
2536  * returns the earlier state.
2537  *
2538  * @note For a more detailed radio state, see \ref RAIL_GetRadioStateDetail().
2539  */
2540 RAIL_RadioState_t RAIL_GetRadioState(RAIL_Handle_t railHandle);
2541 
2542 /**
2543  * Get the detailed current radio state.
2544  *
2545  * @param[in] railHandle A RAIL instance handle.
2546  * @return An enumeration for the current detailed radio state.
2547  *
2548  * Returns the state of the radio as a bitmask. The three core radio states
2549  * IDLE, RX, and TX are represented by mutually exclusive bits \ref
2550  * RAIL_RF_STATE_DETAIL_IDLE_STATE, \ref RAIL_RF_STATE_DETAIL_RX_STATE, and
2551  * \ref RAIL_RF_STATE_DETAIL_TX_STATE respectively. If the radio is
2552  * transitioning between these three states, the returned bitmask will have
2553  * \ref RAIL_RF_STATE_DETAIL_TRANSITION set along with a bit corresponding to
2554  * the destination core radio state. If, while in the receive state, the radio
2555  * is actively receiving a packet, \ref RAIL_RF_STATE_DETAIL_ACTIVE will be set;
2556  * otherwise, this bit will be clear. If frame detection is disabled, \ref
2557  * RAIL_RF_STATE_DETAIL_NO_FRAMES in the returned state bitmask will be set;
2558  * otherwise, this bit will be clear. If the radio is performing an LBT/CSMA
2559  * operation (e.g., a backoff period) \ref RAIL_RF_STATE_DETAIL_LBT in the
2560  * returned state bitmask will be set; otherwise, this bit will be clear.
2561  *
2562  * For the most part, the more detailed radio states returned by this API
2563  * correspond to radio states returned by \ref RAIL_GetRadioState() as follows:
2564  *
2565  *   \ref RAIL_RadioStateDetail_t        \ref RAIL_RadioState_t
2566  *   RAIL_RF_STATE_DETAIL_INACTIVE       RAIL_RF_STATE_INACTIVE
2567  *   RAIL_RF_STATE_DETAIL_IDLE_STATE
2568  *   | RAIL_STATE_DETAIL_TRANSITION      If RX overflow or leaving RX unforced:
2569  *                                         RAIL_RF_STATE_RX
2570  *                                       Else if leaving TX unforced:
2571  *                                         RAIL_RF_STATE_TX
2572  *                                       Else:
2573  *                                         RAIL_RF_STATE_IDLE
2574  *   RAIL_RF_STATE_DETAIL_IDLE_STATE     RAIL_RF_STATE_IDLE
2575  *   RAIL_RF_STATE_DETAIL_IDLE_STATE
2576  *   | RAIL_STATE_DETAIL_LBT             RAIL_RF_STATE_TX
2577  *   RAIL_RF_STATE_DETAIL_RX_STATE
2578  *   | RAIL_STATE_DETAIL_TRANSITION      If leaving TX:
2579  *                                         RAIL_RF_STATE_TX
2580  *                                       Else:
2581  *                                         RAIL_RF_STATE_RX
2582  *   RAIL_RF_STATE_DETAIL_RX_STATE
2583  *   | RAIL_RF_STATE_DETAIL_TRANSITION
2584  *   | RAIL_RF_STATE_DETAIL_NO_FRAMES    If leaving TX:
2585  *                                         RAIL_RF_STATE_TX
2586  *                                       Else:
2587  *                                         RAIL_RF_STATE_RX
2588  *   RAIL_RF_STATE_DETAIL_RX_STATE       RAIL_RF_STATE_RX
2589  *   RAIL_RF_STATE_DETAIL_RX_STATE
2590  *   | RAIL_RF_STATE_DETAIL_NO_FRAMES    RAIL_RF_STATE_RX
2591  *   RAIL_RF_STATE_DETAIL_RX_STATE
2592  *   | RAIL_RF_STATE_DETAIL_LBT          RAIL_RF_STATE_RX
2593  *   RAIL_RF_STATE_DETAIL_RX_STATE
2594  *   | RAIL_RF_STATE_DETAIL_NO_FRAMES
2595  *   | RAIL_RF_STATE_DETAIL_LBT          RAIL_RF_STATE_RX
2596  *   RAIL_RF_STATE_DETAIL_RX_STATE
2597  *   | RAIL_RF_STATE_DETAIL_ACTIVE       RAIL_RF_STATE_RX_ACTIVE
2598  *   RAIL_RF_STATE_DETAIL_TX_STATE
2599  *   | RAIL_RF_STATE_TRANSITION          If leaving RX:
2600  *                                         RAIL_RF_STATE_RX
2601  *                                       Else:
2602  *                                         RAIL_RF_STATE_TX
2603  *   RAIL_RF_STATE_DETAIL_TX_STATE
2604  *   | RAIL_RF_STATE_ACTIVE              RAIL_RF_STATE_TX_ACTIVE
2605  */
2606 RAIL_RadioStateDetail_t RAIL_GetRadioStateDetail(RAIL_Handle_t railHandle);
2607 
2608 /**
2609  * Enable/disable caching of synth calibration value.
2610  *
2611  * @param[in] railHandle A RAIL instance handle.
2612  * @param[in] enable A boolean to enable or disable caching of synth calibration.
2613  * @return Status code indicating success of the function call.
2614  *
2615  * Once enabled, the sequencer will start caching synth calibration values for
2616  * channels and apply them instead of performing calibration on every state
2617  * transition and channel change.
2618  * This will increase the transition time for the first time calibration is
2619  * performed. Subsequent state transitions will be faster. The cache size is 2.
2620  * \ref RAIL_IEEE802154_SUPPORTS_RX_CHANNEL_SWITCHING internally uses this feature
2621  * and there is no need to enable/disable it. This function returns
2622  * \ref RAIL_STATUS_INVALID_STATE if we try to disable it while
2623  * \ref RAIL_IEEE802154_SUPPORTS_RX_CHANNEL_SWITCHING is enabled.
2624  *
2625  * @note This function will improve the minimum timings that can be achieved in
2626  *   \ref RAIL_StateTiming_t::idleToRx, \ref RAIL_StateTiming_t::idleToTx,
2627  *   \ref RAIL_StateTiming_t::rxToTx, \ref RAIL_StateTiming_t::txToRx and
2628  *   \ref RAIL_StateTiming_t::txToTx. A call to \ref RAIL_SetStateTiming()
2629  *   is needed to achieve lower transition times.
2630  *
2631  * @note On a protocol switch the cache is cleared, so it is not suitable for
2632  *   applications where a protocol switch happens frequently, like with
2633  *   Dynamic Multiprotocol.
2634  */
2635 RAIL_Status_t RAIL_EnableCacheSynthCal(RAIL_Handle_t railHandle, bool enable);
2636 
2637 /** @} */ // end of group State_Transitions
2638 
2639 /******************************************************************************
2640  * Transmit
2641  *****************************************************************************/
2642 /**
2643  * @addtogroup Transmit
2644  * @brief APIs related to transmitting data packets
2645  * @{
2646  */
2647 
2648 /// @addtogroup PA Power Amplifier (PA)
2649 /// @brief APIs for interacting with one of the on chip PAs.
2650 ///
2651 /// These APIs let you configure the on-chip PA to get the appropriate output
2652 /// power.
2653 ///
2654 /// These are the function types:
2655 ///   1) Configuration functions: These functions set and get configuration
2656 ///      for the PA. In this case, "configuration" refers to a) indicating
2657 ///      which PA to use, b) the voltage supplied by your board to the PA,
2658 ///      and c) the ramp time over which to ramp the PA up to its full
2659 ///      power.
2660 ///   2) Power-setting functions: These functions consume the actual
2661 ///      values written to the PA registers and write them appropriately.
2662 ///      These values are referred to as "(raw) power levels". The range of
2663 ///      acceptable values for these functions depends on which PA is
2664 ///      currently active. The higher the power level set, the higher
2665 ///      the dBm power output by the radio. However, the mapping
2666 ///      between dBm and these power levels can vary greatly between
2667 ///      modules/boards.
2668 ///   3) Conversion functions: These functions convert
2669 ///      between the "power levels" discussed previously and the
2670 ///      dBm values output by the radio. Continue reading for more information
2671 ///      about unit conversion.
2672 ///
2673 /// The accuracy of the radio output power is application-specific.
2674 /// For some protocols or channels, the protocol itself or
2675 /// legal limitations require applications to know exactly what power
2676 /// they're transmitting at, in dBm. Other applications do not have
2677 /// these restrictions, and users determine power level(s)
2678 /// that fit their criteria for the trade-off between radio range and
2679 /// power savings, regardless of what dBm power that maps to.
2680 ///
2681 /// \ref RAIL_ConvertRawToDbm() and \ref RAIL_ConvertDbmToRaw(),
2682 /// which convert between the dBm power and the raw power levels,
2683 /// provide a solution that fits all these applications.
2684 /// The levels of customization are outlined below:
2685 ///  1) No customization needed: for a given dBm value, the result
2686 ///     of \ref RAIL_ConvertDbmToRaw() provides an appropriate
2687 ///     raw power level that, when written to the registers via
2688 ///     \ref RAIL_SetTxPower(), causes the radio to output at that
2689 ///     dBm power. In this case, no action is needed by the user,
2690 ///     the WEAK versions of the conversion functions can be used
2691 ///     and the default include paths in pa_conversions_efr32.h can
2692 ///     be used.
2693 ///  2) The mapping of power level to dBm is not ideal, but the
2694 ///     level of precision is sufficient: In pa_conversions_efr32.c,
2695 ///     the WEAK versions of the conversion functions work by using
2696 ///     8-segment piecewise linear curves to convert between dBm
2697 ///     and power levels for PA's with hundreds of power levels
2698 ///     and simple mapping tables for use with PA's with only a few
2699 ///     levels. If this method is sufficiently precise, but the mapping
2700 ///     between power levels and dBm is incorrect,
2701 ///     copy pa_curves_efr32.h into a new file, updating the segments
2702 ///     to form a better fit (_DCDC_CURVES or _VBAT_CURVES defines) and
2703 ///     then add the RAIL_PA_CURVES define to your build with the path
2704 ///     to the new file.
2705 ///  3) A different level of precision is needed and the fit is bad:
2706 ///     If the piecewise-linear line segment fit is not appropriate for
2707 ///     your solution, the functions in pa_conversions_efr32.c can be
2708 ///     totally rewritten, as long as \ref RAIL_ConvertDbmToRaw() and
2709 ///     \ref RAIL_ConvertRawToDbm() have the same signatures. It is completely
2710 ///     acceptable to re-write these in a way that makes the
2711 ///     pa_curves_efr32.h and pa_curve_types_efr32.h files referenced in
2712 ///     pa_conversions_efr32.h unnecessary. Those files are needed solely
2713 ///     for the provided conversion methods.
2714 ///  4) dBm values are not necessary: If the application does not require
2715 ///     dBm values at all, overwrite \ref
2716 ///     RAIL_ConvertDbmToRaw() and \ref RAIL_ConvertRawToDbm() with smaller functions
2717 ///     (i.e., return 0 or whatever was input). These functions are called
2718 ///     from within the RAIL library, so they can never be deadstripped,
2719 ///     but making them as small as possible is the best way to reduce code
2720 ///     size. From there, call \ref RAIL_SetTxPower(), without
2721 ///     converting from a dBm value. To stop the library from coercing the
2722 ///     power based on channels, overwrite \ref RAIL_ConvertRawToDbm()
2723 ///     to always return 0 and overwrite \ref RAIL_ConvertDbmToRaw() to
2724 ///     always return 255.
2725 ///
2726 /// The following is example code that shows how to initialize your PA
2727 /// @code{.c}
2728 /// #include "pa_conversions_efr32.h"
2729 ///
2730 /// // A macro RAIL_TX_POWER_CURVES_CONFIG is used as the curve
2731 /// // structures used by the provided conversion functions.
2732 /// RAIL_TxPowerCurvesConfigAlt_t tx_power_curves_config = RAIL_TX_POWER_CURVES_CONFIG;
2733 /// // Saves those curves
2734 /// // to be referenced when the conversion functions are called.
2735 /// RAIL_InitTxPowerCurves(rail_handle, &tx_power_curves_config);
2736 ///
2737 /// // Declares the structure used to configure the PA.
2738 /// RAIL_TxPowerConfig_t txPowerConfig = {
2739 ///   .mode     = RAIL_TX_POWER_MODE_2P4_HP,
2740 ///   .voltage  = 3300,
2741 ///   .rampTime = 10,
2742 /// };
2743 ///
2744 /// // Initializes the PA. Here, it is assumed that 'railHandle' is a valid RAIL_Handle_t
2745 /// // that has already been initialized.
2746 /// RAIL_ConfigTxPower(railHandle, &txPowerConfig);
2747 ///
2748 /// // Picks a dBm power to use: 100 deci-dBm = 10 dBm. See docs on RAIL_TxPower_t.
2749 /// RAIL_TxPower_t power = 100;
2750 ///
2751 /// // Gets the config written by RAIL_ConfigTxPower() to confirm what was actually set.
2752 /// RAIL_GetTxPowerConfig(railHandle, &txPowerConfig);
2753 ///
2754 /// // RAIL_ConvertDbmToRaw() is the default weak version,
2755 /// // or the customer version, if overwritten.
2756 /// RAIL_TxPowerLevel_t powerLevel
2757 ///   = RAIL_ConvertDbmToRaw(railHandle, txPowerConfig.mode, power);
2758 ///
2759 /// // Writes the result of the conversion to the PA power registers in terms
2760 /// // of raw power levels.
2761 /// RAIL_SetTxPower(railHandle, powerLevel);
2762 /// @endcode
2763 ///
2764 /// @note All lines following "RAIL_TxPower_t power = 100;" can be
2765 ///   replaced with the provided utility function, \ref RAIL_SetTxPowerDbm().
2766 ///   However, the full example here was provided for clarity. See the
2767 ///   documentation on \ref RAIL_SetTxPowerDbm() for more details.
2768 ///
2769 /// @{
2770 
2771 /**
2772  * Initialize TX power settings.
2773  *
2774  * @param[in] railHandle A RAIL instance handle.
2775  * @param[in] config A pointer to a power config with the desired initial settings
2776  *   for the TX amplifier.
2777  * @return Status code indicating success of the function call.
2778  *
2779  * These settings include the selection between the multiple TX amplifiers,
2780  * voltage supplied to the TX power amplifier, and ramp times. This must
2781  * be called before any transmit occurs or \ref RAIL_SetTxPower() is called.
2782  * While this function should always be called during initialization,
2783  * it can also be called any time if these settings need to change to adapt
2784  * to a different application/protocol. This API also resets TX power to
2785  * \ref RAIL_TX_POWER_LEVEL_INVALID, so \ref RAIL_SetTxPower() must be called
2786  * afterwards.
2787  *
2788  * At times, certain combinations of configurations cannot be achieved.
2789  * This API attempts to get as close as possible to the requested settings. The
2790  * following "RAIL_GetTxPower..." API can be used to determine what values were set. A
2791  * change in \ref RAIL_TxPowerConfig_t::rampTime may affect the minimum timings
2792  * that can be achieved in \ref RAIL_StateTiming_t::idleToTx and
2793  * \ref RAIL_StateTiming_t::rxToTx. Call \ref RAIL_SetStateTiming() again to
2794  * check whether these times have changed.
2795  */
2796 RAIL_Status_t RAIL_ConfigTxPower(RAIL_Handle_t railHandle,
2797                                  const RAIL_TxPowerConfig_t *config);
2798 
2799 /**
2800  * Get the TX power settings currently used in the amplifier.
2801  *
2802  * @param[in] railHandle A RAIL instance handle.
2803  * @param[out] config A non-NULL pointer to a \ref
2804  *   RAIL_TxPowerConfig_t structure filled in by the function.
2805  * @return Status code indicating success of the function call.
2806  *
2807  * Note that this API does not return the current TX power, which is separately
2808  * managed by the \ref RAIL_GetTxPower() / \ref RAIL_SetTxPower() APIs. Use this API
2809  * to determine which values were set as a result of
2810  * \ref RAIL_ConfigTxPower().
2811  */
2812 RAIL_Status_t RAIL_GetTxPowerConfig(RAIL_Handle_t railHandle,
2813                                     RAIL_TxPowerConfig_t *config);
2814 
2815 /**
2816  * Set the TX power in units of raw units (see \ref rail_chip_specific.h for
2817  * value ranges).
2818  *
2819  * @param[in] railHandle A RAIL instance handle.
2820  * @param[in] powerLevel Power in radio-specific \ref RAIL_TxPowerLevel_t units.
2821  * @return Status code indicating success of the function call.
2822  *
2823  * To convert between decibels and the integer values that the
2824  * registers take, call \ref RAIL_ConvertDbmToRaw().
2825  * A weak version of this function, which works well with our boards is provided. However,
2826  * customers using a custom board need to characterize
2827  * radio operation on that board and override the function to convert
2828  * appropriately from the desired dB values to raw integer values.
2829  *
2830  * Depending on the configuration used in \ref RAIL_ConfigTxPower(), not all
2831  * power levels are achievable. This API will get as close as possible to
2832  * the desired power without exceeding it, and calling \ref RAIL_GetTxPower() is
2833  * the only way to know the exact value written.
2834  *
2835  * Calling this function before configuring the PA (i.e., before a successful
2836  * call to \ref RAIL_ConfigTxPower()) will return an error.
2837  */
2838 RAIL_Status_t RAIL_SetTxPower(RAIL_Handle_t railHandle,
2839                               RAIL_TxPowerLevel_t powerLevel);
2840 
2841 /**
2842  * Return the current power setting of the PA.
2843  *
2844  * @param[in] railHandle A RAIL instance handle.
2845  * @return The radio-specific \ref RAIL_TxPowerLevel_t value of the current
2846  *   transmit power.
2847  *
2848  * This API returns the raw value that was set by \ref RAIL_SetTxPower().
2849  * A weak version of \ref RAIL_ConvertRawToDbm() that works
2850  * with Silicon Labs boards to convert the raw values into actual output dBm values is provided.
2851  * However, customers using a custom board need to
2852  * re-characterize the relationship between raw and decibel values and rewrite
2853  * the provided function.
2854  *
2855  * Calling this function before configuring the PA (i.e., before a successful
2856  * call to \ref RAIL_ConfigTxPower()) will return error \ref
2857  * RAIL_TX_POWER_LEVEL_INVALID.
2858  */
2859 RAIL_TxPowerLevel_t RAIL_GetTxPower(RAIL_Handle_t railHandle);
2860 
2861 /**
2862  * Convert raw values written to registers to decibel value (in units of
2863  * deci-dBm).
2864  *
2865  * @param[in] railHandle A RAIL instance handle.
2866  * @param[in] mode PA mode for which to convert.
2867  * @param[in] powerLevel A raw amplifier register value to be converted to
2868  *   deci-dBm.
2869  * @return raw amplifier values converted to units of deci-dBm.
2870  *
2871  * A weak version of this function is provided that is tuned
2872  * to provide accurate values for our boards. For a
2873  * custom board, the relationship between what is written to the TX amplifier
2874  * and the actual output power should be re-characterized and implemented in an
2875  * overriding version of \ref RAIL_ConvertRawToDbm(). For minimum code size and
2876  * best speed, use only raw values with the \ref RAIL_SetTxPower() API and override this
2877  * function with a smaller function. In the weak version provided with the RAIL
2878  * library, railHandle is only used to indicate to the user from where the
2879  * function was called, so it is okay to use either a real protocol handle, or one
2880  * of the radio-generic ones, such as \ref RAIL_EFR32_HANDLE.
2881  *
2882  * Although the definitions of this function may change, the signature
2883  * must be as declared here.
2884  */
2885 RAIL_TxPower_t RAIL_ConvertRawToDbm(RAIL_Handle_t railHandle,
2886                                     RAIL_TxPowerMode_t mode,
2887                                     RAIL_TxPowerLevel_t powerLevel);
2888 
2889 /**
2890  * Convert the desired decibel value (in units of deci-dBm)
2891  * to raw integer values used by the TX amplifier registers.
2892  *
2893  * @param[in] railHandle A RAIL instance handle.
2894  * @param[in] mode PA mode for which to do the conversion.
2895  * @param[in] power Desired dBm value in units of deci-dBm.
2896  * @return deci-dBm value converted to a raw
2897  *   integer value that can be used directly with \ref RAIL_SetTxPower().
2898  *
2899  * A weak version of this function is provided that is tuned
2900  * to provide accurate values for our boards. For a
2901  * custom board, the relationship between what is written to the TX amplifier
2902  * and the actual output power should be characterized and implemented in an
2903  * overriding version of \ref RAIL_ConvertDbmToRaw(). For minimum code size and
2904  * best speed use only raw values with the \ref RAIL_SetTxPower() API and override this
2905  * function with a smaller function. In the weak version provided with the RAIL
2906  * library, railHandle is only used to indicate to the user from where the
2907  * function was called, so it is okay to use either a real protocol handle, or one
2908  * of the radio-generic ones, such as \ref RAIL_EFR32_HANDLE.
2909  *
2910  * Although the definitions of this function may change, the signature
2911  * must be as declared here.
2912  */
2913 RAIL_TxPowerLevel_t RAIL_ConvertDbmToRaw(RAIL_Handle_t railHandle,
2914                                          RAIL_TxPowerMode_t mode,
2915                                          RAIL_TxPower_t power);
2916 
2917 struct RAIL_TxPowerCurvesConfigAlt;
2918 /// Verify the TX Power Curves on modules.
2919 ///
2920 /// @param[in] config A pointer to TX Power Curves to use on this module.
2921 /// @return Status code indicating success of function call.
2922 ///
2923 /// This function only needs to be called when using a module and has no
2924 /// effect otherwise. Transmit will not work before this function is called.
2925 RAIL_Status_t RAIL_VerifyTxPowerCurves(const struct RAIL_TxPowerCurvesConfigAlt *config);
2926 
2927 /// Set the TX power in terms of deci-dBm instead of raw power level.
2928 ///
2929 /// @param[in] railHandle A RAIL instance handle.
2930 /// @param[in] power A desired deci-dBm power to be set.
2931 /// @return Status code indicating success of the function call.
2932 ///
2933 /// This is a utility function for user convenience. Normally, to set TX
2934 /// power in dBm, do the following:
2935 /// @code{.c}
2936 /// RAIL_TxPower_t power = 100; // 100 deci-dBm, 10 dBm
2937 /// RAIL_TxPowerConfig_t txPowerConfig;
2938 /// RAIL_GetTxPowerConfig(railHandle, &txPowerConfig);
2939 /// // RAIL_ConvertDbmToRaw() will be the weak version provided by Silicon Labs
2940 /// // by default, or the customer version, if overwritten.
2941 /// RAIL_TxPowerLevel_t powerLevel
2942 ///   = RAIL_ConvertDbmToRaw(railHandle, txPowerConfig.mode, power);
2943 /// RAIL_SetTxPower(railHandle, powerLevel);
2944 /// @endcode
2945 ///
2946 /// This function wraps all those calls in a single function with power passed in
2947 /// as a parameter.
2948 ///
2949 RAIL_Status_t RAIL_SetTxPowerDbm(RAIL_Handle_t railHandle,
2950                                  RAIL_TxPower_t power);
2951 
2952 /// Get the TX power in terms of deci-dBm instead of raw power level.
2953 ///
2954 /// @param[in] railHandle A RAIL instance handle.
2955 /// @return The current output power in deci-dBm.
2956 ///
2957 /// This is a utility function for user convenience. Normally, to get TX
2958 /// power in dBm, do the following:
2959 /// @code{.c}
2960 /// RAIL_TxPowerLevel_t powerLevel = RAIL_GetTxPower(railHandle);
2961 /// RAIL_TxPowerConfig_t txPowerConfig;
2962 /// RAIL_GetTxPowerConfig(railHandle, &txPowerConfig);
2963 /// // RAIL_ConvertRawToDbm() will be the weak version provided by Silicon Labs
2964 /// // by default, or the customer version, if overwritten.
2965 /// RAIL_TxPower_t power
2966 ///   = RAIL_ConvertRawToDbm(railHandle, txPowerConfig.mode, powerLevel);
2967 /// return power;
2968 /// @endcode
2969 ///
2970 /// This function wraps all those calls in a single function with power returned
2971 /// as the result.
2972 ///
2973 RAIL_TxPower_t RAIL_GetTxPowerDbm(RAIL_Handle_t railHandle);
2974 
2975 /**
2976  * Get the TX PA power setting table and related values.
2977  *
2978  * @param[in] railHandle A RAIL instance handle.
2979  * @param[in] mode PA mode for which to get the powersetting table.
2980  * @param[out] minPower A pointer to a \ref RAIL_TxPower_t.
2981  * @param[out] maxPower A pointer to a \ref RAIL_TxPower_t.
2982  * @param[out] step A pointer to a \ref RAIL_TxPowerLevel_t, but in deci-dBm units.
2983  * @return Power setting table start address. When NULL is returned all out params
2984  *   above won't be set.
2985  *
2986  * The number of entries in the table can be calculated based on output
2987  * minPower, maxPower, and step parameters.
2988  * For example, for minPower = 115 (11.5 dBm), maxPower = 300 (30 dBm),
2989  * and step = 1 (0.1 dBm), the number of entries in table would be 186.
2990  */
2991 const RAIL_PaPowerSetting_t *RAIL_GetPowerSettingTable(RAIL_Handle_t railHandle, RAIL_TxPowerMode_t mode,
2992                                                        RAIL_TxPower_t *minPower, RAIL_TxPower_t *maxPower,
2993                                                        RAIL_TxPowerLevel_t *step);
2994 
2995 /**
2996  * Set the TX PA power setting used to configure the PA hardware for the PA output
2997  * power determined by \ref RAIL_SetTxPowerDbm().
2998  *
2999  * @param[in] railHandle A RAIL instance handle.
3000  * @param[in] paPowerSetting The desired PA power setting.
3001  * @param[in] minPowerDbm The minimum power in dBm that the PA can output.
3002  * @param[in] maxPowerDbm The maximum power in dBm that the PA can output.
3003  * @param[in] currentPowerDbm The corresponding output power in dBm for this power setting.
3004  * @return Status code indicating success of the function call.
3005  */
3006 RAIL_Status_t RAIL_SetPaPowerSetting(RAIL_Handle_t railHandle,
3007                                      RAIL_PaPowerSetting_t paPowerSetting,
3008                                      RAIL_TxPower_t minPowerDbm,
3009                                      RAIL_TxPower_t maxPowerDbm,
3010                                      RAIL_TxPower_t currentPowerDbm);
3011 
3012 /**
3013  * Get the TX PA power setting, which is used to configure power configurations
3014  * when the dBm to paPowerSetting mapping table mode is used.
3015  *
3016  * @param[in] railHandle A RAIL instance handle.
3017  * @return The current PA power setting.
3018  */
3019 RAIL_PaPowerSetting_t RAIL_GetPaPowerSetting(RAIL_Handle_t railHandle);
3020 
3021 /**
3022  * Enable automatic switching between PAs internally to the RAIL library.
3023  *
3024  * @param[in] railHandle A real RAIL instance handle.
3025  * @param[in] enable Enable or disable PA Auto Mode.
3026  * @return Status code indicating success of the function call.
3027  *
3028  * While PA Automode is enabled, the PA will be chosen and set automatically whenever
3029  * \ref RAIL_SetTxPowerDbm() is called or whenever powers are coerced automatically,
3030  * internally to the RAIL library during a channel change. While PA Auto Mode
3031  * is enabled, users cannot call \ref RAIL_ConfigTxPower() or
3032  * \ref RAIL_SetTxPower(). When entering auto mode, \ref RAIL_SetTxPowerDbm() must
3033  * be called to specify the desired power. When leaving auto mode,
3034  * \ref RAIL_ConfigTxPower() as well as one of \ref RAIL_SetTxPower() or
3035  * \ref RAIL_SetTxPowerDbm() must be called to re-specify the desired PA and power
3036  * level combination.
3037  *
3038  * @note: Power conversion curves must be initialized before calling this function.
3039  *   That is, \ref RAIL_ConvertDbmToRaw() and \ref RAIL_ConvertRawToDbm() most both be
3040  *   able to operate properly to ensure that PA Auto Mode functions correctly.
3041  *   See the PA Conversions plugin or AN1127 for more details.
3042  */
3043 RAIL_Status_t RAIL_EnablePaAutoMode(RAIL_Handle_t railHandle, bool enable);
3044 
3045 /**
3046  * Query status of PA Auto Mode.
3047  *
3048  * @param[in] railHandle A real RAIL instance handle.
3049  * @return Indicator of whether Auto Mode is enabled (true) or not (false).
3050  */
3051 bool RAIL_IsPaAutoModeEnabled(RAIL_Handle_t railHandle);
3052 
3053 /**
3054  * Callback that decides which PA and power level should be
3055  * used while in PA auto mode.
3056  *
3057  * @param[in] railHandle A RAIL instance handle.
3058  * @param[in,out] power A pointer to the dBm output power (in deci-dBm, 10*dBm)
3059  *   being requested. The value this points to when the function returns
3060  *   will be applied to the radio.
3061  * @param[out] mode A pointer to the \ref RAIL_TxPowerMode_t to be used to
3062  *   achieve the requested power. The value this points to when the function
3063  *   returns will be applied to the radio.
3064  * @param[in] chCfgEntry A pointer to a \ref RAIL_ChannelConfigEntry_t.
3065  *   While switching channels, it will be the entry RAIL is switch *to*,
3066  *   during a call to \ref RAIL_SetTxPowerDbm(), it will be the entry
3067  *   RAIL is *already on*. Can be NULL if a channel configuration
3068  *   was not set or no valid channels are present.
3069  * @return Status code indicating success of the function call. If this
3070  *   is anything except \ref RAIL_STATUS_NO_ERROR, neither PA's nor their
3071  *   powers will be configured automatically.
3072  *
3073  * Whatever values mode and powerLevel point to when this function return
3074  * will be applied to the PA hardware and used for transmits.
3075  *
3076  * @note The mode and power level provided by this function depends on the
3077  *   \ref RAIL_PaAutoModeConfig provided for the radio. The \ref RAIL_PaAutoModeConfig
3078  *   definition for a radio should tend to cover all the bands supported by the radio
3079  *   and cover the full range of power in each to find a valid entry for requested power
3080  *   for a specific band.
3081  */
3082 RAIL_Status_t RAILCb_PaAutoModeDecision(RAIL_Handle_t railHandle,
3083                                         RAIL_TxPower_t *power,
3084                                         RAIL_TxPowerMode_t *mode,
3085                                         const RAIL_ChannelConfigEntry_t *chCfgEntry);
3086 
3087 /** @} */ // end of group PA
3088 
3089 /// @addtogroup Packet_TX Packet Transmit
3090 /// @brief APIs which initiate a packet transmission in RAIL.
3091 ///
3092 /// When using any of these functions, the data to be transmitted must have been
3093 /// previously written to the transmit FIFO via \ref RAIL_SetTxFifo() and/or
3094 /// \ref RAIL_WriteTxFifo().
3095 ///
3096 /// @{
3097 
3098 /**
3099  * Start a transmit.
3100  *
3101  * @param[in] railHandle A RAIL instance handle.
3102  * @param[in] channel Define the channel to transmit on.
3103  * @param[in] options TX options to be applied to this transmit only.
3104  * @param[in] schedulerInfo A pointer to information to allow the radio scheduler to place
3105  *   this transmit appropriately. This is only used in multiprotocol version of
3106  *   RAIL and may be set to NULL in all other versions.
3107  * @return Status code indicating success of the function call. If successfully
3108  *   initiated, transmit completion or failure will be reported by a later
3109  *   \ref RAIL_Config_t::eventsCallback with the appropriate \ref RAIL_Events_t.
3110  *
3111  * The transmit process will begin immediately or as soon as a packet being
3112  * received has finished. The data to be transmitted must have been previously
3113  * established via \ref RAIL_SetTxFifo() and/or \ref RAIL_WriteTxFifo().
3114  *
3115  * Returns an error if a previous transmit is still in progress.
3116  * If changing channels, any ongoing packet reception is aborted.
3117  *
3118  * In multiprotocol, ensure that the radio is properly yielded after this
3119  * operation completes. See \ref rail_radio_scheduler_yield for more details.
3120  */
3121 RAIL_Status_t RAIL_StartTx(RAIL_Handle_t railHandle,
3122                            uint16_t channel,
3123                            RAIL_TxOptions_t options,
3124                            const RAIL_SchedulerInfo_t *schedulerInfo);
3125 
3126 /**
3127  * Schedule sending a packet.
3128  *
3129  * @param[in] railHandle A RAIL instance handle.
3130  * @param[in] channel The channel to transmit on.
3131  * @param[in] options TX options to be applied to this transmit only.
3132  * @param[in] config A pointer to the \ref RAIL_ScheduleTxConfig_t
3133  *   structure indicating when and how the transmit should occur.
3134  * @param[in] schedulerInfo A pointer to information to allow the radio scheduler to place
3135  *   this transmit appropriately. This is only used in multiprotocol version of
3136  *   RAIL and may be set to NULL in all other versions.
3137  * @return Status code indicating success of the function call. If successfully
3138  *   initiated, a transmit completion or failure will be reported by a later
3139  *   \ref RAIL_Config_t::eventsCallback with the appropriate \ref RAIL_Events_t.
3140  *
3141  * The transmit process will begin at the scheduled time. The data to be
3142  * transmitted must have been previously established via \ref RAIL_SetTxFifo()
3143  * and/or \ref RAIL_WriteTxFifo().
3144  * The time (in microseconds) and whether that time is absolute or
3145  * relative is specified using the \ref RAIL_ScheduleTxConfig_t structure.
3146  * What to do if a scheduled transmit fires in
3147  * the middle of receiving a packet is also specified in this structure.
3148  *
3149  * Returns an error if a previous transmit is still in progress.
3150  * If changing channels, the channel is changed immediately and
3151  * will abort any ongoing packet reception.
3152  *
3153  * In multiprotocol, ensure that the radio is properly yielded after this
3154  * operation completes. See \ref rail_radio_scheduler_yield for more details.
3155  */
3156 RAIL_Status_t RAIL_StartScheduledTx(RAIL_Handle_t railHandle,
3157                                     uint16_t channel,
3158                                     RAIL_TxOptions_t options,
3159                                     const RAIL_ScheduleTxConfig_t *config,
3160                                     const RAIL_SchedulerInfo_t *schedulerInfo);
3161 
3162 /**
3163  * Start a transmit using CSMA.
3164  *
3165  * @param[in] railHandle A RAIL instance handle.
3166  * @param[in] channel The channel to transmit on.
3167  * @param[in] options TX options to be applied to this transmit only.
3168  * @param[in] csmaConfig A pointer to the RAIL_CsmaConfig_t structure
3169  *   describing the CSMA parameters to use for this transmit.
3170  *   \n In multiprotocol this must point to global or heap storage that remains
3171  *   valid after the API returns until the transmit is actually started.
3172  * @param[in] schedulerInfo A pointer to information to allow the radio scheduler to place
3173  *   this transmit appropriately. This is only used in multiprotocol version of
3174  *   RAIL and may be set to NULL in all other versions.
3175  * @return Status code indicating success of the function call. If successfully
3176  *   initiated, a transmit completion or failure will be reported by a later
3177  *   \ref RAIL_Config_t::eventsCallback with the appropriate \ref RAIL_Events_t.
3178  *
3179  * Perform the Carrier Sense Multiple Access (CSMA) algorithm, and if
3180  * the channel is deemed clear (RSSI below the specified threshold), it will
3181  * commence transmission. The data to be transmitted must have been previously
3182  * established via \ref RAIL_SetTxFifo() and/or \ref RAIL_WriteTxFifo().
3183  * Packets can be received during CSMA backoff periods if receive is active
3184  * throughout the CSMA process. This will happen either by starting the CSMA
3185  * process while receive is already active, or if the \ref
3186  * RAIL_CsmaConfig_t::ccaBackoff time is less than the RAIL_StateTiming_t::idleToRx
3187  * time. If the \ref RAIL_CsmaConfig_t::ccaBackoff time is greater than the
3188  * \ref RAIL_StateTiming_t::idleToRx time, receive will only be active during
3189  * CSMA's clear channel assessments.
3190  *
3191  * If the CSMA algorithm deems the channel busy, the \ref RAIL_Config_t::eventsCallback
3192  * occurs with \ref RAIL_EVENT_TX_CHANNEL_BUSY, and the contents
3193  * of the transmit FIFO remain intact.
3194  *
3195  * Returns an error if a previous transmit is still in progress.
3196  * If changing channels, the channel is changed immediately and any ongoing
3197  * packet reception is aborted.
3198  *
3199  * Returns an error if a scheduled RX is still in progress.
3200  *
3201  * In multiprotocol, ensure that the radio is properly yielded after this
3202  * operation completes. See \ref rail_radio_scheduler_yield for more details.
3203  */
3204 RAIL_Status_t RAIL_StartCcaCsmaTx(RAIL_Handle_t railHandle,
3205                                   uint16_t channel,
3206                                   RAIL_TxOptions_t options,
3207                                   const RAIL_CsmaConfig_t *csmaConfig,
3208                                   const RAIL_SchedulerInfo_t *schedulerInfo);
3209 
3210 /**
3211  * Start a transmit using LBT.
3212  *
3213  * @param[in] railHandle A RAIL instance handle.
3214  * @param[in] channel The channel to transmit on.
3215  * @param[in] options TX options to be applied to this transmit only.
3216  * @param[in] lbtConfig A pointer to the \ref RAIL_LbtConfig_t structure
3217  *   describing the LBT parameters to use for this transmit.
3218  *   \n In multiprotocol this must point to global or heap storage that remains
3219  *   valid after the API returns until the transmit is actually started.
3220  * @param[in] schedulerInfo A pointer to information to allow the radio scheduler to place
3221  *   this transmit appropriately. This is only used in multiprotocol version of
3222  *   RAIL and may be set to NULL in all other versions.
3223  * @return Status code indicating success of the function call. If successfully
3224  *   initiated, a transmit completion or failure will be reported by a later
3225  *   \ref RAIL_Config_t::eventsCallback with the appropriate \ref RAIL_Events_t.
3226  *
3227  * Performs the Listen Before Talk (LBT) algorithm, and if the channel
3228  * is deemed clear (RSSI below the specified threshold), it will commence
3229  * transmission. The data to be transmitted must have been previously established
3230  * via \ref RAIL_SetTxFifo() and/or \ref RAIL_WriteTxFifo().
3231  * Packets can be received during LBT backoff periods if receive is active
3232  * throughout the LBT process. This will happen either by starting the LBT
3233  * process while receive is already active, or if the \ref
3234  * RAIL_LbtConfig_t::lbtBackoff time is less than the \ref RAIL_StateTiming_t::idleToRx
3235  * time. If the \ref RAIL_LbtConfig_t::lbtBackoff time is greater than the
3236  * \ref RAIL_StateTiming_t::idleToRx time, receive will only be active during
3237  * LBT's clear channel assessments.
3238  *
3239  * If the LBT algorithm deems the channel busy, the \ref RAIL_Config_t::eventsCallback occurs with
3240  * \ref RAIL_EVENT_TX_CHANNEL_BUSY, and the contents
3241  * of the transmit FIFO remain intact.
3242  *
3243  * Returns an error if a previous transmit is still in progress.
3244  * If changing channels, the channel is changed immediately and any ongoing
3245  * packet reception is aborted.
3246  *
3247  * Returns an error if a scheduled RX is still in progress.
3248  *
3249  * In multiprotocol, ensure that the radio is properly yielded after this
3250  * operation completes. See \ref rail_radio_scheduler_yield for more details.
3251  */
3252 RAIL_Status_t RAIL_StartCcaLbtTx(RAIL_Handle_t railHandle,
3253                                  uint16_t channel,
3254                                  RAIL_TxOptions_t options,
3255                                  const RAIL_LbtConfig_t *lbtConfig,
3256                                  const RAIL_SchedulerInfo_t *schedulerInfo);
3257 
3258 /**
3259  * Schedule a transmit using CSMA.
3260  *
3261  * @param[in] railHandle A RAIL instance handle.
3262  * @param[in] channel The channel to transmit on.
3263  * @param[in] options TX options to be applied to this transmit only.
3264  * @param[in] scheduleTxConfig A pointer to the \ref RAIL_ScheduleTxConfig_t
3265  *   structure describing the CSMA parameters to use for this transmit.
3266  * @param[in] csmaConfig A pointer to the \ref RAIL_CsmaConfig_t structure
3267  *   describing the CSMA parameters to use for this transmit.
3268  *   \n In multiprotocol this must point to global or heap storage that remains
3269  *   valid after the API returns until the transmit is actually started.
3270  * @param[in] schedulerInfo A pointer to information to allow the radio scheduler to place
3271  *   this transmit appropriately. This is only used in multiprotocol version of
3272  *   RAIL and may be set to NULL in all other versions.
3273  * @return Status code indicating success of the function call. If successfully
3274  *   initiated, a transmit completion or failure will be reported by a later
3275  *   \ref RAIL_Config_t::eventsCallback with the appropriate \ref RAIL_Events_t.
3276  *
3277  * Internally, the RAIL library needs a PRS channel for this feature.
3278  * It will allocate an available PRS channel to use and hold onto that
3279  * channel for future use. If no PRS channel is available, the function
3280  * returns with \ref RAIL_STATUS_INVALID_CALL.
3281  *
3282  * This is a scheduled variation of \ref RAIL_StartCcaCsmaTx(); refer to
3283  * that function for CSMA details.
3284  *
3285  * Returns an error if a previous transmit is still in progress.
3286  * If changing channels, the channel is changed immediately and any ongoing
3287  * packet reception is aborted.
3288  *
3289  * Returns an error if a scheduled RX is still in progress.
3290  *
3291  * In multiprotocol, ensure that the radio is properly yielded after this
3292  * operation completes. See \ref rail_radio_scheduler_yield for more details.
3293  */
3294 RAIL_Status_t RAIL_StartScheduledCcaCsmaTx(RAIL_Handle_t railHandle,
3295                                            uint16_t channel,
3296                                            RAIL_TxOptions_t options,
3297                                            const RAIL_ScheduleTxConfig_t *scheduleTxConfig,
3298                                            const RAIL_CsmaConfig_t *csmaConfig,
3299                                            const RAIL_SchedulerInfo_t *schedulerInfo);
3300 
3301 /**
3302  * Schedule a transmit using LBT.
3303  *
3304  * @param[in] railHandle A RAIL instance handle.
3305  * @param[in] channel The channel to transmit on.
3306  * @param[in] options TX options to be applied to this transmit only.
3307  * @param[in] scheduleTxConfig A pointer to the \ref RAIL_ScheduleTxConfig_t
3308  *   structure describing the CSMA parameters to use for this transmit.
3309  * @param[in] lbtConfig A pointer to the \ref RAIL_LbtConfig_t structure
3310  *   describing the LBT parameters to use for this transmit.
3311  *   \n In multiprotocol this must point to global or heap storage that remains
3312  *   valid after the API returns until the transmit is actually started.
3313  * @param[in] schedulerInfo A pointer to information to allow the radio scheduler to place
3314  *   this transmit appropriately. This is only used in multiprotocol version of
3315  *   RAIL and may be set to NULL in all other versions.
3316  * @return Status code indicating success of the function call. If successfully
3317  *   initiated, a transmit completion or failure will be reported by a later
3318  *   \ref RAIL_Config_t::eventsCallback with the appropriate \ref RAIL_Events_t.
3319  *
3320  * Internally, the RAIL library needs a PRS channel for this feature.
3321  * It will allocate an available PRS channel to use and hold onto that
3322  * channel for future use. If no PRS channel is available, the function
3323  * returns with \ref RAIL_STATUS_INVALID_CALL.
3324  *
3325  * This is a scheduled variation of \ref RAIL_StartCcaLbtTx; refer to
3326  * that function for LBT details.
3327  *
3328  * Returns an error if a previous transmit is still in progress.
3329  * If changing channels, the channel is changed immediately and any ongoing
3330  * packet reception is aborted.
3331  *
3332  * Returns an error if a scheduled RX is still in progress.
3333  *
3334  * In multiprotocol, ensure that the radio is properly yielded after this
3335  * operation completes. See \ref rail_radio_scheduler_yield for more details.
3336  */
3337 RAIL_Status_t RAIL_StartScheduledCcaLbtTx(RAIL_Handle_t railHandle,
3338                                           uint16_t channel,
3339                                           RAIL_TxOptions_t options,
3340                                           const RAIL_ScheduleTxConfig_t *scheduleTxConfig,
3341                                           const RAIL_LbtConfig_t *lbtConfig,
3342                                           const RAIL_SchedulerInfo_t *schedulerInfo);
3343 
3344 /** @} */ // end of group Packet_TX
3345 
3346 /**
3347  * Stop an active or pending transmit.
3348  *
3349  * @param[in] railHandle A RAIL instance handle.
3350  * @param[in] mode Specifies the type(s) of transmit to stop.
3351  * @return \ref RAIL_STATUS_NO_ERROR if the transmit was successfully
3352  *   stopped or \ref RAIL_STATUS_INVALID_STATE if there is no transmit
3353  *   operation to stop.
3354  *
3355  * @note When mode includes \ref RAIL_STOP_MODE_ACTIVE, this can also stop
3356  *   an active Auto-Ack transmit. When an active transmit is stopped, \ref
3357  *   RAIL_EVENT_TX_ABORTED or \ref RAIL_EVENT_TXACK_ABORTED should occur.
3358  *   When mode includes \ref RAIL_STOP_MODE_PENDING this can also stop
3359  *   a \ref RAIL_TX_OPTION_CCA_ONLY transmit operation. When a pending
3360  *   transmit is stopped, \ref RAIL_EVENT_TX_BLOCKED should occur.
3361  */
3362 RAIL_Status_t RAIL_StopTx(RAIL_Handle_t railHandle, RAIL_StopMode_t mode);
3363 
3364 /**
3365  * Set the CCA threshold in dBm.
3366  *
3367  * @param[in] railHandle A RAIL instance handle.
3368  * @param[in] ccaThresholdDbm The CCA threshold in dBm.
3369  * @return Status code indicating success of the function call.
3370  *
3371  * Unlike \ref RAIL_StartCcaCsmaTx() or \ref RAIL_StartCcaLbtTx(), which can cause a
3372  * transmit, this function only modifies the CCA threshold. A possible
3373  * use case for this function involves setting the CCA threshold to invalid RSSI
3374  * of -128 which blocks transmission by preventing clear channel assessments
3375  * from succeeding.
3376  */
3377 RAIL_Status_t RAIL_SetCcaThreshold(RAIL_Handle_t railHandle,
3378                                    int8_t ccaThresholdDbm);
3379 
3380 /**
3381  * Get detailed information about the last packet transmitted.
3382  *
3383  * @param[in] railHandle A RAIL instance handle.
3384  * @param[in,out] pPacketDetails An application-provided pointer to store
3385  *   RAIL_TxPacketDetails_t corresponding to the transmit event.
3386  *   The isAck and timeSent fields totalPacketBytes and timePosition
3387  *   must be initialized prior to each call:
3388  *   - isAck true to obtain details about the most recent Ack transmit,
3389  *     false to obtain details about the most recent app-initiated transmit.
3390  *   - totalPacketBytes with the total number of bytes of the transmitted
3391  *     packet for RAIL to use when calculating the specified timestamp.
3392  *     This should account for all bytes sent over the air after the
3393  *     Preamble and Sync word(s), including CRC bytes.
3394  *   - timePosition with a \ref RAIL_PacketTimePosition_t value specifying
3395  *     the packet position to put in the timeSent field on return.
3396  *     This field will also be updated with the actual position corresponding
3397  *     to the timeSent value filled in.
3398  * @return \ref RAIL_STATUS_NO_ERROR if pPacketDetails was filled in,
3399  *   or an appropriate error code otherwise.
3400  *
3401  * @note Consider using \ref RAIL_GetTxPacketDetailsAlt2 for smaller code size.
3402  *
3403  * This function can only be called from callback context for either
3404  * \ref RAIL_EVENT_TX_PACKET_SENT or \ref RAIL_EVENT_TXACK_PACKET_SENT
3405  * events.
3406  */
3407 RAIL_Status_t RAIL_GetTxPacketDetails(RAIL_Handle_t railHandle,
3408                                       RAIL_TxPacketDetails_t *pPacketDetails);
3409 
3410 /**
3411  * Get detailed information about the last packet transmitted.
3412  *
3413  * @param[in] railHandle A RAIL instance handle.
3414  * @param[in] isAck true to obtain details about the most recent Ack transmit.
3415  *   false to obtain details about the most recent app-initiated transmit.
3416  * @param[out] pPacketTime An application-provided non-NULL pointer to store a
3417  *   RAIL_Time_t corresponding to the transmit event. This will be populated
3418  *   with a timestamp corresponding to an arbitrary location in the packet. Call
3419  *   \ref RAIL_GetTxTimePreambleStart, \ref RAIL_GetTxTimeSyncWordEnd, or
3420  *   \ref RAIL_GetTxTimeFrameEnd to adjust the timestamp for different locations
3421  *   in the packet.
3422  * @return \ref RAIL_STATUS_NO_ERROR if pPacketTime was filled in,
3423  *   or an appropriate error code otherwise.
3424  *
3425  * @note Consider using \ref RAIL_GetTxPacketDetailsAlt2 to pass in
3426  *   a \ref RAIL_PacketTimeStamp_t structure instead of a \ref RAIL_Time_t
3427  *   structure, particularly when \ref RAIL_PacketTimePosition_t information
3428  *   is needed or useful.
3429  *
3430  * This function can only be called from callback context for either
3431  * \ref RAIL_EVENT_TX_PACKET_SENT or \ref RAIL_EVENT_TXACK_PACKET_SENT
3432  * events.
3433  */
3434 RAIL_Status_t RAIL_GetTxPacketDetailsAlt(RAIL_Handle_t railHandle,
3435                                          bool isAck,
3436                                          RAIL_Time_t *pPacketTime);
3437 
3438 /**
3439  * Get detailed information about the last packet transmitted.
3440  *
3441  * @param[in] railHandle A RAIL instance handle.
3442  * @param[in,out] pPacketDetails An application-provided pointer to store
3443  *   \ref RAIL_TxPacketDetails_t corresponding to the transmit event.
3444  *   The isAck field must be initialized prior to each call:
3445  *   - isAck true to obtain details about the most recent Ack transmit,
3446  *     false to obtain details about the most recent app-initiated transmit.
3447  *   The timeSent field packetTime will be populated with a timestamp
3448  *   corresponding to a default location in the packet. The timeSent field
3449  *   timePosition will be populated with a \ref RAIL_PacketTimePosition_t value
3450  *   specifying that default packet location.
3451  *   Call \ref RAIL_GetTxTimePreambleStartAlt(),
3452  *   \ref RAIL_GetTxTimeSyncWordEndAlt(), or \ref RAIL_GetTxTimeFrameEndAlt() to
3453  *   adjust the timestamp for different locations in the packet.
3454  * @return \ref RAIL_STATUS_NO_ERROR if pPacketDetails was filled in,
3455  *   or an appropriate error code otherwise.
3456  *
3457  * This function can only be called from callback context for either
3458  * \ref RAIL_EVENT_TX_PACKET_SENT or \ref RAIL_EVENT_TXACK_PACKET_SENT
3459  * events.
3460  */
3461 RAIL_Status_t RAIL_GetTxPacketDetailsAlt2(RAIL_Handle_t railHandle,
3462                                           RAIL_TxPacketDetails_t *pPacketDetails);
3463 
3464 /**
3465  * Adjust a RAIL TX completion timestamp to refer to the start of the
3466  * preamble. Also used to retrieve the \ref RAIL_EVENT_TX_STARTED
3467  * timestamp.
3468  *
3469  * @param[in] railHandle A RAIL instance handle.
3470  * @param[in] totalPacketBytes The total number of bytes of the transmitted
3471  *   packet for RAIL to use when adjusting the provided timestamp. This
3472  *   should account for all bytes transmitted over the air after the Preamble
3473  *   and Sync word(s), including CRC bytes. Pass \ref RAIL_TX_STARTED_BYTES
3474  *   to retrieve the start-of-normal-TX timestamp (see below).
3475  * @param[in,out] pPacketTime This points to the \ref RAIL_Time_t returned
3476  *   from a previous call to \ref RAIL_GetTxPacketDetailsAlt() for this same
3477  *   packet. That time will be updated with the time that the preamble for
3478  *   this packet started on air.
3479  *   Must be non-NULL.
3480  * @return \ref RAIL_STATUS_NO_ERROR if pPacketTime was successfully
3481  *   determined or an appropriate error code otherwise.
3482  *
3483  * When used for timestamp adjustment, call this function in the
3484  * same transmit-complete event-handling context as
3485  * \ref RAIL_GetTxPacketDetailsAlt() is called.
3486  *
3487  * This function may be called when handling the \ref RAIL_EVENT_TX_STARTED
3488  * event to retrieve that event's start-of-normal-TX timestamp. (Ack
3489  * transmits currently have no equivalent event or associated timestamp.)
3490  * In this case, totalPacketBytes must be \ref RAIL_TX_STARTED_BYTES, and
3491  * pPacketTime is an output-only parameter filled in with that time (so no
3492  * need to initialize it beforehand by calling \ref
3493  * RAIL_GetTxPacketDetailsAlt()).
3494  *
3495  */
3496 RAIL_Status_t RAIL_GetTxTimePreambleStart(RAIL_Handle_t railHandle,
3497                                           uint16_t totalPacketBytes,
3498                                           RAIL_Time_t *pPacketTime);
3499 
3500 /**
3501  * Adjust a RAIL TX completion timestamp to refer to the start of the
3502  * preamble. Also used to retrieve the \ref RAIL_EVENT_TX_STARTED
3503  * timestamp.
3504  *
3505  * @param[in] railHandle A RAIL instance handle.
3506  * @param[in,out] pPacketDetails A non-NULL pointer to the details that were returned from
3507  *   a previous call to \ref RAIL_GetTxPacketDetailsAlt2() for this same packet.
3508  *   The application must update the timeSent field totalPacketBytes to be
3509  *   the total number of bytes of the sent packet for RAIL to use when
3510  *   calculating the specified timestamp. This should account for all bytes
3511  *   transmitted over the air after the Preamble and Sync word(s), including CRC
3512  *   bytes. Pass \ref RAIL_TX_STARTED_BYTES to retrieve the start-of-normal-TX
3513  *   timestamp (see below). After this function, the timeSent field packetTime
3514  *   will be updated with the time that the preamble for this packet started on air.
3515  * @return \ref RAIL_STATUS_NO_ERROR if the packet time was successfully
3516  *   calculated, or an appropriate error code otherwise.
3517  *
3518  * When used for timestamp adjustment, call this function in the
3519  * same transmit-complete event-handling context as
3520  * \ref RAIL_GetTxPacketDetailsAlt2() is called.
3521  *
3522  * This function may be called when handling the \ref RAIL_EVENT_TX_STARTED
3523  * event to retrieve that event's start-of-normal-TX timestamp. (Ack
3524  * transmits currently have no equivalent event or associated timestamp.)
3525  * In this case, the timeSent field totalPacketBytes must be
3526  * \ref RAIL_TX_STARTED_BYTES, and the timeSent field packetTime is an
3527  * output-only parameter filled in with that time (so no need to initialize
3528  * it beforehand by calling \ref RAIL_GetTxPacketDetailsAlt2()).
3529  *
3530  */
3531 RAIL_Status_t RAIL_GetTxTimePreambleStartAlt(RAIL_Handle_t railHandle,
3532                                              RAIL_TxPacketDetails_t *pPacketDetails);
3533 
3534 /**
3535  * Adjust a RAIL TX timestamp to refer to the end of the sync word.
3536  *
3537  * @param[in] railHandle A RAIL instance handle.
3538  * @param[in] totalPacketBytes The total number of bytes of the transmitted
3539  *   packet for RAIL to use when calculating the specified timestamp. This
3540  *   should account for all bytes transmitted over the air after the Preamble
3541  *   and Sync word(s), including CRC bytes.
3542  * @param[in,out] pPacketTime The time that was returned in a
3543  *   \ref RAIL_Time_t from a previous call to \ref RAIL_GetTxPacketDetailsAlt()
3544  *   for this same packet. After this function, the time at that location will
3545  *   be updated with the time that the sync word for this packet finished on
3546  *   air. Must be non-NULL.
3547  * @return \ref RAIL_STATUS_NO_ERROR if pPacketTime was successfully calculated,
3548  *   or an appropriate error code otherwise.
3549  *
3550  * Call the timestamp adjustment function in the same
3551  * transmit-complete event-handling context as
3552  * \ref RAIL_GetTxPacketDetailsAlt() is called.
3553  */
3554 RAIL_Status_t RAIL_GetTxTimeSyncWordEnd(RAIL_Handle_t railHandle,
3555                                         uint16_t totalPacketBytes,
3556                                         RAIL_Time_t *pPacketTime);
3557 
3558 /**
3559  * Adjust a RAIL TX timestamp to refer to the end of the sync word.
3560  *
3561  * @param[in] railHandle A RAIL instance handle.
3562  * @param[in,out] pPacketDetails A non-NULL pointer to the details that were returned from
3563  *   a previous call to \ref RAIL_GetTxPacketDetailsAlt2() for this same packet.
3564  *   The application must update the timeSent field totalPacketBytes to be
3565  *   the total number of bytes of the sent packet for RAIL to use when
3566  *   calculating the specified timestamp. This should account for all bytes
3567  *   transmitted over the air after the Preamble and Sync word(s), including CRC
3568  *   bytes. After this function, the timeSent field packetTime
3569  *   will be updated with the time that the sync word for this packet finished on
3570  *   air.
3571  * @return \ref RAIL_STATUS_NO_ERROR if the packet time was successfully
3572  *   calculated, or an appropriate error code otherwise.
3573  *
3574  * Call the timestamp adjustment function in the same
3575  * transmit-complete event-handling context as
3576  * \ref RAIL_GetTxPacketDetailsAlt2() is called.
3577  */
3578 RAIL_Status_t RAIL_GetTxTimeSyncWordEndAlt(RAIL_Handle_t railHandle,
3579                                            RAIL_TxPacketDetails_t *pPacketDetails);
3580 
3581 /**
3582  * Adjust a RAIL TX timestamp to refer to the end of frame.
3583  *
3584  * @param[in] railHandle A RAIL instance handle.
3585  * @param[in] totalPacketBytes The total number of bytes of the transmitted
3586  *   packet for RAIL to use when calculating the specified timestamp. This
3587  *   should account for all bytes transmitted over the air after the Preamble
3588  *   and Sync word(s), including CRC bytes.
3589  * @param[in,out] pPacketTime The time that was returned in a
3590  *   \ref RAIL_Time_t from a previous call to \ref RAIL_GetTxPacketDetailsAlt()
3591  *   for this same packet. After this function, the time at that location will
3592  *   be updated with the time that this packet finished on air. Must be
3593  *   non-NULL.
3594  * @return \ref RAIL_STATUS_NO_ERROR if pPacketTime was successfully calculated,
3595  *   or an appropriate error code otherwise.
3596  *
3597  * Call the timestamp adjustment function in the same
3598  * transmit-complete event-handling context as
3599  * \ref RAIL_GetTxPacketDetailsAlt() is called.
3600  */
3601 RAIL_Status_t RAIL_GetTxTimeFrameEnd(RAIL_Handle_t railHandle,
3602                                      uint16_t totalPacketBytes,
3603                                      RAIL_Time_t *pPacketTime);
3604 
3605 /**
3606  * Adjust a RAIL TX timestamp to refer to the end of frame.
3607  *
3608  * @param[in] railHandle A RAIL instance handle.
3609  * @param[in,out] pPacketDetails A non-NULL pointer to the details that were returned from
3610  *   a previous call to \ref RAIL_GetTxPacketDetailsAlt2() for this same packet.
3611  *   The application must update the timeSent field totalPacketBytes to be
3612  *   the total number of bytes of the sent packet for RAIL to use when
3613  *   calculating the specified timestamp. This should account for all bytes
3614  *   transmitted over the air after the Preamble and Sync word(s), including CRC
3615  *   bytes. After this function, the timeSent field packetTime
3616  *   will be updated with the time that this packet finished on air.
3617  * @return \ref RAIL_STATUS_NO_ERROR if the packet time was successfully
3618  *   calculated, or an appropriate error code otherwise.
3619  *
3620  * Call the timestamp adjustment function in the same
3621  * transmit-complete event-handling context as
3622  * \ref RAIL_GetTxPacketDetailsAlt2() is called.
3623  */
3624 RAIL_Status_t RAIL_GetTxTimeFrameEndAlt(RAIL_Handle_t railHandle,
3625                                         RAIL_TxPacketDetails_t *pPacketDetails);
3626 
3627 /**
3628  * Prevent the radio from starting a transmit.
3629  *
3630  * @param[in] railHandle A RAIL instance handle.
3631  * @param[in] enable Enable/Disable TX hold off.
3632  * @return Status code indicating success of the function call.
3633  *
3634  * Enable TX hold off to prevent the radio from starting any transmits.
3635  * Disable TX hold off to allow the radio to transmit again.
3636  * Attempting to transmit with the TX hold off enabled will result in
3637  * \ref RAIL_EVENT_TX_BLOCKED and/or \ref RAIL_EVENT_TXACK_BLOCKED
3638  * events.
3639  *
3640  * @note This function does not affect a transmit that has already started.
3641  *   To stop an already-started transmission, use \ref RAIL_Idle() with
3642  *   \ref RAIL_IDLE_ABORT.
3643  */
3644 RAIL_Status_t RAIL_EnableTxHoldOff(RAIL_Handle_t railHandle, bool enable);
3645 
3646 /**
3647  * Check whether or not TX hold off is enabled.
3648  *
3649  * @param[in] railHandle A RAIL instance handle.
3650  * @return true if TX hold off is enabled, false otherwise.
3651  *
3652  * TX hold off can be enabled/disabled using \ref RAIL_EnableTxHoldOff().
3653  * Attempting to transmit with the TX hold off enabled will block the
3654  * transmission and result in \ref RAIL_EVENT_TX_BLOCKED
3655  * and/or \ref RAIL_EVENT_TXACK_BLOCKED events.
3656  */
3657 bool RAIL_IsTxHoldOffEnabled(RAIL_Handle_t railHandle);
3658 
3659 /**
3660  * Set an alternate transmitter preamble length.
3661  *
3662  * @param[in] railHandle A RAIL instance handle.
3663  * @param[in] length The desired preamble length, in bits.
3664  * @return Status code indicating success of the function call.
3665  *
3666  * To cause a transmission to use this alternate preamble length,
3667  * specify \ref RAIL_TX_OPTION_ALT_PREAMBLE_LEN in the txOptions
3668  * parameter passed to the respective RAIL transmit API.
3669  *
3670  * @note Attempting to set a preamble length of 0xFFFF bits will result in
3671  *   \ref RAIL_STATUS_INVALID_PARAMETER.
3672  **/
3673 RAIL_Status_t RAIL_SetTxAltPreambleLength(RAIL_Handle_t railHandle, uint16_t length);
3674 
3675 /** @} */ // end of group Transmit
3676 
3677 /******************************************************************************
3678  * Receive
3679  *****************************************************************************/
3680 /**
3681  * @addtogroup Receive
3682  * @brief APIs related to packet receive
3683  * @{
3684  */
3685 
3686 /**
3687  * Configure receive options.
3688  *
3689  * @param[in] railHandle A RAIL instance handle.
3690  * @param[in] mask A bitmask containing which options should be modified.
3691  * @param[in] options A bitmask containing desired configuration settings.
3692  *   Bit positions for each option are found in the \ref RAIL_RxOptions_t.
3693  * @return Status code indicating success of the function call.
3694  *
3695  * Configure the radio receive flow based on the list of available options.
3696  * Only the options indicated by the mask parameter will be affected. Pass
3697  * \ref RAIL_RX_OPTIONS_ALL to set all parameters.
3698  * The previous settings may affect the current frame if a packet is
3699  * received during this configuration.
3700  */
3701 RAIL_Status_t RAIL_ConfigRxOptions(RAIL_Handle_t railHandle,
3702                                    RAIL_RxOptions_t mask,
3703                                    RAIL_RxOptions_t options);
3704 
3705 /**
3706  * Include the code necessary for frame type based length decoding.
3707  *
3708  * @param[in] railHandle A RAIL instance handle.
3709  * @return Status code indicating success of the function call.
3710  *
3711  * This function must be called before \ref RAIL_ConfigChannels() to allow configurations
3712  * using a frame type based length setup. It is called by default
3713  * in the \ref RAILCb_ConfigFrameTypeLength() API which can be overridden to save
3714  * code space.
3715  */
3716 RAIL_Status_t RAIL_IncludeFrameTypeLength(RAIL_Handle_t railHandle);
3717 
3718 /**
3719  * Handle frame type length.
3720  *
3721  * @param[in] railHandle A RAIL instance handle.
3722  * @param[in] frameType A pointer to a frame type configuration structure.
3723  *
3724  * This function is implemented in the radio configuration.
3725  * Currently, the frame type passed in only handles packet length decoding. If
3726  * NULL is passed into this function, it clears any currently configured
3727  * frame type settings. This will either be implemented as an empty function in
3728  * the radio configuration if it is not needed, to assist in dead code
3729  * elimination.
3730  */
3731 void RAILCb_ConfigFrameTypeLength(RAIL_Handle_t railHandle,
3732                                   const RAIL_FrameType_t *frameType);
3733 
3734 /**
3735  * Start the receiver on a specific channel.
3736  *
3737  * @param[in] railHandle A RAIL instance handle.
3738  * @param[in] channel The channel to listen on.
3739  * @param[in] schedulerInfo A pointer to information to allow the radio scheduler to place
3740  *   this receive appropriately. This is only used in multiprotocol version of
3741  *   RAIL and may be set to NULL in all other versions.
3742  * @return Status code indicating success of the function call.
3743  *
3744  * This is a non-blocking function. Whenever a packet is received, \ref RAIL_Config_t::eventsCallback
3745  * will fire with \ref RAIL_EVENT_RX_PACKET_RECEIVED set. If you call
3746  * this while not idle but with a different channel, any ongoing
3747  * receive or transmit operation will be aborted.
3748  */
3749 RAIL_Status_t RAIL_StartRx(RAIL_Handle_t railHandle,
3750                            uint16_t channel,
3751                            const RAIL_SchedulerInfo_t *schedulerInfo);
3752 
3753 /**
3754  * Schedule a receive window for some future time.
3755  *
3756  * @param[in] railHandle A RAIL instance handle.
3757  * @param[in] channel A channel to listen on.
3758  * @param[in] cfg A pointer to a configuration structure to define the receive window.
3759  * @param[in] schedulerInfo A pointer to information to allow the radio scheduler to place
3760  *   this receive appropriately. This is only used in multiprotocol version of
3761  *   RAIL and may be set to NULL in all other versions.
3762  * @return Status code indicating success of the function call.
3763  *
3764  * This API immediately changes the channel and schedules receive to start
3765  * at the specified time and end at the given end time. If you do not specify
3766  * an end time, you may call this API later with an end time as long as you set
3767  * the start time to disabled. You can also terminate the receive
3768  * operation immediately using the \ref RAIL_Idle() function. Note that relative
3769  * end times are always relative to the start unless no start time is
3770  * specified. If changing channels, the channel is changed immediately and
3771  * will abort any ongoing packet transmission or reception.
3772  *
3773  * Returns an error if a CSMA or LBT transmit is still in progress.
3774  *
3775  * In multiprotocol, ensure that you properly yield the radio after this
3776  * call. See \ref rail_radio_scheduler_yield for more details.
3777  */
3778 RAIL_Status_t RAIL_ScheduleRx(RAIL_Handle_t railHandle,
3779                               uint16_t channel,
3780                               const RAIL_ScheduleRxConfig_t *cfg,
3781                               const RAIL_SchedulerInfo_t *schedulerInfo);
3782 
3783 /**
3784  * Enable automatic PRS LNA bypass for external FEM.
3785  *
3786  * @param[in] railHandle A radio-generic or real RAIL instance handle.
3787  * @param[in] enable Enable/Disable automatic PRS LNA bypass.
3788  * @param[in] pPrsLnaBypassConfig A pointer to an automatic PRS LNA bypass
3789  *   configuration structure. It must be non-NULL to enable the feature.
3790  * @return Status code indicating success of the function call.
3791  *
3792  * If automatic PRS LNA bypass is enabled on chip that supports the feature
3793  * (\ref RAIL_SUPPORTS_PRS_LNA_BYPASS), a level is generated on a PRS channel
3794  * when the received power exceed a threshold. It is turned off after frame
3795  * reception or after timeout if no frame has been detected.
3796  *
3797  * @warning As this function relies on PRS access and RAIL is meant to run in
3798  *   TrustZone non-secure world, it is not supported if PRS is configured as
3799  *   secure peripheral and it will return \ref RAIL_STATUS_INVALID_CALL.
3800  */
3801 RAIL_Status_t RAIL_EnablePrsLnaBypass(RAIL_Handle_t railHandle,
3802                                       bool enable,
3803                                       const RAIL_PrsLnaBypassConfig_t *pPrsLnaBypassConfig);
3804 
3805 /******************************************************************************
3806  * Packet Information (RX)
3807  *****************************************************************************/
3808 /// @addtogroup Packet_Information Packet Information
3809 /// @brief APIs to get information about received packets.
3810 ///
3811 /// After receiving a packet, RAIL will trigger a
3812 /// \ref RAIL_EVENT_RX_PACKET_RECEIVED event. At that point, there is a variety
3813 /// of information available to the application about the received packet. The
3814 /// following example code assumes that the
3815 /// \ref RAIL_RX_OPTION_REMOVE_APPENDED_INFO is not used, and the application
3816 /// wants as much data about the packet as possible.
3817 /// @code{.c}
3818 /// // Get all information about a received packet.
3819 /// RAIL_Status_t status;
3820 /// RAIL_RxPacketInfo_t rxInfo;
3821 /// RAIL_RxPacketDetails_t rxDetails;
3822 /// RAIL_RxPacketHandle_t rxHandle
3823 ///   = RAIL_GetRxPacketInfo(railHandle, RAIL_RX_PACKET_HANDLE_NEWEST, &rxInfo);
3824 /// assert(rxHandle != RAIL_RX_PACKET_HANDLE_INVALID);
3825 /// status = RAIL_GetRxPacketDetailsAlt(railHandle, rxHandle, &rxDetails);
3826 /// assert(status == RAIL_STATUS_NO_ERROR);
3827 /// if (rxDetails.timeReceived.timePosition == RAIL_PACKET_TIME_INVALID) {
3828 ///   return; // No timestamp available for this packet
3829 /// }
3830 /// // CRC_BYTES only needs to be added when not using RAIL_RX_OPTION_STORE_CRC
3831 /// rxDetails.timeReceived.totalPacketBytes = rxInfo.packetBytes + CRC_BYTES;
3832 /// // Choose the function which gives the desired timestamp
3833 /// status = RAIL_GetRxTimeFrameEndAlt(railHandle, &rxDetails);
3834 /// assert(status == RAIL_STATUS_NO_ERROR);
3835 /// // Now all fields of rxInfo and rxDetails have been populated correctly
3836 /// @endcode
3837 ///
3838 /// @{
3839 
3840 /**
3841  * Get basic information about a pending or received packet.
3842  *
3843  * @param[in] railHandle A RAIL instance handle.
3844  * @param[in] packetHandle A packet handle for the unreleased packet as
3845  *   returned from a previous call, or sentinel values
3846  *   \ref RAIL_RX_PACKET_HANDLE_OLDEST,
3847  *   \ref RAIL_RX_PACKET_HANDLE_OLDEST_COMPLETE or
3848  *   \ref RAIL_RX_PACKET_HANDLE_NEWEST.
3849  * @param[out] pPacketInfo A non-NULL pointer to a \ref RAIL_RxPacketInfo_t
3850  *   to store info for the requested packet.
3851  * @return The packet handle for the requested packet:
3852  *   if packetHandle was one of the sentinel values, returns the actual
3853  *   packet handle for that packet, otherwise returns packetHandle.
3854  *   It may return \ref RAIL_RX_PACKET_HANDLE_INVALID to indicate an error.
3855  *
3856  * This function can be used in any RX mode. It does not free any receive FIFO
3857  * or internal receive resources. If used in receive
3858  * \ref RAIL_DataMethod_t::FIFO_MODE, the
3859  * value in \ref RAIL_RxPacketInfo_t::packetBytes will only return the data
3860  * remaining in the FIFO. Any data read via earlier calls to
3861  * \ref RAIL_ReadRxFifo() is not included.
3862  *
3863  * @note When getting information about an arriving packet that is not yet complete,
3864  *   (i.e., pPacketInfo->packetStatus == \ref RAIL_RX_PACKET_RECEIVING), keep
3865  *   in mind its data is highly suspect because it has not yet passed any CRC
3866  *   integrity checking. Also note that the packet could be aborted, canceled, or
3867  *   fail momentarily, invalidating its data in Packet mode. Furthermore, there
3868  *   is a small chance towards the end of packet reception that the filled-in
3869  *   \ref RAIL_RxPacketInfo_t could include not only packet data received so far,
3870  *   but also some raw radio-appended info detail bytes that RAIL's
3871  *   packet-completion processing will subsequently deal with. It's up to the
3872  *   application to know its packet format well enough to avoid confusing such
3873  *   info as packet data.
3874  */
3875 RAIL_RxPacketHandle_t RAIL_GetRxPacketInfo(RAIL_Handle_t railHandle,
3876                                            RAIL_RxPacketHandle_t packetHandle,
3877                                            RAIL_RxPacketInfo_t *pPacketInfo);
3878 
3879 /**
3880  * Get information about the live incoming packet (if any).
3881  * Differs from \ref RAIL_GetRxPacketInfo() by only returning information
3882  * about a packet actively being received, something which even the
3883  * \ref RAIL_RX_PACKET_HANDLE_NEWEST may not represent if there are
3884  * completed but unprocessed packets in the receive FIFO.
3885  *
3886  * @param[in] railHandle A RAIL instance handle.
3887  * @param[out] pPacketInfo A non-NULL pointer to store \ref RAIL_RxPacketInfo_t
3888  *   for the incoming packet.
3889  * @return Status code indicating success of the function call.
3890  *
3891  * This function can only be called from callback context, e.g.,
3892  * when handling \ref RAIL_EVENT_RX_FILTER_PASSED or
3893  * \ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND.
3894  * It must not be used with receive \ref RAIL_DataMethod_t::FIFO_MODE
3895  * if any portion of an incoming packet has already been extracted from
3896  * the receive FIFO.
3897  *
3898  * @note The incomplete data of an arriving packet is highly suspect because
3899  *   it has not yet passed any CRC integrity checking. Also note that the
3900  *   packet could be aborted, canceled, or fail momentarily, invalidating
3901  *   its data in Packet mode. Furthermore, there is a small chance towards
3902  *   the end of packet reception that the filled-in \ref RAIL_RxPacketInfo_t
3903  *   could include not only packet data received so far, but also some raw
3904  *   radio-appended info detail bytes that RAIL's packet-completion
3905  *   processing will subsequently deal with. It's up to the application to
3906  *   know its packet format well enough to avoid confusing such info as
3907  *   packet data.
3908  */
3909 RAIL_Status_t RAIL_GetRxIncomingPacketInfo(RAIL_Handle_t railHandle,
3910                                            RAIL_RxPacketInfo_t *pPacketInfo);
3911 
3912 /**
3913  * Copy a full packet to a user-specified contiguous buffer.
3914  *
3915  * @param[out] pDest A non-NULL application-provided pointer to a buffer of at
3916  *   least pPacketInfo->packetBytes in size to store the packet data
3917  *   contiguously. This buffer must never overlay RAIL's receive FIFO buffer.
3918  *   Exactly pPacketInfo->packetBytes of packet data will be written into it.
3919  * @param[in] pPacketInfo A non-NULL pointer to the
3920  *   \ref RAIL_RxPacketInfo_t for the requested packet.
3921  *
3922  * @note This is a convenience helper function, which
3923  *   is intended to be expedient. As a result, it does not
3924  *   check the validity of its arguments,
3925  *   so don't pass either as NULL, and don't
3926  *   pass a pDest pointer to a buffer that's too small for the packet's data.
3927  * @note If only a portion of the packet is needed, use \ref RAIL_PeekRxPacket()
3928  *   instead.
3929  */
3930 static inline
RAIL_CopyRxPacket(uint8_t * pDest,const RAIL_RxPacketInfo_t * pPacketInfo)3931 void RAIL_CopyRxPacket(uint8_t *pDest,
3932                        const RAIL_RxPacketInfo_t *pPacketInfo)
3933 {
3934   (void)memcpy(pDest, pPacketInfo->firstPortionData, pPacketInfo->firstPortionBytes);
3935   if (pPacketInfo->lastPortionData != NULL) {
3936     uint16_t size = pPacketInfo->packetBytes - pPacketInfo->firstPortionBytes;
3937     (void)memcpy(pDest + pPacketInfo->firstPortionBytes,
3938                  pPacketInfo->lastPortionData, size);
3939   }
3940 }
3941 
3942 /**
3943  * Get detailed information about a received packet.
3944  * This function can be used in any RX mode; it does not free any receive FIFO
3945  * or internal receive resources.
3946  *
3947  * @param[in] railHandle A RAIL instance handle.
3948  * @param[in] packetHandle A packet handle for the unreleased packet as
3949  *   returned from a previous call to RAIL_GetRxPacketInfo() or
3950  *   RAIL_HoldRxPacket(), or sentinel values \ref RAIL_RX_PACKET_HANDLE_OLDEST,
3951  *   \ref RAIL_RX_PACKET_HANDLE_OLDEST_COMPLETE
3952  *   or \ref RAIL_RX_PACKET_HANDLE_NEWEST.
3953  * @param[in,out] pPacketDetails An application-provided non-NULL pointer to
3954  *   store \ref RAIL_RxPacketDetails_t for the requested packet.
3955  *   For \ref RAIL_RxPacketStatus_t RAIL_RX_PACKET_READY_ packets,
3956  *   the timeReceived fields totalPacketBytes and timePosition must be
3957  *   initialized prior to each call:
3958  *   - totalPacketBytes with the total number of bytes of the received
3959  *     packet for RAIL to use when calculating the specified timestamp.
3960  *     This should account for all bytes received over the air after the
3961  *     Preamble and Sync word(s), including CRC bytes.
3962  *   - timePosition with a \ref RAIL_PacketTimePosition_t value specifying
3963  *     the packet position to put in the timeReceived field on return.
3964  *     This field will also be updated with the actual position corresponding
3965  *     to the timeReceived value filled in.
3966  * @return \ref RAIL_STATUS_NO_ERROR if pPacketDetails was filled in,
3967  *   or an appropriate error code otherwise.
3968  *
3969  * @note Certain details are always available, while others are only available
3970  *   if the \ref RAIL_RxOptions_t \ref RAIL_RX_OPTION_REMOVE_APPENDED_INFO
3971  *   option is not in effect and the received packet's
3972  *   \ref RAIL_RxPacketStatus_t is among the RAIL_RX_PACKET_READY_ set.
3973  *   See \ref RAIL_RxPacketDetails_t for clarification.
3974  *
3975  * @note Consider using \ref RAIL_GetRxPacketDetailsAlt for smaller code size.
3976  */
3977 RAIL_Status_t RAIL_GetRxPacketDetails(RAIL_Handle_t railHandle,
3978                                       RAIL_RxPacketHandle_t packetHandle,
3979                                       RAIL_RxPacketDetails_t *pPacketDetails);
3980 
3981 /**
3982  * Get detailed information about a received packet.
3983  * This function can be used in any RX mode; it does not free any receive FIFO
3984  * or receive internal resources.
3985  *
3986  * @param[in] railHandle A RAIL instance handle.
3987  * @param[in] packetHandle A packet handle for the unreleased packet as
3988  *   returned from a previous call to \ref RAIL_GetRxPacketInfo() or
3989  *   \ref RAIL_HoldRxPacket(), or sentinel values \ref RAIL_RX_PACKET_HANDLE_OLDEST
3990  *   \ref RAIL_RX_PACKET_HANDLE_OLDEST_COMPLETE or
3991  *   \ref RAIL_RX_PACKET_HANDLE_NEWEST.
3992  * @param[out] pPacketDetails A non-NULL application-provided pointer to
3993  *   store \ref RAIL_RxPacketDetails_t for the requested packet.
3994  *   For \ref RAIL_RxPacketStatus_t RAIL_RX_PACKET_READY_ packets,
3995  *   the timeReceived field packetTime will be populated with a timestamp
3996  *   corresponding to a default location in the packet. The timeReceived field
3997  *   timePosition will be populated with a \ref RAIL_PacketTimePosition_t value
3998  *   specifying that default packet location. Call
3999  *   \ref RAIL_GetRxTimePreambleStart(), \ref RAIL_GetRxTimeSyncWordEnd(), or
4000  *   \ref RAIL_GetRxTimeFrameEnd() to adjust that timestamp for different
4001  *   locations in the packet.
4002  * @return \ref RAIL_STATUS_NO_ERROR if pPacketDetails was filled in,
4003  *   or an appropriate error code otherwise.
4004  *
4005  * This alternative API allows for smaller code size by deadstripping the
4006  * timestamp adjustment algorithms which are not in use.
4007  *
4008  * @note Certain details are always available, while others are only available
4009  *   if the \ref RAIL_RxOptions_t \ref RAIL_RX_OPTION_REMOVE_APPENDED_INFO
4010  *   option is not in effect and the received packet's
4011  *   \ref RAIL_RxPacketStatus_t is among the RAIL_RX_PACKET_READY_ set.
4012  *   See \ref RAIL_RxPacketDetails_t for clarification.
4013  *
4014  * @note This function should be called soon (no more than a minute) after
4015  *   packet reception for the packet timestamp information to be valid.
4016  */
4017 RAIL_Status_t RAIL_GetRxPacketDetailsAlt(RAIL_Handle_t railHandle,
4018                                          RAIL_RxPacketHandle_t packetHandle,
4019                                          RAIL_RxPacketDetails_t *pPacketDetails);
4020 
4021 /**
4022  * Adjust a RAIL RX timestamp to refer to the start of the preamble.
4023  *
4024  * @param[in] railHandle A RAIL instance handle.
4025  * @param[in] totalPacketBytes The total number of bytes of the received packet
4026  *   for RAIL to use when calculating the specified timestamp. This should
4027  *   account for all bytes received over the air after the Preamble and Sync
4028  *   word(s), including CRC bytes.
4029  * @param[in,out] pPacketTime A pointer to the time that was returned in the
4030  *   \ref RAIL_PacketTimeStamp_t::packetTime field of
4031  *   \ref RAIL_RxPacketDetails_t::timeReceived from a previous call to
4032  *   \ref RAIL_GetRxPacketDetailsAlt for this same packet. After this
4033  *   function, the time at that location will be updated with the time that the
4034  *   preamble for this packet started on air. Must be non-NULL.
4035  * @return \ref RAIL_STATUS_NO_ERROR if pPacketTime was successfully calculated,
4036  *   or an appropriate error code otherwise.
4037  *
4038  * Call this API while the given railHandle is active, or it will
4039  * return an error code of \ref RAIL_STATUS_INVALID_STATE. Note that this API
4040  * may return incorrect timestamps when sub-phys are in use. Prefer
4041  * \ref RAIL_GetRxTimePreambleStartAlt in those situations. See
4042  * \ref RAIL_RxPacketDetails_t::subPhyId for more details.
4043  */
4044 RAIL_Status_t RAIL_GetRxTimePreambleStart(RAIL_Handle_t railHandle,
4045                                           uint16_t totalPacketBytes,
4046                                           RAIL_Time_t *pPacketTime);
4047 
4048 /**
4049  * Adjust a RAIL RX timestamp to refer to the start of the preamble.
4050  *
4051  * @param[in] railHandle A RAIL instance handle.
4052  * @param[in,out] pPacketDetails A non-NULL pointer to the details that were returned from
4053  *   a previous call to \ref RAIL_GetRxPacketDetailsAlt() for this same packet.
4054  *   The application must update the timeReceived field totalPacketBytes to be
4055  *   the total number of bytes of the received packet for RAIL to use when
4056  *   calculating the specified timestamp. This should account for all bytes
4057  *   received over the air after the Preamble and Sync word(s), including CRC
4058  *   bytes. After this function, the timeReceived field packetTime will be
4059  *   updated with the time that the preamble for this packet started on air.
4060  * @return \ref RAIL_STATUS_NO_ERROR if the packet time was successfully
4061  *   calculated, or an appropriate error code otherwise.
4062  */
4063 RAIL_Status_t RAIL_GetRxTimePreambleStartAlt(RAIL_Handle_t railHandle,
4064                                              RAIL_RxPacketDetails_t *pPacketDetails);
4065 
4066 /**
4067  * Adjust a RAIL RX timestamp to refer to the end of the sync word.
4068  *
4069  * @param[in] railHandle A RAIL instance handle.
4070  * @param[in] totalPacketBytes The total number of bytes of the received packet
4071  *   for RAIL to use when calculating the specified timestamp. This should
4072  *   account for all bytes received over the air after the Preamble and Sync
4073  *   word(s), including CRC bytes.
4074  * @param[in,out] pPacketTime A pointer to the time that was returned in the
4075  *   \ref RAIL_PacketTimeStamp_t::packetTime field of
4076  *   \ref RAIL_RxPacketDetails_t::timeReceived from a previous call to
4077  *   \ref RAIL_GetRxPacketDetailsAlt for this same packet. After this
4078  *   function, the time at that location will be updated with the time that the
4079  *   sync word for this packet finished on air. Must be non-NULL.
4080  * @return \ref RAIL_STATUS_NO_ERROR if pPacketTime was successfully calculated,
4081  *   or an appropriate error code otherwise.
4082  *
4083  * Call this API while the given railHandle is active, or it will
4084  * return an error code of \ref RAIL_STATUS_INVALID_STATE. Note that this API
4085  * may return incorrect timestamps when sub-phys are in use. Prefer
4086  * \ref RAIL_GetRxTimePreambleStartAlt in those situations. See
4087  * \ref RAIL_RxPacketDetails_t::subPhyId for more details.
4088  */
4089 RAIL_Status_t RAIL_GetRxTimeSyncWordEnd(RAIL_Handle_t railHandle,
4090                                         uint16_t totalPacketBytes,
4091                                         RAIL_Time_t *pPacketTime);
4092 
4093 /**
4094  * Adjust a RAIL RX timestamp to refer to the end of the sync word.
4095  *
4096  * @param[in] railHandle A RAIL instance handle.
4097  * @param[in,out] pPacketDetails A non-NULL pointer to the details that were returned from
4098  *   a previous call to \ref RAIL_GetRxPacketDetailsAlt() for this same packet.
4099  *   The application must update the timeReceived field totalPacketBytes to be
4100  *   the total number of bytes of the received packet for RAIL to use when
4101  *   calculating the specified timestamp. This should account for all bytes
4102  *   received over the air after the Preamble and Sync word(s), including CRC
4103  *   bytes. After this function, the timeReceived field packetTime will be
4104  *   updated with the time that the sync word for this packet finished on air.
4105  * @return \ref RAIL_STATUS_NO_ERROR if the packet time was successfully
4106  *   calculated, or an appropriate error code otherwise.
4107  */
4108 RAIL_Status_t RAIL_GetRxTimeSyncWordEndAlt(RAIL_Handle_t railHandle,
4109                                            RAIL_RxPacketDetails_t *pPacketDetails);
4110 
4111 /**
4112  * Adjust a RAIL RX timestamp to refer to the end of frame.
4113  *
4114  * @param[in] railHandle A RAIL instance handle.
4115  * @param[in] totalPacketBytes The total number of bytes of the received packet
4116  *   for RAIL to use when calculating the specified timestamp. This should
4117  *   account for all bytes received over the air after the Preamble and Sync
4118  *   word(s), including CRC bytes.
4119  * @param[in,out] pPacketTime A pointer to the time that was returned in the
4120  *   \ref RAIL_PacketTimeStamp_t::packetTime field of
4121  *   \ref RAIL_RxPacketDetails_t::timeReceived from a previous call to
4122  *   \ref RAIL_GetRxPacketDetailsAlt for this same packet. After this
4123  *   function, the time at that location will be updated with the time that this
4124  *   packet finished on air. Must be non-NULL.
4125  * @return \ref RAIL_STATUS_NO_ERROR if pPacketTime was successfully calculated,
4126  *   or an appropriate error code otherwise.
4127  *
4128  * Call this API while the given railHandle is active, or it will
4129  * return an error code of \ref RAIL_STATUS_INVALID_STATE. Note that this API
4130  * may return incorrect timestamps when sub-phys are in use. Prefer
4131  * \ref RAIL_GetRxTimePreambleStartAlt in those situations. See
4132  * \ref RAIL_RxPacketDetails_t::subPhyId for more details.
4133  */
4134 RAIL_Status_t RAIL_GetRxTimeFrameEnd(RAIL_Handle_t railHandle,
4135                                      uint16_t totalPacketBytes,
4136                                      RAIL_Time_t *pPacketTime);
4137 
4138 /**
4139  * Adjust a RAIL RX timestamp to refer to the end of frame.
4140  *
4141  * @param[in] railHandle A RAIL instance handle.
4142  * @param[in,out] pPacketDetails A non-NULL pointer to the details that were returned from
4143  *   a previous call to \ref RAIL_GetRxPacketDetailsAlt() for this same packet.
4144  *   The application must update the timeReceived field totalPacketBytes to be
4145  *   the total number of bytes of the received packet for RAIL to use when
4146  *   calculating the specified timestamp. This should account for all bytes
4147  *   received over the air after the Preamble and Sync word(s), including CRC
4148  *   bytes. After this function, the timeReceived field packetTime will be
4149  *   updated with the time that the packet finished on air.
4150  * @return \ref RAIL_STATUS_NO_ERROR if the packet time was successfully
4151  *   calculated, or an appropriate error code otherwise.
4152  */
4153 RAIL_Status_t RAIL_GetRxTimeFrameEndAlt(RAIL_Handle_t railHandle,
4154                                         RAIL_RxPacketDetails_t *pPacketDetails);
4155 
4156 /** @} */ // end of group Packet_Information
4157 
4158 /**
4159  * Place a temporary hold on this packet's data in the receive
4160  * FIFO and internal packet metadata FIFO.
4161  *
4162  * This function can only be called from within RAIL callback context.
4163  * It can be used in any RX mode.
4164  *
4165  * Normally, when RAIL issues its callback indicating a packet is ready
4166  * or aborted, it expects the application's callback to retrieve and
4167  * copy (or discard) the packet's information and data, and will free
4168  * the packet data and metadata after the callback returns. This function
4169  * tells RAIL to hold onto those resources in the receive FIFO and internal
4170  * metadata FIFO after the callback returns in case the application wants to
4171  * defer processing the packet to a later time, e.g., outside of callback
4172  * context.
4173  *
4174  * @param[in] railHandle A RAIL instance handle.
4175  * @return The packet handle for the packet associated with the callback,
4176  *   \ref RAIL_RX_PACKET_HANDLE_INVALID if no such packet yet exists or
4177  *   railHandle is not active.
4178  *
4179  * @note When using multiprotocol the receive FIFO and internal receive
4180  *   metadata FIFO are reset during protocol switches losing any held packets.
4181  *   It is best to avoid using \ref RAIL_HoldRxPacket in DMP or to at least
4182  *   invalidate any held packet handles and related \ref RAIL_RxPacketInfo_t
4183  *   information when the \ref RAIL_EVENT_CONFIG_UNSCHEDULED occurs.
4184  */
4185 RAIL_RxPacketHandle_t RAIL_HoldRxPacket(RAIL_Handle_t railHandle);
4186 
4187 /**
4188  * Copy 'len' bytes of packet data starting from 'offset' from the
4189  * receive FIFO. Those bytes remain valid for re-peeking.
4190  *
4191  * @param[in] railHandle A RAIL instance handle.
4192  * @param[in] packetHandle A packet handle as returned from a previous
4193  *   \ref RAIL_GetRxPacketInfo() or \ref RAIL_HoldRxPacket() call, or
4194  *   sentinel values \ref RAIL_RX_PACKET_HANDLE_OLDEST,
4195  *   \ref RAIL_RX_PACKET_HANDLE_OLDEST_COMPLETE
4196  *   or \ref RAIL_RX_PACKET_HANDLE_NEWEST.
4197  * @param[out] pDst A pointer to the location where the received bytes will
4198  *   be copied. If NULL, no copying occurs.
4199  * @param[in] len A number of packet data bytes to copy.
4200  * @param[in] offset A byte offset within remaining packet data from which
4201  *   to copy.
4202  * @return Number of packet bytes copied.
4203  *
4204  * @note Peek does not permit peeking beyond the requested packet's
4205  *   available packet data (though there is a small chance it might
4206  *   for a \ref RAIL_RX_PACKET_HANDLE_NEWEST packet at the very end of
4207  *   still being received). Nor can one peek into already-consumed data read
4208  *   by \ref RAIL_ReadRxFifo(). len and offset are relative to the remaining data
4209  *   available in the packet, if any was already consumed by \ref RAIL_ReadRxFifo().
4210  */
4211 uint16_t RAIL_PeekRxPacket(RAIL_Handle_t railHandle,
4212                            RAIL_RxPacketHandle_t packetHandle,
4213                            uint8_t *pDst,
4214                            uint16_t len,
4215                            uint16_t offset);
4216 
4217 /**
4218  * Release RAIL's resources for a packet previously held in the receive FIFO
4219  * and internal receive metadata FIFO.
4220  *
4221  * This function must be called for any packet previously held via
4222  * \ref RAIL_HoldRxPacket(). It may optionally be called within a
4223  * callback context to release RAIL resources sooner than at
4224  * callback completion time when not holding the packet.
4225  * This function can be used in any RX mode.
4226  *
4227  * @param[in] railHandle A RAIL instance handle.
4228  * @param[in] packetHandle A packet handle as returned from a previous
4229  *   \ref RAIL_HoldRxPacket() call, or sentinel values
4230  *   \ref RAIL_RX_PACKET_HANDLE_OLDEST,
4231  *   \ref RAIL_RX_PACKET_HANDLE_OLDEST_COMPLETE
4232  *   or \ref RAIL_RX_PACKET_HANDLE_NEWEST.
4233  *   The latter might be used within RAIL callback context to explicitly
4234  *   release the packet associated with the callback early, before it's
4235  *   released automatically by RAIL on callback return (unless explicitly
4236  *   held).
4237  * @return \ref RAIL_STATUS_NO_ERROR if the held packet was released
4238  *   or an appropriate error code otherwise.
4239  */
4240 RAIL_Status_t RAIL_ReleaseRxPacket(RAIL_Handle_t railHandle,
4241                                    RAIL_RxPacketHandle_t packetHandle);
4242 
4243 /**
4244  * Return the current raw RSSI.
4245  *
4246  * @param[in] railHandle A RAIL instance handle.
4247  * @param[in] wait if false returns instant RSSI with no checks.
4248  * @return \ref RAIL_RSSI_INVALID if the receiver is disabled and an RSSI
4249  *   value can't be obtained. Otherwise, return the RSSI in quarter dBm, dbm*4.
4250  *
4251  * Gets the current RSSI value. This value represents the current energy of the
4252  * channel. It can change rapidly and will be low if no RF energy is
4253  * in the current channel. The function from the value reported to dBm is an
4254  * offset dependent on the PHY and the PCB layout. Characterize the
4255  * RSSI received on your hardware and apply an offset in the application to
4256  * account for board and PHY parameters. When 'wait' is false, the radio needs
4257  * to be currently in RX and have been in there for a sufficient amount of time
4258  * for a fresh RSSI value to be read and returned. Otherwise, the RSSI is
4259  * considered stale and \ref RAIL_RSSI_INVALID is returned instead. When 'wait'
4260  * is true, if the radio is transitioning to or already in RX, this function
4261  * will wait for a valid RSSI to be read and return it. Otherwise, if the radio
4262  * is in or transitions to IDLE or TX, \ref RAIL_RSSI_INVALID will be returned.
4263  * On low datarate PHYs, this function can take a significantly longer time when
4264  * wait is true.
4265  *
4266  * In multiprotocol, this function returns \ref RAIL_RSSI_INVALID
4267  * immediately if railHandle is not the currently active \ref RAIL_Handle_t.
4268  * Additionally, 'wait' should never be set 'true' in multiprotocol
4269  * as the wait time is not consistent, so scheduling a scheduler
4270  * slot cannot be done accurately. Rather if waiting for a valid RSSI is
4271  * desired, use \ref RAIL_GetRssiAlt instead to apply a bounded time period.
4272  *
4273  * @note If RX Antenna Diversity is enabled via \ref RAIL_ConfigRxOptions(),
4274  *   pass true for the wait parameter otherwise it's very likely
4275  *   \ref RAIL_RSSI_INVALID will be returned.
4276  *
4277  * @note If RX channel hopping is turned on, do not use this API.
4278  *   Instead, see RAIL_GetChannelHoppingRssi().
4279  *
4280  * @note When 'wait' is false, this API is equivalent to \ref RAIL_GetRssiAlt
4281  *   with 'waitTimeout' set to \ref RAIL_GET_RSSI_NO_WAIT. When 'wait' is
4282  *   true, this API is equivalent to \ref RAIL_GetRssiAlt with 'waitTimeout'
4283  *   set to \ref RAIL_GET_RSSI_WAIT_WITHOUT_TIMEOUT. Consider using
4284  *   \ref RAIL_GetRssiAlt if a bounded maximum wait timeout is desired.
4285  */
4286 int16_t RAIL_GetRssi(RAIL_Handle_t railHandle, bool wait);
4287 
4288 /**
4289  * Return the current raw RSSI in quarter-dBm within a definitive time period.
4290  *
4291  * @param[in] railHandle A RAIL instance handle.
4292  * @param[in] waitTimeout Sets the maximum time in microseconds to wait for a valid RSSI.
4293  *   If equal to \ref RAIL_GET_RSSI_NO_WAIT returns instant RSSI with no checks.
4294  *   If equal to \ref RAIL_GET_RSSI_WAIT_WITHOUT_TIMEOUT waits for a valid RSSI
4295  *   with no maximum timeout.
4296  * @return \ref RAIL_RSSI_INVALID if the receiver is disabled and an RSSI
4297  *   value can't be obtained. Otherwise, return the RSSI in quarter dBm (dBm*4).
4298  *
4299  * Gets the current RSSI value. This value represents the current energy of the
4300  * channel. It can change rapidly, and will be low if no RF energy is
4301  * in the current channel. The function from the value reported to dBm is an
4302  * offset dependent on the PHY and the PCB layout. Characterize the
4303  * RSSI received on your hardware and apply an offset in the application to
4304  * account for board and PHY parameters. If a value of \ref RAIL_GET_RSSI_NO_WAIT
4305  * is given for waitTimeout, the radio needs to be currently in RX and have been
4306  * in there for a sufficient amount of time for a fresh RSSI value to be read and
4307  * returned. Otherwise the RSSI is considered stale and \ref RAIL_RSSI_INVALID is
4308  * returned instead. For non-zero values of waitTimeout, if the radio is
4309  * transitioning to or already in RX, this function will wait a maximum time equal
4310  * to waitTimeout (or indefinitely if waitTimeout is set to
4311  * \ref RAIL_GET_RSSI_WAIT_WITHOUT_TIMEOUT) for a valid RSSI to be read and return
4312  * it. Otherwise, if the waitTimeout is reached, or the radio is in or transitions
4313  * to IDLE or TX, \ref RAIL_RSSI_INVALID will be returned. On low datarate PHYs,
4314  * this function can take a significantly longer time when waitTimeout is non-zero.
4315  *
4316  * In multiprotocol, this function returns \ref RAIL_RSSI_INVALID
4317  * immediately if railHandle is not the currently active \ref RAIL_Handle_t.
4318  * Additionally, waitTimeout should never be set to a value other than
4319  * \ref RAIL_GET_RSSI_NO_WAIT in multiprotocol as the integration between this
4320  * feature and the radio scheduler has not been implemented.
4321  *
4322  * @note If RX Antenna Diversity is enabled via \ref RAIL_ConfigRxOptions(),
4323  *   pass true for the wait parameter otherwise it's very likely
4324  *   \ref RAIL_RSSI_INVALID will be returned.
4325  *
4326  * @note If RX Antenna Diversity is enabled via \ref RAIL_ConfigRxOptions(),
4327  *   the RSSI value returned could come from either antenna and vary between antennas.
4328  *
4329  * @note If RX channel hopping is turned on, do not use this API.
4330  *   Instead, see \ref RAIL_GetChannelHoppingRssi().
4331  */
4332 int16_t RAIL_GetRssiAlt(RAIL_Handle_t railHandle, RAIL_Time_t waitTimeout);
4333 
4334 /**
4335  * Start the RSSI averaging over a specified time in us.
4336  *
4337  * @param[in] railHandle A RAIL instance handle.
4338  * @param[in] channel The physical channel to set.
4339  * @param[in] averagingTimeUs Averaging time in microseconds.
4340  * @param[in] schedulerInfo A pointer to information to allow the radio scheduler to place
4341  *   this operation appropriately. This is only used in multiprotocol version of
4342  *   RAIL and may be set to NULL in all other versions.
4343  * @return Status code indicating success of the function call.
4344  *
4345  * Starts a non-blocking hardware-based RSSI averaging mechanism. Only a single
4346  * instance of RSSI averaging can be run at any time and the radio must be idle
4347  * to start.
4348  *
4349  * In multiprotocol, this is a scheduled event. It will start when railHandle
4350  * becomes active. railHandle needs to stay active until the averaging
4351  * completes. If the averaging is interrupted, calls to
4352  * \ref RAIL_GetAverageRssi() will return \ref RAIL_RSSI_INVALID.
4353  *
4354  * Also in multiprotocol, the user is required to call \ref RAIL_YieldRadio()
4355  * after this event completes (i.e., when \ref RAIL_EVENT_RSSI_AVERAGE_DONE
4356  * occurs).
4357  *
4358  * @note If the radio is idled while RSSI averaging is still in effect, a
4359  *   \ref RAIL_EVENT_RSSI_AVERAGE_DONE event may not occur and
4360  *   \ref RAIL_IsAverageRssiReady() may never return true.
4361  *
4362  * @note Completion of RSSI averaging, marked by RAIL event
4363  *   \ref RAIL_EVENT_RSSI_AVERAGE_DONE, will return the radio to idle state.
4364  */
4365 RAIL_Status_t RAIL_StartAverageRssi(RAIL_Handle_t railHandle,
4366                                     uint16_t channel,
4367                                     RAIL_Time_t averagingTimeUs,
4368                                     const RAIL_SchedulerInfo_t *schedulerInfo);
4369 
4370 /**
4371  * Query whether the RSSI averaging is done.
4372  *
4373  * @param[in] railHandle A RAIL instance handle.
4374  * @return true if done and false otherwise.
4375  *
4376  * This function can be used to poll for completion of the RSSI averaging
4377  * to avoid relying on an interrupt-based callback.
4378  *
4379  * @note If the radio is idled while RSSI averaging is still in effect,
4380  *   this function may never return true.
4381  */
4382 bool RAIL_IsAverageRssiReady(RAIL_Handle_t railHandle);
4383 
4384 /**
4385  * Get the RSSI in quarter-dBm averaged over a specified time in microseconds.
4386  *
4387  * @param[in] railHandle A RAIL instance handle.
4388  * @return The RSSI in quarter-dBm (dBm * 4), or \ref RAIL_RSSI_INVALID
4389  *   if the receiver is disabled or an an RSSI value couldn't be obtained.
4390  *
4391  * Gets the hardware RSSI average after issuing \ref RAIL_StartAverageRssi().
4392  * Use after \ref RAIL_StartAverageRssi().
4393  */
4394 int16_t RAIL_GetAverageRssi(RAIL_Handle_t railHandle);
4395 
4396 /**
4397  * Set the RSSI offset.
4398  *
4399  * @param[in] railHandle A radio-generic or real RAIL instance handle.
4400  * @param[in] rssiOffset desired dB offset to be added to the RSSI measurements.
4401  * @return Status code indicating success of the function call.
4402  *   \ref RAIL_STATUS_INVALID_CALL if called with radio-generic handle, such
4403  *   as \ref RAIL_EFR32_HANDLE, after RAIL initialization.
4404  *   \ref RAIL_STATUS_INVALID_PARAMETER if the RSSI offset is deemed large
4405  *   enough to cause the RSSI readings to underflow or overflow.
4406  *
4407  * Adds an offset to the RSSI in dBm. This offset affects all functionality that
4408  * depends on RSSI values, such as CCA functions. Do not modify the offset
4409  * dynamically during packet reception. This function
4410  * can only be called while the radio is off, or in the case of multiprotocol,
4411  * on an inactive protocol.
4412  *
4413  * @note: If RAIL has not been initialized, a radio-generic handle,
4414  *   such as \ref RAIL_EFR32_HANDLE, can be used to set a radio's RSSI offset
4415  *   applied to all protocols on that radio.
4416  *
4417  * @note: Setting a large rssiOffset may still cause the RSSI readings to
4418  *   underflow. If that happens, the RSSI value returned by
4419  *   \ref RAIL_GetRssi(), \ref RAIL_GetAverageRssi(),
4420  *   \ref RAIL_GetChannelHoppingRssi() etc. will be \ref RAIL_RSSI_LOWEST.
4421  *
4422  * @note: During \ref Rx_Channel_Hopping this API will not update the
4423  *   RSSI offset immediately if channel hopping has already been configured.
4424  *   A subsequent call to \ref RAIL_ZWAVE_ConfigRxChannelHopping() or
4425  *   \ref RAIL_ConfigRxChannelHopping() is required for the new RSSI offset to
4426  *   take effect.
4427  */
4428 RAIL_Status_t RAIL_SetRssiOffset(RAIL_Handle_t railHandle, int8_t rssiOffset);
4429 
4430 /**
4431  * Get the radio or protocol RSSI offset in dB.
4432  *
4433  * @param[in] railHandle A radio-generic or real RAIL instance handle.
4434  * @return The RSSI offset in dB corresponding to the railHandle.
4435  *
4436  * @note: A radio-generic handle, such as \ref RAIL_EFR32_HANDLE, can be used to
4437  *   get the radio's RSSI offset otherwise this will return the RSSI offset
4438  *   value associated with the RAIL protocol instance handle, exclusive of any
4439  *   radio RSSI offset correction, if any.
4440  */
4441 int8_t RAIL_GetRssiOffset(RAIL_Handle_t railHandle);
4442 
4443 /**
4444  * Set the RSSI detection threshold in dBm to trigger
4445  * \ref RAIL_EVENT_DETECT_RSSI_THRESHOLD.
4446  *
4447  * @param[in] railHandle A RAIL instance handle.
4448  * @param[in] rssiThresholdDbm desired RSSI threshold in dBm over which the event
4449  *   \ref RAIL_EVENT_DETECT_RSSI_THRESHOLD is triggered.
4450  * @return Status code indicating success of the function call.
4451  *   Returns \ref RAIL_STATUS_INVALID_STATE in multiprotocol,
4452  *   if the requested railHandle is not active.
4453  *   Returns \ref RAIL_STATUS_INVALID_CALL if called on parts on which this function
4454  *   is not supported.
4455  *
4456  * When in receive, RSSI is sampled and if it exceeds the threshold,
4457  * \ref RAIL_EVENT_DETECT_RSSI_THRESHOLD is triggered.
4458  *
4459  * @note: If the radio is idled or this function is called with rssiThresholdDbm as
4460  *   \ref RAIL_RSSI_INVALID_DBM while RSSI detect is still in effect, a
4461  *   \ref RAIL_EVENT_DETECT_RSSI_THRESHOLD may not occur and the detection is disabled.
4462  *   If the RSSI is already above threshold when this function is called then
4463  *   \ref RAIL_EVENT_DETECT_RSSI_THRESHOLD will occur.
4464  *   Once the RSSI goes over the configured threshold and
4465  *   \ref RAIL_EVENT_DETECT_RSSI_THRESHOLD occurs, this function needs to be
4466  *   called again to reactivate the RSSI threshold detection.
4467  *
4468  * This function is only available on EFR32 Series 2 Sub-GHz parts EFR32xG23 and EFR32xG25.
4469  */
4470 RAIL_Status_t RAIL_SetRssiDetectThreshold(RAIL_Handle_t railHandle,
4471                                           int8_t rssiThresholdDbm);
4472 
4473 /**
4474  * Get the RSSI detection threshold in dBm.
4475  *
4476  * @param[in] railHandle a RAIL instance handle.
4477  * @return The RSSI threshold in dBm corresponding to the railHandle.
4478  *
4479  * @note: The function returns \ref RAIL_RSSI_INVALID_DBM when
4480  *   \ref RAIL_SetRssiDetectThreshold() is not supported or disabled.
4481  *   In multiprotocol, the function returns \ref RAIL_RSSI_INVALID_DBM if railHandle
4482  *   is not active.
4483  *
4484  * This function is only available on EFR32 Series 2 Sub-GHz parts EFR32xG23 and EFR32xG25.
4485  */
4486 int8_t RAIL_GetRssiDetectThreshold(RAIL_Handle_t railHandle);
4487 
4488 /**
4489  * Return the RSSI associated with the incoming packet.
4490  *
4491  * @param[in] railHandle A RAIL instance handle.
4492  * @return The RSSI on the incoming packet in dBm,
4493  *   or \ref RAIL_RSSI_INVALID_DBM if not available.
4494  *
4495  * This function can only be called from callback context, e.g.,
4496  * when handling \ref RAIL_EVENT_RX_FILTER_PASSED or
4497  * \ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND.
4498  */
4499 int8_t RAIL_GetRxIncomingPacketRssi(RAIL_Handle_t railHandle);
4500 
4501 /**
4502  * Set up a callback function capable of converting a RX packet's LQI value
4503  * before being consumed by application code.
4504  *
4505  * @param[in] railHandle A RAIL instance handle.
4506  * @param[in] cb A callback of type \ref RAIL_ConvertLqiCallback_t that is
4507  *   called before the RX packet LQI value is loaded into the \ref
4508  *   RAIL_RxPacketDetails_t structure for application consumption.
4509  * @return Status code indicating success of the function call.
4510  */
4511 RAIL_Status_t RAIL_ConvertLqi(RAIL_Handle_t railHandle,
4512                               RAIL_ConvertLqiCallback_t cb);
4513 
4514 /******************************************************************************
4515  * Address Filtering (RX)
4516  *****************************************************************************/
4517 /**
4518  * @addtogroup Address_Filtering Address Filtering
4519  * @brief Configuration APIs for receive packet address filtering.
4520  *
4521  * The address filtering code examines the packet as follows.
4522  *
4523  * | `Bytes: 0 - 255` |  `0 - 8`  | `0 - 255` |  `0 - 8`  | `Variable` |
4524  * |:----------------:|----------:|----------:|----------:|:----------:|
4525  * | `Data_0`         | `Field_0` | `Data_1`  | `Field_1` | `Data_2`   |
4526  *
4527  * In the above structure, anything listed as Data_# is an optional section of
4528  * bytes that RAIL will not process for address filtering. The Field_# segments
4529  * reference specific sections in the packet that will each be interpreted
4530  * as an address during address filtering. The application may submit up to
4531  * four addresses to attempt to match each field segment and each address may
4532  * have a size of up to 8 bytes. To set up address filtering, first configure
4533  * the locations and length of the addresses in the packet. Next, configure
4534  * which combinations of matches in Field_0 and Field_1 should constitute an
4535  * address match. Last, enter addresses into tables for each field and
4536  * enable them. The first two of these are part of the \ref RAIL_AddrConfig_t
4537  * structure while the second part is configured at runtime using the
4538  * \ref RAIL_SetAddressFilterAddress() API. A brief description of each
4539  * configuration is listed below.
4540  *
4541  * The offsets and sizes of the fields
4542  * are assumed fixed for the RAIL address filter. To set them, specify
4543  * arrays for these values in the sizes and offsets entries in the
4544  * \ref RAIL_AddrConfig_t structure. A size of zero indicates that a field is
4545  * disabled. The start offset for a field is relative to the previous start
4546  * offset and, if you're using frame type decoding, the first start offset is
4547  * relative to the end of the byte containing the frame type.
4548  *
4549  * Configuring which combinations of Field_0 and Field_1 constitute a match is
4550  * the most complex portion of the address filter. The easiest way to think
4551  * about this is with a truth table. If you consider each of the four possible
4552  * address entries in a field, you can have a match on any one of those or a
4553  * match for none of them. This is shown in the 5x5 truth table below where
4554  * Field_0 matches are the rows and Field_1 matches are the columns.
4555  *
4556  * |                | No Match | Address 0 | Address 1 | Address 2 | Address 3 |
4557  * |----------------|----------|-----------|-----------|-----------|-----------|
4558  * | __No Match__   | bit 0    | bit 1     | bit 2     | bit 3     | bit 4     |
4559  * | __Address 0__  | bit 5    | bit 6     | bit 7     | bit 8     | bit 9     |
4560  * | __Address 1__  | bit 10   | bit 11    | bit 12    | bit 13    | bit 14    |
4561  * | __Address 2__  | bit 15   | bit 16    | bit 17    | bit 18    | bit 19    |
4562  * | __Address 3__  | bit 20   | bit 21    | bit 22    | bit 23    | bit 24    |
4563  *
4564  * Because this is only 25 bits, it can be represented in one 32-bit integer
4565  * where 1 indicates a filter pass and 0 indicates a filter fail. This is the
4566  * \ref RAIL_AddrConfig_t::matchTable field and is used during
4567  * filtering. For common simple configurations, two defines are provided with
4568  * the truth tables as shown below. The first is \ref
4569  * ADDRCONFIG_MATCH_TABLE_SINGLE_FIELD, which can be used if only using
4570  * one address field (either field). If using two fields and want to
4571  * force in the same address entry in each field, use the second define: \ref
4572  * ADDRCONFIG_MATCH_TABLE_DOUBLE_FIELD. For more complex systems,
4573  * create a valid custom table.
4574  *
4575  * @note Address filtering does not function reliably with PHYs that use a data
4576  *   rate greater than 500 kbps. If this is a requirement, filtering must
4577  *   currently be done by the application.
4578  *
4579  * @{
4580  */
4581 
4582 /**
4583  * Configure address filtering.
4584  *
4585  * @param[in] railHandle A RAIL instance handle.
4586  * @param[in] addrConfig A pointer to the configuration structure, which defines how
4587  *   addresses are set up in your packets. May be NULL to reset address filtering.
4588  * @return Status code indicating success of the function call.
4589  *
4590  * You must call this function to set up address filtering. You may call it
4591  * multiple times but all previous information is wiped out each time you call
4592  * and any configured addresses must be reset.
4593  */
4594 RAIL_Status_t RAIL_ConfigAddressFilter(RAIL_Handle_t railHandle,
4595                                        const RAIL_AddrConfig_t *addrConfig);
4596 
4597 /**
4598  * Enable address filtering.
4599  *
4600  * @param[in] railHandle A RAIL instance handle.
4601  * @param[in] enable An argument to indicate whether or not to enable address
4602  *   filtering.
4603  * @return true if address filtering was enabled to start with and false
4604  *   otherwise.
4605  *
4606  * Only allow packets through that pass the current address filtering
4607  * configuration. This does not reset or change the configuration so you can
4608  * set that up before turning on this feature.
4609  */
4610 bool RAIL_EnableAddressFilter(RAIL_Handle_t railHandle, bool enable);
4611 
4612 /**
4613  * Return whether address filtering is currently enabled.
4614  *
4615  * @param[in] railHandle A RAIL instance handle.
4616  * @return true if address filtering is enabled and false otherwise.
4617  */
4618 bool RAIL_IsAddressFilterEnabled(RAIL_Handle_t railHandle);
4619 
4620 /**
4621  * Reset the address filtering configuration.
4622  *
4623  * @param[in] railHandle A RAIL instance handle.
4624  * @return Status code indicating success of the function call.
4625  *
4626  * Resets all structures related to address filtering. This does not disable
4627  * address filtering. It leaves the radio in a state where no packets
4628  * pass filtering.
4629  */
4630 RAIL_Status_t RAIL_ResetAddressFilter(RAIL_Handle_t railHandle);
4631 
4632 /**
4633  * Set an address for filtering in hardware.
4634  *
4635  * @param[in] railHandle A RAIL instance handle.
4636  * @param[in] field Indicates an address field for this address.
4637  * @param[in] index Indicates a match entry for this address for a
4638  *   given field.
4639  * @param[in] value A pointer to the address data. This must be at least as
4640  *   long as the size specified in \ref RAIL_ConfigAddressFilter(). The first byte,
4641  *   value[0], will be compared to the first byte received over the air for this
4642  *   address field.
4643  * @param[in] enable A boolean to indicate whether this address should be
4644  *   enabled immediately.
4645  * @return Status code indicating success of the function call.
4646  *
4647  * This function loads the given address into hardware for filtering and
4648  * starts filtering if you set the enable parameter to true. Otherwise,
4649  * call \ref RAIL_EnableAddressFilterAddress() to turn it on later.
4650  */
4651 RAIL_Status_t RAIL_SetAddressFilterAddress(RAIL_Handle_t railHandle,
4652                                            uint8_t field,
4653                                            uint8_t index,
4654                                            const uint8_t *value,
4655                                            bool enable);
4656 
4657 /**
4658  * Set an address bit mask for filtering in hardware.
4659  *
4660  * @param[in] railHandle A RAIL instance handle.
4661  * @param[in] field Indicates an address field for this address bit mask.
4662  * @param[in] bitMask A pointer to the address bitmask. This must be at least
4663  *   as long as the size specified in \ref RAIL_ConfigAddressFilter(). The first
4664  *   byte, bitMask[0], will be applied to the first byte received over the air
4665  *   for this address field. Bits set to 1 in the bit mask indicate which bit
4666  *   positions in the incoming packet to compare against the stored addresses
4667  *   during address filtering. Bits set to 0 indicate which bit positions to
4668  *   ignore in the incoming packet during address filtering. This bit mask is
4669  *   applied to all address entries.
4670  * @return Status code indicating success of the function call.
4671  *
4672  * This function loads the given address bit mask into hardware for use when
4673  * address filtering is enabled. All bits in the stored address bit mask are
4674  * set to 1 during hardware initialization and when either \ref
4675  * RAIL_ConfigAddressFilter() or \ref RAIL_ResetAddressFilter() are called.
4676  *
4677  * @note This feature/API is not supported on the EFR32xG21.
4678  *   Use the compile time symbol \ref
4679  *   RAIL_SUPPORTS_ADDR_FILTER_ADDRESS_BIT_MASK or the runtime call \ref
4680  *   RAIL_SupportsAddrFilterAddressBitMask() to check whether the platform
4681  *   supports this feature.
4682  */
4683 RAIL_Status_t RAIL_SetAddressFilterAddressMask(RAIL_Handle_t railHandle,
4684                                                uint8_t field,
4685                                                const uint8_t *bitMask);
4686 
4687 /**
4688  * Enable address filtering for the specified address.
4689  *
4690  * @param[in] railHandle A RAIL instance handle.
4691  * @param[in] enable An argument to indicate whether or not to enable address
4692  *   filtering.
4693  * @param[in] field Indicates an address for the address.
4694  * @param[in] index Indicates a match entry in the given field you want to enable.
4695  * @return Status code indicating success of the function call.
4696  */
4697 RAIL_Status_t RAIL_EnableAddressFilterAddress(RAIL_Handle_t railHandle,
4698                                               bool enable,
4699                                               uint8_t field,
4700                                               uint8_t index);
4701 
4702 /** @} */ // end of group Address_Filtering
4703 
4704 /** @} */ // end of group Receive
4705 
4706 /******************************************************************************
4707  * Auto-Acking
4708  *****************************************************************************/
4709 /// @addtogroup Auto_Ack Auto-Ack
4710 /// @brief APIs for configuring Auto-Ack functionality
4711 ///
4712 /// These APIs configure the radio for automatic acknowledgment
4713 /// features. Auto-Ack inherently changes how the underlying state machine
4714 /// behaves so users should not modify \ref RAIL_SetRxTransitions() and
4715 /// \ref RAIL_SetTxTransitions() while using Auto-Ack features.
4716 /// @code{.c}
4717 /// // Go to RX after Ack operation.
4718 /// RAIL_AutoAckConfig_t autoAckConfig = {
4719 ///   .enable = true,
4720 ///   .ackTimeout = 1000,
4721 ///   .rxTransitions = {
4722 ///      .success = RAIL_RF_STATE_RX,
4723 ///      .error   = RAIL_RF_STATE_RX
4724 ///   },
4725 ///   .txTransitions = {
4726 ///      .success = RAIL_RF_STATE_RX,
4727 ///      .error   = RAIL_RF_STATE_RX,
4728 ///   },
4729 /// };
4730 ///
4731 /// RAIL_Status_t status = RAIL_ConfigAutoAck(railHandle, &autoAckConfig);
4732 ///
4733 /// uint8_t ackData[] = {0x05, 0x02, 0x10, 0x00};
4734 ///
4735 /// RAIL_Status_t status = RAIL_WriteAutoAckFifo(railHandle,
4736 ///                                              ackData,
4737 ///                                              sizeof(ackData));
4738 /// @endcode
4739 ///
4740 /// The acknowledgment transmits based on the frame format configured via
4741 /// the Radio Configurator. For example, if the frame format is using a variable
4742 /// length scheme, the Ack will be sent according to that scheme. If a 10-byte
4743 /// packet is loaded into the Ack, but the variable length field of the Ack
4744 /// payload specifies a length of 5, only 5 bytes will transmit for the Ack.
4745 /// The converse is also true, if the frame length is configured to be a fixed
4746 /// 10-byte packet but only 5 bytes are loaded into the Ack buffer, a TX
4747 /// underflow occurs during the Ack transmit.
4748 ///
4749 /// Unlike in non-Auto-Ack mode, Auto-Ack mode will always return to a single
4750 /// state after all Ack sequences complete, regardless of whether
4751 /// the Ack was successfully received/sent or not. See the documentation
4752 /// of \ref RAIL_ConfigAutoAck() for configuration information. To
4753 /// suspend automatic acknowledgment of a series of packets after transmit
4754 /// or receive call \ref RAIL_PauseTxAutoAck() or \ref RAIL_PauseRxAutoAck() respectively
4755 /// with the pause parameter set to true. When Auto-Acking is paused, after
4756 /// receiving or transmitting a packet (regardless of success), the radio
4757 /// transitions to the same state it would use while Acking. To return to
4758 /// normal state transition logic outside of Acking, call \ref
4759 /// RAIL_ConfigAutoAck() with the \ref RAIL_AutoAckConfig_t::enable field false
4760 /// and specify the desired transitions in the \ref
4761 /// RAIL_AutoAckConfig_t::rxTransitions and RAIL_AutoAckConfig_t::txTransitions
4762 /// fields. To get out of a paused state and resume Auto-Acking, call \ref
4763 /// RAIL_PauseTxAutoAck() and/or \ref RAIL_PauseRxAutoAck() with the pause parameter
4764 /// set to false.
4765 ///
4766 /// Applications can cancel the transmission of an Ack with \ref
4767 /// RAIL_CancelAutoAck(). Conversely, applications can control if a transmit
4768 /// operation should wait for an Ack after transmitting by using
4769 /// the \ref RAIL_TX_OPTION_WAIT_FOR_ACK option.
4770 ///
4771 /// When \ref Antenna_Control is used for multiple antennas, Acks are
4772 /// transmitted on the antenna that was selected to receive the packet
4773 /// being acknowledged. When receiving an Ack, the
4774 /// \ref RAIL_RxOptions_t antenna options are used just like for any other
4775 /// receive.
4776 ///
4777 /// If the Ack payload is dynamic, the application must call \ref
4778 /// RAIL_WriteAutoAckFifo() with the appropriate Ack payload after the
4779 /// application processes the receive. RAIL can Auto-Ack from the normal
4780 /// transmit buffer if \ref RAIL_UseTxFifoForAutoAck() is called before the radio
4781 /// transmits the Ack. Ensure the transmit buffer contains data loaded by \ref
4782 /// RAIL_WriteTxFifo().
4783 ///
4784 /// Standard-based protocols that contain Auto-Ack functionality are normally
4785 /// configured in the protocol-specific configuration function. For example,
4786 /// \ref RAIL_IEEE802154_Init() provides Auto-Ack configuration parameters in \ref
4787 /// RAIL_IEEE802154_Config_t and should only be configured through that
4788 /// function. It is not advisable to call both \ref RAIL_IEEE802154_Init() and \ref
4789 /// RAIL_ConfigAutoAck(). However, Ack modification functions are still valid to
4790 /// use with protocol-specific Acks. To cancel an IEEE 802.15.4 Ack transmit,
4791 /// use \ref RAIL_CancelAutoAck().
4792 ///
4793 /// @{
4794 
4795 /// Configure and enable automatic acknowledgment.
4796 ///
4797 /// @param[in] railHandle A RAIL instance handle.
4798 /// @param[in] config A pointer to an Auto-Ack configuration structure.
4799 /// @return Status code indicating success of the function call.
4800 ///
4801 /// Configures the RAIL state machine for hardware-accelerated automatic
4802 /// acknowledgment. Ack timing parameters are defined in the configuration
4803 /// structure.
4804 ///
4805 /// While Auto-Acking is enabled, do not call the following RAIL functions:
4806 ///   - \ref RAIL_SetRxTransitions()
4807 ///   - \ref RAIL_SetTxTransitions()
4808 ///
4809 /// When Auto-Acking is enabled, only one state transition can be defined
4810 /// (without notion of success or error).
4811 /// Thus if you are enabling Auto-Ack (i.e., config->enable field is true)
4812 /// the "error" states of config->rxTransitions and config->txTransitions are ignored.
4813 /// After all Ack sequences, (success or fail) the state machine will return
4814 /// the radio to the "success" state, which can be either
4815 /// \ref RAIL_RF_STATE_RX or \ref RAIL_RF_STATE_IDLE (returning to
4816 /// \ref RAIL_RF_STATE_TX is not supported).
4817 /// Alternatively when Auto-Acking is disabled (i.e., config->enable field is
4818 /// false), transitions are reconfigured using all fields of config->rxTransitions
4819 /// and config->txTransitions. When disabling, the "ackTimeout" field isn't used.
4820 ///
4821 /// If you need information about the
4822 /// actual success of the Ack sequence, use RAIL events such as
4823 /// \ref RAIL_EVENT_TXACK_PACKET_SENT to make sure an Ack was sent, or
4824 /// \ref RAIL_EVENT_RX_ACK_TIMEOUT to make sure that an Ack was received
4825 /// within the specified timeout.
4826 ///
4827 /// To set a certain turnaround time (i.e., txToRx and rxToTx
4828 /// in \ref RAIL_StateTiming_t), make txToRx lower than
4829 /// desired to ensure you get to RX in time to receive the Ack.
4830 /// Silicon Labs recommends setting 10 us lower than desired:
4831 /// @code{.c}
4832 /// void setAutoAckStateTimings(void)
4833 /// {
4834 ///   RAIL_StateTiming_t timings;
4835 ///
4836 ///   // User is already in Auto-Ack and wants a turnaround of 192 us.
4837 ///   timings.rxToTx = 192;
4838 ///   timings.txToRx = 192 - 10;
4839 ///
4840 ///   // Set other fields of timings...
4841 ///   timings.idleToRx = 100;
4842 ///   timings.idleToTx = 100;
4843 ///   timings.rxSearchTimeout = 0;
4844 ///   timings.txToRxSearchTimeout = 0;
4845 ///
4846 ///   RAIL_SetStateTiming(railHandle, &timings);
4847 /// }
4848 /// @endcode
4849 ///
4850 /// @note Auto-Acking may not be enabled while RX Channel Hopping is enabled,
4851 ///   or when BLE is enabled.
4852 ///
4853 RAIL_Status_t RAIL_ConfigAutoAck(RAIL_Handle_t railHandle,
4854                                  const RAIL_AutoAckConfig_t *config);
4855 
4856 /**
4857  * Return the enable status of the Auto-Ack feature.
4858  *
4859  * @param[in] railHandle A RAIL instance handle.
4860  * @return true if Auto-Ack is enabled, false if disabled.
4861  */
4862 bool RAIL_IsAutoAckEnabled(RAIL_Handle_t railHandle);
4863 
4864 /**
4865  * Load the Auto-Ack buffer with Ack data.
4866  *
4867  * @param[in] railHandle A RAIL instance handle.
4868  * @param[in] ackData A pointer to Ack data to transmit.
4869  *   This may be NULL, in which case it's assumed the data has already
4870  *   been emplaced into the Ack buffer and RAIL just needs to be told
4871  *   how many bytes are there. Use \ref RAIL_GetAutoAckFifo() to get
4872  *   the address of RAIL's Auto-Ack buffer in RAM and its size.
4873  * @param[in] ackDataLen The number of bytes in Ack data.
4874  * @return Status code indicating success of the function call.
4875  *
4876  * If the Ack buffer is available for updates, load the Ack buffer with data.
4877  * If it is not available, \ref RAIL_STATUS_INVALID_STATE is returned.
4878  * If ackDataLen exceeds \ref RAIL_AUTOACK_MAX_LENGTH then
4879  * \ref RAIL_STATUS_INVALID_PARAMETER will be returned and nothing is
4880  * written to the Ack buffer (unless ackData is NULL in which case this
4881  * indicates the application has already likely corrupted RAM).
4882  */
4883 RAIL_Status_t RAIL_WriteAutoAckFifo(RAIL_Handle_t railHandle,
4884                                     const uint8_t *ackData,
4885                                     uint16_t ackDataLen);
4886 
4887 /**
4888  * Get the address and size of the Auto-Ack transmit buffer for direct access.
4889  *
4890  * @param[in] railHandle A RAIL instance handle.
4891  * @param[in,out] ackBuffer A pointer to a uint8_t pointer that will be
4892  *   updated to the RAM base address of the Auto-Ack FIFO buffer.
4893  * @param[in,out] ackBufferBytes A pointer to a uint16_t that will be
4894  *   updated to the size of the Auto-Ack FIFO buffer, in bytes,
4895  *   currently \ref RAIL_AUTOACK_MAX_LENGTH.
4896  * @return Status code indicating success of the function call.
4897  *
4898  * Applications can use this to more flexibly write Auto-Ack data into
4899  * the buffer directly and in pieces, passing NULL ackData parameter to
4900  * \ref RAIL_WriteAutoAckFifo() or \ref RAIL_IEEE802154_WriteEnhAck()
4901  * to inform RAIL of its final length.
4902  */
4903 RAIL_Status_t RAIL_GetAutoAckFifo(RAIL_Handle_t railHandle,
4904                                   uint8_t **ackBuffer,
4905                                   uint16_t *ackBufferBytes);
4906 
4907 /**
4908  * Pause/resume RX Auto-Ack functionality.
4909  *
4910  * @param[in] railHandle A RAIL instance handle.
4911  * @param[in] pause Pause or resume RX Auto-Acking.
4912  * @return Status code indicating success of the function call.
4913  *
4914  * When RX Auto-Acking is paused, the radio transitions to
4915  * \ref RAIL_AutoAckConfig_t::rxTransitions's
4916  * \ref RAIL_StateTransitions_t::success state after receiving a packet and
4917  * does not transmit an Ack. When RX Auto-Ack is resumed, the radio resumes
4918  * automatically Acking every successfully received packet.
4919  */
4920 RAIL_Status_t RAIL_PauseRxAutoAck(RAIL_Handle_t railHandle,
4921                                   bool pause);
4922 
4923 /**
4924  * Return whether the RX Auto-Ack is paused.
4925  *
4926  * @param[in] railHandle A RAIL instance handle.
4927  * @return true if RX Auto-Ack is paused, false if not paused.
4928  */
4929 bool RAIL_IsRxAutoAckPaused(RAIL_Handle_t railHandle);
4930 
4931 /**
4932  * Pause/resume TX Auto-Ack functionality.
4933  *
4934  * @param[in] railHandle A RAIL instance handle.
4935  * @param[in] pause Pause or resume TX Auto-Acking.
4936  * @return Status code indicating success of the function call.
4937  *
4938  * When TX Auto-Acking is paused, the radio transitions to
4939  * \ref RAIL_AutoAckConfig_t::txTransitions's
4940  * \ref RAIL_StateTransitions_t::success state after transmitting a packet and
4941  * does not wait for an Ack. When TX Auto-Ack is resumed, the radio resumes
4942  * automatically waiting for an Ack after a successful transmit.
4943  */
4944 RAIL_Status_t RAIL_PauseTxAutoAck(RAIL_Handle_t railHandle, bool pause);
4945 
4946 /**
4947  * Return whether the TX Auto-Ack is paused.
4948  *
4949  * @param[in] railHandle A RAIL instance handle.
4950  * @return true if TX Auto-Ack is paused, false if not paused.
4951  */
4952 bool RAIL_IsTxAutoAckPaused(RAIL_Handle_t railHandle);
4953 
4954 /**
4955  * Modify the upcoming Ack to use the transmit FIFO.
4956  *
4957  * @param[in] railHandle A RAIL instance handle.
4958  * @return Status code indicating success of the function call. The call will
4959  *   fail if it is too late to modify the outgoing Ack.
4960  *
4961  * This function allows the application to use the normal transmit FIFO as
4962  * the data source for the upcoming Ack. The Ack modification to use the
4963  * transmit FIFO only applies to one Ack transmission.
4964  *
4965  * This function only returns true if the following conditions are met:
4966  *   - Radio has not already decided to use the Ack buffer AND
4967  *   - Radio is either looking for sync, receiving the packet after sync, or in
4968  *     the \ref RAIL_StateTiming_t::rxToTx turnaround before the Ack is sent.
4969  *
4970  * @note The transmit FIFO must not be used for Auto-Ack when IEEE 802.15.4,
4971  *   Z-Wave, or BLE protocols are active.
4972  */
4973 RAIL_Status_t RAIL_UseTxFifoForAutoAck(RAIL_Handle_t railHandle);
4974 
4975 /**
4976  * Cancel the upcoming Ack.
4977  *
4978  * @param[in] railHandle A RAIL instance handle.
4979  * @return Status code indicating success of the function call. This call will
4980  *   fail if it is too late to modify the outgoing Ack.
4981  *
4982  * This function allows the application to cancel the upcoming automatic
4983  * acknowledgment.
4984  *
4985  * This function only returns true if the following conditions are met:
4986  *   - Radio has not already decided to transmit the Ack, and
4987  *   - Radio is either looking for sync, receiving the packet after sync or in
4988  *     the \ref RAIL_StateTiming_t::rxToTx turnaround before the Ack is sent.
4989  */
4990 RAIL_Status_t RAIL_CancelAutoAck(RAIL_Handle_t railHandle);
4991 
4992 /**
4993  * Return whether the radio is currently waiting for an Ack.
4994  *
4995  * @param[in] railHandle A RAIL instance handle.
4996  * @return true if radio is waiting for Ack, false if radio is not waiting for
4997  *   an Ack.
4998  *
4999  * This function allows the application to query whether the radio is currently
5000  * waiting for an Ack after a transmit operation.
5001  */
5002 bool RAIL_IsAutoAckWaitingForAck(RAIL_Handle_t railHandle);
5003 
5004 /** @} */ // end of group Auto_Ack
5005 
5006 /******************************************************************************
5007  * Calibration
5008  *****************************************************************************/
5009 /// @addtogroup Calibration
5010 /// @brief APIs for calibrating the radio
5011 /// @{
5012 ///
5013 /// These APIs calibrate the radio. The RAIL library
5014 /// determines which calibrations are necessary. Calibrations can
5015 /// be enabled/disabled with the \ref RAIL_CalMask_t parameter.
5016 ///
5017 /// Some calibrations produce values that can be saved and reapplied to
5018 /// avoid repeating the calibration process.
5019 ///
5020 /// Calibrations can either be run with \ref RAIL_Calibrate(), or with the
5021 /// individual chip-specific calibration routines. An example for running code
5022 /// with \ref RAIL_Calibrate() looks like the following:
5023 /// @code{.c}
5024 /// static RAIL_CalValues_t calValues = RAIL_CALVALUES_UNINIT;
5025 /// static volatile bool calibrateRadio = false;
5026 ///
5027 /// void RAILCb_Event(RAIL_Handle_t railHandle, RAIL_Events_t events)
5028 /// {
5029 ///   // Omitting other event handlers
5030 ///   if (events & RAIL_EVENT_CAL_NEEDED) {
5031 ///     calibrateRadio = true;
5032 ///   }
5033 /// }
5034 ///
5035 /// void main(void)
5036 /// {
5037 ///   // Initialize RAIL ...
5038 ///
5039 ///   // Application main loop
5040 ///   while (1) {
5041 ///     ...
5042 ///     if (calibrateRadio) {
5043 ///       // Run all pending calibrations, and save the results
5044 ///       RAIL_Calibrate(railHandle, &calValues, RAIL_CAL_ALL_PENDING);
5045 ///       calibrateRadio = false;
5046 ///     }
5047 ///     ...
5048 ///   }
5049 /// }
5050 /// @endcode
5051 ///
5052 /// Alternatively, if the image rejection calibration for your radio can be
5053 /// determined ahead of time, such as by running the calibration on a separate
5054 /// firmware image on each chip, the following calibration process will
5055 /// result in smaller code.
5056 /// @code{.c}
5057 /// static RAIL_IrCalValues_t irCalValues = {
5058 ///   .rxIrCalValues = {
5059 ///     RX_IRCAL_VALUE_RF_PATH0,
5060 ///     RX_IRCAL_VALUE_RF_PATH1,
5061 ///   },
5062 ///   .txIrCalValues = {
5063 ///     .dcOffsetIQ = TX_IRCAL_DC_OFFSET_IQ,
5064 ///     .phiEpsilon = TX_IRCAL_PHI_EPSILON,
5065 ///   },
5066 /// };
5067 ///
5068 /// void RAILCb_Event(RAIL_Handle_t railHandle, RAIL_Events_t events)
5069 /// {
5070 ///   // Omitting other event handlers
5071 ///   if (events & RAIL_EVENT_CAL_NEEDED) {
5072 ///     RAIL_CalMask_t pendingCals = RAIL_GetPendingCal(railHandle);
5073 ///     // Disable the radio if we have to do an offline calibration
5074 ///     if (pendingCals & RAIL_CAL_TEMP_VC0) {
5075 ///       (void) RAIL_CalibrateTemp(railHandle);
5076 ///     }
5077 ///     if (pendingCals & RAIL_CAL_ONETIME_IRCAL) {
5078 ///       (void) RAIL_ApplyIrCalibrationAlt(rail_handle, &ir_cal_values, RAIL_ANTENNA_AUTO);
5079 ///     }
5080 ///   }
5081 /// }
5082 /// @endcode
5083 
5084 /**
5085  * Initialize RAIL calibration.
5086  *
5087  * @param[in] railHandle A RAIL instance handle.
5088  * @param[in] calEnable A bitmask that indicates which calibrations
5089  *   to enable for a callback notification.
5090  *   The exact meaning of these bits is radio-specific.
5091  * @return Status code indicating success of the function call.
5092  *
5093  * Calibration initialization provides the calibration settings that
5094  * correspond to the current radio configuration.
5095  */
5096 RAIL_Status_t RAIL_ConfigCal(RAIL_Handle_t railHandle,
5097                              RAIL_CalMask_t calEnable);
5098 
5099 /**
5100  * Start the calibration process.
5101  *
5102  * @param[in] railHandle A RAIL instance handle.
5103  * @param[in,out] calValues A pointer to a structure of calibration values to apply.
5104  *   If a valid calibration structure is provided and the structure
5105  *   contains valid calibration values, those values will be applied to the
5106  *   hardware and the RAIL library will cache those values for use again later.
5107  *   If a valid calibration structure is provided and the structure
5108  *   contains a calibration value of \ref RAIL_CAL_INVALID_VALUE for the
5109  *   desired calibration, the desired calibration will run, the calibration
5110  *   values structure will be updated with a valid calibration value, and the
5111  *   RAIL library will cache that value for use again later.
5112  *   If a NULL pointer is provided, the desired calibration will run
5113  *   and the RAIL library will cache that value for use again later. However,
5114  *   the valid calibration value will not be returned to the application.
5115  * @param[in] calForce A mask to force specific calibration(s) to execute.
5116  *   To run all pending calibrations, use the value \ref RAIL_CAL_ALL_PENDING.
5117  *   Only the calibrations specified will run, even if not enabled during
5118  *   initialization.
5119  * @return Status code indicating success of the function call.
5120  *
5121  * If calibrations were performed previously and the application saves the
5122  * calibration values (i.e., call this function with a calibration values
5123  * structure containing calibration values of \ref RAIL_CAL_INVALID_VALUE
5124  * before a reset), the application can later bypass the time it would normally
5125  * take to recalibrate hardware by reusing previous calibration values (i.e.,
5126  * call this function with a calibration values structure containing valid
5127  * calibration values after a reset).
5128  *
5129  * Silicon Labs recommends calling this function from the application main loop.
5130  *
5131  * If multiple protocols are used, this function will make the given railHandle
5132  * active, if not already, and perform calibration. If called during a protocol
5133  * switch, to perform an IR calibration for the first time, it will
5134  * return \ref RAIL_STATUS_INVALID_STATE, in which case the application must
5135  * defer calibration until after the protocol switch is complete.
5136  *
5137  * @note Instead of this function, consider using the individual calibration-specific
5138  *   functions. Using the individual functions will allow for better
5139  *   dead-stripping if not all calibrations are run.
5140  * @note Some calibrations should only be executed when the radio is IDLE. See
5141  *   chip-specific documentation for more details.
5142  */
5143 RAIL_Status_t RAIL_Calibrate(RAIL_Handle_t railHandle,
5144                              RAIL_CalValues_t *calValues,
5145                              RAIL_CalMask_t calForce);
5146 
5147 /**
5148  * Return the current set of pending calibrations.
5149  *
5150  * @param[in] railHandle A RAIL instance handle.
5151  * @return A mask of all pending calibrations that the user has been asked to
5152  *   perform.
5153  *
5154  * This function returns a full set of pending calibrations. The only way
5155  * to clear pending calibrations is to perform them using the \ref
5156  * RAIL_Calibrate() API with the appropriate list of calibrations.
5157  */
5158 RAIL_CalMask_t RAIL_GetPendingCal(RAIL_Handle_t railHandle);
5159 
5160 /**
5161  * Apply a given image rejection calibration value.
5162  *
5163  * @param[in] railHandle A RAIL instance handle.
5164  * @param[in] imageRejection The image rejection value to apply.
5165  * @return Status code indicating success of the function call.
5166  *
5167  * Take an image rejection calibration value and apply it. This value should be
5168  * determined from a previous run of \ref RAIL_CalibrateIr on the same
5169  * physical device with the same radio configuration. The imageRejection value
5170  * will also be stored to the \ref RAIL_ChannelConfigEntry_t::attr, if possible.
5171  *
5172  * If multiple protocols are used, this function will return
5173  * \ref RAIL_STATUS_INVALID_STATE if it is called and the given railHandle is
5174  * not active. In that case, the caller must attempt to re-call this function later.
5175  *
5176  * @deprecated Please use \ref RAIL_ApplyIrCalibrationAlt instead.
5177  */
5178 RAIL_Status_t RAIL_ApplyIrCalibration(RAIL_Handle_t railHandle,
5179                                       uint32_t imageRejection);
5180 
5181 /**
5182  * Apply given image rejection calibration values.
5183  *
5184  * @param[in] railHandle A RAIL instance handle.
5185  * @param[in] imageRejection A pointer to the image rejection values to apply.
5186  * @param[in] rfPath RF path(s) to calibrate.
5187  * @return Status code indicating success of the function call.
5188  *
5189  * Take image rejection calibration values and apply them. These values should be
5190  * determined from a previous run of \ref RAIL_CalibrateIrAlt() on the same
5191  * physical device with the same radio configuration. The imageRejection values
5192  * will also be stored to the \ref RAIL_ChannelConfigEntry_t::attr, if possible.
5193  *
5194  * @note: To make sure the imageRejection values are stored/configured correctly,
5195  *   \ref RAIL_ConfigAntenna() should be called before calling this API.
5196  *
5197  * If multiple protocols are used, this function will return
5198  * \ref RAIL_STATUS_INVALID_STATE if it is called and the given railHandle is
5199  * not active. In that case, the caller must attempt to re-call this function later.
5200  */
5201 RAIL_Status_t RAIL_ApplyIrCalibrationAlt(RAIL_Handle_t railHandle,
5202                                          RAIL_IrCalValues_t *imageRejection,
5203                                          RAIL_AntennaSel_t rfPath);
5204 
5205 /**
5206  * Run the image rejection calibration.
5207  *
5208  * @param[in] railHandle A RAIL instance handle.
5209  * @param[out] imageRejection The result of the image rejection calibration.
5210  * @return Status code indicating success of the function call.
5211  *
5212  * Run the image rejection calibration and apply the resulting value. If the
5213  * imageRejection parameter is not NULL, store the value at that
5214  * location. The imageRejection value will also be stored to the
5215  * \ref RAIL_ChannelConfigEntry_t::attr, if possible. This is a long-running
5216  * calibration that adds significant code space when run and can be run with a
5217  * separate firmware image on each device to save code space in the
5218  * final image. Silicon Labs recommends calling this function from the
5219  * application main loop.
5220  *
5221  * If multiple protocols are used, this function will make the given railHandle
5222  * active, if not already, and perform calibration. If called during a protocol
5223  * switch, it will return \ref RAIL_STATUS_INVALID_STATE. In this case,
5224  * \ref RAIL_ApplyIrCalibration may be called to apply a previously determined
5225  * IR calibration value, or the app must defer calibration until the
5226  * protocol switch is complete.
5227  *
5228  * @deprecated Please use \ref RAIL_CalibrateIrAlt instead.
5229  */
5230 RAIL_Status_t RAIL_CalibrateIr(RAIL_Handle_t railHandle,
5231                                uint32_t *imageRejection);
5232 
5233 /**
5234  * Run the image rejection calibration.
5235  *
5236  * @param[in] railHandle A RAIL instance handle.
5237  * @param[out] imageRejection A pointer to the image rejection results.
5238  * @param[in] rfPath RF path(s) to calibrate.
5239  * @return Status code indicating success of the function call.
5240  *
5241  * Run the image rejection calibration and apply the resulting values. If the
5242  * imageRejection parameter is not NULL, store the values at that
5243  * location. The imageRejection values will also be stored to the
5244  * \ref RAIL_ChannelConfigEntry_t::attr, if possible. This is a long-running
5245  * calibration that adds significant code space when run and can be run with a
5246  * separate firmware image on each device to save code space in the
5247  * final image. Silicon Labs recommends calling this function from the
5248  * application main loop.
5249  *
5250  * @note: To make sure the imageRejection values are stored/configured correctly,
5251  *   \ref RAIL_ConfigAntenna() should be called before calling this API.
5252  *
5253  * If multiple protocols are used, this function will return
5254  * \ref RAIL_STATUS_INVALID_STATE if it is called and the given railHandle is
5255  * not active. In that case, the caller must attempt to re-call this function later.
5256  */
5257 RAIL_Status_t RAIL_CalibrateIrAlt(RAIL_Handle_t railHandle,
5258                                   RAIL_IrCalValues_t *imageRejection,
5259                                   RAIL_AntennaSel_t rfPath);
5260 
5261 /**
5262  * Run the temperature calibration.
5263  *
5264  * @param[in] railHandle A RAIL instance handle.
5265  * @return Status code indicating success of the function call.
5266  *
5267  * Run the temperature calibration, which needs to recalibrate the synth if
5268  * the temperature crosses 0C or the temperature delta since the last
5269  * calibration exceeds 70C while in receive. RAIL will run the VCO calibration
5270  * automatically upon entering receive or transmit states, so the application
5271  * can omit this calibration if the stack re-enters receive or transmit with
5272  * enough frequency to avoid reaching the temperature delta. If the application
5273  * does not calibrate for temperature, it's possible to miss receive packets due
5274  * to a drift in the carrier frequency.
5275  *
5276  * If multiple protocols are used, this function will return
5277  * \ref RAIL_STATUS_INVALID_STATE if it is called and the given railHandle is
5278  * not active. In that case, the calibration will be automatically performed
5279  * next time the radio enters receive.
5280  */
5281 RAIL_Status_t RAIL_CalibrateTemp(RAIL_Handle_t railHandle);
5282 
5283 /**
5284  * Performs HFXO compensation.
5285  *
5286  * @param[in] railHandle A RAIL instance handle.
5287  * @param[out] crystalPPMError A pointer for RAIL to store the current
5288  *   deviation that has been corrected, measured in PPM. May be NULL.
5289  * @return Status code indicating the result of the function call.
5290  *
5291  * Compute the PPM correction using the thermistor value available when
5292  * \ref RAIL_EVENT_THERMISTOR_DONE occurs, after
5293  * \ref RAIL_StartThermistorMeasurement() call.
5294  * Then correct the RF frequency as well as TX and RX sampling.
5295  *
5296  * This function calls the following RAIL functions in sequence saving having
5297  * to call them individually:
5298  *   - \ref RAIL_ConvertThermistorImpedance()
5299  *   - \ref RAIL_ComputeHFXOPPMError()
5300  *   - \ref RAIL_CompensateHFXO()
5301  *
5302  * @note This function makes the radio idle.
5303  */
5304 RAIL_Status_t RAIL_CalibrateHFXO(RAIL_Handle_t railHandle, int8_t *crystalPPMError);
5305 
5306 /**
5307  * Enable/disable the PA calibration.
5308  *
5309  * @param[in] enable Enables/disables the PA calibration.
5310  *
5311  * Enabling will ensure that the PA power remains constant chip-to-chip.
5312  * This feature is enabled by default on Series-2 platforms.
5313  *
5314  * On EFR32xG21 and EFR32xG24 platforms, particularly the 20 dBm variants,
5315  * it is recommended to keep this feature enabled in order to utilize the
5316  * chip-specific calibrations designated for the chip.
5317  *
5318  * The chip-specific define SL_RAIL_UTIL_PA_CALIBRATION_ENABLE in the
5319  * \ref rail_util_pa plugin also enables/disables PA calibrations
5320  * on initialization, which can override the default state of the feature.
5321  *
5322  * @note Call this function before \ref RAIL_ConfigTxPower() if this
5323  *   feature is not desired.
5324  */
5325 void RAIL_EnablePaCal(bool enable);
5326 
5327 /** @} */ // end of group Calibration
5328 
5329 /******************************************************************************
5330  * RF Sense Structures
5331  *****************************************************************************/
5332 /**
5333  * @addtogroup Rf_Sense RF Sense
5334  * @{
5335  */
5336 
5337 /**
5338  * Start/stop the RF Sense functionality in Energy Detection Mode for use
5339  * during low-energy sleep modes.
5340  *
5341  * @param[in] railHandle A RAIL instance handle.
5342  * @param[in] band The frequency band(s) on which to sense the RF energy.
5343  *   To stop RF Sense, specify \ref RAIL_RFSENSE_OFF.
5344  * @param[in] senseTime The time (in microseconds) the RF energy must be
5345  *   continually detected to be considered "sensed".
5346  * @param[in] cb \ref RAIL_RfSense_CallbackPtr_t is called when the RF is
5347  *   sensed. Set NULL if using \ref RAIL_EVENT_RF_SENSED or polling via
5348  *   \ref RAIL_IsRfSensed().
5349  * @return The actual senseTime used, which may be different than
5350  *   requested due to limitations of the hardware. If 0, RF sense was
5351  *   disabled or could not be enabled (no callback or event will be issued).
5352  *
5353  * Some EFR32 radios have the ability to sense the presence of RF energy above -20 dBm
5354  * within either or both the 2.4 GHz and Sub-GHz bands and trigger an event
5355  * if that energy is continuously present for certain durations of time. An
5356  * application can check when RF energy is sensed either by enabling the event
5357  * \ref RAIL_EVENT_RF_SENSED, by polling on the \ref RAIL_IsRfSensed() API, or
5358  * by using the cb callback.
5359  *
5360  * @note After RF energy has been sensed, the RF Sense is automatically
5361  *   disabled and \ref RAIL_StartRfSense() must be called again to reactivate it.
5362  *   If RF energy has not been sensed and to manually disable RF Sense,
5363  *   \ref RAIL_StartRfSense() must be called with band specified as
5364  *   \ref RAIL_RFSENSE_OFF or with senseTime set to 0 microseconds.
5365  *
5366  * @note Packet reception is not guaranteed to work correctly once RF Sense is
5367  *   enabled, both in single protocol and multiprotocol RAIL.
5368  *   To be safe, an application should turn this on only after idling
5369  *   the radio to stop receive and turn it off before attempting to restart
5370  *   receive. Since EM4 sleep causes the chip to come up through the reset
5371  *   vector any wake from EM4 must also shut off RF Sense to ensure proper
5372  *   receive functionality.
5373  *
5374  * @warning For some radios, RF Sense functionality is only guaranteed within
5375  *   a specified temperature range.
5376  *   See chip-specific documentation for more details.
5377  */
5378 RAIL_Time_t RAIL_StartRfSense(RAIL_Handle_t railHandle,
5379                               RAIL_RfSenseBand_t band,
5380                               RAIL_Time_t senseTime,
5381                               RAIL_RfSense_CallbackPtr_t cb);
5382 
5383 /// Start/stop the RF Sense functionality in Selective(OOK Based) Mode for use
5384 /// during low-energy sleep modes.
5385 ///
5386 /// @param[in] railHandle A RAIL instance handle.
5387 /// @param[in] config A pointer to a \ref RAIL_RfSenseSelectiveOokConfig_t
5388 ///   which holds the RFSENSE configuration for Selective(OOK) mode.
5389 /// @return Status code indicating success of the function call.
5390 ///
5391 /// Some radios support Selective RF energy detection (OOK mode) where the
5392 /// user can program the radio to look for a particular sync word pattern
5393 /// (1-4 bytes) sent using OOK and wake only when that is detected.
5394 /// See chip-specific documentation for more details.
5395 ///
5396 /// The following code gives an example of how to use RF Sense functionality
5397 /// in Selective(OOK Based) Mode.
5398 /// @code{.c}
5399 /// // Sync word length in bytes, 1-4 bytes.
5400 /// #define NUM_SYNC_WORD_BYTES (2U)
5401 /// // Sync word value.
5402 /// #define SYNC_WORD           (0xB16FU)
5403 /// // Desired RF band
5404 /// RAIL_RfSenseBand_t rfBand = RAIL_RFSENSE_2_4GHZ;
5405 ///
5406 /// // Configure the transmitting node for sending the wakeup packet.
5407 /// RAIL_Idle(railHandle, RAIL_IDLE_ABORT, true);
5408 /// RAIL_ConfigRfSenseSelectiveOokWakeupPhy(railHandle);
5409 /// RAIL_SetRfSenseSelectiveOokWakeupPayload(railHandle, NUM_SYNC_WORD_BYTES, SYNC_WORD);
5410 /// RAIL_StartTx(railHandle, channel, RAIL_TX_OPTIONS_DEFAULT, NULL);
5411 ///
5412 /// // Configure the receiving node (EFR32xG22) for RF Sense.
5413 /// RAIL_RfSenseSelectiveOokConfig_t config = {
5414 ///  .band = rfBand,
5415 ///  .syncWordNumBytes = NUM_SYNC_WORD_BYTES,
5416 ///  .syncWord = SYNC_WORD,
5417 ///  .cb = NULL // Use RAIL_EVENT_RF_SENSED event or poll RAIL_IsRfSensed()
5418 /// };
5419 /// RAIL_StartSelectiveOokRfSense(railHandle, &config);
5420 /// @endcode
5421 ///
5422 /// @note After RF energy has been sensed, the RF Sense is automatically
5423 ///   disabled and \ref RAIL_StartSelectiveOokRfSense() must be called again to
5424 ///   reactivate. If RF energy has not been sensed and to manually disable
5425 ///   RF Sense, \ref RAIL_StartSelectiveOokRfSense() must be called with band
5426 ///   specified as \ref RAIL_RFSENSE_OFF or with
5427 ///   \ref RAIL_RfSenseSelectiveOokConfig_t as NULL.
5428 ///
5429 /// @note Packet reception is not guaranteed to work correctly once RF Sense is
5430 ///   enabled, both in single protocol and multiprotocol RAIL.
5431 ///   To be safe, an application should turn this on only after idling
5432 ///   the radio to stop receive and turn it off before attempting to restart
5433 ///   receive. Since EM4 sleep causes the chip to come up through the reset
5434 ///   vector any wake from EM4 must also shut off RF Sense to ensure proper
5435 ///   receive functionality.
5436 ///
5437 RAIL_Status_t RAIL_StartSelectiveOokRfSense(RAIL_Handle_t railHandle,
5438                                             RAIL_RfSenseSelectiveOokConfig_t *config);
5439 
5440 /**
5441  * Switch to RF Sense Selective(OOK) PHY.
5442  *
5443  * @param[in] railHandle A handle for RAIL instance.
5444  * @return Status code indicating success of the function call.
5445  *
5446  * This function switches to the RFSENSE Selective(OOK) PHY for transmitting a
5447  * packet to wake up a chip that supports Selective RF energy detection (OOK
5448  * mode). You may only call this function while the radio is idle. While the
5449  * radio is configured for this PHY, receive functionality should not be used.
5450  *
5451  * @note The user must also set up the transmit FIFO, via
5452  *   \ref RAIL_SetRfSenseSelectiveOokWakeupPayload, post this function call to
5453  *   include the first byte as the Preamble byte, followed by the
5454  *   Sync word (1-4 bytes).
5455  *   See chip-specific documentation for more details.
5456  */
5457 RAIL_Status_t RAIL_ConfigRfSenseSelectiveOokWakeupPhy(RAIL_Handle_t railHandle);
5458 
5459 /**
5460  * Set the transmit payload for waking up a node configured for
5461  * RF Sense Selective(OOK).
5462  *
5463  * @param[in] railHandle A handle for RAIL instance.
5464  * @param[in] numSyncwordBytes Sync word length in bytes, 1-4 bytes.
5465  * @param[in] syncword Sync word value.
5466  * @return Status code indicating success of the function call.
5467  *
5468  * @note You must call this function after the chip has been set up with the
5469  *   RF Sense Selective(OOK) PHY, using \ref RAIL_ConfigRfSenseSelectiveOokWakeupPhy.
5470  */
5471 RAIL_Status_t RAIL_SetRfSenseSelectiveOokWakeupPayload(RAIL_Handle_t railHandle,
5472                                                        uint8_t numSyncwordBytes,
5473                                                        uint32_t syncword);
5474 
5475 /**
5476  * Check whether the RF was sensed.
5477  *
5478  * @param[in] railHandle A RAIL instance handle.
5479  * @return true if RF was sensed since the last call to \ref RAIL_StartRfSense().
5480  *   false otherwise.
5481  *
5482  * This function is useful if \ref RAIL_StartRfSense() is called with a NULL
5483  * callback. It is generally used after EM4 reboot but can be used any time.
5484  */
5485 bool RAIL_IsRfSensed(RAIL_Handle_t railHandle);
5486 
5487 /** @} */ // end of group Rf_Sense
5488 
5489 /******************************************************************************
5490  * RX Channel Hopping
5491  *****************************************************************************/
5492 /**
5493  * @addtogroup Rx_Channel_Hopping RX Channel Hopping
5494  * @brief Hardware accelerated hopping between channels while waiting for a
5495  *   packet in receive.
5496  * @{
5497  *
5498  * Channel hopping provides a hardware accelerated method for
5499  * scanning across multiple channels quickly, as part of a receive protocol.
5500  * While it is possible to call \ref RAIL_StartRx() on different channels,
5501  * back to back, and listen on many channels sequentially in that way, the
5502  * time it takes to switch channels with that method may be too long for some
5503  * protocols. This API pre-computes necessary channel change operations
5504  * for a given list of channels, so that the radio can move from channel
5505  * to channel much faster. Additionally, it leads to more succinct code
5506  * as channel changes will be done implicitly, without requiring numerous calls
5507  * to \ref RAIL_StartRx(). Currently, while this feature is enabled, the radio
5508  * will hop channels in the given sequence each time it enters RX.
5509  * Note that RX Channel hopping and EFR32xG25's concurrent mode / collision
5510  * detection are mutually exclusive.
5511  *
5512  * The channel hopping buffer requires \ref RAIL_CHANNEL_HOPPING_BUFFER_SIZE_PER_CHANNEL
5513  * number of 32-bit words of overhead per channel, plus 3 words overall plus the
5514  * twice the size of the \ref RAIL_ChannelConfig_t::phyConfigDeltaSubtract
5515  * of the whole radio configuration, plus the twice the sum of the sizes of all
5516  * the \ref RAIL_ChannelConfigEntry_t::phyConfigDeltaAdd in all the channel
5517  * hopping channels.
5518  *
5519  * The following code gives an example of how to use
5520  * the RX Channel Hopping API.
5521  * @code{.c}
5522  * #define CHANNEL_HOPPING_NUMBER_OF_CHANNELS 4
5523  * #define CHANNEL_HOPPING_BUFFER_SIZE do {        \
5524  *   3 +                                           \
5525  *   (RAIL_CHANNEL_HOPPING_BUFFER_SIZE_PER_CHANNEL \
5526  *    * CHANNEL_HOPPING_NUMBER_OF_CHANNELS) +      \
5527  *   2 * (SIZEOF_UINT32_DELTA_SUBTRACT +           \
5528  *   SIZEOF_UINT32_DELTA_ADD_0 +                   \
5529  *   SIZEOF_UINT32_DELTA_ADD_1 +                   \
5530  *   SIZEOF_UINT32_DELTA_ADD_2 +                   \
5531  *   SIZEOF_UINT32_DELTA_ADD_3)                    \
5532  * } while (0)
5533  *
5534  * RAIL_RxChannelHoppingConfigEntry_t channelHoppingEntries[CHANNEL_HOPPING_NUMBER_OF_CHANNELS];
5535  * uint32_t channelHoppingBuffer[CHANNEL_HOPPING_BUFFER_SIZE];
5536  *
5537  * RAIL_RxChannelHoppingConfig_t channelHoppingConfig = {
5538  *   .buffer = channelHoppingBuffer,
5539  *   .bufferLength = CHANNEL_HOPPING_BUFFER_SIZE,
5540  *   .numberOfChannels = CHANNEL_HOPPING_NUMBER_OF_CHANNELS,
5541  *   .entries = channelHoppingEntries
5542  * };
5543  *
5544  * channelHoppingEntries[0].channel = 1;
5545  * channelHoppingEntries[1].channel = 2;
5546  * channelHoppingEntries[2].channel = 3;
5547  *
5548  * RAIL_ConfigRxChannelHopping(railHandle, &channelHoppingConfig);
5549  * RAIL_EnableRxChannelHopping(railHandle, true, true)
5550  * @endcode
5551  */
5552 
5553 /**
5554  * Configure RX channel hopping.
5555  *
5556  * @param[in] railHandle A RAIL instance handle.
5557  * @param[in] config A pointer to the configuration parameters for RX Channel Hopping.
5558  * @return Status code indicating success of the function call.
5559  *
5560  * Configure channel hopping channels, conditions, and parameters. This
5561  * API must be called before \ref RAIL_EnableRxChannelHopping(). This API must
5562  * never be called while the radio is on with RX Duty Cycle or Channel
5563  * Hopping enabled.
5564  *
5565  * @note Use the compile time symbol \ref RAIL_SUPPORTS_CHANNEL_HOPPING or
5566  *   the runtime call \ref RAIL_SupportsChannelHopping() to check whether
5567  *   the platform supports this feature.
5568  *
5569  * @note Calling this function will overwrite any settings configured with
5570  *   \ref RAIL_ConfigRxDutyCycle().
5571  */
5572 RAIL_Status_t RAIL_ConfigRxChannelHopping(RAIL_Handle_t railHandle,
5573                                           RAIL_RxChannelHoppingConfig_t *config);
5574 
5575 /**
5576  * Enable RX channel hopping.
5577  *
5578  * @param[in] railHandle A RAIL instance handle.
5579  * @param[in] enable Enable (true) or disable (false) RX Channel Hopping.
5580  * @param[in] reset Start from the first channel of the channel hopping
5581  *   sequence (true) or from wherever hopping left off last time the code
5582  *   left RX.
5583  * @return Status code indicating success of the function call.
5584  *
5585  * Enable or disable Channel Hopping. Additionally, specify whether hopping
5586  * should be reset to start from the first channel index, or continue
5587  * from the channel last hopped to. The radio should not be on when
5588  * this API is called. \ref RAIL_ConfigRxChannelHopping() must be called
5589  * successfully before this API is called.
5590  *
5591  * @note Use the compile time symbol \ref RAIL_SUPPORTS_CHANNEL_HOPPING or
5592  *   the runtime call \ref RAIL_SupportsChannelHopping() to check whether
5593  *   the platform supports this feature.
5594  *
5595  * @note RX Channel Hopping may not be enabled while Auto-Acking is enabled.
5596  *
5597  * @note Calling this function will overwrite any settings configured with
5598  *   \ref RAIL_EnableRxDutyCycle().
5599  */
5600 RAIL_Status_t RAIL_EnableRxChannelHopping(RAIL_Handle_t railHandle,
5601                                           bool enable,
5602                                           bool reset);
5603 
5604 /**
5605  * Get RSSI in deci-dBm of one channel in the channel hopping sequence, during
5606  * channel hopping.
5607  *
5608  * @param[in] railHandle A RAIL instance handle.
5609  * @param[in] channelIndex Index in the channel hopping sequence of the
5610  *   channel of interest.
5611  * @return Latest RSSI in deci-dBm for the channel at the specified index.
5612  *
5613  * @note Use the compile time symbol \ref RAIL_SUPPORTS_CHANNEL_HOPPING or
5614  *   the runtime call \ref RAIL_SupportsChannelHopping() to check whether
5615  *   the platform supports this feature.
5616  *
5617  * @note In multiprotocol, this function returns \ref RAIL_RSSI_INVALID
5618  *   immediately if railHandle is not the currently active \ref RAIL_Handle_t.
5619  *
5620  * @note \ref RAIL_ConfigRxChannelHopping() must be called successfully
5621  *   before this API is called.
5622  *
5623  * @note When the Z-Wave protocol is active, running
5624  *   \ref RAIL_GetChannelHoppingRssi() on the 9.6 kbps PHY returns the RSSI
5625  *   measurement of the 40kpbs PHY. This is because the 9.6 kbps PHY has
5626  *   trouble with RSSI measurements on EFR32xG2x family of chips.
5627  */
5628 int16_t RAIL_GetChannelHoppingRssi(RAIL_Handle_t railHandle,
5629                                    uint8_t channelIndex);
5630 
5631 /// Configure RX duty cycle mode.
5632 ///
5633 /// @param[in] railHandle A RAIL instance handle.
5634 /// @param[in] config A non-NULL pointer to a configuration structure specifying duty cycle parameters.
5635 /// @return Status code indicating success of the function call.
5636 ///
5637 /// Configure RX duty cycle mode. With this mode enabled, every time the radio
5638 /// enters RX, it will duty cycle on and off to save power. The duty cycle
5639 /// ratio can be altered dynamically and intelligently by the hardware by
5640 /// staying on longer if a preamble or other packet segments are detected in
5641 /// the air. This API must never be called while the radio is on with RX Duty
5642 /// Cycle or Channel Hopping enabled.
5643 /// For short delays (in the order of microseconds),
5644 /// \ref RAIL_RxDutyCycleConfig_t::delay, this can be used to save receive
5645 /// current while having little impact on the radio performance, for protocols
5646 /// with long preambles. For long delays (in the order of milliseconds or higher)
5647 /// the chip can be put into EM2 energy mode before re-entering RX,
5648 /// to save extra power, with some application hooks as shown below.
5649 ///
5650 /// @code{.c}
5651 /// #include "rail.h"
5652 ///
5653 /// extern RAIL_Handle_t railHandle;
5654 /// RAIL_Time_t periodicWakeupUs;
5655 ///
5656 /// volatile bool dutyCycleEnd = true;
5657 ///
5658 /// void RAILCb_Event(RAIL_Handle_t railHandle, RAIL_Events_t events)
5659 /// {
5660 ///   // Omitting other event handlers
5661 ///   if (events & RAIL_EVENT_RX_DUTY_CYCLE_RX_END) {
5662 ///     dutyCycleEnd = true;
5663 ///   }
5664 /// }
5665 ///
5666 /// void main(void)
5667 /// {
5668 ///   RAIL_Status_t status;
5669 ///   bool shouldSleep = false;
5670 ///
5671 ///   initializeRail(); // Call RAIL_Init() and such
5672 ///
5673 ///   // This function depends on your board/chip but it must enable the LFCLK
5674 ///   // you intend to use for RTCC sync before we configure sleep as that
5675 ///   // function will attempt to auto detect the clock.
5676 ///   BoardSetupLFCLK();
5677 ///   // Initialize Power Manager module
5678 ///   sl_power_manager_init();
5679 ///   // Initialize RAIL Power Manager
5680 ///   RAIL_InitPowerManager();
5681 ///
5682 ///   // Configure sleep for timer synchronization
5683 ///   RAIL_TimerSyncConfig_t timerSyncConfig = RAIL_TIMER_SYNC_DEFAULT;
5684 ///   status = RAIL_ConfigSleep(railHandle, &timerSyncConfig);
5685 ///   assert(status == RAIL_STATUS_NO_ERROR);
5686 ///
5687 ///   // Configure RX duty-cycling
5688 ///   RAIL_RxDutyCycleConfig_t duty_cycle_config = {
5689 ///     .mode = RAIL_RX_CHANNEL_HOPPING_MODE_PREAMBLE_SENSE,
5690 ///     .parameter = DUTY_CYCLE_ON_TIME,
5691 ///     .delay_us = DUTY_CYCLE_OFF_TIME,
5692 ///     .delay_mode = RAIL_RX_CHANNEL_HOPPING_DELAY_MODE_STATIC,
5693 ///     .options = RAIL_RX_CHANNEL_HOPPING_OPTIONS_NONE,
5694 ///   };
5695 ///   status = RAIL_ConfigRxDutyCycle(rail_handle, &duty_cycle_config);
5696 ///   assert(status == RAIL_STATUS_NO_ERROR);
5697 ///   status = RAIL_EnableRxDutyCycle(rail_handle, true);
5698 ///   assert(status == RAIL_STATUS_NO_ERROR);
5699 ///
5700 ///   // Application main loop
5701 ///   while (1) {
5702 ///     if (dutyCycleEnd) {
5703 ///       dutyCycleEnd = false;
5704 ///       // Schedule the next receive.
5705 ///       RAIL_ScheduleRxConfig_t rxConfig = {
5706 ///         .start = periodicWakeupUs,
5707 ///         .startMode = RAIL_TIME_DELAY,
5708 ///         .end = 0U,
5709 ///         .endMode = RAIL_TIME_DISABLED,
5710 ///         .rxTransitionEndSchedule = 0U,
5711 ///         .hardWindowEnd = 0U
5712 ///       };
5713 ///       RAIL_Idle(railHandle, RAIL_IDLE_ABORT, true);
5714 ///       RAIL_StartScheduledRx(railHandle, channel, &rxConfig, NULL);
5715 ///     }
5716 ///     // ... do normal app stuff and set shouldSleep when we want to sleep
5717 ///     if (shouldSleep) {
5718 ///       // Let the CPU go to sleep if the system allows it.
5719 ///       sl_power_manager_sleep();
5720 ///     }
5721 ///   }
5722 /// }
5723 /// @endcode
5724 ///
5725 /// @note Use the compile time symbol \ref RAIL_SUPPORTS_CHANNEL_HOPPING or
5726 ///   the runtime call \ref RAIL_SupportsChannelHopping() to check whether
5727 ///   the platform supports this feature.
5728 ///
5729 /// @note Calling this function will overwrite any settings configured with
5730 ///   \ref RAIL_ConfigRxChannelHopping().
5731 ///
5732 RAIL_Status_t RAIL_ConfigRxDutyCycle(RAIL_Handle_t railHandle,
5733                                      const RAIL_RxDutyCycleConfig_t *config);
5734 
5735 /**
5736  * Enable RX duty cycle mode.
5737  *
5738  * @param[in] railHandle A RAIL instance handle.
5739  * @param[in] enable Enable (true) or disable (false) RX Duty Cycling.
5740  * @return Status code indicating success of the function call.
5741  *
5742  * Enable or disable RX duty cycle mode. After this is called, the radio
5743  * will begin duty cycling each time it enters RX, based on the
5744  * configuration passed to \ref RAIL_ConfigRxDutyCycle(). This API must not
5745  * be called while the radio is on.
5746  *
5747  * @note Use the compile time symbol \ref RAIL_SUPPORTS_CHANNEL_HOPPING or
5748  *   the runtime call \ref RAIL_SupportsChannelHopping() to check whether
5749  *   the platform supports this feature.
5750  *
5751  * @note Calling this function will overwrite any settings configured with
5752  *   \ref RAIL_EnableRxChannelHopping().
5753  */
5754 RAIL_Status_t RAIL_EnableRxDutyCycle(RAIL_Handle_t railHandle,
5755                                      bool enable);
5756 
5757 /**
5758  * Get the default RX duty cycle configuration.
5759  *
5760  * @param[in] railHandle A RAIL instance handle.
5761  * @param[out] config An application-provided non-NULL pointer to store
5762  *   the default RX duty cycle configuration.
5763  * @return Status code indicating success of the function call.
5764  *   Note that \ref RAIL_STATUS_INVALID_PARAMETER will be returned if the current
5765  *   channel's radio configuration does not support the requested information.
5766  *
5767  * To save power during RX, an application may want to go to low power as long as
5768  * possible by periodically waking up and trying to
5769  * "sense" if there are any incoming packets. This API returns the recommended
5770  * RX duty cycle configuration, so the application can enter low power mode
5771  * periodically without missing packets. To wake up
5772  * earlier, the application can reduce the delay parameter.
5773  * Note that these value might be different if any configuration / channel has
5774  * changed.
5775  **/
5776 RAIL_Status_t RAIL_GetDefaultRxDutyCycleConfig(RAIL_Handle_t railHandle,
5777                                                RAIL_RxDutyCycleConfig_t *config);
5778 
5779 /** @} */ // end of group Rx_Channel_Hopping
5780 
5781 /******************************************************************************
5782  * Multiprotocol-Specific Functions
5783  *****************************************************************************/
5784 /**
5785  * @addtogroup Multiprotocol
5786  * @brief Multiprotocol scheduler APIs to support multiple time-sliced PHYs.
5787  * @{
5788  */
5789 
5790 /**
5791  * Yield the radio to other configurations.
5792  *
5793  * @param[in] railHandle A RAIL instance handle.
5794  * @return Status code indicating success of the function call.
5795  *
5796  * This function is used to indicate that the previous transmit or scheduled
5797  * receive operation has completed. It must be used in multiprotocol RAIL because
5798  * the scheduler assumes that any transmit or receive operation that is started
5799  * can go on indefinitely based on state transitions and your protocol.
5800  * RAIL will not allow a lower priority tasks to run until this is called so it
5801  * can negatively impact performance of those protocols if this is omitted or
5802  * delayed. It is also possible to call the \ref RAIL_Idle() API to
5803  * both terminate the operation and idle the radio. In single protocol RAIL
5804  * this API does nothing, however, if RAIL Power Manager is initialized,
5805  * calling \ref RAIL_YieldRadio() after scheduled TX/RX and instantaneous TX
5806  * completion, is required, to indicate to the Power Manager that the the radio
5807  * is no longer busy and can be idled for sleeping.
5808  *
5809  * See \ref rail_radio_scheduler_yield for more details.
5810  */
5811 RAIL_Status_t RAIL_YieldRadio(RAIL_Handle_t railHandle);
5812 
5813 /**
5814  * Get the status of the RAIL scheduler.
5815  *
5816  * @param[in] railHandle A RAIL instance handle.
5817  * @return \ref RAIL_SchedulerStatus_t status.
5818  *
5819  * This function can only be called from a callback context after the
5820  * \ref RAIL_EVENT_SCHEDULER_STATUS event occurs.
5821  */
5822 RAIL_SchedulerStatus_t RAIL_GetSchedulerStatus(RAIL_Handle_t railHandle);
5823 
5824 /**
5825  * Get the status of the RAIL scheduler, specific to the radio operation,
5826  * along with \ref RAIL_Status_t returned by RAIL API invoked by the
5827  * RAIL scheduler.
5828  *
5829  * @param[in] railHandle A RAIL instance handle.
5830  * @param[out] pSchedulerStatus An application-provided pointer to store
5831  *   \ref RAIL_SchedulerStatus_t status. Can be NULL as long as pRailStatus
5832  *   is not NULL.
5833  * @param[out] pRailStatus An application-provided pointer to store
5834  *   \ref RAIL_Status_t of the RAIL API invoked by the RAIL scheduler.
5835  *   Can be NULL as long as pSchedulerStatus is not NULL.
5836  * @return Status code indicating success of the function call.
5837  *
5838  * This function can only be called from a callback context after the
5839  * \ref RAIL_EVENT_SCHEDULER_STATUS event occurs.
5840  */
5841 RAIL_Status_t RAIL_GetSchedulerStatusAlt(RAIL_Handle_t railHandle,
5842                                          RAIL_SchedulerStatus_t *pSchedulerStatus,
5843                                          RAIL_Status_t *pRailStatus);
5844 
5845 /**
5846  * Change the priority of a specified task type in multiprotocol.
5847  *
5848  * @param[in] railHandle A RAIL instance handle.
5849  * @param[in] priority Desired new priority for the railHandle's active task
5850  * @param[in] taskType Type of task whose priority should be updated
5851  * @return Status code indicating success of the function call.
5852  *
5853  * While the application can use this function however it likes, a major use
5854  * case is being able to increase an infinite receive priority while receiving
5855  * a packet. In other words, a given \ref RAIL_Handle_t can maintain a very low
5856  * priority background receive, but upon getting a
5857  * \ref RAIL_EVENT_RX_SYNC1_DETECT_SHIFT or
5858  * \ref RAIL_EVENT_RX_SYNC2_DETECT_SHIFT event, the app can call this function
5859  * to increase the background RX priority to lower the risk another protocol
5860  * might preempt during packet reception.
5861  */
5862 RAIL_Status_t RAIL_SetTaskPriority(RAIL_Handle_t railHandle,
5863                                    uint8_t priority,
5864                                    RAIL_TaskType_t taskType);
5865 
5866 /**
5867  * Get time needed to switch between protocols.
5868  *
5869  * @return \ref RAIL_Time_t Time needed to switch between protocols.
5870  */
5871 RAIL_Time_t RAIL_GetTransitionTime(void);
5872 
5873 /**
5874  * Set time needed to switch between protocols. Call this API
5875  * only once, before any protocol is initialized via
5876  * \ref RAIL_Init(). Changing this value during normal operation
5877  * can result in improper scheduling behavior.
5878  *
5879  * @param[in] transitionTime Time needed to switch between protocols.
5880  */
5881 void RAIL_SetTransitionTime(RAIL_Time_t transitionTime);
5882 
5883 /** @} */ // end of group Multiprotocol
5884 
5885 /******************************************************************************
5886  * Diagnostic
5887  *****************************************************************************/
5888 /**
5889  * @addtogroup Diagnostic
5890  * @brief APIs for diagnostic and test chip modes
5891  * @{
5892  */
5893 
5894 /**
5895  * Configure direct mode for RAIL.
5896  *
5897  * @param[in] railHandle A RAIL instance handle.
5898  * @param[in] directModeConfig A pointer to a configuration structure to specify direct mode
5899  *   parameters. Default configuration will be used if NULL is passed.
5900  * @return \ref RAIL_STATUS_NO_ERROR on success and an error code on failure.
5901  *
5902  * This API configures direct mode and should be called before
5903  * calling \ref RAIL_EnableDirectMode(). If this function is not called, the
5904  * following default \ref RAIL_DirectModeConfig_t configuration will be used: \n
5905  * @code{.c}
5906  * RAIL_DirectModeConfig_t defaultConfig = {
5907  *   .syncRx   = false,
5908  *   .syncTx   = false,
5909  *   .doutPort = SL_GPIO_PORT_A,
5910  *   .doutPin  = 5,
5911  *   .dinPort  = SL_GPIO_PORT_A,
5912  *   .dinPin   = 7,
5913  *   .dclkPort = SL_GPIO_PORT_A,
5914  *   .dclkPin  = 6,
5915  * };
5916  * @endcode
5917  *
5918  * @warning This API is not safe to use in a multiprotocol app.
5919  */
5920 RAIL_Status_t RAIL_ConfigDirectMode(RAIL_Handle_t railHandle,
5921                                     const RAIL_DirectModeConfig_t *directModeConfig);
5922 
5923 /**
5924  *  Enable or disable direct mode for RAIL.
5925  *
5926  * @param[in] railHandle A RAIL instance handle.
5927  * @param[in] enable Whether or not to enable direct mode for TX and RX.
5928  * @return \ref RAIL_STATUS_NO_ERROR on success and an error code on failure.
5929  *
5930  * See \ref RAIL_EnableDirectModeAlt() for more detailed function
5931  * description.
5932  *
5933  * @warning New applications should consider using \ref RAIL_EnableDirectModeAlt() for
5934  *   this functionality.
5935  *
5936  * @note This feature is only available on certain devices.
5937  *   \ref RAIL_SupportsDirectMode() can be used to check if a particular
5938  *   device supports this feature or not.
5939  *
5940  * @warning As this function relies on GPIO access and RAIL is meant to run in
5941  *   TrustZone non-secure world, it is not supported if GPIO is configured as
5942  *   secure peripheral and it will return \ref RAIL_STATUS_INVALID_CALL.
5943  */
5944 RAIL_Status_t RAIL_EnableDirectMode(RAIL_Handle_t railHandle,
5945                                     bool enable);
5946 
5947 /**
5948  * Enable or disable direct mode for RAIL.
5949  *
5950  * @param[in] railHandle A RAIL instance handle.
5951  * @param[in] enableDirectTx Enable direct mode for data being transmitted out
5952  *   of the radio.
5953  * @param[in] enableDirectRx Enable direct mode for data being received from
5954  *   the radio.
5955  * @return \ref RAIL_STATUS_NO_ERROR on success or an error code on failure.
5956  *
5957  * This API enables or disables the modem and GPIOs for direct mode operation.
5958  * see \ref RAIL_ConfigDirectMode() for information on selecting the
5959  * correct hardware configuration. If direct mode is enabled,
5960  * packets are output and input directly to the radio via GPIO
5961  * and RAIL packet handling is ignored.
5962  *
5963  * @note This feature is only available on certain chips.
5964  *   \ref RAIL_SupportsDirectMode() can be used to check if a particular
5965  *   chip supports this feature or not.
5966  *
5967  * @warning This API is not safe to use in a multiprotocol app.
5968  *
5969  * @warning As this function relies on GPIO access and RAIL is meant to run in
5970  *   TrustZone non-secure world, it is not supported if GPIO is configured as
5971  *   secure peripheral and it will return \ref RAIL_STATUS_INVALID_CALL.
5972  */
5973 RAIL_Status_t RAIL_EnableDirectModeAlt(RAIL_Handle_t railHandle,
5974                                        bool enableDirectTx,
5975                                        bool enableDirectRx);
5976 
5977 /**
5978  * Get the radio subsystem clock frequency in Hz.
5979  *
5980  * @param[in] railHandle A RAIL instance handle.
5981  * @return Radio subsystem clock frequency in Hz.
5982  */
5983 uint32_t RAIL_GetRadioClockFreqHz(RAIL_Handle_t railHandle);
5984 
5985 /**
5986  * Set the crystal tuning.
5987  *
5988  * @param[in] railHandle A RAIL instance handle.
5989  * @param[in] tune A chip-dependent crystal capacitor bank tuning parameter.
5990  * @return Status code indicating success of the function call.
5991  *
5992  * Tunes the crystal that the radio depends on to change the location of the
5993  * center frequency for transmitting and receiving. This function will only
5994  * succeed if the radio is idle at the time of the call.
5995  *
5996  * @note This function proportionally affects the entire chip's timing
5997  *   across all its peripherals, including radio tuning and channel spacing.
5998  *   It is recommended to call this function only when HFXO is not being used,
5999  *   as it can cause disturbance on the HFXO frequency.
6000  *   A separate function, \ref RAIL_SetFreqOffset(), can be used to adjust
6001  *   just the radio tuner without disturbing channel spacing or other chip
6002  *   peripheral timing.
6003  * @note This API sets CTUNEXIANA and internally
6004  *   CTUNEXOANA = CTUNEXIANA + delta where delta is set or changed by
6005  *   \ref RAIL_SetTuneDelta(). The default delta may not be 0 on some devices.
6006  */
6007 RAIL_Status_t RAIL_SetTune(RAIL_Handle_t railHandle, uint32_t tune);
6008 
6009 /**
6010  * Get the crystal tuning.
6011  *
6012  * @param[in] railHandle A RAIL instance handle.
6013  * @return A chip-dependent crystal capacitor bank tuning parameter.
6014  *
6015  * Retrieves the current tuning value used by the crystal that the radio
6016  * depends on.
6017  * @note This is the CTUNEXIANA value.
6018  */
6019 uint32_t RAIL_GetTune(RAIL_Handle_t railHandle);
6020 
6021 /**
6022  * Set the crystal tuning delta.
6023  *
6024  * @param[in] railHandle A RAIL instance handle.
6025  * @param[in] delta A chip-dependent crystal capacitor bank tuning delta.
6026  * @return Status code indicating success of the function call.
6027  *
6028  * Set the CTUNEXOANA delta for \ref RAIL_SetTune() to use:
6029  * CTUNEXOANA = CTUNEXIANA + delta (subject to field-size limitations).
6030  * This function does not change CTUNE values;
6031  * call \ref RAIL_SetTune() to put a new delta into effect.
6032  */
6033 RAIL_Status_t RAIL_SetTuneDelta(RAIL_Handle_t railHandle, int32_t delta);
6034 
6035 /**
6036  * Get the crystal tuning delta.
6037  *
6038  * @param[in] railHandle A RAIL instance handle.
6039  * @return A chip-dependent crystal capacitor bank tuning delta.
6040  *
6041  * Retrieves the current tuning delta used by \ref RAIL_SetTune().
6042  * @note The default delta if \ref RAIL_SetTuneDelta() has never been called
6043  *   is device-dependent and may not be 0.
6044  */
6045 int32_t RAIL_GetTuneDelta(RAIL_Handle_t railHandle);
6046 
6047 /**
6048  * Get the frequency offset.
6049  *
6050  * @param[in] railHandle A RAIL instance handle.
6051  * @return The measured frequency offset on a received packet.
6052  *   The units are described in the \ref RAIL_FrequencyOffset_t
6053  *   documentation. If this returns \ref RAIL_FREQUENCY_OFFSET_INVALID,
6054  *   it was called while the radio wasn't active and there is no way
6055  *   to get the frequency offset.
6056  *
6057  * Retrieves the measured frequency offset used during the previous
6058  * received packet, which includes the current radio frequency offset
6059  * (see \ref RAIL_SetFreqOffset()). If the chip has not been in RX,
6060  * it returns the nominal radio frequency offset.
6061  *
6062  * @note Changing to any non-idle radio state after reception can cause this
6063  *   value to be overwritten so it is safest to capture during packet reception.
6064  */
6065 RAIL_FrequencyOffset_t RAIL_GetRxFreqOffset(RAIL_Handle_t railHandle);
6066 
6067 /**
6068  * Set the nominal radio frequency offset.
6069  *
6070  * @param[in] railHandle A RAIL instance handle.
6071  * @param[in] freqOffset \ref RAIL_FrequencyOffset_t parameter (signed, 2's
6072  *   complement).
6073  * @return Status code indicating success of the function call.
6074  *
6075  * This function is used to adjust the radio's tuning frequency slightly up or down.
6076  * It might be used in conjunction with \ref RAIL_GetRxFreqOffset() after
6077  * receiving a packet from a peer to adjust the tuner to better match the
6078  * peer's tuned frequency.
6079  *
6080  * @note Unlike \ref RAIL_SetTune(), which affects the entire chip's
6081  *   timing including radio tuning and channel spacing, this function
6082  *   only affects radio tuning without disturbing channel spacing or
6083  *   other chip peripheral timing.
6084  */
6085 RAIL_Status_t RAIL_SetFreqOffset(RAIL_Handle_t railHandle,
6086                                  RAIL_FrequencyOffset_t freqOffset);
6087 
6088 /**
6089  * Start transmitting a stream on a certain channel.
6090  *
6091  * @param[in] railHandle A RAIL instance handle.
6092  * @param[in] channel A channel on which to emit a stream.
6093  * @param[in] mode Choose the stream mode (PN9, and so on).
6094  * @return Status code indicating success of the function call.
6095  *
6096  * Begins streaming onto the given channel. The sources can either be an
6097  * unmodulated carrier wave or an encoded stream of bits from a PN9 source.
6098  * All ongoing radio operations will be stopped before transmission begins.
6099  */
6100 RAIL_Status_t RAIL_StartTxStream(RAIL_Handle_t railHandle,
6101                                  uint16_t channel,
6102                                  RAIL_StreamMode_t mode);
6103 
6104 /**
6105  * Start transmitting a stream on a certain channel with the ability to select
6106  * an antenna.
6107  *
6108  * @param[in] railHandle A RAIL instance handle.
6109  * @param[in] channel A channel on which to emit a stream.
6110  * @param[in] mode Choose the stream mode (PN9, and so on).
6111  * @param[in] options Choose the TX Antenna option.
6112  *   Takes only \ref RAIL_TX_OPTION_ANTENNA0, \ref RAIL_TX_OPTION_ANTENNA1,
6113  *   \ref RAIL_TX_OPTIONS_DEFAULT or \ref RAIL_TX_OPTIONS_NONE from the
6114  *   \ref RAIL_TxOptions_t. If some other value is used then, transmission
6115  *   is possible on any antenna.
6116  * @return Status code indicating success of the function call.
6117  *
6118  * Begins streaming onto the given channel. The sources can either be an
6119  * unmodulated carrier wave or an encoded stream of bits from a PN9 source.
6120  * All ongoing radio operations will be stopped before transmission begins.
6121  */
6122 RAIL_Status_t RAIL_StartTxStreamAlt(RAIL_Handle_t railHandle,
6123                                     uint16_t channel,
6124                                     RAIL_StreamMode_t mode,
6125                                     RAIL_TxOptions_t options);
6126 
6127 /**
6128  * Stop stream transmission and idle the radio.
6129  *
6130  * @param[in] railHandle A RAIL instance handle.
6131  * @return Status code indicating success of the function call.
6132  *
6133  * Halts the transmission started by \ref RAIL_StartTxStream().
6134  */
6135 RAIL_Status_t RAIL_StopTxStream(RAIL_Handle_t railHandle);
6136 
6137 /**
6138  * Stop infinite preamble transmission started and start transmitting the rest
6139  * of the packet.
6140  *
6141  * @param[in] railHandle A RAIL instance handle.
6142  * @return Status code indicating success of the function call:
6143  *   \ref RAIL_STATUS_NO_ERROR if infinite preamble was stopped;
6144  *   \ref RAIL_STATUS_INVALID_CALL if the radio isn't configured for infinite
6145  *   preamble;
6146  *   \ref RAIL_STATUS_INVALID_STATE if the radio isn't transmitting.
6147  *
6148  * This function is only useful for radio configurations that specify an
6149  * infinite preamble. Call this API only after \ref RAIL_EVENT_TX_STARTED
6150  * has occurred and the radio is transmitting.
6151  */
6152 RAIL_Status_t RAIL_StopInfinitePreambleTx(RAIL_Handle_t railHandle);
6153 
6154 /**
6155  * Configure the verification of radio memory contents.
6156  *
6157  * @param[in] railHandle A RAIL instance handle.
6158  * @param[in,out] configVerify A pointer to a configuration structure made available to
6159  *   RAIL to perform radio state verification. This structure must be
6160  *   allocated in application global read-write memory. RAIL may modify
6161  *   fields within or referenced by this structure during its operation.
6162  * @param[in] radioConfig A radio configuration (pointer) that is to be used as a
6163  *   white list for verifying memory contents.
6164  * @param[in] cb A callback that notifies the application of a mismatch in
6165  *   expected vs actual memory contents. A NULL parameter may be passed in
6166  *   if a callback is not needed by the application.
6167  * @return \ref RAIL_STATUS_NO_ERROR if setup of the verification feature
6168  *   successfully occurred.
6169  *   \ref RAIL_STATUS_INVALID_PARAMETER is returned if the provided railHandle
6170  *   or configVerify structures are invalid.
6171  */
6172 RAIL_Status_t RAIL_ConfigVerification(RAIL_Handle_t railHandle,
6173                                       RAIL_VerifyConfig_t *configVerify,
6174                                       RAIL_RadioConfig_t radioConfig,
6175                                       RAIL_VerifyCallbackPtr_t cb);
6176 
6177 /**
6178  * Verify radio memory contents.
6179  *
6180  * @param[in,out] configVerify A pointer to the configuration structure
6181  *   previously established by \ref RAIL_ConfigVerification().
6182  * @param[in] durationUs The duration (in microseconds) for how long memory
6183  *   verification should occur before returning to the application. A value of
6184  *   \ref RAIL_VERIFY_DURATION_MAX indicates that all memory contents should be
6185  *   verified before returning to the application.
6186  * @param[in] restart This flag only has meaning if a previous call of this
6187  *   function returned \ref RAIL_STATUS_SUSPENDED. By restarting (true), the
6188  *   verification process starts over from the beginning, or by resuming
6189  *   where verification left off after being suspended (false), verification
6190  *   can proceed towards completion.
6191  * @return \ref RAIL_STATUS_NO_ERROR if the contents of all applicable
6192  *   memory locations have been verified.
6193  *   \ref RAIL_STATUS_SUSPENDED is returned if the provided test duration
6194  *   expired but the time was not sufficient to verify all memory contents.
6195  *   By calling \ref RAIL_Verify() again, further verification will commence.
6196  *   \ref RAIL_STATUS_INVALID_PARAMETER is returned if the provided
6197  *   verifyConfig structure pointer is not configured for use by the active
6198  *   RAIL handle.
6199  *   \ref RAIL_STATUS_INVALID_STATE is returned if any of the verified
6200  *   memory contents are different from their reference values.
6201  */
6202 RAIL_Status_t RAIL_Verify(RAIL_VerifyConfig_t *configVerify,
6203                           uint32_t durationUs,
6204                           bool restart);
6205 
6206 #ifndef DOXYGEN_SHOULD_SKIP_THIS
6207 
6208 /**
6209  * Enable radio state change interrupt.
6210  *
6211  * @param[in] railHandle A RAIL instance handle.
6212  * @param[in] enable Enable/disable Radio state change interrupt.
6213  * @return Status code indicating success of the function call. Returns
6214  *   \ref RAIL_STATUS_NO_ERROR once the interrupt has been enabled or disabled.
6215  *
6216  * @note If enabled, state change events are reported through the separate
6217  *   \ref RAILCb_RadioStateChanged() callback.
6218  */
6219 RAIL_Status_t RAIL_EnableRadioStateChanged(RAIL_Handle_t railHandle,
6220                                            bool enable);
6221 
6222 /**
6223  * Callback on radio state changes.
6224  *
6225  * @param[in] state The current radio state.
6226  */
6227 void RAILCb_RadioStateChanged(uint8_t state);
6228 
6229 /**
6230  * Get the current radio state.
6231  *
6232  * @param[in] railHandle A RAIL instance handle.
6233  * @return An enumeration, \ref RAIL_RadioStateEfr32_t, for the current radio
6234  *   state.
6235  *
6236  */
6237 RAIL_RadioStateEfr32_t RAIL_GetRadioStateAlt(RAIL_Handle_t railHandle);
6238 
6239 #endif//DOXYGEN_SHOULD_SKIP_THIS
6240 
6241 /** @} */ // end of group Diagnostic
6242 
6243 /******************************************************************************
6244  * Front End Module Voltage Detection (VDET)
6245  *****************************************************************************/
6246 /**
6247  * @addtogroup VDET Front End Module Voltage Detection
6248  * @brief APIs for configuring and detecting a voltage from a Front End Module (VDET).
6249  *
6250  * The rail_util_vdet plugin lets customers measure an output voltage from their attached
6251  * Front End Module at a specific time in a Tx packet. This information allows
6252  * optimizations to power configuration, and monitoring FEM performance.
6253  *
6254  * @note VDET is only supported with EFR32xG25 devices.
6255  * @{
6256  */
6257 
6258 /**
6259  * Configure the VDET plugin.
6260  *
6261  * @param[in] genericRailHandle A radio-generic RAIL handle.
6262  * @param[in] config A pointer to a \ref RAIL_VdetConfig_t struct that contains
6263  *   configuration data for the VDET.
6264  * @return \ref RAIL_Status_t
6265  *   \retval RAIL_STATUS_NO_ERROR - All went well
6266  *   \retval RAIL_STATUS_INVALID_STATE - VDET is enabled. Must be disabled first.
6267  *   \retval RAIL_STATUS_INVALID_PARAMETER - mode/resolution/delayUs out-of-bounds.
6268  *
6269  * @warning As this function relies on GPIO access and RAIL is meant to run in
6270  *   TrustZone non-secure world, it is not supported if GPIO is configured as
6271  *   secure peripheral and it will return \ref RAIL_STATUS_INVALID_CALL.
6272  */
6273 RAIL_Status_t RAIL_ConfigVdet(RAIL_Handle_t genericRailHandle,
6274                               const RAIL_VdetConfig_t *config);
6275 
6276 /**
6277  * Get the VDET plugin configuration.
6278  *
6279  * @param[in] genericRailHandle A radio-generic RAIL handle.
6280  * @param[out] config A pointer to a \ref RAIL_VdetConfig_t struct that will
6281  *   return configuration data for the VDET.
6282  * @return \ref RAIL_Status_t
6283  *   \retval RAIL_STATUS_NO_ERROR - All went well.
6284  */
6285 RAIL_Status_t RAIL_GetVdetConfig(RAIL_Handle_t genericRailHandle,
6286                                  RAIL_VdetConfig_t *config);
6287 
6288 /**
6289  * Enable the VDET plugin.
6290  *
6291  * @param[in] genericRailHandle A RAIL instance handle.
6292  * @param[in] enable Enable or disable \ref RAIL_VDET_MODE_AUTOMATIC mode captures.
6293  *   Begins measurement if in \ref RAIL_VDET_MODE_IMMEDIATE.
6294  * @return \ref RAIL_Status_t
6295  *   \retval RAIL_STATUS_NO_ERROR - All went well, VDET is enabled or disabled.
6296  *   \retval RAIL_STATUS_INVALID_STATE - VDET has not been configured or VDET was not idle.
6297  *     VDET is disabled.
6298  *
6299  * @warning As this function relies on HFXO access and RAIL is meant to run in
6300  *   TrustZone non-secure world, it is not supported if HFXO is configured as
6301  *   secure peripheral and it will return \ref RAIL_STATUS_INVALID_CALL.
6302  */
6303 RAIL_Status_t RAIL_EnableVdet(RAIL_Handle_t genericRailHandle,
6304                               bool enable);
6305 
6306 /**
6307  * Check if the VDET plugin is enabled.
6308  *
6309  * @param[in] genericRailHandle A RAIL instance handle.
6310  * @return bool
6311  */
6312 bool RAIL_IsVdetEnabled(RAIL_Handle_t genericRailHandle);
6313 
6314 /**
6315  * Get VDET measurement. A processed measurement in millivolts.
6316  *
6317  * @param[in] genericRailHandle A RAIL instance handle.
6318  * @param[out] pVdetMv A pointer to a uint32_t for returning the measurement.
6319  * @return \ref RAIL_Status_t
6320  *   \retval RAIL_STATUS_NO_ERROR - All went well, value in *pVdetMv is valid.
6321  *   \retval RAIL_STATUS_INVALID_CALL - VDET is in progress, wait until
6322  *     VDET capture is complete and try again.
6323  *   \retval RAIL_STATUS_INVALID_STATE - VDET is not enabled or valid. Wait until next packet
6324        and try reading again.\n
6325  *       \ref RAIL_VDET_MODE_AUTOMATIC - Wait until next packet and try reading again.\n
6326  *       \ref RAIL_VDET_MODE_IMMEDIATE - Resend \ref RAIL_EnableVdet().\n
6327  *   \retval RAIL_STATUS_INVALID_PARAMETER - In \ref RAIL_VDET_MODE_IMMEDIATE, resend \ref RAIL_EnableVdet().\n
6328  *   \retval RAIL_STATUS_SUSPENDED - Blocked by AuxADC contention. Wait until next packet
6329        and try reading again.
6330  *
6331  * @warning As this function relies on HFXO access and RAIL is meant to run in
6332  *   TrustZone non-secure world, it is not supported if HFXO is configured as
6333  *   secure peripheral and it will return \ref RAIL_STATUS_INVALID_CALL.
6334  */
6335 RAIL_Status_t RAIL_GetVdet(RAIL_Handle_t genericRailHandle,
6336                            uint32_t *pVdetMv);
6337 
6338 /** @} */ // end of group VDET
6339 
6340 /******************************************************************************
6341  * Thermal Protection
6342  *****************************************************************************/
6343 /**
6344  * @addtogroup Thermal_Protection Thermal Protection
6345  * @{
6346  */
6347 
6348 /**
6349  * Enable or disable the thermal protection if \ref RAIL_SUPPORTS_THERMAL_PROTECTION
6350  * is defined and update the temperature threshold and cool down hysteresis preventing or
6351  * allowing transmissions.
6352  *
6353  * @param[in] genericRailHandle A radio-generic RAIL handle.
6354  * @param[in] chipTempConfig A pointer to a \ref RAIL_ChipTempConfig_t that contains
6355  *   the configuration to be applied.
6356  * @return Status code indicating the result of the function call.
6357  *   Returns \ref RAIL_STATUS_INVALID_PARAMETER if enable field from \ref RAIL_ChipTempConfig_t
6358  *   is set to false when an EFF is present on the board.
6359  *
6360  * When the temperature threshold minus a precise number of degrees
6361  * specified by the cool down hysteresis parameter is exceeded,
6362  * any future transmits are blocked until the temperature decreases below that limit.
6363  * Besides, if the temperature threshold is exceeded, any active transmit is aborted.
6364  *
6365  * By default the threshold is set to \ref RAIL_CHIP_TEMP_THRESHOLD_MAX and
6366  * the cool down hysteresis is set to \ref RAIL_CHIP_TEMP_COOLDOWN_DEFAULT.
6367  *
6368  * @note The thermal protection is automatically enabled when an EFF is present
6369  *   on the board. There is no use in calling this API in this case.
6370  */
6371 RAIL_Status_t RAIL_ConfigThermalProtection(RAIL_Handle_t genericRailHandle,
6372                                            const RAIL_ChipTempConfig_t *chipTempConfig);
6373 
6374 /**
6375  * Get the current thermal configuration parameter and status.
6376  *
6377  * @param[in] genericRailHandle A radio-generic RAIL handle.
6378  * @param[out] chipTempConfig A non-NULL pointer to a \ref RAIL_ChipTempConfig_t that will
6379  *   be updated with the current configuration.
6380  * @return Status code indicating the result of the function call.
6381  */
6382 RAIL_Status_t RAIL_GetThermalProtection(RAIL_Handle_t genericRailHandle,
6383                                         RAIL_ChipTempConfig_t *chipTempConfig);
6384 
6385 /** Number of temperature values provided for HFXO metrics */
6386 #define RAIL_HFXO_TEMP_MEASURE_COUNT              (1U)
6387 
6388 /** Total number of temperature values provided by \ref RAIL_GetTemperature(). */
6389 #define RAIL_TEMP_MEASURE_COUNT  (RAIL_CHIP_TEMP_MEASURE_COUNT \
6390                                   + RAIL_HFXO_TEMP_MEASURE_COUNT)
6391 
6392 /**
6393  * Get the different temperature measurements in Kelvin done by sequencer or host.
6394  *
6395  * @param[in] railHandle A RAIL instance handle.
6396  * @param[out] tempBuffer The address of the array that will contain temperatures.
6397  *    This array must have at least \ref RAIL_TEMP_MEASURE_COUNT entries.
6398  * @param[in] reset true to reset the temperature statistics, false otherwise.
6399  * @return Status code indicating success of the function call.
6400  *
6401  * Temperatures, in Kelvin, are stored in tempBuffer such as:
6402  * - tempBuffer[0] is the chip temperature
6403  * - tempBuffer[1] is the minimal chip temperature
6404  * - tempBuffer[2] is the maximal chip temperature
6405  *
6406  * Values that are not populated yet or incorrect are set to 0.
6407  *
6408  * If \ref RAIL_SUPPORTS_HFXO_COMPENSATION
6409  * tempBuffer[3] is the HFXO temperature
6410  */
6411 RAIL_Status_t RAIL_GetTemperature(RAIL_Handle_t railHandle,
6412                                   int16_t tempBuffer[RAIL_TEMP_MEASURE_COUNT],
6413                                   bool reset);
6414 
6415 /** @} */ // end of group Thermal_Protection
6416 
6417 /******************************************************************************
6418  * Retiming
6419  *****************************************************************************/
6420 /**
6421  * @addtogroup Retiming
6422  * @{
6423  * @brief EFR32-specific retiming capability.
6424  *
6425  * The EFR product families have many digital and analog modules that can run
6426  * in parallel with a radio. These combinations can cause interference and
6427  * degradation on the radio RX sensitivity. Retiming can
6428  * modify the clocking of the digital modules to reduce the interference.
6429  */
6430 
6431 /**
6432  * Configure retiming options.
6433  *
6434  * @param[in] railHandle A handle of RAIL instance.
6435  * @param[in] mask A bitmask containing which options should be modified.
6436  * @param[in] options A bitmask containing desired configuration settings.
6437  *   Bit positions for each option are found in the \ref RAIL_RetimeOptions_t.
6438  * @return Status code indicating success of the function call.
6439  */
6440 RAIL_Status_t RAIL_ConfigRetimeOptions(RAIL_Handle_t railHandle,
6441                                        RAIL_RetimeOptions_t mask,
6442                                        RAIL_RetimeOptions_t options);
6443 
6444 /**
6445  * Get the currently configured retiming option.
6446  *
6447  * @param[in] railHandle A handle of RAIL instance.
6448  * @param[out] pOptions A pointer to configured retiming options
6449  *   bitmask indicating which are enabled.
6450  * @return Status code indicating success of the function call.
6451  */
6452 RAIL_Status_t RAIL_GetRetimeOptions(RAIL_Handle_t railHandle,
6453                                     RAIL_RetimeOptions_t *pOptions);
6454 
6455 /**
6456  * Indicate that the DCDC peripheral bus clock enable has changed allowing
6457  * RAIL to react accordingly.
6458  *
6459  * @return Status code indicating success of the function call.
6460  *
6461  * @note This should be called after DCDC has been enabled or disabled.
6462  */
6463 RAIL_Status_t RAIL_ChangedDcdc(void);
6464 
6465 /** @} */ // end of group Retiming
6466 
6467 #ifndef DOXYGEN_SHOULD_SKIP_THIS
6468 
6469 /******************************************************************************
6470  * Debug
6471  *****************************************************************************/
6472 /**
6473  * @addtogroup Debug
6474  * @brief APIs for debugging
6475  * @{
6476  */
6477 
6478 /**
6479  * Configure the debug mode for the radio library. Do not use this function
6480  * unless instructed by Silicon Labs.
6481  *
6482  * @param[in] railHandle A RAIL instance handle.
6483  * @param[in] debugMode Debug mode to enter.
6484  * @return Status code indicating success of the function call.
6485  */
6486 RAIL_Status_t RAIL_SetDebugMode(RAIL_Handle_t railHandle, uint32_t debugMode);
6487 
6488 /**
6489  * Return the debug mode for the radio library. Do not use this function
6490  * unless instructed by Silicon Labs.
6491  *
6492  * @param[in] railHandle A RAIL instance handle.
6493  * @return Debug mode for the radio library.
6494  */
6495 uint32_t RAIL_GetDebugMode(RAIL_Handle_t railHandle);
6496 
6497 /**
6498  * Override the radio base frequency.
6499  *
6500  * @param[in] railHandle A RAIL instance handle.
6501  * @param[in] freq A desired frequency in Hz.
6502  * @return Status code indicating success of the function call.
6503  *
6504  * Sets the radio to transmit at the frequency given. This function can only
6505  * be used while in \ref RAIL_DEBUG_MODE_FREQ_OVERRIDE. The given frequency
6506  * needs to be close to the base frequency of the current PHY. After this
6507  * call, a full reset is needed to restore normal RAIL operation.
6508  */
6509 RAIL_Status_t RAIL_OverrideDebugFrequency(RAIL_Handle_t railHandle,
6510                                           uint32_t freq);
6511 
6512 /**
6513  * Get the size of the radio's multiprotocol scheduler state buffer.
6514  *
6515  * @param[in] genericRailHandle A radio-generic RAIL handle.
6516  * @return Size, in bytes, of the radio's internal scheduler state buffer.
6517  *   Zero is returned if the handle is invalid or this is the singleprotocol
6518  *   library.
6519  */
6520 uint32_t RAIL_GetSchedBufferSize(RAIL_Handle_t genericRailHandle);
6521 
6522 /** @} */ // end of group Debug
6523 
6524 #endif//DOXYGEN_SHOULD_SKIP_THIS
6525 
6526 /******************************************************************************
6527  * Assertion Callback
6528  *****************************************************************************/
6529 /**
6530  * @addtogroup Assertions
6531  * @brief Callbacks called by assertions
6532  *
6533  * The assertion framework was implemented to not only
6534  * assert that certain conditions are true in a block of code, but also
6535  * to handle them more appropriately. In previous implementations,
6536  * the behavior upon a failed assert was to hang in a while(1) loop.
6537  * However, with the callback, each assert is given a unique error code so that
6538  * they can be handled on a more case-by-case basis. For documentation on each
6539  * of the errors, see the rail_assert_error_codes.h file.
6540  * \ref RAIL_ASSERT_ERROR_MESSAGES[errorCode] gives the explanation of the error.
6541  * With asserts built into the library, users can choose how to handle each
6542  * error inside the callback.
6543  *
6544  * @{
6545  */
6546 
6547 /**
6548  * Callback called upon failed assertion.
6549  *
6550  * @param[in] railHandle A RAIL instance handle.
6551  * @param[in] errorCode Value passed in by the calling assertion API indicating
6552  *   the RAIL assertion that failed.
6553  */
6554 void RAILCb_AssertFailed(RAIL_Handle_t railHandle,
6555                          RAIL_AssertErrorCodes_t errorCode);
6556 
6557 /** @} */ // end of group Assertions
6558 
6559 /******************************************************************************
6560  * External_Thermistor
6561  *****************************************************************************/
6562 /**
6563  * @addtogroup External_Thermistor External Thermistor
6564  * @brief APIs to measure temperature using an external thermistor
6565  *
6566  * This feature allows reading the temperature via an external thermistor on
6567  * chips that support it. This will require connecting the necessary components
6568  * and configuring the pins as required.
6569  *
6570  * @{
6571  */
6572 
6573 /**
6574  * Start a thermistor measurement.
6575  *
6576  * @param[in] railHandle A radio-generic or real RAIL instance handle.
6577  * @return Status code indicating success of the function call.
6578  *   Returns \ref RAIL_STATUS_INVALID_STATE if the thermistor is started while the
6579  *   radio is transmitting.
6580  *
6581  * To get the thermistor impedance, call the
6582  * function \ref RAIL_GetThermistorImpedance(). On platforms having
6583  * \ref RAIL_SUPPORTS_EXTERNAL_THERMISTOR, this function reconfigures
6584  * GPIO_THMSW_EN_PIN located in GPIO_THMSW_EN_PORT.
6585  * To locate this pin, refer to the data sheet or appropriate header files
6586  * of the device. For proper operation, \ref RAIL_Init() must be called before
6587  * using this function.
6588  *
6589  * @note When an EFF is attached, this function must not be called during
6590  *   transmit.
6591  *
6592  * @warning This API is not safe to use in a multiprotocol app.
6593  *
6594  * @warning As this function relies on EMU, GPIO and HFXO access and RAIL is
6595  *   meant to run in TrustZone non-secure world, it is not supported if EMU,
6596  *   GPIO or HFXO are configured as secure peripheral and it will return
6597  *   \ref RAIL_STATUS_INVALID_CALL.
6598  */
6599 RAIL_Status_t RAIL_StartThermistorMeasurement(RAIL_Handle_t railHandle);
6600 
6601 /**
6602  * Get the thermistor impedance measurement and return \ref
6603  * RAIL_INVALID_THERMISTOR_VALUE if the thermistor is not properly
6604  * configured or the thermistor measurement is not ready.
6605  *
6606  * @param[in] railHandle A radio-generic or real RAIL instance handle.
6607  * @param[out] thermistorImpedance A pointer to a uint32_t updated
6608  *   with the current thermistor impedance measurement in Ohms.
6609  * @return Status code indicating success of the function call.
6610  *
6611  * @note This function is already called in \ref RAIL_CalibrateHFXO().
6612  *   It does not need to be manually called during the compensation sequence.
6613  */
6614 RAIL_Status_t RAIL_GetThermistorImpedance(RAIL_Handle_t railHandle,
6615                                           uint32_t *thermistorImpedance);
6616 
6617 /**
6618  * Convert the thermistor impedance into temperature, in Celsius.
6619  *
6620  * @param[in] railHandle A radio-generic or real RAIL instance handle.
6621  * @param[in] thermistorImpedance Current thermistor impedance measurement in
6622  *   Ohms.
6623  * @param[out] thermistorTemperatureC A non-NULL pointer to an int16_t updated
6624  *   with the current thermistor temperature in eighth of Celsius degrees.
6625  * @return Status code indicating success of the function call.
6626  *
6627  * A version of this function is provided in the \ref rail_util_thermistor
6628  * plugin for Silicon Labs radio boards. For custom boards this function can be
6629  * modified and re-implemented as needed.
6630  *
6631  * @note This plugin is mandatory on EFR32xG25 platform.
6632  */
6633 RAIL_Status_t RAIL_ConvertThermistorImpedance(RAIL_Handle_t railHandle,
6634                                               uint32_t thermistorImpedance,
6635                                               int16_t *thermistorTemperatureC);
6636 
6637 /**
6638  * Compute the crystal PPM deviation from the thermistor temperature.
6639  *
6640  * @param[in] railHandle A radio-generic or real RAIL instance handle.
6641  * @param[in] crystalTemperatureC Current crystal temperature, in Celsius.
6642  * @param[out] crystalPPMError A non-NULL pointer to an int8_t updated
6643  *   with the current ppm error in ppm units.
6644  * @return Status code indicating success of the function call.
6645  *
6646  * This function is provided in the rail_util_thermistor plugin to get
6647  * accurate values from our boards thermistor. For a custom board, this
6648  * function could be modified and re-implemented for other needs.
6649  *
6650  * @note This plugin is mandatory on EFR32xG25 platform.
6651  */
6652 RAIL_Status_t RAIL_ComputeHFXOPPMError(RAIL_Handle_t railHandle,
6653                                        int16_t crystalTemperatureC,
6654                                        int8_t *crystalPPMError);
6655 
6656 /**
6657  * Configure the GPIO for thermistor usage.
6658  *
6659  * @param[in] railHandle A radio-generic or real RAIL instance handle.
6660  * @param[in] pHfxoThermistorConfig A non-NULL pointer to the thermistor configuration
6661  *   indicating the GPIO port and pin to use.
6662  * @return Status code indicating the result of the function call.
6663  *
6664  * @note The port and pin that must be passed in \ref RAIL_HFXOThermistorConfig_t
6665  *   are GPIO_THMSW_EN_PORT and GPIO_THMSW_EN_PIN respectively.
6666  *
6667  * @warning As this function relies on GPIO access and RAIL is meant to run in
6668  *   TrustZone non-secure world, it is not supported if GPIO is configured as
6669  *   secure peripheral and it will return \ref RAIL_STATUS_INVALID_CALL.
6670  */
6671 RAIL_Status_t RAIL_ConfigHFXOThermistor(RAIL_Handle_t railHandle,
6672                                         const RAIL_HFXOThermistorConfig_t *pHfxoThermistorConfig);
6673 
6674 /**
6675  * Configure the temperature parameters for HFXO compensation.
6676  *
6677  * @param[in] railHandle A RAIL instance handle.
6678  * @param[in] pHfxoCompensationConfig A non-NULL pointer to HFXO compensation parameters
6679  *   indicating the temperature variations used to trigger a compensation.
6680  * @return Status code indicating the result of the function call.
6681  *
6682  * @note This function must be called after \ref RAIL_ConfigHFXOThermistor() to succeed.
6683  *
6684  * In \ref RAIL_HFXOCompensationConfig_t, deltaNominal and
6685  * deltaCritical define the temperature variation triggering
6686  * a new compensation.
6687  * The field zoneTemperatureC defines the temperature separating
6688  * the nominal case (below) from the critical one (above).
6689  *
6690  * When enabled and either deltaNominal or deltaCritical
6691  * are exceeded, RAIL raises
6692  * event \ref RAIL_EVENT_CAL_NEEDED with \ref RAIL_CAL_TEMP_HFXO bit set.
6693  * The API \ref RAIL_StartThermistorMeasurement() must be called afterwards.
6694  * The latter will raise \ref RAIL_EVENT_THERMISTOR_DONE with calibration bit
6695  * \ref RAIL_CAL_COMPENSATE_HFXO set and a call to \ref RAIL_CalibrateHFXO() must follow.
6696  *
6697  * @note Set deltaNominal and deltaCritical to 0 to perform
6698  *   compensation after each transmit.
6699  */
6700 RAIL_Status_t RAIL_ConfigHFXOCompensation(RAIL_Handle_t railHandle,
6701                                           const RAIL_HFXOCompensationConfig_t *pHfxoCompensationConfig);
6702 
6703 /**
6704  * Get the temperature parameters for HFXO compensation.
6705  *
6706  * @param[in] railHandle A RAIL instance handle.
6707  * @param[out] pHfxoCompensationConfig A non-NULL pointer to HFXO
6708  *   compensation parameters filled in by the function.
6709  * @return Status code indicating the result of the function call.
6710  */
6711 RAIL_Status_t RAIL_GetHFXOCompensationConfig(RAIL_Handle_t railHandle,
6712                                              RAIL_HFXOCompensationConfig_t *pHfxoCompensationConfig);
6713 
6714 /**
6715  * Compute a frequency offset and compensate HFXO accordingly.
6716  *
6717  * @param[in] railHandle A RAIL instance handle.
6718  * @param[in] crystalPPMError The current ppm error. Positive values indicate
6719  *   the HFXO frequency is too high; negative values indicate it's too low.
6720  * @return Status code indicating success of the function call.
6721  *
6722  * @note This function only works for platforms having
6723  *   \ref RAIL_SUPPORTS_EXTERNAL_THERMISTOR alongside \ref RAIL_SUPPORTS_HFXO_COMPENSATION.
6724  */
6725 RAIL_Status_t RAIL_CompensateHFXO(RAIL_Handle_t railHandle, int8_t crystalPPMError);
6726 
6727 /** @} */ // end of group External_Thermistor
6728 
6729 /******************************************************************************
6730  * TrustZone
6731  *****************************************************************************/
6732 /**
6733  * @addtogroup TrustZone
6734  * @brief APIs to use RAIL with TrustZone enabled and peripherals configured
6735  *   as secure.
6736  *
6737  * RAIL internally accesses CMU, EMU, GPIO, LDMA, HFXO, PRS and SYSRTC.
6738  * If some of them are configured as secure peripherals, some RAIL code must be
6739  * executed as secure code. To do so, callbacks gathered in
6740  * \ref RAIL_TZ_Config_t must be implemented and passed to RAIL through
6741  * \ref RAIL_TZ_InitNonSecure(). Each callback must do the non-secure/secure
6742  * transition, call \ref RAIL_TZ_CheckPeripheralsSecureStates() and then call
6743  * the corresponding RAIL API from secure world:
6744  *
6745  * | Secure peripheral |                                                                                                                                       Callbacks to implement                                                                                                                                           |
6746  * |-------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
6747  * |       CMU         | \ref RAIL_TZ_Config_t::changedDcdcCallback, \ref RAIL_TZ_Config_t::configAntennaGpioCallback, \ref RAIL_TZ_Config_t::radioClockEnableCallback, \ref RAIL_TZ_Config_t::getRadioClockFreqHzCallback, \ref RAIL_TZ_Config_t::rfecaClockEnableCallback, \ref RAIL_TZ_Config_t::rfecaIsClockEnabledCallback |
6748  * |       EMU         | \ref RAIL_TZ_Config_t::readInternalTemperatureCallback, \ref RAIL_TZ_Config_t::enableSecureRadioIrqsCallback, \ref RAIL_TZ_Config_t::disableSecureRadioIrqsCallback                                                                                                                                    |
6749  * |       GPIO        | \ref RAIL_TZ_Config_t::configAntennaGpioCallback                                                                                                                                                                                                                                                       |
6750  * |       LDMA        | \ref RAIL_TZ_Config_t::radioPerformM2mLdmaCallback                                                                                                                                                                                                                                                     |
6751  * |       HFXO        | \ref RAIL_TZ_Config_t::configureHfxoCallback                                                                                                                                                                                                                                                           |
6752  *
6753  * RAIL internally calls platform functions that access CMU, EMU, GPIO, LDMA
6754  * HFXO and PRS.
6755  * If some of them are configured as secure peripherals, some functions must be
6756  * executed as secure code. To do so, those functions are prepended with weak
6757  * symbols and must be overwritten to do the non-secure/secure transition and
6758  * call the corresponding platform function from secure world:
6759  *
6760  * | Secure peripheral |                                Platform functions to overwrite                                |
6761  * |-------------------|-----------------------------------------------------------------------------------------------|
6762  * |       CMU         | CMU_ClockEnable, EMU_DCDCSetPFMXTimeoutMaxCtrl (DCDC access: SL_TRUSTZONE_PERIPHERAL_DCDC_S)  |
6763  * |       HFXO        | CMU_HFXOCTuneSet, CMU_HFXOCTuneGet, CMU_HFXOCoreBiasCurrentCalibrate                          |
6764  * |       PRS         | PRS_SourceAsyncSignalSet, PRS_GetFreeChannel, PRS_ConnectConsumer, PRS_PinOutput, PRS_Combine |
6765  *
6766  * When there is a combination of secure and non-secure peripherals, defines
6767  * must be added in secure application slcp file so non-secure peripherals can
6768  * properly accessed by secure code. Example with only CMU non-secure:
6769  *
6770  * @code{.slcp}
6771  * define:
6772  *   - name: SL_TRUSTZONE_PERIPHERAL_CMU_S
6773  *     value: 0
6774  *     condition: [trustzone_secure]
6775  *   - name: SL_TRUSTZONE_PERIPHERAL_EMU_S
6776  *     value: 1
6777  *     condition: [trustzone_secure]
6778  *   - name: SL_TRUSTZONE_PERIPHERAL_GPIO_S
6779  *     value: 1
6780  *     condition: [trustzone_secure]
6781  *   - name: SL_TRUSTZONE_PERIPHERAL_LDMA_S
6782  *     value: 1
6783  *     condition: [trustzone_secure]
6784  *   - name: SL_TRUSTZONE_PERIPHERAL_HFXO0_S
6785  *     value: 1
6786  *     condition: [trustzone_secure]
6787  *   - name: SL_TRUSTZONE_PERIPHERAL_PRS_S
6788  *     value: 1
6789  *     condition: [trustzone_secure]
6790  *   - name: SL_TRUSTZONE_PERIPHERAL_SYSRTC_S
6791  *     value: 1
6792  *     condition: [trustzone_secure]
6793  * @endcode
6794  *
6795  * Some RAIL API are not suppoted with EMU, GPIO, LDMA, HFXO, PRS or SYSRTC
6796  * configured secure:
6797  *
6798  * | Secure peripheral |                                                                                                             Unsupported RAIL API/features                                                                      |
6799  * |-------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
6800  * |       EMU         | \ref RAIL_StartThermistorMeasurement(), \ref RAIL_InitPowerManager()                                                                                                                                           |
6801  * |       GPIO        | \ref RAIL_EnableDirectMode(), \ref RAIL_EnableDirectModeAlt(), \ref RAIL_EnablePti(), \ref RAIL_ConfigPti(), \ref RAIL_ConfigHFXOThermistor(), \ref RAIL_StartThermistorMeasurement(), \ref RAIL_ConfigVdet()  |
6802  * |       LDMA        | \ref RAIL_IEEE802154_SUPPORTS_RX_CHANNEL_SWITCHING (\ref RAIL_IEEE802154_ConfigRxChannelSwitching() and \ref RAIL_RX_OPTION_CHANNEL_SWITCHING)                                                                 |
6803  * |       HFXO        | \ref RAIL_StartThermistorMeasurement(), \ref RAIL_EnableVdet(), \ref RAIL_GetVdet()                                                                                                                            |
6804  * |       PRS         | \ref RAIL_EnablePrsLnaBypass()                                                                                                                                                                                 |
6805  * |       SYSRTC      | \ref RAIL_ConfigSleep() with \ref RAIL_SleepConfig_t::RAIL_SLEEP_CONFIG_TIMERSYNC_ENABLED, \ref RAIL_ConfigSleepAlt() with \ref RAIL_SleepConfig_t::RAIL_SLEEP_CONFIG_TIMERSYNC_ENABLED                        |
6806  *
6807  * @{
6808  */
6809 
6810 /**
6811  * Init RAIL TrustZone feature for non-secure world
6812  *
6813  * @param[in] pTzConfig A non-NULL pointer to a \ref RAIL_TZ_Config_t
6814  *   structure.
6815  * @return Status code indicating success of the function call.
6816  *
6817  * @note This function must only be called from non-secure world (only if
6818  *   TrustZone is activated) on platforms having
6819  *   \ref RAIL_SUPPORTS_TRUSTZONE_SECURE_PERIPHERALS. It must be called
6820  *   before \ref RAIL_Init() and it must be called again with updated
6821  *   \ref RAIL_TZ_Config_t if peripherals secure configuration has changed.
6822  */
6823 RAIL_Status_t RAIL_TZ_InitNonSecure(const RAIL_TZ_Config_t *pTzConfig);
6824 
6825 /**
6826  * Init RAIL TrustZone feature for secure world
6827  *
6828  * @return Status code indicating success of the function call.
6829  *
6830  * @note This function must only be called from secure world (only if TrustZone
6831  *   is activated) on platforms having
6832  *   \ref RAIL_SUPPORTS_TRUSTZONE_SECURE_PERIPHERALS. It must be called
6833  *   before starting the non-secure application.
6834  */
6835 RAIL_Status_t RAIL_TZ_InitSecure(void);
6836 
6837 /**
6838  * Check the secure state of peripherals used by RAIL.
6839  *
6840  * @return Status code indicating success of the function call.
6841  *
6842  * @note This function must only be called from secure world and it must be
6843  *   called at the beginning of each RAIL TrustZone callbacks
6844  *   (\ref RAIL_TZ_Config_t) secure code to avoid secure fault.
6845  */
6846 RAIL_Status_t RAIL_TZ_CheckPeripheralsSecureStates(void);
6847 
6848 /**
6849  * Enable radio clocks.
6850  *
6851  * @return Status code indicating success of the function call.
6852  *
6853  * @note This function must only be called from secure world when CMU is
6854  *   configured as secure TrustZone peripheral.
6855  *
6856  */
6857 RAIL_Status_t RAIL_TZ_RadioClockEnable(void);
6858 
6859 /**
6860  * Enable RFECA clocks.
6861  *
6862  * @return Status code indicating success of the function call.
6863  *
6864  * @note This function must only be called from secure world when CMU is
6865  *   configured as secure TrustZone peripheral.
6866  *
6867  */
6868 RAIL_Status_t RAIL_TZ_RfecaClockEnable(void);
6869 
6870 /**
6871  * Indicate whether RFECA clocks are enabled.
6872  *
6873  * @return true if RFECA clocks are enabled; false otherwise
6874  *
6875  * @note This function must only be called from secure world when CMU is
6876  *   configured as secure TrustZone peripheral.
6877  *
6878  */
6879 bool RAIL_TZ_RfecaIsClockEnabled(void);
6880 
6881 /**
6882  * Read the internal temperature.
6883  *
6884  * @param[out] internalTemperatureKelvin A pointer to the internal temperature
6885  *   in Kelvin.
6886  * @param[in] enableTemperatureInterrupts Indicate whether temperature
6887  *   interrupts are enabled.
6888  * @return Status code indicating success of the function call.
6889  *
6890  * @note This function must only be called from secure world when EMU is
6891  *   configured as secure TrustZone peripheral.
6892  *
6893  */
6894 RAIL_Status_t RAIL_TZ_ReadInternalTemperature(uint16_t *internalTemperatureKelvin,
6895                                               bool enableTemperatureInterrupts);
6896 
6897 /**
6898  * Enable secure peripheral interrupts needed by the radio.
6899  *
6900  * @return Status code indicating success of the function call.
6901  *
6902  * @note This function must only be called from secure world when EMU is
6903  *   configured as secure TrustZone peripheral.
6904  *
6905  */
6906 RAIL_Status_t RAIL_TZ_EnableSecureRadioIrqs(void);
6907 
6908 /**
6909  * Disable secure peripheral interrupts needed by the radio.
6910  *
6911  * @return Status code indicating success of the function call.
6912  *
6913  * @note This function must only be called from secure world when EMU is
6914  *   configured as secure TrustZone peripheral.
6915  *
6916  */
6917 RAIL_Status_t RAIL_TZ_DisableSecureRadioIrqs(void);
6918 
6919 /**
6920  * Perform ldma transfer for the radio.
6921  *
6922  * @param[in] pDest A pointer to the destination data.
6923  * @param[in] pSrc A pointer to the source data.
6924  * @param[in] numWords Number of words to transfer.
6925  * @return Status code indicating success of the function call.
6926  *
6927  * @note This function must only be called from secure world when LDMA is
6928  *   configured as secure TrustZone peripheral.
6929  *
6930  */
6931 RAIL_Status_t RAIL_TZ_RadioPerformM2mLdma(uint32_t *pDest,
6932                                           const uint32_t *pSrc,
6933                                           uint32_t numWords);
6934 
6935 /**
6936  * Configure HFXO.
6937  *
6938  * @return Status code indicating success of the function call.
6939  *
6940  * @note This function must only be called from secure world when HFXO is
6941  *   configured as secure TrustZone peripheral.
6942  *
6943  */
6944 RAIL_Status_t RAIL_TZ_ConfigureHfxo(void);
6945 
6946 /**
6947  * Set GPIO for antenna config.
6948  *
6949  * @param[in] config A pointer to a configuration structure applied to the relevant Antenna
6950  *   Configuration registers. A NULL configuration will produce undefined behavior.
6951  * @return Status code indicating success of the function call.
6952  *
6953  * @note This function must only be called from secure world when CMU or GPIO
6954  *   are configured as secure TrustZone peripheral.
6955  *
6956  */
6957 RAIL_Status_t RAIL_TZ_ConfigAntennaGpio(const RAIL_AntennaConfig_t *config);
6958 
6959 /** @} */ // end of group TrustZone
6960 
6961 /******************************************************************************
6962  * Features
6963  *****************************************************************************/
6964 /**
6965  * @addtogroup Features
6966  * @{
6967  */
6968 
6969 /**
6970  * Indicate whether RAIL supports 2.4 GHz band operation on this chip.
6971  *
6972  * @param[in] railHandle A radio-generic or real RAIL instance handle.
6973  * @return true if the 2.4 GHz band is supported; false otherwise.
6974  *
6975  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_2P4GHZ_BAND.
6976  */
6977 bool RAIL_Supports2p4GHzBand(RAIL_Handle_t railHandle);
6978 
6979 /**
6980  * Indicate whether RAIL supports SubGHz band operation on this chip.
6981  *
6982  * @param[in] railHandle A radio-generic or real RAIL instance handle.
6983  * @return true if the SubGHz band is supported; false otherwise.
6984  *
6985  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_SUBGHZ_BAND.
6986  */
6987 bool RAIL_SupportsSubGHzBand(RAIL_Handle_t railHandle);
6988 
6989 /**
6990  * Indicate whether this chip supports dual 2.4 GHz and SubGHz band operation.
6991  *
6992  * @param[in] railHandle A radio-generic or real RAIL instance handle.
6993  * @return true if the dual band is supported; false otherwise.
6994  *
6995  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_DUAL_BAND.
6996  */
6997 bool RAIL_SupportsDualBand(RAIL_Handle_t railHandle);
6998 
6999 /**
7000  * Indicate whether this chip supports bit masked address filtering.
7001  *
7002  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7003  * @return true if bit masked address filtering is supported; false otherwise.
7004  *
7005  * Runtime refinement of compile-time
7006  * \ref RAIL_SUPPORTS_ADDR_FILTER_ADDRESS_BIT_MASK.
7007  */
7008 bool RAIL_SupportsAddrFilterAddressBitMask(RAIL_Handle_t railHandle);
7009 
7010 /**
7011  * Indicate whether this chip supports address filter mask information
7012  * for incoming packets in
7013  * \ref RAIL_RxPacketInfo_t::filterMask and
7014  * \ref RAIL_IEEE802154_Address_t::filterMask.
7015  *
7016  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7017  * @return true if address filter information is supported; false otherwise
7018  *   (in which case \ref RAIL_RxPacketInfo_t::filterMask value is undefined).
7019  *
7020  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_ADDR_FILTER_MASK.
7021  */
7022 bool RAIL_SupportsAddrFilterMask(RAIL_Handle_t railHandle);
7023 
7024 /**
7025  * Indicate whether this chip supports alternate TX power settings.
7026  *
7027  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7028  * @return true if alternate TX power settings are supported; false otherwise.
7029  *
7030  * Runtime refinement of compile-time \ref
7031  * RAIL_SUPPORTS_ALTERNATE_TX_POWER.
7032  */
7033 bool RAIL_SupportsAlternateTxPower(RAIL_Handle_t railHandle);
7034 
7035 /**
7036  * Indicate whether this chip supports antenna diversity.
7037  *
7038  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7039  * @return true if antenna diversity is supported; false otherwise.
7040  *
7041  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_ANTENNA_DIVERSITY.
7042  *
7043  * @note Certain radio configurations may not support this feature even
7044  *   if the chip in general claims to support it.
7045  */
7046 bool RAIL_SupportsAntennaDiversity(RAIL_Handle_t railHandle);
7047 
7048 /**
7049  * Indicate whether this chip supports internal RF path diversity.
7050  *
7051  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7052  * @return true if RF path diversity is supported; false otherwise.
7053  *
7054  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_PATH_DIVERSITY.
7055  *
7056  * @note Certain radio configurations may not support this feature even
7057  *   if the chip in general claims to support it.
7058  */
7059 bool RAIL_SupportsPathDiversity(RAIL_Handle_t railHandle);
7060 
7061 /**
7062  * Indicate whether RAIL supports AUXADC measurements on this chip.
7063  *
7064  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7065  * @return true if AUXADC measurements are supported; false otherwise.
7066  *
7067  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_AUXADC.
7068  */
7069 bool RAIL_SupportsAuxAdc(RAIL_Handle_t railHandle);
7070 
7071 /**
7072  * Indicate whether RAIL supports channel hopping on this chip.
7073  *
7074  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7075  * @return true if channel hopping is supported; false otherwise.
7076  *
7077  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_CHANNEL_HOPPING.
7078  */
7079 bool RAIL_SupportsChannelHopping(RAIL_Handle_t railHandle);
7080 
7081 /**
7082  * Indicate whether this chip supports direct mode.
7083  *
7084  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7085  * @return true if direct mode is supported; false otherwise.
7086  *
7087  * Runtime refinement of compile-time \ref
7088  * RAIL_SUPPORTS_DIRECT_MODE.
7089  */
7090 bool RAIL_SupportsDirectMode(RAIL_Handle_t railHandle);
7091 
7092 /**
7093  * Indicate whether this chip supports dual sync words.
7094  *
7095  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7096  * @return true if dual sync words are supported; false otherwise.
7097  *
7098  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_DUAL_SYNC_WORDS.
7099  *
7100  * @note Certain radio configurations may not support this feature even
7101  *   if the chip in general claims to support it.
7102  */
7103 bool RAIL_SupportsDualSyncWords(RAIL_Handle_t railHandle);
7104 
7105 /**
7106  * Indicate whether this chip supports start to start TX repeats.
7107  *
7108  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7109  * @return true if start to start TX repeats are supported; false otherwise.
7110  *
7111  * Runtime refinement of compile-time \ref
7112  * RAIL_SUPPORTS_TX_REPEAT_START_TO_START.
7113  */
7114 bool RAIL_SupportsTxRepeatStartToStart(RAIL_Handle_t railHandle);
7115 
7116 /**
7117  * Indicate whether this chip supports VDET.
7118  *
7119  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7120  * @return true if VDET is supported; false otherwise.
7121  */
7122 bool RAIL_SupportsVdet(RAIL_Handle_t railHandle);
7123 
7124 /**
7125  * Indicate whether RAIL supports thermistor measurements on this chip.
7126  *
7127  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7128  * @return true if thermistor measurements are supported; false otherwise.
7129  *
7130  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_EXTERNAL_THERMISTOR.
7131  */
7132 bool RAIL_SupportsExternalThermistor(RAIL_Handle_t railHandle);
7133 
7134 /**
7135  * Indicate whether RAIL supports HFXO compensation on this chip.
7136  *
7137  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7138  * @return true if HFXO compensation is supported and
7139  *   \ref RAIL_ConfigHFXOThermistor() has been successfully called;
7140  *   false otherwise.
7141  *
7142  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_HFXO_COMPENSATION.
7143  */
7144 bool RAIL_SupportsHFXOCompensation(RAIL_Handle_t railHandle);
7145 
7146 /**
7147  * Indicate whether this chip supports MFM protocol.
7148  *
7149  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7150  * @return true if MFM protocol is supported; false otherwise.
7151  *
7152  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_MFM.
7153  */
7154 bool RAIL_SupportsMfm(RAIL_Handle_t railHandle);
7155 
7156 /**
7157  * Indicate whether RAIL supports OFDM band operation on this chip.
7158  *
7159  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7160  * @return true if OFDM operation is supported; false otherwise.
7161  *
7162  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_OFDM_PA.
7163  */
7164 bool RAIL_SupportsOFDMPA(RAIL_Handle_t railHandle);
7165 
7166 /**
7167  * Indicate whether this chip supports a high-precision LFRCO.
7168  *
7169  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7170  * @return true if high-precision LFRCO is supported; false otherwise.
7171  *
7172  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_PRECISION_LFRCO.
7173  */
7174 bool RAIL_SupportsPrecisionLFRCO(RAIL_Handle_t railHandle);
7175 
7176 /**
7177  * Indicate whether this chip supports radio entropy.
7178  *
7179  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7180  * @return true if radio entropy is supported; false otherwise.
7181  *
7182  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_RADIO_ENTROPY.
7183  */
7184 bool RAIL_SupportsRadioEntropy(RAIL_Handle_t railHandle);
7185 
7186 /**
7187  * Indicate whether RAIL supports RFSENSE Energy Detection Mode on this chip.
7188  *
7189  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7190  * @return true if RFSENSE Energy Detection Mode is supported; false otherwise.
7191  *
7192  * Runtime refinement of compile-time
7193  * \ref RAIL_SUPPORTS_RFSENSE_ENERGY_DETECTION.
7194  */
7195 bool RAIL_SupportsRfSenseEnergyDetection(RAIL_Handle_t railHandle);
7196 
7197 /**
7198  * Indicate whether RAIL supports RFSENSE Selective(OOK) Mode on this chip.
7199  *
7200  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7201  * @return true if RFSENSE Selective(OOK) Mode is supported; false otherwise.
7202  *
7203  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_RFSENSE_SELECTIVE_OOK.
7204  */
7205 bool RAIL_SupportsRfSenseSelectiveOok(RAIL_Handle_t railHandle);
7206 
7207 /**
7208  * Indicate whether this chip supports configurable RSSI threshold
7209  * set by \ref RAIL_SetRssiDetectThreshold().
7210  *
7211  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7212  * @return true if setting configurable RSSI is supported; false otherwise.
7213  *
7214  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_RSSI_DETECT_THRESHOLD.
7215  */
7216 bool RAIL_SupportsRssiDetectThreshold(RAIL_Handle_t railHandle);
7217 
7218 /**
7219  * Indicate whether this chip supports RX direct mode data to FIFO.
7220  *
7221  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7222  * @return true if direct mode data to FIFO is supported; false otherwise.
7223  *
7224  * Runtime refinement of compile-time \ref
7225  * RAIL_SUPPORTS_RX_DIRECT_MODE_DATA_TO_FIFO.
7226  */
7227 bool RAIL_SupportsRxDirectModeDataToFifo(RAIL_Handle_t railHandle);
7228 
7229 /**
7230  * Indicate whether this chip supports raw RX data
7231  * sources other than \ref RAIL_RxDataSource_t::RX_PACKET_DATA.
7232  *
7233  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7234  * @return true if direct mode is supported; false otherwise.
7235  *
7236  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_RX_RAW_DATA.
7237  */
7238 bool RAIL_SupportsRxRawData(RAIL_Handle_t railHandle);
7239 
7240 /**
7241  * Indicate whether this chip supports SQ-based PHY.
7242  *
7243  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7244  * @return true if the SQ-based PHY is supported; false otherwise.
7245  *
7246  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_SQ_PHY.
7247  */
7248 bool RAIL_SupportsSQPhy(RAIL_Handle_t railHandle);
7249 
7250 /**
7251  * Indicate whether this chip supports a particular power mode (PA).
7252  *
7253  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7254  * @param[in] powerMode The power mode to check if supported.
7255  * @param[out] pMaxPowerLevel A pointer to a \ref RAIL_TxPowerLevel_t that
7256  *   if non-NULL will be filled in with the power mode's highest power level
7257  *   allowed if this function returns true.
7258  * @return true if the powerMode is supported; false otherwise.
7259  *
7260  * This function has no compile-time equivalent.
7261  *
7262  * @note Consider using \ref RAIL_SupportsTxPowerModeAlt to also get the power
7263  *   mode's lowest allowed power level.
7264  */
7265 bool RAIL_SupportsTxPowerMode(RAIL_Handle_t railHandle,
7266                               RAIL_TxPowerMode_t powerMode,
7267                               RAIL_TxPowerLevel_t *pMaxPowerLevel);
7268 
7269 /**
7270  * Indicate whether this chip supports a particular power mode (PA) and
7271  * provides the maximum and minimum power level for that power mode
7272  * if supported by the chip.
7273  *
7274  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7275  * @param[in,out] powerMode A pointer to PA power mode to check if supported.
7276  *   If \ref RAIL_TX_POWER_MODE_2P4GIG_HIGHEST or \ref
7277  *   RAIL_TX_POWER_MODE_SUBGIG_HIGHEST is passed in, it will be updated
7278  *   to the highest corresponding PA available on the chip.
7279  * @param[out] maxPowerLevel A pointer to a \ref RAIL_TxPowerLevel_t that
7280  *   if non-NULL will be filled in with the power mode's highest power level
7281  *   allowed if this function returns true.
7282  * @param[out] minPowerLevel A pointer to a \ref RAIL_TxPowerLevel_t that
7283  *   if non-NULL will be filled in with the power mode's lowest power level
7284  *   allowed if this function returns true.
7285  * @return true if powerMode is supported; false otherwise.
7286  *
7287  * This function has no compile-time equivalent.
7288  */
7289 bool RAIL_SupportsTxPowerModeAlt(RAIL_Handle_t railHandle,
7290                                  RAIL_TxPowerMode_t *powerMode,
7291                                  RAIL_TxPowerLevel_t *maxPowerLevel,
7292                                  RAIL_TxPowerLevel_t *minPowerLevel);
7293 
7294 /**
7295  * Indicate whether this chip supports automatic TX to TX transitions.
7296  *
7297  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7298  * @return true if TX to TX transitions are supported; false otherwise.
7299  *
7300  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_TX_TO_TX.
7301  */
7302 bool RAIL_SupportsTxToTx(RAIL_Handle_t railHandle);
7303 
7304 /**
7305  * Indicate whether RAIL supports the BLE protocol on this chip.
7306  *
7307  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7308  * @return true if BLE is supported; false otherwise.
7309  *
7310  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_PROTOCOL_BLE.
7311  */
7312 bool RAIL_SupportsProtocolBLE(RAIL_Handle_t railHandle);
7313 
7314 /**
7315  * Indicate whether this chip supports BLE 1 Mbps Non-Viterbi PHY.
7316  *
7317  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7318  * @return true if BLE 1 Mbps Non-Viterbi is supported; false otherwise.
7319  *
7320  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_1MBPS_NON_VITERBI.
7321  */
7322 bool RAIL_BLE_Supports1MbpsNonViterbi(RAIL_Handle_t railHandle);
7323 
7324 /**
7325  * Indicate whether this chip supports BLE 1 Mbps Viterbi PHY.
7326  *
7327  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7328  * @return true if BLE 1 Mbps Viterbi is supported; false otherwise.
7329  *
7330  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_1MBPS_VITERBI.
7331  */
7332 bool RAIL_BLE_Supports1MbpsViterbi(RAIL_Handle_t railHandle);
7333 
7334 /**
7335  * Indicate whether this chip supports BLE 1 Mbps operation.
7336  *
7337  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7338  * @return true if BLE 1 Mbps operation is supported; false otherwise.
7339  *
7340  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_1MBPS.
7341  */
7342 static inline
RAIL_BLE_Supports1Mbps(RAIL_Handle_t railHandle)7343 bool RAIL_BLE_Supports1Mbps(RAIL_Handle_t railHandle)
7344 {
7345   bool temp = RAIL_BLE_Supports1MbpsViterbi(railHandle); // Required for MISRA compliance
7346   return (RAIL_BLE_Supports1MbpsNonViterbi(railHandle)
7347           || temp);
7348 }
7349 
7350 /**
7351  * Indicate whether this chip supports BLE 2 Mbps Non-Viterbi PHY.
7352  *
7353  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7354  * @return true if BLE 2 Mbps Non-Viterbi is supported; false otherwise.
7355  *
7356  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_2MBPS_NON_VITERBI.
7357  */
7358 bool RAIL_BLE_Supports2MbpsNonViterbi(RAIL_Handle_t railHandle);
7359 
7360 /**
7361  * Indicate whether this chip supports BLE 2 Mbps Viterbi PHY.
7362  *
7363  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7364  * @return true if BLE 2 Mbps Viterbi is supported; false otherwise.
7365  *
7366  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_2MBPS_VITERBI.
7367  */
7368 bool RAIL_BLE_Supports2MbpsViterbi(RAIL_Handle_t railHandle);
7369 
7370 /**
7371  * Indicate whether this chip supports BLE 2 Mbps operation.
7372  *
7373  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7374  * @return true if BLE 2 Mbps operation is supported; false otherwise.
7375  *
7376  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_2MBPS.
7377  */
7378 static inline
RAIL_BLE_Supports2Mbps(RAIL_Handle_t railHandle)7379 bool RAIL_BLE_Supports2Mbps(RAIL_Handle_t railHandle)
7380 {
7381   bool temp = RAIL_BLE_Supports2MbpsViterbi(railHandle); // Required for MISRA compliance
7382   return (RAIL_BLE_Supports2MbpsNonViterbi(railHandle)
7383           || temp);
7384 }
7385 
7386 /**
7387  * Indicate whether this chip supports BLE Antenna Switching needed for
7388  * Angle-of-Arrival receives or Angle-of-Departure transmits.
7389  *
7390  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7391  * @return true if BLE Antenna Switching is supported; false otherwise.
7392  *
7393  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_ANTENNA_SWITCHING.
7394  */
7395 bool RAIL_BLE_SupportsAntennaSwitching(RAIL_Handle_t railHandle);
7396 
7397 /**
7398  * Indicate whether this chip supports BLE Coded PHY used for Long-Range.
7399  *
7400  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7401  * @return true if BLE Coded PHY is supported; false otherwise.
7402  *
7403  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_CODED_PHY.
7404  */
7405 bool RAIL_BLE_SupportsCodedPhy(RAIL_Handle_t railHandle);
7406 
7407 /**
7408  * Indicate whether this chip supports BLE CTE (Constant Tone Extension)
7409  * needed for Angle-of-Arrival/Departure transmits.
7410  *
7411  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7412  * @return true if BLE CTE is supported; false otherwise.
7413  *
7414  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_CTE.
7415  */
7416 bool RAIL_BLE_SupportsCte(RAIL_Handle_t railHandle);
7417 
7418 #ifndef DOXYGEN_SHOULD_SKIP_THIS
7419 /**
7420  * Indicate whether this chip supports BLE CS.
7421  *
7422  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7423  * @return true if BLE CS is supported; false otherwise.
7424  *
7425  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_CS.
7426  */
7427 bool RAIL_BLE_SupportsCs(RAIL_Handle_t railHandle);
7428 #endif//DOXYGEN_SHOULD_SKIP_THIS
7429 
7430 /**
7431  * Indicate whether this chip supports BLE IQ Sampling needed for
7432  * Angle-of-Arrival/Departure receives.
7433  *
7434  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7435  * @return true if BLE IQ Sampling is supported; false otherwise.
7436  *
7437  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_IQ_SAMPLING.
7438  */
7439 bool RAIL_BLE_SupportsIQSampling(RAIL_Handle_t railHandle);
7440 
7441 /**
7442  * Indicate whether this chip supports BLE PHY switch to RX
7443  * functionality, which is used to switch BLE PHYs at a specific time
7444  * to receive auxiliary packets.
7445  *
7446  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7447  * @return true if BLE PHY switch to RX is supported; false otherwise.
7448  *
7449  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_PHY_SWITCH_TO_RX.
7450  */
7451 bool RAIL_BLE_SupportsPhySwitchToRx(RAIL_Handle_t railHandle);
7452 
7453 /**
7454  * Indicate whether this chip supports the Quuppa PHY.
7455  *
7456  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7457  * @return true if the Quuppa is supported; false otherwise.
7458  *
7459  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_QUUPPA.
7460  */
7461 bool RAIL_BLE_SupportsQuuppa(RAIL_Handle_t railHandle);
7462 
7463 /**
7464  * Indicate whether this chip supports BLE signal identifier.
7465  *
7466  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7467  * @return true if signal identifier is supported; false otherwise.
7468  */
7469 bool RAIL_BLE_SupportsSignalIdentifier(RAIL_Handle_t railHandle);
7470 
7471 /**
7472  * Indicate whether this chip supports BLE Simulscan PHY used for simultaneous
7473  * BLE 1 Mbps and Coded PHY reception.
7474  *
7475  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7476  * @return true if BLE Simulscan PHY is supported; false otherwise.
7477  *
7478  * Runtime refinement of compile-time \ref RAIL_BLE_SUPPORTS_SIMULSCAN_PHY.
7479  */
7480 bool RAIL_BLE_SupportsSimulscanPhy(RAIL_Handle_t railHandle);
7481 
7482 /**
7483  * Indicate whether this chip supports the IEEE 802.15.4 protocol.
7484  *
7485  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7486  * @return true if the 802.15.4 protocol is supported; false otherwise.
7487  *
7488  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_PROTOCOL_IEEE802154.
7489  */
7490 bool RAIL_SupportsProtocolIEEE802154(RAIL_Handle_t railHandle);
7491 
7492 #ifndef DOXYGEN_SHOULD_SKIP_THIS
7493 /**
7494  * Indicate whether this chip supports the IEEE 802.15.4 2 Mbps PHY.
7495  *
7496  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7497  * @return true if the 802.15.4 2 Mbps PHY is supported; false otherwise.
7498  *
7499  * Runtime refinement of compile-time \ref RAIL_IEEE802154_SUPPORTS_2MBPS_PHY.
7500  */
7501 bool RAIL_IEEE802154_Supports2MbpsPhy(RAIL_Handle_t railHandle);
7502 #endif //DOXYGEN_SHOULD_SKIP_THIS
7503 
7504 /**
7505  * Indicate whether this chip supports the IEEE 802.15.4 Wi-Fi Coexistence PHY.
7506  *
7507  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7508  * @return true if the 802.15.4 COEX PHY is supported; false otherwise.
7509  *
7510  * Runtime refinement of compile-time \ref RAIL_IEEE802154_SUPPORTS_COEX_PHY.
7511  */
7512 bool RAIL_IEEE802154_SupportsCoexPhy(RAIL_Handle_t railHandle);
7513 
7514 /**
7515  * Indicate whether this chip supports the IEEE 802.15.4 2.4 GHz band variant.
7516  *
7517  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7518  * @return true if IEEE 802.15.4 2.4 GHz band variant is supported;
7519  *   false otherwise.
7520  *
7521  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_IEEE802154_BAND_2P4.
7522  */
7523 bool RAIL_SupportsIEEE802154Band2P4(RAIL_Handle_t railHandle);
7524 
7525 /**
7526  * Indicate whether this chip supports the thermal protection.
7527  *
7528  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7529  * @return true if thermal protection is supported;
7530  *   false otherwise.
7531  *
7532  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_THERMAL_PROTECTION.
7533  */
7534 bool RAIL_SupportsThermalProtection(RAIL_Handle_t railHandle);
7535 
7536 /**
7537  * Indicate whether this chip supports the IEEE 802.15.4 2.4 RX channel switching.
7538  *
7539  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7540  * @return true if IEEE 802.15.4 2.4 GHz RX channel switching is supported;
7541  *   false otherwise.
7542  *
7543  * Runtime refinement of compile-time \ref RAIL_IEEE802154_SUPPORTS_RX_CHANNEL_SWITCHING.
7544  */
7545 bool RAIL_IEEE802154_SupportsRxChannelSwitching(RAIL_Handle_t railHandle);
7546 
7547 /**
7548  * Indicate whether this chip supports the IEEE 802.15.4 PHY with custom settings.
7549  *
7550  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7551  * @return true if the 802.15.4 PHY with custom settings is supported; false otherwise.
7552  *
7553  * Runtime refinement of compile-time \ref RAIL_IEEE802154_SUPPORTS_CUSTOM1_PHY.
7554  */
7555 bool RAIL_IEEE802154_SupportsCustom1Phy(RAIL_Handle_t railHandle);
7556 
7557 /**
7558  * Indicate whether this chip supports the IEEE 802.15.4
7559  * front end module optimized PHY.
7560  *
7561  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7562  * @return true if a front end module is supported; false otherwise.
7563  *
7564  * Runtime refinement of compile-time \ref RAIL_IEEE802154_SUPPORTS_FEM_PHY.
7565  */
7566 bool RAIL_IEEE802154_SupportsFemPhy(RAIL_Handle_t railHandle);
7567 
7568 /**
7569  * Indicate whether this chip supports canceling the frame-pending lookup
7570  * event \ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND when the radio
7571  * transitions to a state that renders the the reporting of this event moot
7572  * (i.e., too late for the stack to influence the outgoing Ack).
7573  *
7574  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7575  * @return true if canceling the lookup event is supported; false otherwise.
7576  *
7577  * Runtime refinement of compile-time \ref
7578  * RAIL_IEEE802154_SUPPORTS_CANCEL_FRAME_PENDING_LOOKUP.
7579  */
7580 bool RAIL_IEEE802154_SupportsCancelFramePendingLookup(RAIL_Handle_t railHandle);
7581 
7582 /**
7583  * Indicate whether this chip supports early triggering of the frame-pending
7584  * lookup event \ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND
7585  * just after MAC address fields have been received.
7586  *
7587  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7588  * @return true if early triggering is supported; false otherwise.
7589  *
7590  * Runtime refinement of compile-time \ref
7591  * RAIL_IEEE802154_SUPPORTS_EARLY_FRAME_PENDING_LOOKUP.
7592  */
7593 bool RAIL_IEEE802154_SupportsEarlyFramePendingLookup(RAIL_Handle_t railHandle);
7594 
7595 /**
7596  * Indicate whether RAIL supports dual PA mode on this chip.
7597  *
7598  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7599  * @return true if the dual PA mode is supported; false otherwise.
7600  *
7601  * Runtime refinement of compile-time \ref RAIL_IEEE802154_SUPPORTS_DUAL_PA_CONFIG.
7602  */
7603 bool RAIL_IEEE802154_SupportsDualPaConfig(RAIL_Handle_t railHandle);
7604 
7605 /**
7606  * Indicate whether this chip supports IEEE 802.15.4E-2012 Enhanced Acking.
7607  *
7608  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7609  * @return true if 802.15.4E Enhanced Acking is supported; false otherwise.
7610  *
7611  * Runtime refinement of compile-time \ref
7612  * RAIL_IEEE802154_SUPPORTS_E_ENHANCED_ACK.
7613  */
7614 bool RAIL_IEEE802154_SupportsEEnhancedAck(RAIL_Handle_t railHandle);
7615 
7616 /**
7617  * Indicate whether this chip supports IEEE 802.15.4E-2012 Multipurpose frame
7618  * reception.
7619  *
7620  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7621  * @return true if Multipurpose frame reception is supported; false otherwise.
7622  *
7623  * Runtime refinement of compile-time \ref
7624  * RAIL_IEEE802154_SUPPORTS_E_MULTIPURPOSE_FRAMES.
7625  */
7626 bool RAIL_IEEE802154_SupportsEMultipurposeFrames(RAIL_Handle_t railHandle);
7627 
7628 /**
7629  * Indicate whether this chip supports the IEEE 802.15.4E-2012 feature
7630  * subset needed for Zigbee R22 GB868.
7631  *
7632  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7633  * @return true if 802.15.4E GB868 subset is supported; false otherwise.
7634  *
7635  * Runtime refinement of compile-time \ref
7636  * RAIL_IEEE802154_SUPPORTS_E_SUBSET_GB868.
7637  */
7638 bool RAIL_IEEE802154_SupportsESubsetGB868(RAIL_Handle_t railHandle);
7639 
7640 /**
7641  * Indicate whether this chip supports IEEE 802.15.4G-2012 reception and
7642  * transmission of frames with 4-byte CRC.
7643  *
7644  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7645  * @return true if 802.15.4G 4-byte CRC is supported; false otherwise.
7646  *
7647  * Runtime refinement of compile-time \ref
7648  * RAIL_IEEE802154_SUPPORTS_G_4BYTE_CRC.
7649  */
7650 bool RAIL_IEEE802154_SupportsG4ByteCrc(RAIL_Handle_t railHandle);
7651 
7652 /**
7653  * Indicate whether this chip supports IEEE 802.15.4G dynamic FEC.
7654  *
7655  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7656  * @return true if dynamic FEC is supported; false otherwise.
7657  *
7658  * Runtime refinement of compile-time \ref
7659  * RAIL_IEEE802154_SUPPORTS_G_DYNFEC.
7660  */
7661 bool RAIL_IEEE802154_SupportsGDynFec(RAIL_Handle_t railHandle);
7662 
7663 /**
7664  * Indicate whether this chip supports Wi-SUN.
7665  *
7666  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7667  * @return true if Wi-SUN is supported; false otherwise.
7668  *
7669  * Runtime refinement of compile-time \ref
7670  * RAIL_SUPPORTS_PROTOCOL_WI_SUN.
7671  */
7672 bool RAIL_SupportsProtocolWiSUN(RAIL_Handle_t railHandle);
7673 
7674 /**
7675  * Indicate whether this chip supports Wi-SUN mode switching.
7676  *
7677  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7678  * @return true if Wi-SUN mode switching is supported; false otherwise.
7679  *
7680  * Runtime refinement of compile-time \ref
7681  * RAIL_IEEE802154_SUPPORTS_G_MODESWITCH.
7682  */
7683 bool RAIL_IEEE802154_SupportsGModeSwitch(RAIL_Handle_t railHandle);
7684 
7685 /**
7686  * Indicate whether this chip supports IEEE 802.15.4G-2012 feature
7687  * subset needed for Zigbee R22 GB868.
7688  *
7689  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7690  * @return true if 802.15.4G GB868 subset is supported; false otherwise.
7691  *
7692  * Runtime refinement of compile-time \ref
7693  * RAIL_IEEE802154_SUPPORTS_G_SUBSET_GB868.
7694  */
7695 bool RAIL_IEEE802154_SupportsGSubsetGB868(RAIL_Handle_t railHandle);
7696 
7697 /**
7698  * Indicate whether this chip supports IEEE 802.15.4G-2012 reception
7699  * of unwhitened frames.
7700  *
7701  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7702  * @return true if 802.15.4G unwhitened frame reception is supported;
7703  *   false otherwise.
7704  *
7705  * Runtime refinement of compile-time \ref
7706  * RAIL_IEEE802154_SUPPORTS_G_UNWHITENED_RX.
7707  */
7708 bool RAIL_IEEE802154_SupportsGUnwhitenedRx(RAIL_Handle_t railHandle);
7709 
7710 /**
7711  * Indicate whether this chip supports IEEE 802.15.4G-2012 transmission
7712  * of unwhitened frames.
7713  *
7714  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7715  * @return true if 802.15.4G unwhitened frame transmit is supported;
7716  *   false otherwise.
7717  *
7718  * Runtime refinement of compile-time \ref
7719  * RAIL_IEEE802154_SUPPORTS_G_UNWHITENED_TX.
7720  */
7721 bool RAIL_IEEE802154_SupportsGUnwhitenedTx(RAIL_Handle_t railHandle);
7722 
7723 /**
7724  * Indicate whether this chip supports WMBUS simultaneous M2O RX of T and C modes.
7725  *
7726  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7727  * @return true if the WMBUS simultaneous M2O RX of T and C modes is supported; false otherwise.
7728  *
7729  * Runtime refinement of compile-time \ref RAIL_WMBUS_SUPPORTS_SIMULTANEOUS_T_C_RX.
7730  */
7731 bool RAIL_WMBUS_SupportsSimultaneousTCRx(RAIL_Handle_t railHandle);
7732 
7733 /**
7734  * Indicate whether this chip supports the Z-Wave protocol.
7735  *
7736  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7737  * @return true if the Z-Wave protocol is supported; false otherwise.
7738  *
7739  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_PROTOCOL_ZWAVE.
7740  */
7741 bool RAIL_SupportsProtocolZWave(RAIL_Handle_t railHandle);
7742 
7743 /**
7744  * Indicate whether this chip supports the Z-Wave concurrent PHY.
7745  *
7746  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7747  * @return true if the Z-Wave concurrent PHY is supported; false otherwise.
7748  *
7749  * Runtime refinement of compile-time \ref RAIL_ZWAVE_SUPPORTS_CONC_PHY.
7750  */
7751 bool RAIL_ZWAVE_SupportsConcPhy(RAIL_Handle_t railHandle);
7752 
7753 /**
7754  * Indicate whether this chip supports the Z-Wave energy detect PHY.
7755  *
7756  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7757  * @return true if the Z-Wave energy detect PHY is supported; false otherwise.
7758  *
7759  * Runtime refinement of compile-time \ref RAIL_ZWAVE_SUPPORTS_ED_PHY.
7760  */
7761 bool RAIL_ZWAVE_SupportsEnergyDetectPhy(RAIL_Handle_t railHandle);
7762 
7763 /**
7764  * Indicate whether this chip supports Z-Wave Region in PTI.
7765  *
7766  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7767  * @return true if ZWAVE Region in PTI is supported; false otherwise.
7768  *
7769  * Runtime refinement of compile-time \ref RAIL_ZWAVE_SUPPORTS_REGION_PTI.
7770  */
7771 bool RAIL_ZWAVE_SupportsRegionPti(RAIL_Handle_t railHandle);
7772 
7773 /**
7774  * Indicate whether this chip supports IEEE 802.15.4 signal identifier.
7775  *
7776  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7777  * @return true if signal identifier is supported; false otherwise.
7778  */
7779 bool RAIL_IEEE802154_SupportsSignalIdentifier(RAIL_Handle_t railHandle);
7780 
7781 /**
7782  * Indicate whether this chip supports fast RX-to-RX.
7783  *
7784  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7785  * @return true if fast RX-to-RX is supported; false otherwise.
7786  *
7787  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_FAST_RX2RX.
7788  */
7789 bool RAIL_SupportsFastRx2Rx(RAIL_Handle_t railHandle);
7790 
7791 /**
7792  * Indicate whether this chip supports collision detection.
7793  *
7794  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7795  * @return true if collision detection is supported; false otherwise.
7796  *
7797  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_COLLISION_DETECTION.
7798  */
7799 bool RAIL_SupportsCollisionDetection(RAIL_Handle_t railHandle);
7800 
7801 /**
7802  * Indicate whether this chip supports Sidewalk protocol.
7803  *
7804  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7805  * @return true if Sidewalk protocol is supported; false otherwise.
7806  *
7807  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_PROTOCOL_SIDEWALK.
7808  */
7809 bool RAIL_SupportsProtocolSidewalk(RAIL_Handle_t railHandle);
7810 
7811 /**
7812  * Indicate whether this chip supports TrustZone secure configuration of
7813  * peripherals used by RAIL.
7814  *
7815  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7816  * @return true if secure mode is supported; false otherwise.
7817  *
7818  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_TRUSTZONE_SECURE_PERIPHERALS.
7819  */
7820 bool RAIL_SupportsTrustZoneSecurePeripherals(RAIL_Handle_t railHandle);
7821 
7822 /**
7823  * Indicate whether this chip supports automatic PRS LNA bypass for external
7824  * FEM.
7825  *
7826  * @param[in] railHandle A radio-generic or real RAIL instance handle.
7827  * @return true if automatic PRS LNA bypass is supported; false otherwise.
7828  *
7829  * Runtime refinement of compile-time \ref RAIL_SUPPORTS_PRS_LNA_BYPASS.
7830  */
7831 bool RAIL_SupportsPrsLnaBypass(RAIL_Handle_t railHandle);
7832 
7833 /** @} */ // end of group Features
7834 
7835 /** @} */ // end of group RAIL_API
7836 
7837 #ifdef __cplusplus
7838 }
7839 #endif
7840 
7841 #endif // __RAIL_H__
7842