1 /***************************************************************************//**
2 * @file
3 * @brief The IEEE 802.15.4 specific header file for the RAIL library.
4 *******************************************************************************
5 * # License
6 * <b>Copyright 2020 Silicon Laboratories Inc. www.silabs.com</b>
7 *******************************************************************************
8 *
9 * SPDX-License-Identifier: Zlib
10 *
11 * The licensor of this software is Silicon Laboratories Inc.
12 *
13 * This software is provided 'as-is', without any express or implied
14 * warranty. In no event will the authors be held liable for any damages
15 * arising from the use of this software.
16 *
17 * Permission is granted to anyone to use this software for any purpose,
18 * including commercial applications, and to alter it and redistribute it
19 * freely, subject to the following restrictions:
20 *
21 * 1. The origin of this software must not be misrepresented; you must not
22 * claim that you wrote the original software. If you use this software
23 * in a product, an acknowledgment in the product documentation would be
24 * appreciated but is not required.
25 * 2. Altered source versions must be plainly marked as such, and must not be
26 * misrepresented as being the original software.
27 * 3. This notice may not be removed or altered from any source distribution.
28 *
29 ******************************************************************************/
30
31 #ifndef __RAIL_IEEE802154_H__
32 #define __RAIL_IEEE802154_H__
33
34 #include "rail_types.h"
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /// @addtogroup IEEE802_15_4 IEEE 802.15.4
41 /// @ingroup Protocol_Specific
42 /// @brief IEEE 802.15.4 configuration routines
43 ///
44 /// The functions in this group configure RAIL IEEE 802.15.4 hardware
45 /// acceleration which includes IEEE 802.15.4 format filtering, address
46 /// filtering, ACKing, and filtering based on the frame type.
47 ///
48 /// To configure IEEE 802.15.4 functionality, the application must first set up
49 /// a RAIL instance with RAIL_Init() and other setup functions.
50 /// Instead of RAIL_ConfigChannels(), however, an
51 /// application may use RAIL_IEEE802154_Config2p4GHzRadio() to set up the
52 /// official IEEE 2.4 GHz 802.15.4 PHY. This configuration is shown below.
53 ///
54 /// 802.15.4 defines its macAckWaitDuration from the end of the transmitted
55 /// packet to complete reception of the ACK. RAIL's ackTimeout only covers
56 /// sync word detection of the ACK. Therefore, subtract the ACK's
57 /// PHY header and payload time to get RAIL's ackTimeout setting.
58 /// For 2.4 GHz OQPSK, macAckWaitDuration is specified as 54 symbols;
59 /// subtracting 2-symbol PHY header and 10-symbol payload yields a RAIL
60 /// ackTimeout of 42 symbols or 672 microseconds at 16 microseconds/symbol.
61 ///
62 /// @code{.c}
63 /// static RAIL_Handle_t railHandle = NULL; // Initialized somewhere else.
64 ///
65 /// static const RAIL_IEEE802154_Config_t rail154Config = {
66 /// .addresses = NULL,
67 /// .ackConfig = {
68 /// .enable = true, // Turn on auto ACK for IEEE 802.15.4.
69 /// .ackTimeout = 672, // See note above: 54-12 sym * 16 us/sym = 672 us.
70 /// .rxTransitions = {
71 /// .success = RAIL_RF_STATE_RX, // Return to RX after ACK processing
72 /// .error = RAIL_RF_STATE_RX, // Ignored
73 /// },
74 /// .txTransitions = {
75 /// .success = RAIL_RF_STATE_RX, // Return to RX after ACK processing
76 /// .error = RAIL_RF_STATE_RX, // Ignored
77 /// },
78 /// },
79 /// .timings = {
80 /// .idleToRx = 100,
81 /// .idleToTx = 100,
82 /// .rxToTx = 192, // 12 symbols * 16 us/symbol = 192 us
83 /// .txToRx = 192, // 12 symbols * 16 us/symbol = 192 us
84 /// .rxSearchTimeout = 0, // Not used
85 /// .txToRxSearchTimeout = 0, // Not used
86 /// },
87 /// .framesMask = RAIL_IEEE802154_ACCEPT_STANDARD_FRAMES,
88 /// .promiscuousMode = false, // Enable format and address filtering.
89 /// .isPanCoordinator = false,
90 /// .defaultFramePendingInOutgoingAcks = false,
91 /// };
92 ///
93 /// void config154(void)
94 /// {
95 /// // Configure the radio and channels for 2.4 GHz IEEE 802.15.4.
96 /// RAIL_IEEE802154_Config2p4GHzRadio(railHandle);
97 /// // Initialize the IEEE 802.15.4 configuration using the static configuration above.
98 /// RAIL_IEEE802154_Init(railHandle, &rail154Config);
99 /// }
100 /// @endcode
101 ///
102 /// To configure address filtering, call
103 /// RAIL_IEEE802154_SetAddresses() with a structure containing all addresses or
104 /// call the individual RAIL_IEEE802154_SetPanId(),
105 /// RAIL_IEEE802154_SetShortAddress(), and RAIL_IEEE802154_SetLongAddress()
106 /// APIs. RAIL supports \ref RAIL_IEEE802154_MAX_ADDRESSES number of address
107 /// pairs to receive packets from multiple IEEE
108 /// 802.15.4 networks at the same time. Broadcast addresses are supported by
109 /// default without any additional configuration so they do not consume one of
110 /// these slots. If the application does not require all address pairs, be sure
111 /// to set unused ones to the proper disabled value for each type. These can
112 /// be found in the \ref RAIL_IEEE802154_AddrConfig_t documentation. Below is
113 /// an example of setting filtering for one set of addresses.
114 ///
115 /// @code{.c}
116 /// // PanID OTA value of 0x34 0x12.
117 /// // Short Address OTA byte order of 0x78 0x56.
118 /// // Long address with OTA byte order of 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88.
119 ///
120 /// // Set up all addresses simultaneously.
121 /// RAIL_Status_t setup1(void)
122 /// {
123 /// RAIL_IEEE802154_AddrConfig_t nodeAddress = {
124 /// { 0x1234, 0xFFFF, 0xFFFF },
125 /// { 0x5678, 0xFFFF, 0xFFFF },
126 /// { { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 },
127 /// { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
128 /// { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } }
129 /// };
130 /// return RAIL_IEEE802154_SetAddresses(railHandle, &nodeAddress);
131 /// }
132 ///
133 /// // Alternatively, the addresses can be set up individually as follows:
134 /// RAIL_Status_t setup2(void)
135 /// {
136 /// RAIL_Status_t status;
137 /// const uint8_t longAddress[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 };
138 ///
139 /// status = RAIL_IEEE802154_SetPanId(railHandle, 0x1234, 0);
140 /// if (status != RAIL_STATUS_NO_ERROR) {
141 /// return status
142 /// }
143 /// status = RAIL_IEEE802154_SetShortAddress(railHandle, 0x5678, 0);
144 /// if (status != RAIL_STATUS_NO_ERROR) {
145 /// return status
146 /// }
147 /// status = RAIL_IEEE802154_SetLongAddress(railHandle, longAddress, 0);
148 /// if (status != RAIL_STATUS_NO_ERROR) {
149 /// return status
150 /// }
151 ///
152 /// return RAIL_STATUS_NO_ERROR;
153 /// }
154 /// @endcode
155 ///
156 /// Address filtering will be enabled except when in promiscuous mode, which can
157 /// be set with RAIL_IEEE802154_SetPromiscuousMode(). The addresses may be
158 /// changed at runtime. However, if you are receiving a packet while
159 /// reconfiguring the address filters, you may get undesired behavior so it's
160 /// safest to do this while not in receive.
161 ///
162 /// Auto ACK is controlled by the ackConfig and timings fields passed to
163 /// RAIL_IEEE802154_Init(). After initialization, they may be controlled
164 /// using the normal \ref Auto_Ack and \ref State_Transitions APIs. When in IEEE
165 /// 802.15.4 mode, the ACK will generally have a 5 byte length, its Frame Type
166 /// will be ACK, its Frame Version 0 (2003), and its Frame Pending bit will be
167 /// false unless the \ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND event is
168 /// triggered in which case it will default to the
169 /// \ref RAIL_IEEE802154_Config_t::defaultFramePendingInOutgoingAcks setting.
170 /// If the default Frame Pending setting is incorrect,
171 /// the app must call \ref RAIL_IEEE802154_ToggleFramePending
172 /// (formerly \ref RAIL_IEEE802154_SetFramePending) while handling the
173 /// \ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND event.
174 ///
175 /// This event must be turned on by the user and will fire whenever a data
176 /// request is being received so that the stack can determine if there
177 /// is pending data. Note that if the default Frame Pending bit needs to
178 /// be changed, it must be done quickly. Otherwise, the ACK may already
179 /// have been transmitted with the default setting. Check the return code of
180 /// RAIL_IEEE802154_ToggleFramePending() to be sure that the bit was changed
181 /// in time.
182 ///
183 /// Transmit and receive operations are done using the standard RAIL APIs in
184 /// IEEE 802.15.4 mode. To send packets using the correct CSMA configuration,
185 /// use \ref RAIL_CSMA_CONFIG_802_15_4_2003_2p4_GHz_OQPSK_CSMA define
186 /// that can initialize the csmaConfig structure passed to \ref
187 /// RAIL_StartCcaCsmaTx().
188 /// @{
189
190 /**
191 * @enum RAIL_IEEE802154_AddressLength_t
192 * @brief Different lengths that an 802.15.4 address can have
193 */
RAIL_ENUM(RAIL_IEEE802154_AddressLength_t)194 RAIL_ENUM(RAIL_IEEE802154_AddressLength_t) {
195 RAIL_IEEE802154_ShortAddress = 2, /**< 2 byte short address. */
196 RAIL_IEEE802154_LongAddress = 3, /**< 8 byte extended address. */
197 };
198
199 #ifndef DOXYGEN_SHOULD_SKIP_THIS
200 // Self-referencing defines minimize compiler complaints when using RAIL_ENUM
201 #define RAIL_IEEE802154_ShortAddress ((RAIL_IEEE802154_AddressLength_t) RAIL_IEEE802154_ShortAddress)
202 #define RAIL_IEEE802154_LongAddress ((RAIL_IEEE802154_AddressLength_t) RAIL_IEEE802154_LongAddress)
203 #endif//DOXYGEN_SHOULD_SKIP_THIS
204
205 /**
206 * @struct RAIL_IEEE802154_Address_t
207 * @brief Representation of 802.15.4 address
208 * This structure is only used for received source address information
209 * needed to perform Frame Pending lookup.
210 */
211 typedef struct RAIL_IEEE802154_Address{
212 /** Convenient storage for different address types. */
213 union {
214 uint16_t shortAddress; /**< Present for 2 byte addresses. */
215 uint8_t longAddress[8]; /**< Present for 8 byte addresses. */
216 };
217 /**
218 * Enumeration of the received address length.
219 */
220 RAIL_IEEE802154_AddressLength_t length;
221 /**
222 * A bitmask representing which address filter(s) this packet has passed.
223 * It is undefined on platforms lacking \ref RAIL_SUPPORTS_ADDR_FILTER_MASK.
224 */
225 RAIL_AddrFilterMask_t filterMask;
226 } RAIL_IEEE802154_Address_t;
227
228 /** The maximum number of allowed addresses of each type. */
229 #define RAIL_IEEE802154_MAX_ADDRESSES (3U)
230
231 /**
232 * @struct RAIL_IEEE802154_AddrConfig_t
233 * @brief A configuration structure for IEEE 802.15.4 Address Filtering. The
234 * broadcast addresses are handled separately and do not need to be specified
235 * here. Any address to be ignored should be set with all bits high.
236 *
237 * This structure allows configuration of multi-PAN functionality by specifying
238 * multiple PAN IDs and short addresses. A packet will be received if it matches
239 * an address and its corresponding PAN ID. Long address 0 and short address 0
240 * match against PAN ID 0, etc. The broadcast PAN ID and address will work with
241 * any address or PAN ID, respectively.
242 */
243 typedef struct RAIL_IEEE802154_AddrConfig{
244 /**
245 * PAN IDs for destination filtering. All must be specified.
246 * To disable a PAN ID, set it to the broadcast value, 0xFFFF.
247 */
248 uint16_t panId[RAIL_IEEE802154_MAX_ADDRESSES];
249 /**
250 * A short network addresses for destination filtering. All must be specified.
251 * To disable a short address, set it to the broadcast value, 0xFFFF.
252 */
253 uint16_t shortAddr[RAIL_IEEE802154_MAX_ADDRESSES];
254 /**
255 * A 64-bit address for destination filtering. All must be specified.
256 * This field is parsed in over-the-air (OTA) byte order. To disable a long
257 * address, set it to the reserved value of 0x00 00 00 00 00 00 00 00.
258 */
259 uint8_t longAddr[RAIL_IEEE802154_MAX_ADDRESSES][8];
260 } RAIL_IEEE802154_AddrConfig_t;
261
262 /**
263 * @struct RAIL_IEEE802154_Config_t
264 * @brief A configuration structure for IEEE 802.15.4 in RAIL.
265 *
266 * @note 802.15.4 radio configurations with Forward Error Correction (FEC)
267 * enabled are incompatible with 802.15.4 filtering and AutoACK on
268 * EFR32xG1 platforms.
269 * AutoACK should be disabled and promiscuous mode enabled when using such
270 * a configuration. This is enforced implicitly on EFR32xG1 platforms with
271 * \ref RAIL_IEEE802154_SUPPORTS_G_DYNFEC true when
272 * \ref RAIL_IEEE802154_ConfigGOptions() is called to enable any G options.
273 */
274 typedef struct RAIL_IEEE802154_Config {
275 /**
276 * Configure the RAIL Address Filter to allow the given destination
277 * addresses. If this pointer is NULL, defer destination address configuration.
278 * If a member of addresses is NULL, defer configuration of just that member.
279 * This can be overridden via RAIL_IEEE802154_SetAddresses(), or the
280 * individual members can be changed via RAIL_IEEE802154_SetPanId(),
281 * RAIL_IEEE802154_SetShortAddress(), and RAIL_IEEE802154_SetLongAddress().
282 */
283 const RAIL_IEEE802154_AddrConfig_t *addresses;
284 /**
285 * Define the ACKing configuration for the IEEE 802.15.4 implementation.
286 */
287 RAIL_AutoAckConfig_t ackConfig;
288 /**
289 * Define state timings for the IEEE 802.15.4 implementation.
290 */
291 RAIL_StateTiming_t timings;
292 /**
293 * Set which 802.15.4 frame types will be received, of Beacon, Data, ACK, and
294 * Command. This setting can be overridden via RAIL_IEEE802154_AcceptFrames().
295 */
296 uint8_t framesMask;
297 /**
298 * Enable promiscuous mode during configuration. This can be overridden via
299 * RAIL_IEEE802154_SetPromiscuousMode() afterwards.
300 */
301 bool promiscuousMode;
302 /**
303 * Set whether the device is a PAN Coordinator during configuration. This can
304 * be overridden via RAIL_IEEE802154_SetPanCoordinator() afterwards.
305 */
306 bool isPanCoordinator;
307 /**
308 * The default value for the Frame Pending bit in outgoing ACKs for packets
309 * that triggered the \ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND event.
310 * Such an ACK's Frame Pending bit can be inverted if necessary during the
311 * handling of that event by calling \ref RAIL_IEEE802154_ToggleFramePending
312 * (formerly \ref RAIL_IEEE802154_SetFramePending).
313 */
314 bool defaultFramePendingInOutgoingAcks;
315 } RAIL_IEEE802154_Config_t;
316
317 /** RX channel switching buffer size, in bytes. */
318 #define RAIL_IEEE802154_RX_CHANNEL_SWITCHING_BUF_BYTES (640U)
319
320 /** Fixed-width type indicating the needed alignment for RX channel switching buffer. */
321 #define RAIL_IEEE802154_RX_CHANNEL_SWITCHING_BUF_ALIGNMENT_TYPE uint32_t
322
323 /** Alignment that is needed for RX channel switching buffer. */
324 #define RAIL_IEEE802154_RX_CHANNEL_SWITCHING_BUF_ALIGNMENT (sizeof(RAIL_IEEE802154_RX_CHANNEL_SWITCHING_BUF_ALIGNMENT_TYPE))
325
326 /** Maximum numbers of channels supported for RX channel switching */
327 #define RAIL_IEEE802154_RX_CHANNEL_SWITCHING_NUM_CHANNELS (2U)
328
329 /**
330 * @struct RAIL_IEEE802154_RxChannelSwitchingCfg_t
331 * @brief A configuration structure for RX channel switching.
332 */
333 typedef struct RAIL_IEEE802154_RxChannelSwitchingCfg {
334 /**
335 * Pointer to contiguous global read-write memory that will be used
336 * by RAIL to store channel specific settings for concurrent listening.
337 * It need not be initialized and applications should never write
338 * data anywhere in this buffer.
339 *
340 * @note the size of this buffer must be at least as large as the
341 * \ref RAIL_IEEE802154_RX_CHANNEL_SWITCHING_BUF_BYTES and needs to be word
342 * aligned.
343 */
344 RAIL_IEEE802154_RX_CHANNEL_SWITCHING_BUF_ALIGNMENT_TYPE *buffer;
345 /**
346 * This parameter must be set to the length of the buffer array, in bytes.
347 * This way, during configuration, the software can confirm it's
348 * writing within the range of the buffer. The configuration API will return
349 * an error if bufferBytes is insufficient.
350 */
351 uint16_t bufferBytes;
352 /**
353 * Array to hold the channel numbers for RX channel switching.
354 * @note Radio will switch between the exact channels specified, and not
355 * across an inclusive range of channels between the specified channels.
356 */
357 uint16_t channels[RAIL_IEEE802154_RX_CHANNEL_SWITCHING_NUM_CHANNELS];
358 } RAIL_IEEE802154_RxChannelSwitchingCfg_t;
359
360 /// @addtogroup IEEE802154_PHY IEEE 802.15.4 Radio Configurations
361 /// Radio configurations for the RAIL 802.15.4 Accelerator
362 ///
363 /// These radio configurations are used to configure 802.15.4 when a function
364 /// such as \ref RAIL_IEEE802154_Config2p4GHzRadio() is called. Each radio
365 /// configuration listed below is compiled into the RAIL library as a weak
366 /// symbol that will take into account per-die defaults. If the board
367 /// configuration in use has different settings than the default, such as a
368 /// different radio subsystem clock frequency, these radio configurations can
369 /// be overridden to account for those settings.
370 /// @{
371
372 /**
373 * Default PHY to use for 2.4 GHz 802.15.4. Will be NULL if
374 * \ref RAIL_SUPPORTS_PROTOCOL_IEEE802154 or \ref RAIL_SUPPORTS_2P4GHZ_BAND
375 * is 0.
376 */
377 extern const RAIL_ChannelConfig_t *const RAIL_IEEE802154_Phy2p4GHz;
378
379 /**
380 * Default PHY to use for 2.4 GHz 802.15.4 with antenna diversity. Will be NULL
381 * if \ref RAIL_SUPPORTS_PROTOCOL_IEEE802154, \ref RAIL_SUPPORTS_2P4GHZ_BAND, or
382 * \ref RAIL_SUPPORTS_ANTENNA_DIVERSITY is 0.
383 */
384 extern const RAIL_ChannelConfig_t *const RAIL_IEEE802154_Phy2p4GHzAntDiv;
385
386 /**
387 * Default PHY to use for 2.4 GHz 802.15.4 optimized for coexistence. Will be
388 * NULL if \ref RAIL_IEEE802154_SUPPORTS_COEX_PHY is 0.
389 */
390 extern const RAIL_ChannelConfig_t *const RAIL_IEEE802154_Phy2p4GHzCoex;
391
392 /**
393 * Default PHY to use for 2.4 GHz 802.15.4 optimized for coexistence, while
394 * supporting antenna diversity. Will be NULL if
395 * \ref RAIL_SUPPORTS_ANTENNA_DIVERSITY or
396 * \ref RAIL_IEEE802154_SUPPORTS_COEX_PHY is 0.
397 */
398 extern const RAIL_ChannelConfig_t *const RAIL_IEEE802154_Phy2p4GHzAntDivCoex;
399
400 /**
401 * Default PHY to use for 2.4 GHz 802.15.4 with a configuration that supports a
402 * front-end module. Will be NULL if
403 * \ref RAIL_IEEE802154_SUPPORTS_FEM_PHY is 0.
404 */
405 extern const RAIL_ChannelConfig_t *const RAIL_IEEE802154_Phy2p4GHzFem;
406
407 /**
408 * Default PHY to use for 2.4 GHz 802.15.4 with a configuration that supports a
409 * front-end module and antenna diversity. Will be NULL if
410 * \ref RAIL_IEEE802154_SUPPORTS_FEM_PHY or \ref RAIL_SUPPORTS_ANTENNA_DIVERSITY
411 * is 0.
412 */
413 extern const RAIL_ChannelConfig_t *const RAIL_IEEE802154_Phy2p4GHzAntDivFem;
414
415 /**
416 * Default PHY to use for 2.4 GHz 802.15.4 with a configuration that supports a
417 * front-end module and is optimized for radio coexistence. Will be NULL if
418 * \ref RAIL_IEEE802154_SUPPORTS_FEM_PHY or
419 * \ref RAIL_IEEE802154_SUPPORTS_COEX_PHY is 0.
420 */
421 extern const RAIL_ChannelConfig_t *const RAIL_IEEE802154_Phy2p4GHzCoexFem;
422
423 /**
424 * Default PHY to use for 2.4 GHz 802.15.4 with a configuration that supports a
425 * front-end module and antenna diversity, and is optimized for radio
426 * coexistence. Will be NULL if \ref RAIL_IEEE802154_SUPPORTS_FEM_PHY,
427 * \ref RAIL_IEEE802154_SUPPORTS_COEX_PHY, or
428 * \ref RAIL_SUPPORTS_ANTENNA_DIVERSITY is 0.
429 */
430 extern const RAIL_ChannelConfig_t *const RAIL_IEEE802154_Phy2p4GHzAntDivCoexFem;
431
432 /**
433 * Default PHY to use for 2.4 GHz 802.15.4 with custom settings. Will be NULL
434 * if \ref RAIL_IEEE802154_SUPPORTS_CUSTOM1_PHY is 0.
435 */
436 extern const RAIL_ChannelConfig_t *const RAIL_IEEE802154_Phy2p4GHzCustom1;
437
438 /**
439 * Default PHY to use for 863MHz GB868 802.15.4. Will be NULL if
440 * \ref RAIL_IEEE802154_SUPPORTS_G_SUBSET_GB868 is 0.
441 */
442 extern const RAIL_ChannelConfig_t *const RAIL_IEEE802154_PhyGB863MHz;
443
444 /**
445 * Default PHY to use for 915MHz GB868 802.15.4. Will be NULL if
446 * \ref RAIL_IEEE802154_SUPPORTS_G_SUBSET_GB868 is 0.
447 */
448 extern const RAIL_ChannelConfig_t *const RAIL_IEEE802154_PhyGB915MHz;
449
450 /// @} // End of group IEEE802154_PHY
451
452 /**
453 * Initialize RAIL for IEEE802.15.4 features.
454 *
455 * @param[in] railHandle A handle of RAIL instance.
456 * @param[in] config An IEEE802154 configuration structure.
457 * @return A status code indicating success of the function call.
458 *
459 * This function calls the following RAIL functions to configure the radio for
460 * IEEE802.15.4 features.
461 *
462 * Initializes the following:
463 * - Enables IEEE802154 hardware acceleration
464 * - Configures RAIL Auto ACK functionality
465 * - Configures RAIL Address Filter for 802.15.4 address filtering
466 *
467 * It saves having to call the following functions individually:
468 * - RAIL_ConfigAutoAck()
469 * - RAIL_SetRxTransitions()
470 * - RAIL_SetTxTransitions()
471 * - RAIL_WriteAutoAckFifo()
472 * - RAIL_SetStateTiming()
473 * - RAIL_ConfigAddressFilter()
474 * - RAIL_EnableAddressFilter()
475 */
476 RAIL_Status_t RAIL_IEEE802154_Init(RAIL_Handle_t railHandle,
477 const RAIL_IEEE802154_Config_t *config);
478
479 /**
480 * Configure the radio for 2.4 GHz 802.15.4 operation.
481 *
482 * @param[in] railHandle A handle of RAIL instance.
483 * @return A status code indicating success of the function call.
484 *
485 * This initializes the radio for 2.4 GHz operation. It takes the place of
486 * calling \ref RAIL_ConfigChannels. After this call,
487 * channels 11-26 will be available, giving the frequencies of those channels
488 * on channel page 0, as defined by IEEE 802.15.4-2011 section 8.1.2.2.
489 *
490 * @note This call implicitly disables all \ref RAIL_IEEE802154_GOptions_t.
491 */
492 RAIL_Status_t RAIL_IEEE802154_Config2p4GHzRadio(RAIL_Handle_t railHandle);
493
494 /**
495 * Configure the radio for 2.4 GHz 802.15.4 operation with antenna diversity.
496 *
497 * @param[in] railHandle A handle of RAIL instance.
498 * @return A status code indicating success of the function call.
499 *
500 * This initializes the radio for 2.4 GHz operation, but with a configuration
501 * that supports antenna diversity. It takes the place of
502 * calling \ref RAIL_ConfigChannels. After this call,
503 * channels 11-26 will be available, giving the frequencies of those channels
504 * on channel page 0, as defined by IEEE 802.15.4-2011 section 8.1.2.2.
505 *
506 * @note This call implicitly disables all \ref RAIL_IEEE802154_GOptions_t.
507 */
508 RAIL_Status_t RAIL_IEEE802154_Config2p4GHzRadioAntDiv(RAIL_Handle_t railHandle);
509
510 /**
511 * Configure the radio for 2.4 GHz 802.15.4 operation with antenna diversity
512 * optimized for radio coexistence.
513 *
514 * @param[in] railHandle A handle of RAIL instance.
515 * @return A status code indicating success of the function call.
516 *
517 * This initializes the radio for 2.4 GHz operation, but with a configuration
518 * that supports antenna diversity optimized for radio coexistence. It takes
519 * the place of calling \ref RAIL_ConfigChannels. After this call,
520 * channels 11-26 will be available, giving the frequencies of those channels
521 * on channel page 0, as defined by IEEE 802.15.4-2011 section 8.1.2.2.
522 *
523 * @note This call implicitly disables all \ref RAIL_IEEE802154_GOptions_t.
524 */
525 RAIL_Status_t RAIL_IEEE802154_Config2p4GHzRadioAntDivCoex(RAIL_Handle_t railHandle);
526
527 /**
528 * Configure the radio for 2.4 GHz 802.15.4 operation optimized for radio coexistence.
529 *
530 * @param[in] railHandle A handle of RAIL instance.
531 * @return A status code indicating success of the function call.
532 *
533 * This initializes the radio for 2.4 GHz operation, but with a configuration
534 * that supports radio coexistence. It takes the place of
535 * calling \ref RAIL_ConfigChannels. After this call,
536 * channels 11-26 will be available, giving the frequencies of those channels
537 * on channel page 0, as defined by IEEE 802.15.4-2011 section 8.1.2.2.
538 *
539 * @note This call implicitly disables all \ref RAIL_IEEE802154_GOptions_t.
540 */
541 RAIL_Status_t RAIL_IEEE802154_Config2p4GHzRadioCoex(RAIL_Handle_t railHandle);
542
543 /**
544 * Configure the radio for 2.4 GHz 802.15.4 operation with a front end module.
545 *
546 * @param[in] railHandle A handle of RAIL instance.
547 * @return A status code indicating success of the function call.
548 *
549 * This initializes the radio for 2.4 GHz operation, but with a configuration
550 * that supports a front end module. It takes the place of
551 * calling \ref RAIL_ConfigChannels. After this call,
552 * channels 11-26 will be available, giving the frequencies of those channels
553 * on channel page 0, as defined by IEEE 802.15.4-2011 section 8.1.2.2.
554 *
555 * @note This call implicitly disables all \ref RAIL_IEEE802154_GOptions_t.
556 */
557 RAIL_Status_t RAIL_IEEE802154_Config2p4GHzRadioFem(RAIL_Handle_t railHandle);
558
559 /**
560 * Configure the radio for 2.4 GHz 802.15.4 operation with antenna diversity
561 * optimized for a front end module.
562 *
563 * @param[in] railHandle A handle of RAIL instance.
564 * @return A status code indicating success of the function call.
565 *
566 * This initializes the radio for 2.4 GHz operation, but with a configuration
567 * that supports antenna diversity and a front end module. It takes the place of
568 * calling \ref RAIL_ConfigChannels. After this call,
569 * channels 11-26 will be available, giving the frequencies of those channels
570 * on channel page 0, as defined by IEEE 802.15.4-2011 section 8.1.2.2.
571 *
572 * @note This call implicitly disables all \ref RAIL_IEEE802154_GOptions_t.
573 */
574 RAIL_Status_t RAIL_IEEE802154_Config2p4GHzRadioAntDivFem(RAIL_Handle_t railHandle);
575
576 /**
577 * Configure the radio for 2.4 GHz 802.15.4 operation optimized for radio coexistence
578 * and a front end module.
579 *
580 * @param[in] railHandle A handle of RAIL instance.
581 * @return A status code indicating success of the function call.
582 *
583 * This initializes the radio for 2.4 GHz operation, but with a configuration
584 * that supports radio coexistence and a front end module. It takes the place of
585 * calling \ref RAIL_ConfigChannels. After this call,
586 * channels 11-26 will be available, giving the frequencies of those channels
587 * on channel page 0, as defined by IEEE 802.15.4-2011 section 8.1.2.2.
588 *
589 * @note This call implicitly disables all \ref RAIL_IEEE802154_GOptions_t.
590 */
591 RAIL_Status_t RAIL_IEEE802154_Config2p4GHzRadioCoexFem(RAIL_Handle_t railHandle);
592
593 /**
594 * Configure the radio for 2.4 GHz 802.15.4 operation with antenna diversity
595 * optimized for radio coexistence and a front end module.
596 *
597 * @param[in] railHandle A handle of RAIL instance.
598 * @return A status code indicating success of the function call.
599 *
600 * This initializes the radio for 2.4 GHz operation, but with a configuration
601 * that supports antenna diversity, radio coexistence and a front end module.
602 * It takes the place of calling \ref RAIL_ConfigChannels.
603 * After this call, channels 11-26 will be available, giving the frequencies of
604 * those channels on channel page 0, as defined by IEEE 802.15.4-2011 section 8.1.2.2.
605 *
606 * @note This call implicitly disables all \ref RAIL_IEEE802154_GOptions_t.
607 */
608 RAIL_Status_t RAIL_IEEE802154_Config2p4GHzRadioAntDivCoexFem(RAIL_Handle_t railHandle);
609
610 /**
611 * Configure the radio for 2.4 GHz 802.15.4 operation with custom
612 * settings. It enables better interoperability with some proprietary
613 * PHYs, but doesn't guarantee data sheet performance.
614 *
615 * @param[in] railHandle A handle of RAIL instance.
616 * @return A status code indicating success of the function call.
617 *
618 * This initializes the radio for 2.4 GHz operation with
619 * custom settings. It replaces needing to call
620 * \ref RAIL_ConfigChannels.
621 * Do not call this function unless instructed by Silicon Labs.
622 *
623 * @note This feature is only available on platforms where
624 * \ref RAIL_IEEE802154_SUPPORTS_CUSTOM1_PHY is true.
625 */
626 RAIL_Status_t RAIL_IEEE802154_Config2p4GHzRadioCustom1(RAIL_Handle_t railHandle);
627
628 /**
629 * Configure the radio for SubGHz GB868 863 MHz 802.15.4 operation.
630 *
631 * @param[in] railHandle A handle of RAIL instance.
632 * @return A status code indicating success of the function call.
633 *
634 * This initializes the radio for SubGHz GB868 863 MHz operation. It takes the
635 * place of calling \ref RAIL_ConfigChannels.
636 * After this call, GB868 channels in the 863 MHz band (channel pages 28, 29,
637 * and 30 -- logical channels 0x80..0x9A, 0xA0..0xA8, 0xC0..0xDA, respectively)
638 * will be available, as defined by Rev 22 of the Zigbee Specification, 2017
639 * document 05-3474-22, section D.10.2.1.3.2.
640 *
641 * @note This call implicitly enables \ref RAIL_IEEE802154_G_OPTION_GB868.
642 */
643 RAIL_Status_t RAIL_IEEE802154_ConfigGB863MHzRadio(RAIL_Handle_t railHandle);
644
645 /**
646 * Configure the radio for SubGHz GB868 915 MHz 802.15.4 operation.
647 *
648 * @param[in] railHandle A handle of RAIL instance.
649 * @return A status code indicating success of the function call.
650 *
651 * This initializes the radio for SubGHz GB868 915 MHz operation. It takes the
652 * place of calling \ref RAIL_ConfigChannels.
653 * After this call, GB868 channels in the 915 MHz band (channel page 31 --
654 * logical channels 0xE0..0xFA) will be available, as defined by Rev 22 of
655 * the Zigbee Specification, 2017 document 05-3474-22, section D.10.2.1.3.2.
656 *
657 * @note This call implicitly enables \ref RAIL_IEEE802154_G_OPTION_GB868.
658 */
659 RAIL_Status_t RAIL_IEEE802154_ConfigGB915MHzRadio(RAIL_Handle_t railHandle);
660
661 /**
662 * De-initialize IEEE802.15.4 hardware acceleration.
663 *
664 * @param[in] railHandle A handle of RAIL instance.
665 * @return A status code indicating success of the function call.
666 *
667 * Disables and resets all IEE802.15.4 hardware acceleration features. This
668 * function should only be called when the radio is IDLE. This calls the
669 * following:
670 * - RAIL_SetStateTiming(), to reset all timings to 100 us
671 * - RAIL_EnableAddressFilter(false)
672 * - RAIL_ResetAddressFilter()
673 */
674 RAIL_Status_t RAIL_IEEE802154_Deinit(RAIL_Handle_t railHandle);
675
676 /**
677 * Return whether IEEE802.15.4 hardware acceleration is currently enabled.
678 *
679 * @param[in] railHandle A handle of RAIL instance.
680 * @return True if IEEE802.15.4 hardware acceleration was enabled to start with
681 * and false otherwise.
682 */
683 bool RAIL_IEEE802154_IsEnabled(RAIL_Handle_t railHandle);
684
685 /**
686 * @enum RAIL_IEEE802154_PtiRadioConfig_t
687 * @brief 802.15.4 PTI radio configuration mode
688 */
RAIL_ENUM(RAIL_IEEE802154_PtiRadioConfig_t)689 RAIL_ENUM(RAIL_IEEE802154_PtiRadioConfig_t) {
690 /**
691 * Built-in 2.4 GHz 802.15.4 radio configuration.
692 */
693 RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ = 0x00U,
694 /**
695 * Built-in 2.4 GHz 802.15.4 radio configuration
696 * with RX antenna diversity support.
697 */
698 RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_ANTDIV = 0x01U,
699 /**
700 * Built-in 2.4 GHz 802.15.4 radio configuration
701 * optimized for radio coexistence.
702 */
703 RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_COEX = 0x02U,
704 /**
705 * Built-in 2.4 GHz 802.15.4 radio configuration with
706 * RX antenna diversity support optimized for radio coexistence.
707 */
708 RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_ANTDIV_COEX = 0x03U,
709 /**
710 * Built-in 2.4 GHz 802.15.4 radio configuration
711 * optimized for front end modules.
712 */
713 RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_FEM = 0x08U,
714 /**
715 * Built-in 2.4 GHz 802.15.4 radio configuration
716 * with RX antenna diversity support optimized for
717 * front end modules.
718 */
719 RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_FEM_ANTDIV = 0x09U,
720 /**
721 * Built-in 2.4 GHz 802.15.4 radio configuration
722 * optimized for radio coexistence and front end modules.
723 */
724 RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_FEM_COEX = 0x0AU,
725 /**
726 * Built-in 2.4 GHz 802.15.4 radio configuration with
727 * RX antenna diversity support optimized for radio coexistence
728 * and front end modules.
729 */
730 RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_FEM_ANTDIV_COEX = 0x0BU,
731 /**
732 * Built-in 863 MHz GB868 802.15.4 radio configuration.
733 */
734 RAIL_IEEE802154_PTI_RADIO_CONFIG_863MHZ_GB868 = 0x85U,
735 /**
736 * Built-in 915 MHz GB868 802.15.4 radio configuration.
737 */
738 RAIL_IEEE802154_PTI_RADIO_CONFIG_915MHZ_GB868 = 0x86U,
739 /**
740 * External 915 MHz Zigbee R23 802.15.4 NA radio configuration.
741 */
742 RAIL_IEEE802154_PTI_RADIO_CONFIG_915MHZ_R23_NA_EXT = 0x97U,
743 /**
744 * 863 MHz SUN OFDM Option 1 802.15.4 radio configuration.
745 */
746 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_OFDM_OPT1_863MHZ = 0x42,
747 /**
748 * 902 MHz SUN OFDM Option 1 802.15.4 radio configuration.
749 */
750 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_OFDM_OPT1_902MHZ = 0x43,
751 /**
752 * 86 3MHz SUN OFDM Option 2 802.15.4 radio configuration.
753 */
754 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_OFDM_OPT2_863MHZ = 0x52,
755 /**
756 * 902 MHz SUN OFDM Option 2 802.15.4 radio configuration.
757 */
758 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_OFDM_OPT2_902MHZ = 0x53,
759 /**
760 * 863 MHz SUN OFDM Option 3 802.15.4 radio configuration.
761 */
762 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_OFDM_OPT3_863MHZ = 0x62,
763 /**
764 * 902 MHz SUN OFDM Option 3 802.15.4 radio configuration.
765 */
766 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_OFDM_OPT3_902MHZ = 0x63,
767 /**
768 * 863 MHz SUN OFDM Option 4 802.15.4 radio configuration.
769 */
770 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_OFDM_OPT4_863MHZ = 0x72,
771 /**
772 * 902 MHz SUN OFDM Option 4 802.15.4 radio configuration.
773 */
774 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_OFDM_OPT4_902MHZ = 0x73,
775 /**
776 * 868 MHz SUN OQPSK 802.15.4 radio configuration.
777 */
778 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_OQPSK_868MHZ = 0x44,
779 /**
780 * 915 MHz SUN OQPSK 802.15.4 radio configuration.
781 */
782 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_OQPSK_915MHZ = 0x45,
783 /**
784 * 863 MHz SUN FSK FEC 802.15.4 radio configuration.
785 */
786 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_FSK_FEC_863MHZ = 0x46,
787 /**
788 * 902 MHz SUN FSK FEC 802.15.4 radio configuration.
789 */
790 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_FSK_FEC_902MHZ = 0x47,
791 /**
792 * 863 MHz SUN FSK NO FEC 802.15.4 radio configuration.
793 */
794 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_FSK_NOFEC_863MHZ = 0x56,
795 /**
796 * 902 MHz SUN FSK NO FEC 802.15.4 radio configuration.
797 */
798 RAIL_IEEE802154_PTI_RADIO_CONFIG_SUN_FSK_NOFEC_902MHZ = 0x57,
799 /**
800 * 868 MHz Legacy OQPSK 802.15.4 radio configuration.
801 */
802 RAIL_IEEE802154_PTI_RADIO_CONFIG_LEG_OQPSK_868MHZ = 0x48,
803 /**
804 * 915 MHz Legacy OQPSK 802.15.4 radio configuration.
805 */
806 RAIL_IEEE802154_PTI_RADIO_CONFIG_LEG_OQPSK_915MHZ = 0x49
807 };
808
809 #ifndef DOXYGEN_SHOULD_SKIP_THIS
810 // Self-referencing defines minimize compiler complaints when using RAIL_ENUM
811 #define RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ ((RAIL_IEEE802154_PtiRadioConfig_t) RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ)
812 #define RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_ANTDIV ((RAIL_IEEE802154_PtiRadioConfig_t) RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_ANTDIV)
813 #define RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_COEX ((RAIL_IEEE802154_PtiRadioConfig_t) RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_COEX)
814 #define RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_ANTDIV_COEX ((RAIL_IEEE802154_PtiRadioConfig_t) RAIL_IEEE802154_PTI_RADIO_CONFIG_2P4GHZ_ANTDIV_COEX)
815 #define RAIL_IEEE802154_PTI_RADIO_CONFIG_863MHZ_GB868 ((RAIL_IEEE802154_PtiRadioConfig_t) RAIL_IEEE802154_PTI_RADIO_CONFIG_863MHZ_GB868)
816 #define RAIL_IEEE802154_PTI_RADIO_CONFIG_915MHZ_GB868 ((RAIL_IEEE802154_PtiRadioConfig_t) RAIL_IEEE802154_PTI_RADIO_CONFIG_915MHZ_GB868)
817 #define RAIL_IEEE802154_PTI_RADIO_CONFIG_915MHZ_R23_NA_EXT ((RAIL_IEEE802154_PtiRadioConfig_t) RAIL_IEEE802154_PTI_RADIO_CONFIG_915MHZ_R23_NA_EXT)
818 #endif//DOXYGEN_SHOULD_SKIP_THIS
819
820 /**
821 * Return IEEE802.15.4 PTI radio config.
822 *
823 * @param[in] railHandle A handle of RAIL instance.
824 * @return PTI (Packet Trace Information) radio config ID.
825 */
826 RAIL_IEEE802154_PtiRadioConfig_t RAIL_IEEE802154_GetPtiRadioConfig(RAIL_Handle_t railHandle);
827
828 #ifndef DOXYGEN_SHOULD_SKIP_THIS
829 /**
830 * Set IEEE802.15.4 PTI radio config (for Silicon Labs internal use only).
831 *
832 * @param[in] railHandle A handle of RAIL instance.
833 * @param[in] ptiRadioConfig PTI (Packet Trace Information) radio config ID.
834 * @return Status code indicating success of the function call.
835 */
836 RAIL_Status_t RAIL_IEEE802154_SetPtiRadioConfig(RAIL_Handle_t railHandle,
837 RAIL_IEEE802154_PtiRadioConfig_t ptiRadioConfigId);
838 #endif
839
840 /**
841 * Configure the RAIL Address Filter for 802.15.4 filtering.
842 *
843 * @param[in] railHandle A handle of RAIL instance.
844 * @param[in] addresses The address information that should be used.
845 * @return A status code indicating success of the function call. If this returns
846 * an error, the 802.15.4 address filter is in an undefined state.
847 *
848 * Set up the 802.15.4 address filter to accept messages to the given
849 * addresses. This will return false if any of the addresses failed to be set.
850 * If NULL is passed in for addresses, all addresses will be set to their
851 * reset value.
852 */
853 RAIL_Status_t RAIL_IEEE802154_SetAddresses(RAIL_Handle_t railHandle,
854 const RAIL_IEEE802154_AddrConfig_t *addresses);
855
856 /**
857 * Set a PAN ID for 802.15.4 address filtering.
858 *
859 * @param[in] railHandle A handle of RAIL instance.
860 * @param[in] panId The 16-bit PAN ID information.
861 * This will be matched against the destination PAN ID of incoming messages.
862 * The PAN ID is sent little endian over the air, meaning panId[7:0] is first in
863 * the payload followed by panId[15:8]. Set to 0xFFFF to disable for this index.
864 * @param[in] index Indicates which PAN ID to set. Must be below
865 * RAIL_IEEE802154_MAX_ADDRESSES.
866 * @return A status code indicating success of the function call.
867 *
868 * Set up the 802.15.4 address filter to accept messages to the given PAN ID.
869 */
870 RAIL_Status_t RAIL_IEEE802154_SetPanId(RAIL_Handle_t railHandle,
871 uint16_t panId,
872 uint8_t index);
873
874 /**
875 * Set a short address for 802.15.4 address filtering.
876 *
877 * @param[in] railHandle A handle of RAIL instance
878 * @param[in] shortAddr 16 bit short address value. This will be matched against the
879 * destination short address of incoming messages. The short address is sent
880 * little endian over the air meaning shortAddr[7:0] is first in the payload
881 * followed by shortAddr[15:8]. Set to 0xFFFF to disable for this index.
882 * @param[in] index Which short address to set. Must be below
883 * RAIL_IEEE802154_MAX_ADDRESSES.
884 * @return A status code indicating success of the function call.
885 *
886 * Set up the 802.15.4 address filter to accept messages to the given short
887 * address.
888 */
889 RAIL_Status_t RAIL_IEEE802154_SetShortAddress(RAIL_Handle_t railHandle,
890 uint16_t shortAddr,
891 uint8_t index);
892
893 /**
894 * Set a long address for 802.15.4 address filtering.
895 *
896 * @param[in] railHandle A handle of RAIL instance.
897 * @param[in] longAddr A pointer to an 8-byte array containing the long address
898 * information. The long address must be in over-the-air byte order. This will
899 * be matched against the destination long address of incoming messages. Set to
900 * 0x00 00 00 00 00 00 00 00 to disable for this index.
901 * @param[in] index Indicates which long address to set. Must be below
902 * RAIL_IEEE802154_MAX_ADDRESSES.
903 * @return A status code indicating success of the function call.
904 *
905 * Set up the 802.15.4 address filter to accept messages to the given long
906 * address.
907 */
908 RAIL_Status_t RAIL_IEEE802154_SetLongAddress(RAIL_Handle_t railHandle,
909 const uint8_t *longAddr,
910 uint8_t index);
911
912 /**
913 * Set whether the current node is a PAN coordinator.
914 *
915 * @param[in] railHandle A handle of RAIL instance.
916 * @param[in] isPanCoordinator True if this device is a PAN coordinator.
917 * @return A status code indicating success of the function call.
918 *
919 * If the device is a PAN Coordinator, it will accept data and command
920 * frames with no destination address. This function will fail if 802.15.4
921 * hardware acceleration is not currently enabled. This setting may be changed
922 * at any time when 802.15.4 hardware acceleration is enabled.
923 */
924 RAIL_Status_t RAIL_IEEE802154_SetPanCoordinator(RAIL_Handle_t railHandle,
925 bool isPanCoordinator);
926
927 /**
928 * Set whether to enable 802.15.4 promiscuous mode.
929 *
930 * @param[in] railHandle A handle of RAIL instance.
931 * @param[in] enable True if all frames and addresses should be accepted.
932 * @return A status code indicating success of the function call.
933 *
934 * If promiscuous mode is enabled, no frame or address filtering steps
935 * will be performed other than checking the CRC. This function will fail if
936 * 802.15.4 hardware acceleration is not currently enabled. This setting may be
937 * changed at any time when 802.15.4 hardware acceleration is enabled.
938 */
939 RAIL_Status_t RAIL_IEEE802154_SetPromiscuousMode(RAIL_Handle_t railHandle,
940 bool enable);
941
942 /**
943 * @enum RAIL_IEEE802154_EOptions_t
944 * @brief 802.15.4E-2012 options, in reality a bitmask.
945 */
RAIL_ENUM_GENERIC(RAIL_IEEE802154_EOptions_t,uint32_t)946 RAIL_ENUM_GENERIC(RAIL_IEEE802154_EOptions_t, uint32_t) {
947 /** Shift position of \ref RAIL_IEEE802154_E_OPTION_GB868 bit. */
948 RAIL_IEEE802154_E_OPTION_GB868_SHIFT = 0,
949 RAIL_IEEE802154_E_OPTION_ENH_ACK_SHIFT,
950 RAIL_IEEE802154_E_OPTION_IMPLICIT_BROADCAST_SHIFT,
951 };
952
953 /** A value representing no options enabled. */
954 #define RAIL_IEEE802154_E_OPTIONS_NONE 0UL
955 /** All options disabled by default . */
956 #define RAIL_IEEE802154_E_OPTIONS_DEFAULT RAIL_IEEE802154_E_OPTIONS_NONE
957
958 /**
959 * An option to enable/disable 802.15.4E-2012 features needed for GB868.
960 * When not promiscuous, RAIL normally accepts only 802.15.4 MAC frames
961 * whose MAC header Frame Version is 0 (802.15.4-2003) or 1 (802.15.4-2006),
962 * filtering out higher Frame Version packets (as \ref
963 * RAIL_RX_PACKET_ABORT_FORMAT).
964 * Enabling this feature additionally allows Frame Version 2 (802.15.4E-2012 /
965 * 802.15.4-2015) packets to be accepted and passed to the application.
966 *
967 * @note Enabling this feature also automatically enables \ref
968 * RAIL_IEEE802154_E_OPTION_ENH_ACK on platforms that support
969 * that feature.
970 *
971 * @note This feature does not automatically enable receiving Multipurpose
972 * frames; that can be enabled via RAIL_IEEE802154_AcceptFrames()'s
973 * \ref RAIL_IEEE802154_ACCEPT_MULTIPURPOSE_FRAMES.
974 */
975 #define RAIL_IEEE802154_E_OPTION_GB868 (1UL << RAIL_IEEE802154_E_OPTION_GB868_SHIFT)
976
977 /**
978 * An option to enable/disable 802.15.4E-2012 features needed for Enhanced ACKs.
979 * This option requires that \ref RAIL_IEEE802154_E_OPTION_GB868 also be
980 * enabled, and is enabled automatically on platforms that support this
981 * feature. It exists as a separate flag to allow runtime detection of whether
982 * the platform supports this feature or not.
983 *
984 * When enabled, only an Enhanced ACK is expected in response to a transmitted
985 * ACK-requesting 802.15.4E Version 2 frame. RAIL only knows how to construct
986 * 802.15.4 Immediate ACKs but not Enhanced ACKs.
987 *
988 * This option causes \ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND to be
989 * issued for ACK-requesting Version 2 MAC Command frames, Data frames
990 * (if \ref RAIL_IEEE802154_EnableDataFramePending() is enabled), and
991 * Multipurpose Frames (if \ref RAIL_IEEE802154_ACCEPT_MULTIPURPOSE_FRAMES
992 * is enabled).
993 *
994 * The application is expected to handle this event by calling \ref
995 * RAIL_GetRxIncomingPacketInfo() and parsing the partly-received incoming
996 * frame to determine the type of ACK needed:
997 * - If an Immediate ACK, determine Frame Pending needs based on the packet
998 * type and addressing information and call \ref
999 * RAIL_IEEE802154_ToggleFramePending() if necessary;
1000 * - If an Enhanced ACK, generate the complete payload of the Enhanced ACK
1001 * including any Frame Pending information and call \ref
1002 * RAIL_IEEE802154_WriteEnhAck() in time for that Enhanced ACK to
1003 * be sent. If not called in time, \ref RAIL_EVENT_TXACK_UNDERFLOW will
1004 * likely result.
1005 * Note that if 802.15.4 MAC-level encryption is used with Version 2
1006 * frames, the application should decrypt the MAC Command byte in a
1007 * MAC Command frame to determine whether it is a Data Request or other
1008 * MAC Command.
1009 *
1010 * An application can also enable \ref
1011 * RAIL_IEEE802154_EnableEarlyFramePending() if the protocol doesn't
1012 * need to examine the MAC Command byte of MAC Command frames but can
1013 * infer it to be a Data Request.
1014 *
1015 * On 802.15.4E GB868 platforms that lack this support, legacy Immediate ACKs
1016 * are sent/expected for received/transmitted ACK-requesting 802.15.4E Frame
1017 * Version 2 frames; calls to \ref RAIL_IEEE802154_WriteEnhAck() have no
1018 * effect. Attempting to use this feature via \ref
1019 * RAIL_IEEE802154_ConfigEOptions() returns an error.
1020 */
1021 #define RAIL_IEEE802154_E_OPTION_ENH_ACK (1UL << RAIL_IEEE802154_E_OPTION_ENH_ACK_SHIFT)
1022
1023 /**
1024 * An option to enable/disable 802.15.4E-2012 macImplicitBroadcast feature.
1025 *
1026 * When enabled, received Frame Version 2 frames without a destination
1027 * PAN ID or destination address are treated as though they are addressed
1028 * to the broadcast PAN ID and broadcast short address. When disabled, such
1029 * frames are filtered unless the device is the PAN coordinator and
1030 * appropriate source addressing information exists in the packet
1031 */
1032 #define RAIL_IEEE802154_E_OPTION_IMPLICIT_BROADCAST (1UL << RAIL_IEEE802154_E_OPTION_IMPLICIT_BROADCAST_SHIFT)
1033
1034 /** A value representing all possible options. */
1035 #define RAIL_IEEE802154_E_OPTIONS_ALL 0xFFFFFFFFUL
1036
1037 /**
1038 * Configure certain 802.15.4E-2012 / 802.15.4-2015 Frame Version 2 features.
1039 *
1040 * @param[in] railHandle A handle of RAIL instance.
1041 * @param[in] mask A bitmask containing which options should be modified.
1042 * @param[in] options A bitmask containing desired options settings.
1043 * Bit positions for each option are found in the \ref
1044 * RAIL_IEEE802154_EOptions_t.
1045 * @return A status code indicating success of the function call.
1046 *
1047 * This function will fail if 802.15.4 hardware acceleration is not
1048 * currently enabled or the platform does not support the feature(s).
1049 * These settings may be changed at any time when 802.15.4 hardware
1050 * acceleration is enabled.
1051 */
1052 RAIL_Status_t RAIL_IEEE802154_ConfigEOptions(RAIL_Handle_t railHandle,
1053 RAIL_IEEE802154_EOptions_t mask,
1054 RAIL_IEEE802154_EOptions_t options);
1055
1056 /**
1057 * @enum RAIL_IEEE802154_GOptions_t
1058 * @brief 802.15.4G-2012 options, in reality a bitmask.
1059 */
RAIL_ENUM_GENERIC(RAIL_IEEE802154_GOptions_t,uint32_t)1060 RAIL_ENUM_GENERIC(RAIL_IEEE802154_GOptions_t, uint32_t) {
1061 /** Shift position of \ref RAIL_IEEE802154_G_OPTION_GB868 bit. */
1062 RAIL_IEEE802154_G_OPTION_GB868_SHIFT = 0,
1063 /** Shift position of \ref RAIL_IEEE802154_G_OPTION_DYNFEC bit. */
1064 RAIL_IEEE802154_G_OPTION_DYNFEC_SHIFT,
1065 /** Shift position of \ref RAIL_IEEE802154_G_OPTION_WISUN_MODESWITCH bit. */
1066 RAIL_IEEE802154_G_OPTION_WISUN_MODESWITCH_SHIFT,
1067 };
1068
1069 /** A value representing no options enabled. */
1070 #define RAIL_IEEE802154_G_OPTIONS_NONE 0UL
1071 /** All options disabled by default . */
1072 #define RAIL_IEEE802154_G_OPTIONS_DEFAULT RAIL_IEEE802154_G_OPTIONS_NONE
1073
1074 /**
1075 * An option to enable/disable 802.15.4G-2012 features needed for GB868.
1076 * Normally RAIL supports 802.15.4-2003 and -2006 radio configurations
1077 * that have the single-byte PHY header allowing frames up to 128 bytes
1078 * in size. This feature must be enabled for 802.15.4G-2012 or
1079 * 802.15.4-2015 SUN PHY radio configurations with the two-byte
1080 * bit-reversed-length PHY header format.
1081 *
1082 * While GB868 only supports whitened non-FEC non-mode-switch frames
1083 * up to 129 bytes including 2-byte CRC, this option also enables:
1084 * - On platforms where \ref RAIL_FEAT_IEEE802154_G_4BYTE_CRC_SUPPORTED
1085 * is true: automatic per-packet 2/4-byte Frame Check Sequence (FCS)
1086 * reception and transmission based on the FCS Type bit in the
1087 * received/transmitted PHY header. This includes ACK reception
1088 * and automatically-generated ACKs reflect the CRC size of the
1089 * incoming frame being acknowledged (i.e., their MAC payload will be
1090 * increased to 7 bytes when sending 4-byte FCS).
1091 * On other platforms, only the 2-byte FCS is supported.
1092 * - On platforms where \ref RAIL_FEAT_IEEE802154_G_UNWHITENED_RX_SUPPORTED
1093 * and/or \ref RAIL_FEAT_IEEE802154_G_UNWHITENED_TX_SUPPORTED are true:
1094 * automatic per-packet whitened/unwhitened reception and transmission,
1095 * respectively, based on the Data Whitening bit in the received/transmitted
1096 * PHY header. This includes ACK reception and automatically-generated ACKs
1097 * which reflect the whitening of the incoming frame being acknowledged.
1098 * On other platforms, only whitened frames are supported.
1099 * - Support for frames up to 2049 bytes per the radio configuration's
1100 * maximum packet length setting.
1101 *
1102 * @note Sending/receiving whitened frames assumes the radio configuration
1103 * has established an appropriate 802.15.4-compliant whitening algorithm.
1104 * RAIL does not itself override the radio configuration's whitening
1105 * settings other than to enable/disable it per-packet based on the
1106 * packet's PHY header Data Whitening flag.
1107 */
1108 #define RAIL_IEEE802154_G_OPTION_GB868 (1UL << RAIL_IEEE802154_G_OPTION_GB868_SHIFT)
1109 /**
1110 * An option to enable/disable 802.15.4G dynamic FEC feature (SUN FSK only).
1111 * The syncWord, called start-of-frame delimiter (SFD) in the 15.4 spec, indicates whether
1112 * the rest of the packet is FEC encoded or not. This feature requires per-packet
1113 * dual syncWord detection and specific receiver pausing.
1114 * Note that this feature is only available on platforms where
1115 * \ref RAIL_IEEE802154_SUPPORTS_G_DYNFEC is true.
1116 *
1117 * This option is only valid for SUN PHYs that have the FEC configured and enabled.
1118 *
1119 * The syncWord used during transmit is selected with \ref RAIL_TX_OPTION_SYNC_WORD_ID.
1120 *
1121 * The syncWord corresponding to the FEC encoded mode must be SYNC1, with SYNC2 indicating non-FEC.
1122 * SyncWords are set appropriately in all Sun FEC-enabled PHYs so there should
1123 * never be a need to call \ref RAIL_ConfigSyncWords() when this option is enabled.
1124 *
1125 * Also, dual syncWord detection is set in all SUN FEC enabled PHYs, then there is no need
1126 * to change \ref RAIL_RX_OPTION_ENABLE_DUALSYNC .
1127 *
1128 * @note EFR32xG12 support for 802.15.4 FEC-capable PHYs and dynamic FEC
1129 * are incompatible with 802.15.4 filtering and AutoACK.
1130 * \ref RAIL_IEEE802154_Config_t::promiscuousMode must be true and \ref
1131 * RAIL_IEEE802154_Config_t::ackConfig's \ref RAIL_AutoAckConfig_t.enable
1132 * must be false on these platforms when using a FEC-capable PHY.
1133 */
1134 #define RAIL_IEEE802154_G_OPTION_DYNFEC (1UL << RAIL_IEEE802154_G_OPTION_DYNFEC_SHIFT)
1135 /**
1136 * An option to enable/disable Wi-SUN Mode Switch feature.
1137 * This feature consists in switching to a new PHY mode with a higher rate typically
1138 * by sending/receiving a specific Mode Switch packet that indicates the incoming new PHY mode.
1139 * The Mode Switch packet is an FSK-modulated 2-byte PHY header with no payload.
1140 * Because this feature relies on specific receiver pausing, note that it is only available
1141 * on platforms where \ref RAIL_IEEE802154_SUPPORTS_G_MODESWITCH is true.
1142 */
1143 #define RAIL_IEEE802154_G_OPTION_WISUN_MODESWITCH (1UL << RAIL_IEEE802154_G_OPTION_WISUN_MODESWITCH_SHIFT)
1144
1145 /** A value representing all possible options. */
1146 #define RAIL_IEEE802154_G_OPTIONS_ALL 0xFFFFFFFFUL
1147
1148 /**
1149 * Configure certain 802.15.4G-2012 / 802.15.4-2015 SUN PHY features
1150 * (only for radio configurations designed accordingly).
1151 *
1152 * @param[in] railHandle A handle of RAIL instance.
1153 * @param[in] mask A bitmask containing which options should be modified.
1154 * @param[in] options A bitmask containing desired options settings.
1155 * Bit positions for each option are found in the \ref
1156 * RAIL_IEEE802154_GOptions_t.
1157 * @return A status code indicating success of the function call.
1158 *
1159 * This function will fail if 802.15.4 hardware acceleration is not
1160 * currently enabled, the platform does not support the feature(s),
1161 * the radio configuration is not appropriate, or the radio is not idle.
1162 */
1163 RAIL_Status_t RAIL_IEEE802154_ConfigGOptions(RAIL_Handle_t railHandle,
1164 RAIL_IEEE802154_GOptions_t mask,
1165 RAIL_IEEE802154_GOptions_t options);
1166
1167 /**
1168 * @struct RAIL_IEEE802154_ModeSwitchPhr_t
1169 * @brief A structure containing the PHYModeID value and the corresponding mode
1170 * switch PHR as defined in Wi-SUN spec.
1171 * These structures are usually generated by the radio configurator.
1172 */
1173 typedef struct RAIL_IEEE802154_ModeSwitchPhr {
1174 uint8_t phyModeId; /**< PHY mode Id */
1175 uint16_t phr; /**< Corresponding Mode Switch PHY header */
1176 } RAIL_IEEE802154_ModeSwitchPhr_t;
1177
1178 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1179 /** When filtering PhyModeId, this is the minimum OFDM value */
1180 #define MIN_OFDM_PHY_MODE_ID (0x20U)
1181 /** When filtering PhyModeId, this is the maximum OFDM value */
1182 #define MAX_OFDM_PHY_MODE_ID (0x5FU)
1183 #endif //DOXYGEN_SHOULD_SKIP_THIS
1184
1185 /**
1186 * Compute channel to switch to given a targeted PhyMode ID
1187 * in the context of Wi-SUN mode switching.
1188 *
1189 * @param[in] railHandle A handle of RAIL instance.
1190 * @param[in] newPhyModeId A targeted PhyMode ID.
1191 * @param[out] pChannel A pointer to the channel to switch to.
1192 * @return A status code indicating success of the function call.
1193 *
1194 * This function will fail if the targeted PhyModeID is the same as the
1195 * current PhyMode ID, or if called on a platform that lacks
1196 * \ref RAIL_IEEE802154_SUPPORTS_G_MODESWITCH.
1197 * For newPhyModeId associated with a FSK FEC_off PHY, if dynamic FEC is
1198 * activated (see \ref RAIL_IEEE802154_G_OPTION_DYNFEC), the returned
1199 * channel can correspond to the associated FSK FEC_on PHY corresponding
1200 * then to PhyModeID = newPhyModeId + 16
1201 */
1202 RAIL_Status_t RAIL_IEEE802154_ComputeChannelFromPhyModeId(RAIL_Handle_t railHandle,
1203 uint8_t newPhyModeId,
1204 uint16_t *pChannel);
1205
1206 #if RAIL_IEEE802154_SUPPORTS_G_MODESWITCH
1207 /**
1208 * This function can be implemented to manage forbidden channels during mode
1209 * switch.
1210 *
1211 * @param[in] currentBaseFreq The current frequency of the base channel.
1212 * @param[in] newPhyModeId A targeted PhyMode ID.
1213 * @param[in] configEntryNewPhyModeId A pointer to \ref RAIL_ChannelConfigEntry_t
1214 * structure corresponding to the new PHY configEntry.
1215 * @param[in, out] pChannel A pointer to the channel to switch to. If channel
1216 * is valid, the function must just return. If channel is forbidden, the
1217 * function must update it with the closest valid channel. The highest
1218 * channel must be selected in case of two valid channels being equidistant
1219 * to a forbiden channel.
1220 * @return A status code indicating success of the function call. It must
1221 * return RAIL_STATUS_INVALID_PARAMETER for failure or RAIL_STATUS_NO_ERROR
1222 * for success.
1223 *
1224 * This function must fail if no valid channel has been found. If so, RAIL will
1225 * abort the mode switch.
1226 */
1227 RAIL_Status_t RAILCb_IEEE802154_IsModeSwitchNewChannelValid(uint32_t currentBaseFreq,
1228 uint8_t newPhyModeId,
1229 const RAIL_ChannelConfigEntry_t *configEntryNewPhyModeId,
1230 uint16_t *pChannel);
1231 #endif//RAIL_IEEE802154_SUPPORTS_G_MODESWITCH
1232
1233 /// When receiving packets, accept 802.15.4 BEACON frame types.
1234 #define RAIL_IEEE802154_ACCEPT_BEACON_FRAMES (0x01)
1235 /// When receiving packets, accept 802.15.4 DATA frame types.
1236 #define RAIL_IEEE802154_ACCEPT_DATA_FRAMES (0x02)
1237 /// When receiving packets, accept 802.15.4 ACK frame types.
1238 /// @note Expected ACK frame types will still be accepted regardless
1239 /// of this setting when waiting for an ACK after a transmit that
1240 /// used \ref RAIL_TX_OPTION_WAIT_FOR_ACK and auto-ACK is enabled.
1241 #define RAIL_IEEE802154_ACCEPT_ACK_FRAMES (0x04)
1242 /// When receiving packets, accept 802.15.4 COMMAND frame types.
1243 #define RAIL_IEEE802154_ACCEPT_COMMAND_FRAMES (0x08)
1244 // Reserved for possible future use: (0x10)
1245 /// When receiving packets, accept 802.15.4-2015 Multipurpose frame types.
1246 /// (Not supported on EFR32XG1.)
1247 #define RAIL_IEEE802154_ACCEPT_MULTIPURPOSE_FRAMES (0x20)
1248
1249 /// In standard operation, accept BEACON, DATA and COMMAND frames.
1250 /// Don't receive ACK frames unless waiting for ACK (i.e., only
1251 /// receive expected ACKs).
1252 #define RAIL_IEEE802154_ACCEPT_STANDARD_FRAMES (RAIL_IEEE802154_ACCEPT_BEACON_FRAMES \
1253 | RAIL_IEEE802154_ACCEPT_DATA_FRAMES \
1254 | RAIL_IEEE802154_ACCEPT_COMMAND_FRAMES)
1255
1256 /**
1257 * Set which 802.15.4 frame types to accept.
1258 *
1259 * @param[in] railHandle A handle of RAIL instance.
1260 * @param[in] framesMask A mask containing which 802.15.4 frame types to receive.
1261 * @return A status code indicating success of the function call.
1262 *
1263 * This function will fail if 802.15.4 hardware acceleration is not currently
1264 * enabled or framesMask requests an unsupported frame type.
1265 * This setting may be changed at any time when 802.15.4 hardware
1266 * acceleration is enabled. Only Beacon, Data, ACK, Command, and Multipurpose
1267 * (except on EFR32XG1) frames may be received.
1268 * The RAIL_IEEE802154_ACCEPT_XXX_FRAMES defines may be combined to create a
1269 * bitmask to pass into this function.
1270 *
1271 * \ref RAIL_IEEE802154_ACCEPT_ACK_FRAMES behaves slightly different than the
1272 * other defines. If \ref RAIL_IEEE802154_ACCEPT_ACK_FRAMES is set, the radio
1273 * will accept an ACK frame during normal packet reception, but only a
1274 * truly expected ACK will have its \ref RAIL_RxPacketDetails_t::isAck true.
1275 * If \ref RAIL_IEEE802154_ACCEPT_ACK_FRAMES is not set, ACK frames will be
1276 * filtered unless they're expected when the radio is waiting for an ACK.
1277 */
1278 RAIL_Status_t RAIL_IEEE802154_AcceptFrames(RAIL_Handle_t railHandle,
1279 uint8_t framesMask);
1280
1281 /**
1282 * Enable early Frame Pending lookup event notification
1283 * (\ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND).
1284 *
1285 * @param[in] railHandle A handle of RAIL instance.
1286 * @param[in] enable True to enable, false to disable.
1287 * @return A status code indicating success of the function call.
1288 *
1289 * Normally, \ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND is triggered after
1290 * receiving the entire MAC header and MAC command byte for an ACK-requesting
1291 * MAC command frame. Version 0/1 frames also require that command to be a
1292 * Data Request for this event to occur.
1293 * Enabling this feature causes this event to be triggered earlier to allow for
1294 * more time to determine the type of ACK needed (Immediate or Enhanced) and/or
1295 * perform frame pending lookup to influence the outgoing ACK by using \ref
1296 * RAIL_IEEE802154_WriteEnhAck() or \ref RAIL_IEEE802154_ToggleFramePending().
1297 *
1298 * For Frame Version 0/1 packets and for Frame Version 2 packets when \ref
1299 * RAIL_IEEE802154_E_OPTION_ENH_ACK is not in use, "early" means right
1300 * after receiving the source address information in the MAC header.
1301 *
1302 * For Frame Version 2 packets when \ref RAIL_IEEE802154_E_OPTION_ENH_ACK
1303 * is in use, "early" means right after receiving any Auxiliary Security
1304 * header which follows the source address information in the MAC header.
1305 *
1306 * This feature is useful when the protocol knows an ACK-requesting MAC
1307 * Command must be a data poll without needing to receive the MAC Command
1308 * byte, giving it a bit more time to adjust Frame Pending or generate an
1309 * Enhanced ACK.
1310 *
1311 * This function will fail if 802.15.4 hardware acceleration is not
1312 * currently enabled, or on platforms that do not support this feature.
1313 * This setting may be changed at any time when 802.15.4 hardware
1314 * acceleration is enabled.
1315 */
1316 RAIL_Status_t RAIL_IEEE802154_EnableEarlyFramePending(RAIL_Handle_t railHandle,
1317 bool enable);
1318
1319 /**
1320 * Enable Frame Pending lookup event notification
1321 * (\ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND) for MAC Data frames.
1322 *
1323 * @param[in] railHandle A handle of RAIL instance.
1324 * @param[in] enable True to enable, false to disable.
1325 * @return A status code indicating success of the function call.
1326 *
1327 * Normally \ref RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND is triggered only
1328 * for ACK-requesting MAC command frames.
1329 * Enabling this feature causes this event to also be triggered for MAC data
1330 * frames, at the same point in the packet as \ref
1331 * RAIL_IEEE802154_EnableEarlyFramePending() would trigger.
1332 * This feature is necessary to support the Thread Basil-Hayden Enhanced
1333 * Frame Pending feature in Version 0/1 frames, and to support Version 2
1334 * Data frames which require an Enhanced ACK.
1335 *
1336 * This function will fail if 802.15.4 hardware acceleration is not
1337 * currently enabled. This setting may be changed at any time when
1338 * 802.15.4 hardware acceleration is enabled.
1339 */
1340 RAIL_Status_t RAIL_IEEE802154_EnableDataFramePending(RAIL_Handle_t railHandle,
1341 bool enable);
1342
1343 /**
1344 * Alternate naming for function \ref RAIL_IEEE802154_SetFramePending
1345 * to depict it is used for changing the default setting specified by
1346 * \ref RAIL_IEEE802154_Config_t::defaultFramePendingInOutgoingAcks in
1347 * an outgoing ACK.
1348 */
1349 #define RAIL_IEEE802154_ToggleFramePending RAIL_IEEE802154_SetFramePending
1350
1351 /**
1352 * Change the Frame Pending bit on the outgoing legacy Immediate ACK from
1353 * the default specified by
1354 * \ref RAIL_IEEE802154_Config_t::defaultFramePendingInOutgoingAcks.
1355 * @param[in] railHandle A handle of RAIL instance
1356 * @return A status code indicating success of the function call.
1357 *
1358 * This function must only be called while processing the \ref
1359 * RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND if the ACK
1360 * for this packet should go out with its Frame Pending bit set differently
1361 * than what was specified by
1362 * \ref RAIL_IEEE802154_Config_t::defaultFramePendingInOutgoingAcks.
1363 *
1364 * It's intended only for use with 802.15.4 legacy immediate ACKs and
1365 * not 802.15.4E enhanced ACKs.
1366 * This will return \ref RAIL_STATUS_INVALID_STATE if it is too late to
1367 * modify the outgoing Immediate ACK.
1368
1369 * @note This function is used to set the Frame Pending bit but its meaning
1370 * depends on the value of
1371 * \ref RAIL_IEEE802154_Config_t::defaultFramePendingInOutgoingAcks
1372 * while transmitting ACK.
1373 * If \ref RAIL_IEEE802154_Config_t::defaultFramePendingInOutgoingAcks
1374 * is not set, then Frame Pending bit is set in outgoing ACK.
1375 * Whereas, if \ref RAIL_IEEE802154_Config_t::defaultFramePendingInOutgoingAcks
1376 * is set, then Frame Pending bit is cleared in outgoing ACK.
1377 *
1378 * Therefore, this function is to be called if the frame is pending when
1379 * \ref RAIL_IEEE802154_Config_t::defaultFramePendingInOutgoingAcks
1380 * is not set or if there is no frame pending when
1381 * \ref RAIL_IEEE802154_Config_t::defaultFramePendingInOutgoingAcks
1382 * is set.
1383 */
1384 RAIL_Status_t RAIL_IEEE802154_SetFramePending(RAIL_Handle_t railHandle);
1385
1386 /**
1387 * Get the source address of the incoming data request.
1388 *
1389 * @param[in] railHandle A RAIL instance handle.
1390 * @param[out] pAddress A pointer to \ref RAIL_IEEE802154_Address_t structure
1391 * to populate with source address information.
1392 * @return A status code indicating success of the function call.
1393 *
1394 * This function must only be called when handling the \ref
1395 * RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND event. This will return
1396 * \ref RAIL_STATUS_INVALID_STATE if the address information is stale
1397 * (i.e., it is too late to affect the outgoing ACK).
1398 */
1399 RAIL_Status_t RAIL_IEEE802154_GetAddress(RAIL_Handle_t railHandle,
1400 RAIL_IEEE802154_Address_t *pAddress);
1401
1402 /**
1403 * Write the AutoACK FIFO for the next outgoing 802.15.4E Enhanced ACK.
1404 *
1405 * @param[in] railHandle A handle of RAIL instance.
1406 * @param[in] ackData Pointer to ACK data to transmit
1407 * @param[in] ackDataLen Length of ACK data, in bytes
1408 * @return A status code indicating success of the function call.
1409 *
1410 * This function sets the AutoACK data to use in acknowledging the frame
1411 * being received. It must only be called while processing the \ref
1412 * RAIL_EVENT_IEEE802154_DATA_REQUEST_COMMAND, and is intended for use
1413 * when packet information from \ref RAIL_GetRxIncomingPacketInfo()
1414 * indicates an 802.15.4E Enhanced ACK must be sent instead of a legacy
1415 * Immediate ACK. \ref RAIL_IEEE802154_ToggleFramePending() should not be
1416 * called for an Enhanced ACK; instead the Enhanced ACK's Frame Control
1417 * Field should have the Frame Pending bit set appropriately in its ackData.
1418 * This will return \ref RAIL_STATUS_INVALID_STATE if it is too late to
1419 * write the outgoing ACK -- a situation that will likely trigger
1420 * a \ref RAIL_EVENT_TXACK_UNDERFLOW event. When successful, the Enhanced
1421 * ackData will only be sent once. Subsequent packets needing an Enhanced
1422 * ACK will each need to call this function to write their ACK information.
1423 */
1424 RAIL_Status_t RAIL_IEEE802154_WriteEnhAck(RAIL_Handle_t railHandle,
1425 const uint8_t *ackData,
1426 uint8_t ackDataLen);
1427
1428 /**
1429 * Convert RSSI into 802.15.4 Link Quality Indication (LQI) metric
1430 * compatible with the Silicon Labs Zigbee stack.
1431 *
1432 * @param[in] origLqi The original LQI, for example from
1433 * \ref RAIL_RxPacketDetails_t::lqi.
1434 * This parameter is not currently used but may be used in the future.
1435 * @param[in] rssiDbm The RSSI in dBm, for example from
1436 * \ref RAIL_RxPacketDetails_t::rssi.
1437 * @return An LQI value (range 0..255 but not all intermediate values are
1438 * possible) based on the rssiDbm and the chip's RSSI sensitivity range.
1439 *
1440 * This function is compatible with \ref RAIL_ConvertLqiCallback_t and
1441 * is suitable to pass to \ref RAIL_ConvertLqi().
1442 */
1443 uint8_t RAIL_IEEE802154_ConvertRssiToLqi(uint8_t origLqi, int8_t rssiDbm);
1444
1445 /**
1446 * Convert RSSI into 802.15.4 Energy Detection (ED) metric
1447 * compatible with the Silicon Labs Zigbee stack.
1448 *
1449 * @param[in] rssiDbm The RSSI in dBm, for example from
1450 * \ref RAIL_RxPacketDetails_t::rssi.
1451 * @return An Energy Detect value (range 0..255 but not all intermediate
1452 * values are possible) based on the rssiDbm and the chip's RSSI
1453 * sensitivity range.
1454 */
1455 uint8_t RAIL_IEEE802154_ConvertRssiToEd(int8_t rssiDbm);
1456
1457 /**
1458 * @enum RAIL_IEEE802154_CcaMode_t
1459 * @brief Available CCA modes.
1460 */
RAIL_ENUM(RAIL_IEEE802154_CcaMode_t)1461 RAIL_ENUM(RAIL_IEEE802154_CcaMode_t) {
1462 /**
1463 * RSSI-based CCA. CCA reports a busy medium upon detecting any energy
1464 * above \ref RAIL_CsmaConfig_t.ccaThreshold.
1465 */
1466 RAIL_IEEE802154_CCA_MODE_RSSI = 0,
1467 /**
1468 * Signal Identifier-based CCA. CCA reports a busy medium only upon the
1469 * detection of a signal compliant with this standard with the same modulation
1470 * and spreading characteristics of the PHY that is currently in use.
1471 */
1472 RAIL_IEEE802154_CCA_MODE_SIGNAL,
1473 /**
1474 * RSSI or signal identifier-based CCA. CCA reports a busy medium on
1475 * either detecting any energy above \ref RAIL_CsmaConfig_t.ccaThreshold
1476 * or detection of a signal compliant with this standard with the same
1477 * modulation and spreading characteristics of the PHY that is currently in use.
1478 */
1479 RAIL_IEEE802154_CCA_MODE_SIGNAL_OR_RSSI,
1480 /**
1481 * RSSI and signal identifier-based CCA. CCA reports a busy medium only
1482 * on detecting any energy above \ref RAIL_CsmaConfig_t.ccaThreshold of a
1483 * signal compliant with this standard with the same modulation and spreading
1484 * characteristics of the PHY that is currently in use.
1485 */
1486 RAIL_IEEE802154_CCA_MODE_SIGNAL_AND_RSSI,
1487 /**
1488 * ALOHA. Always transmit CCA=1. CCA always reports an idle medium.
1489 */
1490 RAIL_IEEE802154_CCA_MODE_ALWAYS_TRANSMIT,
1491 /**
1492 * Number of CCA modes.
1493 */
1494 RAIL_IEEE802154_CCA_MODE_COUNT
1495 };
1496
1497 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1498 // Self-referencing defines minimize compiler complaints when using RAIL_ENUM
1499 #define RAIL_IEEE802154_CCA_MODE_RSSI ((RAIL_IEEE802154_CcaMode_t)RAIL_IEEE802154_CCA_MODE_RSSI)
1500 #define RAIL_IEEE802154_CCA_MODE_SIGNAL ((RAIL_IEEE802154_CcaMode_t)RAIL_IEEE802154_CCA_MODE_SIGNAL)
1501 #define RAIL_IEEE802154_CCA_MODE_SIGNAL_OR_RSSI ((RAIL_IEEE802154_CcaMode_t)RAIL_IEEE802154_CCA_MODE_SIGNAL_OR_RSSI)
1502 #define RAIL_IEEE802154_CCA_MODE_SIGNAL_AND_RSSI ((RAIL_IEEE802154_CcaMode_t)RAIL_IEEE802154_CCA_MODE_SIGNAL_AND_RSSI)
1503 #define RAIL_IEEE802154_CCA_MODE_ALWAYS_TRANSMIT ((RAIL_IEEE802154_CcaMode_t)RAIL_IEEE802154_CCA_MODE_ALWAYS_TRANSMIT)
1504 #define RAIL_IEEE802154_CCA_MODE_COUNT ((RAIL_IEEE802154_CcaMode_t)RAIL_IEEE802154_CCA_MODE_COUNT)
1505 #endif
1506
1507 /**
1508 * @enum RAIL_IEEE802154_SignalIdentifierMode_t
1509 * @brief Available Signal identifier modes.
1510 */
RAIL_ENUM(RAIL_IEEE802154_SignalIdentifierMode_t)1511 RAIL_ENUM(RAIL_IEEE802154_SignalIdentifierMode_t) {
1512 /* Disable signal detection mode. */
1513 RAIL_IEEE802154_SIGNAL_IDENTIFIER_MODE_DISABLE = 0,
1514 /* 2.4Ghz 802.15.4 signal detection mode. */
1515 RAIL_IEEE802154_SIGNAL_IDENTIFIER_MODE_154
1516 };
1517
1518 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1519 // Self-referencing defines minimize compiler complaints when using RAIL_ENUM
1520 #define RAIL_IEEE802154_SIGNAL_IDENTIFIER_MODE_DISABLE ((RAIL_IEEE802154_SignalIdentifierMode_t)RAIL_IEEE802154_SIGNAL_IDENTIFIER_MODE_DISABLE)
1521 #define RAIL_IEEE802154_SIGNAL_IDENTIFIER_MODE_154 ((RAIL_IEEE802154_SignalIdentifierMode_t)RAIL_IEEE802154_SIGNAL_IDENTIFIER_MODE_154)
1522 #endif
1523
1524 /**
1525 * Configure signal identifier for 802.15.4 signal detection.
1526 *
1527 * @param[in] railHandle A RAIL instance handle.
1528 * @param[in] signalIdentifierMode Mode of signal identifier operation.
1529 *
1530 * This features allows detection of 2.4Ghz 802.15.4 signal on air. This
1531 * function must be called once before \ref RAIL_IEEE802154_EnableSignalDetection
1532 * to configure and enable signal identifier.
1533 *
1534 * To enable event for signal detection \ref RAIL_ConfigEvents() must be called
1535 * for enabling \ref RAIL_EVENT_SIGNAL_DETECTED.
1536 *
1537 * This function is only supported by chips where
1538 * \ref RAIL_IEEE802154_SUPPORTS_SIGNAL_IDENTIFIER and
1539 * \ref RAIL_IEEE802154_SupportsSignalIdentifier() are true.
1540 *
1541 * @return Status code indicating success of the function call.
1542 */
1543 RAIL_Status_t RAIL_IEEE802154_ConfigSignalIdentifier(RAIL_Handle_t railHandle,
1544 RAIL_IEEE802154_SignalIdentifierMode_t signalIdentifierMode);
1545
1546 /**
1547 * Enable or disable signal identifier for 802.15.4 signal detection.
1548 *
1549 * @param[in] railHandle A RAIL instance handle.
1550 * @param[in] enable Signal detection is enabled if true, disabled if false.
1551 *
1552 * \ref RAIL_IEEE802154_ConfigSignalIdentifier must be called once before calling
1553 * this function to configure and enable signal identifier.
1554 * Once a signal is detected signal detection will be turned off and this
1555 * function should be called to re-enable the signal detection without needing
1556 * to call \ref RAIL_IEEE802154_ConfigSignalIdentifier if the signal identifier
1557 * is already configured and enabled.
1558 *
1559 * This function is only supported by chips where
1560 * \ref RAIL_IEEE802154_SUPPORTS_SIGNAL_IDENTIFIER and
1561 * \ref RAIL_IEEE802154_SupportsSignalIdentifier() are true.
1562 *
1563 * @return Status code indicating success of the function call.
1564 */
1565 RAIL_Status_t RAIL_IEEE802154_EnableSignalDetection(RAIL_Handle_t railHandle,
1566 bool enable);
1567
1568 /**
1569 * @brief Backward compatible name for the \ref
1570 * RAIL_IEEE802154_EnableSignalDetection API.
1571 */
1572 #define RAIL_IEEE802154_EnableSignalIdentifier RAIL_IEEE802154_EnableSignalDetection
1573
1574 /**
1575 * Set 802.15.4 CCA mode.
1576 *
1577 * @param[in] railHandle A RAIL instance handle.
1578 * @param[in] ccaMode Mode of CCA operation.
1579 *
1580 * This function sets the CCA mode \ref RAIL_IEEE802154_CcaMode_t.
1581 * If not called, RAIL_IEEE802154_CCA_MODE_RSSI (RSSI-based CCA) is used for CCA.
1582 *
1583 * In RAIL_IEEE802154_CCA_MODE_SIGNAL, RAIL_IEEE802154_CCA_MODE_SIGNAL_OR_RSSI and
1584 * RAIL_IEEE802154_CCA_MODE_SIGNAL_AND_RSSI signal identifier is enabled
1585 * for the duration of LBT. If previously enabled by
1586 * \ref RAIL_IEEE802154_ConfigSignalIdentifier, the signal identifier will remain
1587 * active until triggered.
1588 *
1589 * This function is only supported by chips where
1590 * \ref RAIL_IEEE802154_SUPPORTS_SIGNAL_IDENTIFIER and
1591 * \ref RAIL_IEEE802154_SupportsSignalIdentifier() are true.
1592 *
1593 * @return Status code indicating success of the function call.
1594 * An error should be returned if ccaMode is unsuppported on a given device.
1595 */
1596 RAIL_Status_t RAIL_IEEE802154_ConfigCcaMode(RAIL_Handle_t railHandle,
1597 RAIL_IEEE802154_CcaMode_t ccaMode);
1598
1599 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1600 /**
1601 * Allow certain malformed MAC Header frames to be received.
1602 *
1603 * @param[in] railHandle A handle of RAIL instance.
1604 * @param[in] enable True to enable, false to disable.
1605 * @return A status code indicating success of the function call.
1606 *
1607 * When allowed, certain MAC header formats that 802.15.4 deems
1608 * illegal will be received rather than filtered. This is to
1609 * support interoperablity with an old spec-violating 802.15.4
1610 * peer and is only supported on certain Series-2 platforms.
1611 *
1612 * @note \ref RAIL_IEEE802154_SetPanCoordinator() must also be
1613 * enabled to receive malformed frames lacking destination
1614 * address information.
1615 */
1616 RAIL_Status_t RAIL_IEEE802154_AllowMalformed(RAIL_Handle_t railHandle,
1617 bool allow);
1618 #endif//DOXYGEN_SHOULD_SKIP_THIS
1619
1620 /**
1621 * Configure RX channel switching for 802.15.4.
1622 *
1623 * @param[in] railHandle A RAIL instance handle.
1624 * @param[in] pConfig A pointer to \ref RAIL_IEEE802154_RxChannelSwitchingCfg_t structure.
1625 * @return Status code indicating success of the function call.
1626 *
1627 * This function configures RX channel switching, allowing reception of 2.4Ghz 802.15.4
1628 * signals on two specified radio channels. This function must be called once before
1629 * \ref RAIL_StartRx and/or enabling \ref RAIL_RX_OPTION_CHANNEL_SWITCHING.
1630 *
1631 * @note IEEE 802.15.4 must be enabled, \ref RAIL_IEEE802154_Init, and radio must be
1632 * in idle state when configuring RX channel switching. This function requires a DMA channel,
1633 * see \ref RAIL_UseDma, and one must be allocated if not done already.
1634 *
1635 * @note When RX channel switching is active, receive sensitivity and performance are
1636 * slightly impacted.
1637 */
1638 RAIL_Status_t RAIL_IEEE802154_ConfigRxChannelSwitching(RAIL_Handle_t railHandle,
1639 const RAIL_IEEE802154_RxChannelSwitchingCfg_t *pConfig);
1640
1641 /** @} */ // end of IEEE802.15.4
1642
1643 #ifdef __cplusplus
1644 }
1645 #endif
1646
1647 #endif // __RAIL_IEEE802154_H__
1648