1 /*
2  * Copyright (c) 2017, Nordic Semiconductor ASA
3  * All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice, this
11  *    list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
18  *    contributors may be used to endorse or promote products derived from this
19  *    software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  */
34 
35 #ifndef NRF_802154_TYPES_H__
36 #define NRF_802154_TYPES_H__
37 
38 #include <stdbool.h>
39 #include <stdint.h>
40 #include <nrf_802154_config.h>
41 
42 /**
43  * Avoid including nrfx dependencies in a build only containing
44  * serialization commands
45  */
46 #if !NRF_802154_SERIALIZATION_HOST
47     #include "hal/nrf_radio.h"
48 #else
49 typedef uint8_t nrf_radio_cca_mode_t;
50 
51 /** @brief RADIO Clear Channel Assessment modes. */
52 #define NRF_RADIO_CCA_MODE_ED             0x00
53 #define NRF_RADIO_CCA_MODE_CARRIER        0x01
54 #define NRF_RADIO_CCA_MODE_CARRIER_AND_ED 0x02
55 #define NRF_RADIO_CCA_MODE_CARRIER_OR_ED  0x03
56 #endif
57 
58 /**
59  * @defgroup nrf_802154_types Type definitions used in the 802.15.4 driver
60  * @{
61  * @ingroup nrf_802154
62  * @brief Definitions of types used in the 802.15.4 driver.
63  */
64 
65 /**
66  * @brief States of the driver.
67  */
68 typedef uint8_t nrf_802154_state_t;
69 
70 #define NRF_802154_STATE_INVALID            0x01 // !< Radio in an invalid state.
71 #define NRF_802154_STATE_SLEEP              0x02 // !< Radio in the sleep state.
72 #define NRF_802154_STATE_RECEIVE            0x03 // !< Radio in the receive state.
73 #define NRF_802154_STATE_TRANSMIT           0x04 // !< Radio in the transmit state.
74 #define NRF_802154_STATE_ENERGY_DETECTION   0x05 // !< Radio in the energy detection state.
75 #define NRF_802154_STATE_CCA                0x06 // !< Radio in the CCA state.
76 #define NRF_802154_STATE_CONTINUOUS_CARRIER 0x07 // !< Radio in the continuous carrier state.
77 #define NRF_802154_STATE_MODULATED_CARRIER  0x08 // !< Radio in the modulated carrier state.
78 
79 /**
80  * @brief Errors reported during the frame transmission.
81  */
82 typedef uint8_t nrf_802154_tx_error_t;
83 
84 #define NRF_802154_TX_ERROR_NONE                0x00 // !< There is no transmit error.
85 #define NRF_802154_TX_ERROR_BUSY_CHANNEL        0x01 // !< CCA reported busy channel before the transmission.
86 #define NRF_802154_TX_ERROR_INVALID_ACK         0x02 // !< Received ACK frame is other than expected.
87 #define NRF_802154_TX_ERROR_NO_MEM              0x03 // !< No receive buffer is available to receive an ACK.
88 #define NRF_802154_TX_ERROR_TIMESLOT_ENDED      0x04 // !< Radio timeslot ended during the transmission procedure.
89 #define NRF_802154_TX_ERROR_NO_ACK              0x05 // !< ACK frame was not received during the timeout period.
90 #define NRF_802154_TX_ERROR_ABORTED             0x06 // !< Procedure was aborted by another operation.
91 #define NRF_802154_TX_ERROR_TIMESLOT_DENIED     0x07 // !< Transmission did not start due to a denied timeslot request.
92 #define NRF_802154_TX_ERROR_KEY_ID_INVALID      0x08 // !< Transmission did not start due to invalid key ID in frame's security header.
93 #define NRF_802154_TX_ERROR_FRAME_COUNTER_ERROR 0x09 // !< Transmission did not start due a frame counter error.
94 
95 /**
96  * @brief Possible errors during the frame reception.
97  */
98 typedef uint8_t nrf_802154_rx_error_t;
99 
100 #define NRF_802154_RX_ERROR_NONE                    0x00 // !< There is no receive error.
101 #define NRF_802154_RX_ERROR_INVALID_FRAME           0x01 // !< Received a malformed frame.
102 #define NRF_802154_RX_ERROR_INVALID_FCS             0x02 // !< Received a frame with an invalid checksum.
103 #define NRF_802154_RX_ERROR_INVALID_DEST_ADDR       0x03 // !< Received a frame with a mismatched destination address.
104 #define NRF_802154_RX_ERROR_RUNTIME                 0x04 // !< Runtime error occurred (for example, CPU was held for too long).
105 #define NRF_802154_RX_ERROR_TIMESLOT_ENDED          0x05 // !< Radio timeslot ended during the frame reception.
106 #define NRF_802154_RX_ERROR_ABORTED                 0x06 // !< Procedure was aborted by another operation.
107 #define NRF_802154_RX_ERROR_DELAYED_TIMESLOT_DENIED 0x07 // !< Delayed reception request was rejected due to a denied timeslot request.
108 #define NRF_802154_RX_ERROR_DELAYED_TIMEOUT         0x08 // !< Delayed reception timeslot ended.
109 #define NRF_802154_RX_ERROR_INVALID_LENGTH          0x09 // !< Received a frame with invalid length.
110 #define NRF_802154_RX_ERROR_DELAYED_ABORTED         0x0A // !< Delayed operation in the ongoing state was aborted by other request.
111 #define NRF_802154_RX_ERROR_NO_BUFFER               0x0B // !< Reception suppressed because there was no free buffer available.
112 
113 /**
114  * @brief Possible errors during the energy detection.
115  */
116 typedef uint8_t nrf_802154_ed_error_t;
117 
118 #define NRF_802154_ED_ERROR_ABORTED 0x01 // !< Procedure was aborted by another operation.
119 
120 /**
121  * @brief Possible errors during the CCA procedure.
122  */
123 typedef uint8_t nrf_802154_cca_error_t;
124 
125 #define NRF_802154_CCA_ERROR_ABORTED 0x01 // !< Procedure was aborted by another operation.
126 
127 /**
128  * @brief Possible errors during sleep procedure call.
129  */
130 typedef uint8_t nrf_802154_sleep_error_t;
131 
132 #define NRF_802154_SLEEP_ERROR_NONE 0x00 // !< There is no error.
133 #define NRF_802154_SLEEP_ERROR_BUSY 0x01 // !< The driver cannot enter the sleep state due to the ongoing operation.
134 
135 /**
136  * @brief Possible errors during key handling.
137  */
138 typedef uint8_t nrf_802154_security_error_t;
139 
140 #define NRF_802154_SECURITY_ERROR_NONE                   0x00 // !< There is no error.
141 #define NRF_802154_SECURITY_ERROR_STORAGE_FULL           0x01 // !< The key storage is full - removal of stored keys is needed.
142 #define NRF_802154_SECURITY_ERROR_KEY_NOT_FOUND          0x02 // !< The provided key was not found inside the storage.
143 #define NRF_802154_SECURITY_ERROR_ALREADY_PRESENT        0x03 // !< The storage already has the key of the same ID.
144 #define NRF_802154_SECURITY_ERROR_TYPE_NOT_SUPPORTED     0x04 // !< The provided key type is not supported.
145 #define NRF_802154_SECURITY_ERROR_MODE_NOT_SUPPORTED     0x05 // !< The provided key id mode is not supported.
146 #define NRF_802154_SECURITY_ERROR_FRAME_COUNTER_OVERFLOW 0x06 // !< The associated frame counter overflowed.
147 
148 /**
149  * @brief Termination level selected for a particular request.
150  *
151  * Each request can terminate an ongoing operation. This type selects which operation should be
152  * aborted by a given request.
153  */
154 typedef uint8_t nrf_802154_term_t;
155 
156 #define NRF_802154_TERM_NONE   0x00 // !< Request is skipped if another operation is ongoing.
157 #define NRF_802154_TERM_802154 0x01 // !< Request terminates the ongoing 802.15.4 operation.
158 
159 /**
160  * @brief Structure for configuring CCA.
161  */
162 typedef struct
163 {
164     nrf_radio_cca_mode_t mode;           // !< CCA mode.
165     uint8_t              ed_threshold;   // !< Busy threshold of the CCA energy. Not used in @ref NRF_RADIO_CCA_MODE_CARRIER.
166     uint8_t              corr_threshold; // !< Busy threshold of the CCA correlator. Not used in @ref NRF_RADIO_CCA_MODE_ED.
167     uint8_t              corr_limit;     // !< Limit of occurrences above the busy threshold of the CCA correlator. Not used in @ref NRF_RADIO_CCA_MODE_ED.
168 } nrf_802154_cca_cfg_t;
169 
170 /**
171  * @brief Types of data that can be set in an ACK message.
172  */
173 typedef uint8_t nrf_802154_ack_data_t;
174 
175 #define NRF_802154_ACK_DATA_PENDING_BIT 0x00 // !< Frame Pending bit should be set in the Ack.
176 #define NRF_802154_ACK_DATA_IE          0x01 // !< Header Information Element should be set in the Ack.
177 
178 /**
179  * @brief Methods of source address matching.
180  *
181  * You can use one of the following methods that can be set during the initialization phase
182  * by calling @ref nrf_802154_src_addr_matching_method_set :
183  *   - For Thread: @ref NRF_802154_SRC_ADDR_MATCH_THREAD -- The pending bit is set only for the addresses found in the list.
184  *   - For Zigbee: @ref NRF_802154_SRC_ADDR_MATCH_ZIGBEE -- The pending bit is cleared only for the short addresses found in the list.\n
185  *     This method does not set pending bit in non-command and non-data-request frames.
186  *   - For standard-compliant implementation: @ref NRF_802154_SRC_ADDR_MATCH_ALWAYS_1 -- The pending bit is always set to 1.\n
187  *     This requires an empty data frame with AR set to 0 to be transmitted immediately afterwards.
188  */
189 typedef uint8_t nrf_802154_src_addr_match_t;
190 
191 #define NRF_802154_SRC_ADDR_MATCH_THREAD   0x00 // !< Implementation for the Thread protocol.
192 #define NRF_802154_SRC_ADDR_MATCH_ZIGBEE   0x01 // !< Implementation for the Zigbee protocol.
193 #define NRF_802154_SRC_ADDR_MATCH_ALWAYS_1 0x02 // !< Standard compliant implementation.
194 
195 /**
196  * @brief RSSI measurement results.
197  */
198 #define NRF_802154_RSSI_INVALID            INT8_MAX
199 
200 /**
201  * @brief Type holding the CSMA/CA backoff control test mode
202  *
203  * Possible values:
204  * - @ref NRF_802154_TEST_MODE_CSMACA_BACKOFF_RANDOM
205  * - @ref NRF_802154_TEST_MODE_CSMACA_BACKOFF_ALWAYS_MAX
206  * - @ref NRF_802154_TEST_MODE_CSMACA_BACKOFF_ALWAYS_MIN
207  */
208 typedef uint8_t nrf_802154_test_mode_csmaca_backoff_t;
209 
210 #define NRF_802154_TEST_MODE_CSMACA_BACKOFF_RANDOM     0x00 // !< The CSMA/CA uses random number of backoff periods (IEEE Std. 802.15.4 compliant)
211 #define NRF_802154_TEST_MODE_CSMACA_BACKOFF_ALWAYS_MAX 0x01 // !< The CSMA/CA uses always maximum backoff periods (Test mode, non-compliant to IEEE Std. 802.15.4)
212 #define NRF_802154_TEST_MODE_CSMACA_BACKOFF_ALWAYS_MIN 0x02 // !< The CSMA/CA uses always minimum backoff periods (Test mode, non-compliant to IEEE Std. 802.15.4)
213 
214 /**
215  * @brief Mode of triggering receive request to Coex arbiter.
216  *
217  * Possible values:
218  * - @ref NRF_802154_COEX_RX_REQUEST_MODE_ENERGY_DETECTION,
219  * - @ref NRF_802154_COEX_RX_REQUEST_MODE_PREAMBLE,
220  * - @ref NRF_802154_COEX_RX_REQUEST_MODE_DESTINED
221  */
222 typedef uint8_t nrf_802154_coex_rx_request_mode_t;
223 
224 #define NRF_802154_COEX_RX_REQUEST_MODE_ENERGY_DETECTION 0x01 // !< Coex requests to arbiter in receive mode upon energy detected.
225 #define NRF_802154_COEX_RX_REQUEST_MODE_PREAMBLE         0x02 // !< Coex requests to arbiter in receive mode upon preamble reception.
226 #define NRF_802154_COEX_RX_REQUEST_MODE_DESTINED         0x03 // !< Coex requests to arbiter in receive mode upon detection that frame is addressed to this device.
227 
228 /**
229  * @brief Mode of triggering transmit request to Coex arbiter.
230  *
231  * Possible values:
232  * - @ref NRF_802154_COEX_TX_REQUEST_MODE_FRAME_READY,
233  * - @ref NRF_802154_COEX_TX_REQUEST_MODE_CCA_START,
234  * - @ref NRF_802154_COEX_TX_REQUEST_MODE_CCA_DONE,
235  * - @ref NRF_802154_COEX_TX_REQUEST_MODE_ON_CCA_TOGGLE
236  */
237 typedef uint8_t nrf_802154_coex_tx_request_mode_t;
238 
239 #define NRF_802154_COEX_TX_REQUEST_MODE_FRAME_READY   0x01 // !< Coex requests to arbiter in transmit mode when the frame is ready to be transmitted.
240 #define NRF_802154_COEX_TX_REQUEST_MODE_CCA_START     0x02 // !< Coex requests to arbiter in transmit mode before CCA is started.
241 #define NRF_802154_COEX_TX_REQUEST_MODE_CCA_DONE      0x03 // !< Coex requests to arbiter in transmit mode after CCA is finished.
242 #define NRF_802154_COEX_TX_REQUEST_MODE_ON_CCA_TOGGLE 0x04 // !< Coex requests to arbiter in transmit mode before CCA is started and releases the request if CCA reports busy channel.
243 
244 /**
245  * @brief Mode of handling Interframe spacing.
246  *
247  * Possible values:
248  * - @ref NRF_802154_IFS_MODE_DISABLED,
249  * - @ref NRF_802154_IFS_MODE_MATCHING_ADDRESSES,
250  * - @ref NRF_802154_IFS_MODE_ALWAYS
251  */
252 typedef uint8_t nrf_802154_ifs_mode_t;
253 
254 #define NRF_802154_IFS_MODE_DISABLED           0x00 // !< Interframe spacing is never inserted.
255 #define NRF_802154_IFS_MODE_MATCHING_ADDRESSES 0x01 // !< Interframe spacing is inserted only on matching addresses.
256 #define NRF_802154_IFS_MODE_ALWAYS             0x02 // !< Interframe spacing is always inserted.
257 
258 /**
259  * @brief Capabilities of nrf 802.15.4 radio driver
260  *
261  * Possible values:
262  * - @ref NRF_802154_CAPABILITY_CSMA,
263  * - @ref NRF_802154_CAPABILITY_DELAYED_TX,
264  * - @ref NRF_802154_CAPABILITY_DELAYED_RX,
265  * - @ref NRF_802154_CAPABILITY_ACK_TIMEOUT,
266  * - @ref NRF_802154_CAPABILITY_ANT_DIVERSITY,
267  * - @ref NRF_802154_CAPABILITY_IFS,
268  * - @ref NRF_802154_CAPABILITY_TIMESTAMP
269  * - @ref NRF_802154_CAPABILITY_SECURITY
270  *
271  */
272 typedef uint32_t nrf_802154_capabilities_t;
273 
274 #define NRF_802154_CAPABILITY_CSMA          (1UL << 0UL) // !< CSMA-CA supported
275 #define NRF_802154_CAPABILITY_DELAYED_TX    (1UL << 1UL) // !< TX at specified time supported
276 #define NRF_802154_CAPABILITY_DELAYED_RX    (1UL << 2UL) // !< RX at specified time supported
277 #define NRF_802154_CAPABILITY_ACK_TIMEOUT   (1UL << 3UL) // !< ACK timeout supported
278 #define NRF_802154_CAPABILITY_ANT_DIVERSITY (1UL << 4UL) // !< Antenna diversity supported
279 #define NRF_802154_CAPABILITY_IFS           (1UL << 5UL) // !< Inter-frame spacing supported
280 #define NRF_802154_CAPABILITY_TIMESTAMP     (1UL << 6UL) // !< Frame timestamping supported
281 #define NRF_802154_CAPABILITY_SECURITY      (1UL << 7UL) // !< Frame security supported
282 
283 /**
284  * @brief Types of keys which can be used with the nRF 802.15.4 Radio Driver.
285  *
286  * Possible values:
287  * - @ref NRF_802154_KEY_CLEARTEXT,
288  *
289  */
290 typedef uint32_t nrf_802154_key_type_t;
291 
292 #define NRF_802154_KEY_CLEARTEXT 0x00 // !< Key stored in clear text.
293 
294 /**
295  * @brief Type of structure holding statistic counters.
296  *
297  * This structure holds counters of @c uint32_t type only.
298  */
299 typedef struct
300 {
301     /**@brief Number of failed CCA attempts. */
302     uint32_t cca_failed_attempts;
303     /**@brief Number of frames received with correct CRC and with filtering passing. */
304     uint32_t received_frames;
305     /**@brief Number of times energy was detected in receive mode.*/
306     uint32_t received_energy_events;
307     /**@brief Number of times a preamble was received in receive mode. */
308     uint32_t received_preambles;
309     /**@brief Number of coex requests issued to coex arbiter. */
310     uint32_t coex_requests;
311     /**@brief Number of coex requests issued to coex arbiter that have been granted. */
312     uint32_t coex_granted_requests;
313     /**@brief Number of coex requests issued to coex arbiter that have been denied. */
314     uint32_t coex_denied_requests;
315     /**@brief Number of coex grant activations that have been not requested. */
316     uint32_t coex_unsolicited_grants;
317 } nrf_802154_stat_counters_t;
318 
319 /**
320  * @brief Type of structure holding time stamps of certain events.
321  */
322 typedef struct
323 {
324     /**@brief Time stamp of last CSMA/CA procedure started. */
325     uint64_t last_csmaca_start_timestamp;
326     /**@brief Time stamp of last CCA start attempt. */
327     uint64_t last_cca_start_timestamp;
328     /**@brief Time stamp of last CCA attempt finished with CCA IDLE (channel was free to transmit). */
329     uint64_t last_cca_idle_timestamp;
330     /**@brief Time stamp when last bit of transmitted frame was sent on the air. */
331     uint64_t last_tx_end_timestamp;
332     /**@brief Time stamp when last bit of acknowledge frame was received */
333     uint64_t last_ack_end_timestamp;
334     /**@brief Time stamp when last bit of received frame was received. */
335     uint64_t last_rx_end_timestamp;
336 } nrf_802154_stat_timestamps_t;
337 
338 /**
339  * @brief Type of structure holding statistics about the Radio Driver behavior.
340  */
341 typedef struct
342 {
343     /**@brief Statistic counters */
344     nrf_802154_stat_counters_t   counters;
345 
346     /**@brief Time stamps of events */
347     nrf_802154_stat_timestamps_t timestamps;
348 } nrf_802154_stats_t;
349 
350 /**
351  * @brief Type holding the value of Key Id Mode of the key stored in nRF 802.15.4 Radio Driver.
352  */
353 typedef uint8_t nrf_802154_key_id_mode_t;
354 
355 /**
356  * @brief Type holding the value of Key Id for the keys stored in nRF 802.15.4 Radio Driver.
357  */
358 typedef struct
359 {
360     nrf_802154_key_id_mode_t mode;     // !< Key Id Mode (0..3)
361     uint8_t                * p_key_id; // !< Pointer to the Key Id field
362 } nrf_802154_key_id_t;
363 
364 /**
365  * @brief Type of structure holding a 802.15.4 MAC Security Key.
366  */
367 typedef struct
368 {
369     union
370     {
371         uint8_t * p_cleartext_key;                  // !< Pointer to the cleartext representation of the key.
372     }                     value;                    // !< Union holding different representations of the key.
373     nrf_802154_key_id_t   id;                       // !< Key Id of the key.
374     nrf_802154_key_type_t type;                     // !< @ref nrf_802154_key_type_t type of the key used.
375     uint32_t              frame_counter;            // !< Frame counter to use in case @ref use_global_frame_counter is set to false.
376     bool                  use_global_frame_counter; // !< Whether to use the global frame counter instead of the one defined in this structure.
377 } nrf_802154_key_t;
378 
379 /**
380  * @brief Structure with frame properties associated with the transmission operation.
381  *
382  * @note When using to request transmission, parameters contained here influence whether or not
383  *       the security related data transformation will be performed. In particular, the driver may:
384  *        - update frame counter field if the dynamic parts of the frame are not yet updated
385  *        - secure a non-secured frame on-the-fly
386  *       If performed, the above operations are configured by the IEEE 802.15.4 Auxiliary Security
387  *       Header present in the transmitted frame.
388  *
389  * @note It is recommended to use values defined in @ref NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT
390  *       to perform the first transmission attempt. Using other values may result in transmitting
391  *       malformed or incorrect frames and creating security breaches.
392  *
393  * @note The combination with is_secured = true and dynamic_data_is_set = false is not allowed.
394  *       An attempt to transmit a frame with such parameters will fail unconditionally.
395  */
396 typedef struct
397 {
398     bool is_secured;          // !< If the frame to be transmitted is already secured (in the sense of IEEE 802.15.4 security operations).
399     bool dynamic_data_is_set; // !< If dynamic data of the frame frame to be transmitted is set.
400 } nrf_802154_transmitted_frame_props_t;
401 
402 /**
403  * @brief Structure passed in transmit metadata with information needed to set transmission power.
404  *
405  * If the @p use_metadata_value field is set to true the power in dBm used to transmit the frame is set to the value of the
406  * field @p power.
407  * Otherwise the value from PIB set by @ref nrf_802154_tx_power_set is used
408  */
409 typedef struct
410 {
411     bool   use_metadata_value; // !< Set to true if the value in @p power should be used as the TX power in dBm
412     int8_t power;              // !< Transmission power in dBm
413 } nrf_802154_tx_power_metadata_t;
414 
415 /**
416  * @brief Structure passed in transmit metadata with information needed to set transmission channel.
417  *
418  * If the @p use_metadata_value field is set to true the channel used to transmit the frame is set to the value of the field @p channel.
419  * Otherwise the value from PIB set by @ref nrf_802154_channel_set is used.
420  */
421 typedef struct
422 {
423     bool    use_metadata_value; // !< Set to true if the value in @p channel should be used as the TX channel
424     uint8_t channel;            // !< Transmission channel
425 } nrf_802154_tx_channel_metadata_t;
426 
427 /**
428  * @brief Default initializer for nrf_802154_transmitted_frame_props_t.
429  */
430 #define NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT \
431     (nrf_802154_transmitted_frame_props_t){             \
432         .is_secured          = false,                   \
433         .dynamic_data_is_set = false                    \
434     }
435 
436 /**
437  * @brief Structure with transmit request metadata for simple transmission request.
438  */
439 typedef struct
440 {
441     nrf_802154_transmitted_frame_props_t frame_props; // !< Properties of the frame to be transmitted.
442     bool                                 cca;         // !< If the driver is to perform a CCA procedure before transmission.
443     nrf_802154_tx_power_metadata_t       tx_power;    // !< Information about the TX power to be used.
444     nrf_802154_tx_channel_metadata_t     tx_channel;  // !< Information about the TX channel to be used.
445 } nrf_802154_transmit_metadata_t;
446 
447 /**
448  * @brief Structure with transmit request metadata for scheduling transmission at a specific time.
449  */
450 typedef struct
451 {
452     nrf_802154_transmitted_frame_props_t frame_props;        // !< Properties of the frame to be transmitted.
453     bool                                 cca;                // !< If the driver is to perform a CCA procedure before transmission.
454     uint8_t                              channel;            // !< Radio channel on which the frame is to be transmitted.
455     nrf_802154_tx_power_metadata_t       tx_power;           // !< Information about the TX power to be used.
456     uint8_t                              extra_cca_attempts; // !< Maximum number of additional CCA attempts that can be performed if the first attempt returns busy channel. Ignored if @ref cca equals @c false.
457 } nrf_802154_transmit_at_metadata_t;
458 
459 /**
460  * @brief Structure with transmit request metadata for transmission preceded by CSMA-CA procedure.
461  */
462 typedef struct
463 {
464     nrf_802154_transmitted_frame_props_t frame_props; // !< Properties of the frame to be transmitted.
465     nrf_802154_tx_power_metadata_t       tx_power;    // !< Information about the TX power to be used.
466     nrf_802154_tx_channel_metadata_t     tx_channel;  // !< Information about the TX channel to be used.
467 } nrf_802154_transmit_csma_ca_metadata_t;
468 
469 /**
470  * @brief Structure that holds transmission result metadata.
471  */
472 typedef struct
473 {
474     nrf_802154_transmitted_frame_props_t frame_props; // !< Properties of the returned frame.
475 
476     union
477     {
478         struct
479         {
480             uint8_t * p_ack; // !< A pointer to a buffer that contains PHR and PSDU of the received ACK. The first byte
481                              // in the buffer is the length of the frame (PHR). The following bytes contain the ACK frame itself (PSDU). The length byte
482                              // (PHR) includes FCS. FCS is already verified by the hardware and may be modified by the hardware.
483                              // If ACK was not requested or requested but not received, @ref p_ack is set to NULL.
484             uint8_t  length; // !< Length of the received ACK payload or 0 if @ref p_ack is NULL.
485             int8_t   power;  // !< RSSI of the received frame or 0 if @ref p_ack is NULL.
486             uint8_t  lqi;    // !< LQI of the received frame or 0 if @ref p_ack is NULL.
487             uint64_t time;   // !< Timestamp taken when the last symbol of ACK is received. If @ref p_ack is NULL, this field is set to 0, but is considered invalid.
488         } transmitted;       // !< Result values for a successful frame transmission.
489     } data;                  // !< Result values that are valid only for successful operations.
490 } nrf_802154_transmit_done_metadata_t;
491 
492 /**
493  * @brief Function pointer used for notifying about transmission failure.
494  */
495 typedef void (* nrf_802154_transmit_failed_notification_t)(
496     uint8_t                                   * p_frame,
497     nrf_802154_tx_error_t                       error,
498     const nrf_802154_transmit_done_metadata_t * p_meta);
499 
500 /**
501  * @brief Structure that holds results of energy detection procedure.
502  */
503 typedef struct
504 {
505     int8_t ed_dbm; // !< Maximum detected ED in dBm.
506 } nrf_802154_energy_detected_t;
507 
508 /**
509  *@}
510  **/
511 
512 #endif // NRF_802154_TYPES_H__
513