1 /*
2 * Copyright (c) 2018 - 2023, 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 /**
36 * @file
37 * This file implements the nrf 802.15.4 radio driver.
38 *
39 */
40
41 #define NRF_802154_MODULE_ID NRF_802154_DRV_MODULE_ID_APPLICATION
42
43 #include "nrf_802154.h"
44
45 #include <assert.h>
46 #include <stdbool.h>
47 #include <stddef.h>
48 #include <stdint.h>
49 #include <string.h>
50
51 #include "nrf_802154_config.h"
52 #include "nrf_802154_const.h"
53 #include "nrf_802154_core.h"
54 #include "nrf_802154_critical_section.h"
55 #include "nrf_802154_debug.h"
56 #include "nrf_802154_notification.h"
57 #include "nrf_802154_nrfx_addons.h"
58 #include "nrf_802154_pib.h"
59 #include "nrf_802154_request.h"
60 #include "nrf_802154_rx_buffer.h"
61 #include "nrf_802154_tx_power.h"
62 #include "nrf_802154_stats.h"
63 #include "hal/nrf_radio.h"
64 #include "platform/nrf_802154_clock.h"
65 #include "platform/nrf_802154_random.h"
66 #include "platform/nrf_802154_temperature.h"
67 #include "rsch/nrf_802154_rsch.h"
68 #include "rsch/nrf_802154_rsch_crit_sect.h"
69 #include "timer/nrf_802154_timer_coord.h"
70
71 #include "mac_features/nrf_802154_ack_timeout.h"
72 #include "mac_features/nrf_802154_delayed_trx.h"
73 #include "mac_features/nrf_802154_ie_writer.h"
74 #include "mac_features/nrf_802154_ifs.h"
75 #include "mac_features/nrf_802154_security_pib.h"
76 #include "mac_features/ack_generator/nrf_802154_ack_data.h"
77
78 #include "nrf_802154_sl_ant_div.h"
79 #include "nrf_802154_sl_crit_sect_if.h"
80 #include "nrf_802154_sl_capabilities.h"
81 #include "nrf_802154_sl_timer.h"
82
83 #if !NRF_802154_USE_RAW_API || NRF_802154_CARRIER_FUNCTIONS_ENABLED
84 /** Static transmit buffer used by @sa nrf_802154_transmit() family of functions.
85 *
86 * If none of functions using this buffer is called and link time optimization is enabled, this
87 * buffer should be removed by linker.
88 */
89 static uint8_t m_tx_buffer[RAW_PAYLOAD_OFFSET + MAX_PACKET_SIZE];
90
91 #endif // !NRF_802154_USE_RAW_API || NRF_802154_CARRIER_FUNCTIONS_ENABLED
92
93 #if !NRF_802154_USE_RAW_API
94 /**
95 * @brief Fill transmit buffer with given data.
96 *
97 * @param[in] p_data Pointer to array containing payload of a data to transmit. The array
98 * should exclude PHR or FCS fields of 802.15.4 frame.
99 * @param[in] length Length of given frame. This value shall exclude PHR and FCS fields from
100 * the given frame (exact size of buffer pointed by @p p_data).
101 */
tx_buffer_fill(const uint8_t * p_data,uint8_t length)102 static void tx_buffer_fill(const uint8_t * p_data, uint8_t length)
103 {
104 assert(length <= MAX_PACKET_SIZE - FCS_SIZE);
105
106 m_tx_buffer[RAW_LENGTH_OFFSET] = length + FCS_SIZE;
107 memcpy(&m_tx_buffer[RAW_PAYLOAD_OFFSET], p_data, length);
108 }
109
110 #endif // !NRF_802154_USE_RAW_API
111
112 #if NRF_802154_CARRIER_FUNCTIONS_ENABLED
113 /**
114 * @brief Fill the transmit buffer with given data in order to use it with the
115 * modulated carrier functionality.
116 *
117 * @param[in] p_data Pointer to array containing modulating data.
118 */
tx_buffer_fill_for_modulated_carrier(const uint8_t * p_data)119 static void tx_buffer_fill_for_modulated_carrier(const uint8_t * p_data)
120 {
121 uint8_t length = p_data[RAW_LENGTH_OFFSET];
122
123 assert(length <= MAX_PACKET_SIZE);
124
125 memcpy(m_tx_buffer, p_data, RAW_PAYLOAD_OFFSET + length);
126 }
127
128 #endif // NRF_802154_CARRIER_FUNCTIONS_ENABLED
129
are_frame_properties_valid(const nrf_802154_transmitted_frame_props_t * p_props)130 static inline bool are_frame_properties_valid(const nrf_802154_transmitted_frame_props_t * p_props)
131 {
132 return p_props->dynamic_data_is_set || !(p_props->is_secured);
133 }
134
nrf_802154_channel_set(uint8_t channel)135 void nrf_802154_channel_set(uint8_t channel)
136 {
137 bool changed = nrf_802154_pib_channel_get() != channel;
138
139 nrf_802154_pib_channel_set(channel);
140
141 if (changed)
142 {
143 (void)nrf_802154_request_channel_update(REQ_ORIG_HIGHER_LAYER);
144 }
145 }
146
nrf_802154_channel_get(void)147 uint8_t nrf_802154_channel_get(void)
148 {
149 return nrf_802154_pib_channel_get();
150 }
151
nrf_802154_tx_power_set(int8_t power)152 void nrf_802154_tx_power_set(int8_t power)
153 {
154 nrf_802154_pib_tx_power_set(power);
155 }
156
nrf_802154_tx_power_get(void)157 int8_t nrf_802154_tx_power_get(void)
158 {
159 nrf_802154_fal_tx_power_split_t split_power = {0};
160
161 return nrf_802154_tx_power_split_pib_power_get(&split_power);
162 }
163
nrf_802154_coex_rx_request_mode_set(nrf_802154_coex_rx_request_mode_t mode)164 bool nrf_802154_coex_rx_request_mode_set(nrf_802154_coex_rx_request_mode_t mode)
165 {
166 return nrf_802154_pib_coex_rx_request_mode_set(mode);
167 }
168
nrf_802154_coex_rx_request_mode_get(void)169 nrf_802154_coex_rx_request_mode_t nrf_802154_coex_rx_request_mode_get(void)
170 {
171 return nrf_802154_pib_coex_rx_request_mode_get();
172 }
173
nrf_802154_coex_tx_request_mode_set(nrf_802154_coex_tx_request_mode_t mode)174 bool nrf_802154_coex_tx_request_mode_set(nrf_802154_coex_tx_request_mode_t mode)
175 {
176 return nrf_802154_pib_coex_tx_request_mode_set(mode);
177 }
178
nrf_802154_coex_tx_request_mode_get(void)179 nrf_802154_coex_tx_request_mode_t nrf_802154_coex_tx_request_mode_get(void)
180 {
181 return nrf_802154_pib_coex_tx_request_mode_get();
182 }
183
nrf_802154_temperature_changed(void)184 void nrf_802154_temperature_changed(void)
185 {
186 nrf_802154_request_cca_cfg_update();
187 }
188
nrf_802154_pan_id_set(const uint8_t * p_pan_id)189 void nrf_802154_pan_id_set(const uint8_t * p_pan_id)
190 {
191 nrf_802154_pib_pan_id_set(p_pan_id);
192 }
193
nrf_802154_extended_address_set(const uint8_t * p_extended_address)194 void nrf_802154_extended_address_set(const uint8_t * p_extended_address)
195 {
196 nrf_802154_pib_extended_address_set(p_extended_address);
197 }
198
nrf_802154_short_address_set(const uint8_t * p_short_address)199 void nrf_802154_short_address_set(const uint8_t * p_short_address)
200 {
201 nrf_802154_pib_short_address_set(p_short_address);
202 }
203
nrf_802154_dbm_from_energy_level_calculate(uint8_t energy_level)204 int8_t nrf_802154_dbm_from_energy_level_calculate(uint8_t energy_level)
205 {
206 return nrf_802154_addons_dbm_from_energy_level_calculate(energy_level);
207 }
208
nrf_802154_ccaedthres_from_dbm_calculate(int8_t dbm)209 uint8_t nrf_802154_ccaedthres_from_dbm_calculate(int8_t dbm)
210 {
211 return dbm - ED_RSSIOFFS;
212 }
213
nrf_802154_first_symbol_timestamp_get(uint64_t end_timestamp,uint8_t psdu_length)214 uint64_t nrf_802154_first_symbol_timestamp_get(uint64_t end_timestamp, uint8_t psdu_length)
215 {
216 uint32_t frame_symbols = PHY_SHR_SYMBOLS;
217
218 frame_symbols += (PHR_SIZE + psdu_length) * PHY_SYMBOLS_PER_OCTET;
219
220 return end_timestamp - (frame_symbols * PHY_US_PER_SYMBOL);
221 }
222
nrf_802154_mhr_timestamp_get(uint64_t end_timestamp,uint8_t psdu_length)223 uint64_t nrf_802154_mhr_timestamp_get(uint64_t end_timestamp, uint8_t psdu_length)
224 {
225 return end_timestamp - (psdu_length * PHY_SYMBOLS_PER_OCTET * PHY_US_PER_SYMBOL);
226 }
227
nrf_802154_init(void)228 void nrf_802154_init(void)
229 {
230 static const nrf_802154_sl_crit_sect_interface_t crit_sect_int =
231 {
232 .enter = nrf_802154_critical_section_enter,
233 .exit = nrf_802154_critical_section_exit
234 };
235
236 nrf_802154_ack_data_init();
237 nrf_802154_core_init();
238 nrf_802154_clock_init();
239 nrf_802154_critical_section_init();
240 nrf_802154_sl_crit_sect_init(&crit_sect_int);
241 nrf_802154_debug_init();
242 nrf_802154_notification_init();
243 nrf_802154_pib_init();
244 nrf_802154_security_pib_init();
245 nrf_802154_sl_timer_module_init();
246 nrf_802154_random_init();
247 nrf_802154_request_init();
248 nrf_802154_rsch_crit_sect_init();
249 nrf_802154_rsch_init();
250 nrf_802154_rx_buffer_init();
251 nrf_802154_temperature_init();
252 nrf_802154_timer_coord_init();
253 #if NRF_802154_ACK_TIMEOUT_ENABLED
254 nrf_802154_ack_timeout_init();
255 #endif
256 #if NRF_802154_DELAYED_TRX_ENABLED
257 nrf_802154_delayed_trx_init();
258 #endif
259 #if NRF_802154_IFS_ENABLED
260 nrf_802154_ifs_init();
261 #endif
262 }
263
nrf_802154_deinit(void)264 void nrf_802154_deinit(void)
265 {
266 nrf_802154_timer_coord_uninit();
267 nrf_802154_temperature_deinit();
268 nrf_802154_rsch_uninit();
269 nrf_802154_random_deinit();
270 nrf_802154_security_pib_deinit();
271 nrf_802154_sl_timer_module_uninit();
272 nrf_802154_clock_deinit();
273 nrf_802154_core_deinit();
274 #if NRF_802154_ACK_TIMEOUT_ENABLED
275 nrf_802154_ack_timeout_deinit();
276 #endif
277 #if NRF_802154_DELAYED_TRX_ENABLED
278 nrf_802154_delayed_trx_deinit();
279 #endif
280 #if NRF_802154_IFS_ENABLED
281 nrf_802154_ifs_deinit();
282 #endif
283 }
284
nrf_802154_antenna_diversity_rx_mode_set(nrf_802154_sl_ant_div_mode_t mode)285 bool nrf_802154_antenna_diversity_rx_mode_set(nrf_802154_sl_ant_div_mode_t mode)
286 {
287 bool result = false;
288
289 #if defined(RADIO_INTENSET_SYNC_Msk)
290 result = nrf_802154_sl_ant_div_cfg_mode_set(NRF_802154_SL_ANT_DIV_OP_RX, mode);
291 #endif
292
293 if (result)
294 {
295 nrf_802154_request_antenna_update();
296 }
297
298 return result;
299 }
300
nrf_802154_antenna_diversity_rx_mode_get(void)301 nrf_802154_sl_ant_div_mode_t nrf_802154_antenna_diversity_rx_mode_get(void)
302 {
303 return nrf_802154_sl_ant_div_cfg_mode_get(NRF_802154_SL_ANT_DIV_OP_RX);
304 }
305
nrf_802154_antenna_diversity_tx_mode_set(nrf_802154_sl_ant_div_mode_t mode)306 bool nrf_802154_antenna_diversity_tx_mode_set(nrf_802154_sl_ant_div_mode_t mode)
307 {
308 bool result = false;
309
310 #if defined(RADIO_INTENSET_SYNC_Msk)
311 result = nrf_802154_sl_ant_div_cfg_mode_set(NRF_802154_SL_ANT_DIV_OP_TX, mode);
312 #endif
313
314 if (result)
315 {
316 nrf_802154_request_antenna_update();
317 }
318
319 return result;
320 }
321
nrf_802154_antenna_diversity_tx_mode_get(void)322 nrf_802154_sl_ant_div_mode_t nrf_802154_antenna_diversity_tx_mode_get(void)
323 {
324 return nrf_802154_sl_ant_div_cfg_mode_get(NRF_802154_SL_ANT_DIV_OP_TX);
325 }
326
nrf_802154_antenna_diversity_rx_antenna_set(nrf_802154_sl_ant_div_antenna_t antenna)327 bool nrf_802154_antenna_diversity_rx_antenna_set(nrf_802154_sl_ant_div_antenna_t antenna)
328 {
329 bool result =
330 nrf_802154_sl_ant_div_cfg_antenna_set(NRF_802154_SL_ANT_DIV_OP_RX, antenna);
331 bool is_manual_mode = nrf_802154_sl_ant_div_cfg_mode_get(NRF_802154_SL_ANT_DIV_OP_RX) ==
332 NRF_802154_SL_ANT_DIV_MODE_MANUAL;
333
334 if (result && is_manual_mode)
335 {
336 nrf_802154_request_antenna_update();
337 }
338
339 return result;
340 }
341
nrf_802154_antenna_diversity_rx_antenna_get(void)342 nrf_802154_sl_ant_div_antenna_t nrf_802154_antenna_diversity_rx_antenna_get(void)
343 {
344 return nrf_802154_sl_ant_div_cfg_antenna_get(NRF_802154_SL_ANT_DIV_OP_RX);
345 }
346
nrf_802154_antenna_diversity_tx_antenna_set(nrf_802154_sl_ant_div_antenna_t antenna)347 bool nrf_802154_antenna_diversity_tx_antenna_set(nrf_802154_sl_ant_div_antenna_t antenna)
348 {
349 bool result =
350 nrf_802154_sl_ant_div_cfg_antenna_set(NRF_802154_SL_ANT_DIV_OP_TX, antenna);
351 bool is_manual_mode = nrf_802154_sl_ant_div_cfg_mode_get(NRF_802154_SL_ANT_DIV_OP_TX) ==
352 NRF_802154_SL_ANT_DIV_MODE_MANUAL;
353
354 if (result && is_manual_mode)
355 {
356 nrf_802154_request_antenna_update();
357 }
358
359 return result;
360 }
361
nrf_802154_antenna_diversity_tx_antenna_get(void)362 nrf_802154_sl_ant_div_antenna_t nrf_802154_antenna_diversity_tx_antenna_get(void)
363 {
364 return nrf_802154_sl_ant_div_cfg_antenna_get(NRF_802154_SL_ANT_DIV_OP_TX);
365 }
366
nrf_802154_antenna_diversity_last_rx_best_antenna_get(void)367 nrf_802154_sl_ant_div_antenna_t nrf_802154_antenna_diversity_last_rx_best_antenna_get(void)
368 {
369 return nrf_802154_sl_ant_div_last_rx_best_antenna_get();
370 }
371
nrf_802154_antenna_diversity_config_set(const nrf_802154_sl_ant_div_cfg_t * p_cfg)372 void nrf_802154_antenna_diversity_config_set(const nrf_802154_sl_ant_div_cfg_t * p_cfg)
373 {
374 #if defined(RADIO_INTENSET_SYNC_Msk)
375 nrf_802154_sl_ant_div_cfg_set(p_cfg);
376 #endif
377 }
378
nrf_802154_antenna_diversity_config_get(nrf_802154_sl_ant_div_cfg_t * p_cfg)379 bool nrf_802154_antenna_diversity_config_get(nrf_802154_sl_ant_div_cfg_t * p_cfg)
380 {
381 return nrf_802154_sl_ant_div_cfg_get(p_cfg);
382 }
383
nrf_802154_antenna_diversity_init(void)384 bool nrf_802154_antenna_diversity_init(void)
385 {
386 return nrf_802154_sl_ant_div_init();
387 }
388
nrf_802154_antenna_diversity_timer_irq_handler(void)389 void nrf_802154_antenna_diversity_timer_irq_handler(void)
390 {
391 #if defined(RADIO_INTENSET_SYNC_Msk)
392 nrf_802154_sl_ant_div_timer_irq_handle();
393 #endif
394 }
395
nrf_802154_state_get(void)396 nrf_802154_state_t nrf_802154_state_get(void)
397 {
398 switch (nrf_802154_core_state_get())
399 {
400 case RADIO_STATE_SLEEP:
401 case RADIO_STATE_FALLING_ASLEEP:
402 return NRF_802154_STATE_SLEEP;
403
404 case RADIO_STATE_RX:
405 case RADIO_STATE_TX_ACK:
406 return NRF_802154_STATE_RECEIVE;
407
408 case RADIO_STATE_CCA_TX:
409 case RADIO_STATE_TX:
410 case RADIO_STATE_RX_ACK:
411 return NRF_802154_STATE_TRANSMIT;
412
413 case RADIO_STATE_ED:
414 return NRF_802154_STATE_ENERGY_DETECTION;
415
416 case RADIO_STATE_CCA:
417 return NRF_802154_STATE_CCA;
418
419 #if NRF_802154_CARRIER_FUNCTIONS_ENABLED
420
421 case RADIO_STATE_CONTINUOUS_CARRIER:
422 return NRF_802154_STATE_CONTINUOUS_CARRIER;
423
424 case RADIO_STATE_MODULATED_CARRIER:
425 return NRF_802154_STATE_MODULATED_CARRIER;
426 #endif // NRF_802154_CARRIER_FUNCTIONS_ENABLED
427
428 }
429
430 return NRF_802154_STATE_INVALID;
431 }
432
nrf_802154_sleep(void)433 bool nrf_802154_sleep(void)
434 {
435 bool result;
436
437 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
438
439 result = nrf_802154_request_sleep(NRF_802154_TERM_802154);
440
441 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
442
443 return result;
444 }
445
nrf_802154_sleep_if_idle(void)446 nrf_802154_sleep_error_t nrf_802154_sleep_if_idle(void)
447 {
448 nrf_802154_sleep_error_t result;
449
450 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
451
452 result =
453 nrf_802154_request_sleep(NRF_802154_TERM_NONE) ? NRF_802154_SLEEP_ERROR_NONE :
454 NRF_802154_SLEEP_ERROR_BUSY;
455
456 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
457
458 return result;
459 }
460
nrf_802154_receive(void)461 bool nrf_802154_receive(void)
462 {
463 bool result;
464
465 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
466
467 result = nrf_802154_request_receive(NRF_802154_TERM_802154,
468 REQ_ORIG_HIGHER_LAYER,
469 NULL,
470 true,
471 NRF_802154_RESERVED_IMM_RX_WINDOW_ID);
472
473 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
474 return result;
475 }
476
477 #if NRF_802154_USE_RAW_API
nrf_802154_transmit_raw(uint8_t * p_data,const nrf_802154_transmit_metadata_t * p_metadata)478 bool nrf_802154_transmit_raw(uint8_t * p_data,
479 const nrf_802154_transmit_metadata_t * p_metadata)
480 {
481 bool result;
482
483 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
484
485 if (p_metadata == NULL)
486 {
487 static const nrf_802154_transmit_metadata_t metadata_default =
488 {
489 .frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
490 .cca = true,
491 .tx_power = {.use_metadata_value = false}
492 };
493
494 p_metadata = &metadata_default;
495 }
496
497 nrf_802154_transmit_params_t params =
498 {
499 .frame_props = p_metadata->frame_props,
500 .tx_power = {0},
501 .cca = p_metadata->cca,
502 .immediate = false
503 };
504
505 (void)nrf_802154_tx_power_convert_metadata_to_tx_power_split(nrf_802154_pib_channel_get(),
506 p_metadata->tx_power,
507 ¶ms.tx_power);
508
509 result = are_frame_properties_valid(¶ms.frame_props);
510 if (result)
511 {
512 result = nrf_802154_request_transmit(NRF_802154_TERM_NONE,
513 REQ_ORIG_HIGHER_LAYER,
514 p_data,
515 ¶ms,
516 NULL);
517 }
518
519 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
520 return result;
521 }
522
523 #else // NRF_802154_USE_RAW_API
524
nrf_802154_transmit(const uint8_t * p_data,uint8_t length,const nrf_802154_transmit_metadata_t * p_metadata)525 bool nrf_802154_transmit(const uint8_t * p_data,
526 uint8_t length,
527 const nrf_802154_transmit_metadata_t * p_metadata)
528 {
529 bool result;
530
531 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
532
533 if (p_metadata == NULL)
534 {
535 static const nrf_802154_transmit_metadata_t metadata_default =
536 {
537 .frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
538 .cca = true,
539 .tx_power = {.use_metadata_value = false}
540 };
541
542 p_metadata = &metadata_default;
543 }
544
545 nrf_802154_transmit_params_t params =
546 {
547 .frame_props = p_metadata->frame_props,
548 .tx_power = {0},
549 .cca = p_metadata->cca,
550 .immediate = false
551 };
552
553 (void)nrf_802154_tx_power_convert_metadata_to_tx_power_split(nrf_802154_pib_channel_get(),
554 p_metadata->tx_power,
555 ¶ms.tx_power);
556
557 result = are_frame_properties_valid(¶ms.frame_props);
558 if (result)
559 {
560 tx_buffer_fill(p_data, length);
561 result = nrf_802154_request_transmit(NRF_802154_TERM_NONE,
562 REQ_ORIG_HIGHER_LAYER,
563 m_tx_buffer,
564 ¶ms,
565 NULL);
566 }
567
568 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
569 return result;
570 }
571
572 #endif // NRF_802154_USE_RAW_API
573
574 #if NRF_802154_DELAYED_TRX_ENABLED
nrf_802154_transmit_raw_at(uint8_t * p_data,uint64_t tx_time,const nrf_802154_transmit_at_metadata_t * p_metadata)575 bool nrf_802154_transmit_raw_at(uint8_t * p_data,
576 uint64_t tx_time,
577 const nrf_802154_transmit_at_metadata_t * p_metadata)
578 {
579 bool result;
580 nrf_802154_transmit_at_metadata_t metadata_default =
581 {
582 .frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
583 .cca = true,
584 .tx_power = {.use_metadata_value = false}
585 };
586
587 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
588
589 if (p_metadata == NULL)
590 {
591 metadata_default.channel = nrf_802154_channel_get();
592 p_metadata = &metadata_default;
593 }
594
595 result = are_frame_properties_valid(&p_metadata->frame_props);
596 if (result)
597 {
598 result = nrf_802154_request_transmit_raw_at(p_data, tx_time, p_metadata);
599 }
600
601 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
602 return result;
603 }
604
nrf_802154_transmit_at_cancel(void)605 bool nrf_802154_transmit_at_cancel(void)
606 {
607 bool result;
608
609 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
610
611 result = nrf_802154_request_transmit_at_cancel();
612
613 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
614 return result;
615 }
616
nrf_802154_receive_at(uint64_t rx_time,uint32_t timeout,uint8_t channel,uint32_t id)617 bool nrf_802154_receive_at(uint64_t rx_time,
618 uint32_t timeout,
619 uint8_t channel,
620 uint32_t id)
621 {
622 bool result;
623
624 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
625
626 result = nrf_802154_request_receive_at(rx_time, timeout, channel, id);
627
628 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
629 return result;
630 }
631
nrf_802154_receive_at_cancel(uint32_t id)632 bool nrf_802154_receive_at_cancel(uint32_t id)
633 {
634 bool result;
635
636 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
637
638 result = nrf_802154_request_receive_at_cancel(id);
639
640 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
641 return result;
642 }
643
644 #endif // NRF_802154_DELAYED_TRX_ENABLED
645
nrf_802154_energy_detection(uint32_t time_us)646 bool nrf_802154_energy_detection(uint32_t time_us)
647 {
648 bool result;
649
650 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
651
652 result = nrf_802154_request_energy_detection(NRF_802154_TERM_NONE, time_us);
653
654 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
655 return result;
656 }
657
nrf_802154_cca(void)658 bool nrf_802154_cca(void)
659 {
660 bool result;
661
662 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
663
664 result = nrf_802154_request_cca(NRF_802154_TERM_NONE);
665
666 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
667 return result;
668 }
669
670 #if NRF_802154_CARRIER_FUNCTIONS_ENABLED
671
nrf_802154_continuous_carrier(void)672 bool nrf_802154_continuous_carrier(void)
673 {
674 bool result;
675
676 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
677
678 result = nrf_802154_request_continuous_carrier(NRF_802154_TERM_NONE);
679
680 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
681 return result;
682 }
683
nrf_802154_modulated_carrier(const uint8_t * p_data)684 bool nrf_802154_modulated_carrier(const uint8_t * p_data)
685 {
686 bool result;
687
688 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
689
690 tx_buffer_fill_for_modulated_carrier(p_data);
691
692 result = nrf_802154_request_modulated_carrier(NRF_802154_TERM_NONE, m_tx_buffer);
693
694 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
695 return result;
696 }
697
698 #endif // NRF_802154_CARRIER_FUNCTIONS_ENABLED
699
700 #if NRF_802154_USE_RAW_API
701
nrf_802154_buffer_free_raw(uint8_t * p_data)702 void nrf_802154_buffer_free_raw(uint8_t * p_data)
703 {
704 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
705
706 bool result;
707 rx_buffer_t * p_buffer = (rx_buffer_t *)p_data;
708
709 assert(p_buffer->free == false);
710 (void)p_buffer;
711
712 result = nrf_802154_request_buffer_free(p_data);
713 assert(result);
714 (void)result;
715
716 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
717 }
718
nrf_802154_buffer_free_immediately_raw(uint8_t * p_data)719 bool nrf_802154_buffer_free_immediately_raw(uint8_t * p_data)
720 {
721 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
722
723 bool result;
724 rx_buffer_t * p_buffer = (rx_buffer_t *)p_data;
725
726 assert(p_buffer->free == false);
727 (void)p_buffer;
728
729 result = nrf_802154_request_buffer_free(p_data);
730
731 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
732 return result;
733 }
734
735 #else // NRF_802154_USE_RAW_API
736
nrf_802154_buffer_free(uint8_t * p_data)737 void nrf_802154_buffer_free(uint8_t * p_data)
738 {
739 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
740
741 bool result;
742 rx_buffer_t * p_buffer = (rx_buffer_t *)(p_data - RAW_PAYLOAD_OFFSET);
743
744 assert(p_buffer->free == false);
745 (void)p_buffer;
746
747 result = nrf_802154_request_buffer_free(p_data - RAW_PAYLOAD_OFFSET);
748 assert(result);
749 (void)result;
750
751 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
752 }
753
nrf_802154_buffer_free_immediately(uint8_t * p_data)754 bool nrf_802154_buffer_free_immediately(uint8_t * p_data)
755 {
756 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
757
758 bool result;
759 rx_buffer_t * p_buffer = (rx_buffer_t *)(p_data - RAW_PAYLOAD_OFFSET);
760
761 assert(p_buffer->free == false);
762 (void)p_buffer;
763
764 result = nrf_802154_request_buffer_free(p_data - RAW_PAYLOAD_OFFSET);
765
766 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
767 return result;
768 }
769
770 #endif // NRF_802154_USE_RAW_API
771
nrf_802154_rssi_measure_begin(void)772 bool nrf_802154_rssi_measure_begin(void)
773 {
774 return nrf_802154_request_rssi_measure();
775 }
776
nrf_802154_rssi_last_get(void)777 int8_t nrf_802154_rssi_last_get(void)
778 {
779 int8_t result = 0;
780
781 if (!nrf_802154_request_rssi_measurement_get(&result))
782 {
783 result = NRF_802154_RSSI_INVALID;
784 }
785
786 return result;
787 }
788
nrf_802154_promiscuous_get(void)789 bool nrf_802154_promiscuous_get(void)
790 {
791 return nrf_802154_pib_promiscuous_get();
792 }
793
nrf_802154_promiscuous_set(bool enabled)794 void nrf_802154_promiscuous_set(bool enabled)
795 {
796 nrf_802154_pib_promiscuous_set(enabled);
797 }
798
nrf_802154_auto_ack_set(bool enabled)799 void nrf_802154_auto_ack_set(bool enabled)
800 {
801 nrf_802154_pib_auto_ack_set(enabled);
802 }
803
nrf_802154_auto_ack_get(void)804 bool nrf_802154_auto_ack_get(void)
805 {
806 return nrf_802154_pib_auto_ack_get();
807 }
808
nrf_802154_pan_coord_get(void)809 bool nrf_802154_pan_coord_get(void)
810 {
811 return nrf_802154_pib_pan_coord_get();
812 }
813
nrf_802154_pan_coord_set(bool enabled)814 void nrf_802154_pan_coord_set(bool enabled)
815 {
816 nrf_802154_pib_pan_coord_set(enabled);
817 }
818
nrf_802154_src_addr_matching_method_set(nrf_802154_src_addr_match_t match_method)819 void nrf_802154_src_addr_matching_method_set(nrf_802154_src_addr_match_t match_method)
820 {
821 nrf_802154_ack_data_src_addr_matching_method_set(match_method);
822 }
823
nrf_802154_ack_data_set(const uint8_t * p_addr,bool extended,const void * p_data,uint16_t length,nrf_802154_ack_data_t data_type)824 bool nrf_802154_ack_data_set(const uint8_t * p_addr,
825 bool extended,
826 const void * p_data,
827 uint16_t length,
828 nrf_802154_ack_data_t data_type)
829 {
830 return nrf_802154_ack_data_for_addr_set(p_addr, extended, data_type, p_data, length);
831 }
832
nrf_802154_ack_data_clear(const uint8_t * p_addr,bool extended,nrf_802154_ack_data_t data_type)833 bool nrf_802154_ack_data_clear(const uint8_t * p_addr,
834 bool extended,
835 nrf_802154_ack_data_t data_type)
836 {
837 return nrf_802154_ack_data_for_addr_clear(p_addr, extended, data_type);
838 }
839
nrf_802154_auto_pending_bit_set(bool enabled)840 void nrf_802154_auto_pending_bit_set(bool enabled)
841 {
842 nrf_802154_ack_data_enable(enabled);
843 }
844
nrf_802154_pending_bit_for_addr_set(const uint8_t * p_addr,bool extended)845 bool nrf_802154_pending_bit_for_addr_set(const uint8_t * p_addr, bool extended)
846 {
847 return nrf_802154_ack_data_for_addr_set(p_addr,
848 extended,
849 NRF_802154_ACK_DATA_PENDING_BIT,
850 NULL,
851 0);
852 }
853
nrf_802154_pending_bit_for_addr_clear(const uint8_t * p_addr,bool extended)854 bool nrf_802154_pending_bit_for_addr_clear(const uint8_t * p_addr, bool extended)
855 {
856 return nrf_802154_ack_data_for_addr_clear(p_addr, extended, NRF_802154_ACK_DATA_PENDING_BIT);
857 }
858
nrf_802154_pending_bit_for_addr_reset(bool extended)859 void nrf_802154_pending_bit_for_addr_reset(bool extended)
860 {
861 nrf_802154_ack_data_reset(extended, NRF_802154_ACK_DATA_PENDING_BIT);
862 }
863
nrf_802154_cca_cfg_set(const nrf_802154_cca_cfg_t * p_cca_cfg)864 void nrf_802154_cca_cfg_set(const nrf_802154_cca_cfg_t * p_cca_cfg)
865 {
866 nrf_802154_pib_cca_cfg_set(p_cca_cfg);
867
868 nrf_802154_request_cca_cfg_update();
869 }
870
nrf_802154_cca_cfg_get(nrf_802154_cca_cfg_t * p_cca_cfg)871 void nrf_802154_cca_cfg_get(nrf_802154_cca_cfg_t * p_cca_cfg)
872 {
873 nrf_802154_pib_cca_cfg_get(p_cca_cfg);
874 }
875
876 #if NRF_802154_CSMA_CA_ENABLED
877 #if NRF_802154_USE_RAW_API
878
nrf_802154_transmit_csma_ca_raw(uint8_t * p_data,const nrf_802154_transmit_csma_ca_metadata_t * p_metadata)879 bool nrf_802154_transmit_csma_ca_raw(uint8_t * p_data,
880 const nrf_802154_transmit_csma_ca_metadata_t * p_metadata)
881 {
882 bool result;
883
884 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
885
886 if (p_metadata == NULL)
887 {
888 static const nrf_802154_transmit_csma_ca_metadata_t metadata_default =
889 {
890 .frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
891 .tx_power = {.use_metadata_value = false}
892 };
893
894 p_metadata = &metadata_default;
895 }
896
897 result = are_frame_properties_valid(&p_metadata->frame_props);
898 if (result)
899 {
900 nrf_802154_request_csma_ca_start(p_data, p_metadata);
901 }
902
903 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
904 return result;
905 }
906
907 #else // NRF_802154_USE_RAW_API
908
nrf_802154_transmit_csma_ca(const uint8_t * p_data,uint8_t length,const nrf_802154_transmit_csma_ca_metadata_t * p_metadata)909 bool nrf_802154_transmit_csma_ca(const uint8_t * p_data,
910 uint8_t length,
911 const nrf_802154_transmit_csma_ca_metadata_t * p_metadata)
912 {
913 bool result;
914
915 nrf_802154_log_function_enter(NRF_802154_LOG_VERBOSITY_LOW);
916
917 if (p_metadata == NULL)
918 {
919 static const nrf_802154_transmit_csma_ca_metadata_t metadata_default =
920 {
921 .frame_props = NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT,
922 .tx_power = {.use_metadata_value = false}
923 };
924
925 p_metadata = &metadata_default;
926 }
927
928 result = are_frame_properties_valid(&p_metadata->frame_props);
929 if (result)
930 {
931 tx_buffer_fill(p_data, length);
932 nrf_802154_request_csma_ca_start(m_tx_buffer, p_metadata);
933 }
934
935 nrf_802154_log_function_exit(NRF_802154_LOG_VERBOSITY_LOW);
936 return result;
937 }
938
939 #endif // NRF_802154_USE_RAW_API
940
nrf_802154_csma_ca_min_be_set(uint8_t min_be)941 bool nrf_802154_csma_ca_min_be_set(uint8_t min_be)
942 {
943 return nrf_802154_pib_csmaca_min_be_set(min_be);
944 }
945
nrf_802154_csma_ca_min_be_get(void)946 uint8_t nrf_802154_csma_ca_min_be_get(void)
947 {
948 return nrf_802154_pib_csmaca_min_be_get();
949 }
950
nrf_802154_csma_ca_max_be_set(uint8_t max_be)951 bool nrf_802154_csma_ca_max_be_set(uint8_t max_be)
952 {
953 return nrf_802154_pib_csmaca_max_be_set(max_be);
954 }
955
nrf_802154_csma_ca_max_be_get(void)956 uint8_t nrf_802154_csma_ca_max_be_get(void)
957 {
958 return nrf_802154_pib_csmaca_max_be_get();
959 }
960
nrf_802154_csma_ca_max_backoffs_set(uint8_t max_backoffs)961 void nrf_802154_csma_ca_max_backoffs_set(uint8_t max_backoffs)
962 {
963 nrf_802154_pib_csmaca_max_backoffs_set(max_backoffs);
964 }
965
nrf_802154_csma_ca_max_backoffs_get(void)966 uint8_t nrf_802154_csma_ca_max_backoffs_get(void)
967 {
968 return nrf_802154_pib_csmaca_max_backoffs_get();
969 }
970
971 #endif // NRF_802154_CSMA_CA_ENABLED
972
973 #if NRF_802154_ACK_TIMEOUT_ENABLED
974
nrf_802154_ack_timeout_set(uint32_t time)975 void nrf_802154_ack_timeout_set(uint32_t time)
976 {
977 nrf_802154_ack_timeout_time_set(time);
978 }
979
980 #endif // NRF_802154_ACK_TIMEOUT_ENABLED
981
982 #if NRF_802154_IFS_ENABLED
983
nrf_802154_ifs_mode_get(void)984 nrf_802154_ifs_mode_t nrf_802154_ifs_mode_get(void)
985 {
986 return nrf_802154_pib_ifs_mode_get();
987 }
988
nrf_802154_ifs_mode_set(nrf_802154_ifs_mode_t mode)989 bool nrf_802154_ifs_mode_set(nrf_802154_ifs_mode_t mode)
990 {
991 return nrf_802154_pib_ifs_mode_set(mode);
992 }
993
nrf_802154_ifs_min_sifs_period_get(void)994 uint16_t nrf_802154_ifs_min_sifs_period_get(void)
995 {
996 return nrf_802154_pib_ifs_min_sifs_period_get();
997 }
998
nrf_802154_ifs_min_sifs_period_set(uint16_t period)999 void nrf_802154_ifs_min_sifs_period_set(uint16_t period)
1000 {
1001 nrf_802154_pib_ifs_min_sifs_period_set(period);
1002 }
1003
nrf_802154_ifs_min_lifs_period_get(void)1004 uint16_t nrf_802154_ifs_min_lifs_period_get(void)
1005 {
1006 return nrf_802154_pib_ifs_min_lifs_period_get();
1007 }
1008
nrf_802154_ifs_min_lifs_period_set(uint16_t period)1009 void nrf_802154_ifs_min_lifs_period_set(uint16_t period)
1010 {
1011 nrf_802154_pib_ifs_min_lifs_period_set(period);
1012 }
1013
1014 #endif // NRF_802154_IFS_ENABLED
1015
nrf_802154_capabilities_get(void)1016 nrf_802154_capabilities_t nrf_802154_capabilities_get(void)
1017 {
1018 nrf_802154_capabilities_t caps_drv = 0UL;
1019 nrf_802154_sl_capabilities_t caps_sl = nrf_802154_sl_capabilities_get();
1020
1021 /* Capabilities of the Service Layer depend on the version of it linked in,
1022 * hence require run-time probing. */
1023 caps_drv |= (NRF_802154_SL_CAPABILITY_CSMA & caps_sl) ?
1024 NRF_802154_CAPABILITY_CSMA : 0UL;
1025 caps_drv |= (NRF_802154_SL_CAPABILITY_DELAYED_TX & caps_sl) ?
1026 NRF_802154_CAPABILITY_DELAYED_TX : 0UL;
1027 caps_drv |= (NRF_802154_SL_CAPABILITY_DELAYED_RX & caps_sl) ?
1028 NRF_802154_CAPABILITY_DELAYED_RX : 0UL;
1029 caps_drv |= (NRF_802154_SL_CAPABILITY_ANT_DIVERSITY & caps_sl) ?
1030 NRF_802154_CAPABILITY_ANT_DIVERSITY : 0UL;
1031 caps_drv |= (NRF_802154_SL_CAPABILITY_TIMESTAMP & caps_sl) ?
1032 NRF_802154_CAPABILITY_TIMESTAMP : 0UL;
1033
1034 /* Some Radio Driver capabilities are configured at compile time. */
1035 caps_drv |= (NRF_802154_ACK_TIMEOUT_ENABLED ?
1036 NRF_802154_CAPABILITY_ACK_TIMEOUT : 0UL);
1037
1038 caps_drv |= ((NRF_802154_SECURITY_WRITER_ENABLED && NRF_802154_ENCRYPTION_ENABLED) ?
1039 NRF_802154_CAPABILITY_SECURITY : 0UL);
1040
1041 /* Both IFS and ACK Timeout features require SL timer, however
1042 * using them both at the same time requires that SL is able to schedule
1043 * several timers simultaneously.
1044 *
1045 * ACK Timeout capability takes precedence over IFS if only one timer
1046 * can be scheduled because there is no known usecase for IFS without ACK Timeout,
1047 * and this configuration would require additional testing. If such usecase emerges,
1048 * this logic should be updated.
1049 */
1050 if (NRF_802154_SL_CAPABILITY_MULTITIMER & caps_sl)
1051 {
1052 caps_drv |= (NRF_802154_IFS_ENABLED ?
1053 NRF_802154_CAPABILITY_IFS : 0UL);
1054 }
1055
1056 return caps_drv;
1057 }
1058
nrf_802154_time_get(void)1059 uint64_t nrf_802154_time_get(void)
1060 {
1061 return nrf_802154_sl_timer_current_time_get();
1062 }
1063
nrf_802154_security_global_frame_counter_set(uint32_t frame_counter)1064 void nrf_802154_security_global_frame_counter_set(uint32_t frame_counter)
1065 {
1066 nrf_802154_security_pib_global_frame_counter_set(frame_counter);
1067 }
1068
nrf_802154_security_global_frame_counter_set_if_larger(uint32_t frame_counter)1069 void nrf_802154_security_global_frame_counter_set_if_larger(uint32_t frame_counter)
1070 {
1071 nrf_802154_security_pib_global_frame_counter_set_if_larger(frame_counter);
1072 }
1073
nrf_802154_security_key_store(nrf_802154_key_t * p_key)1074 nrf_802154_security_error_t nrf_802154_security_key_store(nrf_802154_key_t * p_key)
1075 {
1076 return nrf_802154_security_pib_key_store(p_key);
1077 }
1078
nrf_802154_security_key_remove(nrf_802154_key_id_t * p_id)1079 nrf_802154_security_error_t nrf_802154_security_key_remove(nrf_802154_key_id_t * p_id)
1080 {
1081 return nrf_802154_security_pib_key_remove(p_id);
1082 }
1083
1084 #if NRF_802154_DELAYED_TRX_ENABLED && NRF_802154_IE_WRITER_ENABLED
1085
nrf_802154_csl_writer_period_set(uint16_t period)1086 void nrf_802154_csl_writer_period_set(uint16_t period)
1087 {
1088 nrf_802154_ie_writer_csl_period_set(period);
1089 }
1090
nrf_802154_csl_writer_anchor_time_set(uint64_t anchor_time)1091 void nrf_802154_csl_writer_anchor_time_set(uint64_t anchor_time)
1092 {
1093 nrf_802154_ie_writer_csl_anchor_time_set(anchor_time);
1094 }
1095
1096 #endif
1097
nrf_802154_custom_part_of_radio_init(void)1098 __WEAK void nrf_802154_custom_part_of_radio_init(void)
1099 {
1100 // Intentionally empty
1101 }
1102
nrf_802154_tx_ack_started(const uint8_t * p_data)1103 __WEAK void nrf_802154_tx_ack_started(const uint8_t * p_data)
1104 {
1105 (void)p_data;
1106 }
1107
1108 #if NRF_802154_USE_RAW_API
nrf_802154_received_raw(uint8_t * p_data,int8_t power,uint8_t lqi)1109 __WEAK void nrf_802154_received_raw(uint8_t * p_data, int8_t power, uint8_t lqi)
1110 {
1111 uint64_t timestamp;
1112
1113 nrf_802154_stat_timestamp_read(×tamp, last_rx_end_timestamp);
1114
1115 nrf_802154_received_timestamp_raw(p_data,
1116 power,
1117 lqi,
1118 timestamp);
1119 }
1120
nrf_802154_received_timestamp_raw(uint8_t * p_data,int8_t power,uint8_t lqi,uint64_t time)1121 __WEAK void nrf_802154_received_timestamp_raw(uint8_t * p_data,
1122 int8_t power,
1123 uint8_t lqi,
1124 uint64_t time)
1125 {
1126 (void)power;
1127 (void)lqi;
1128 (void)time;
1129
1130 nrf_802154_buffer_free_raw(p_data);
1131 }
1132
1133 #else // NRF_802154_USE_RAW_API
1134
nrf_802154_received(uint8_t * p_data,uint8_t length,int8_t power,uint8_t lqi)1135 __WEAK void nrf_802154_received(uint8_t * p_data, uint8_t length, int8_t power, uint8_t lqi)
1136 {
1137 nrf_802154_received_timestamp(p_data, length, power, lqi, last_rx_frame_timestamp_get());
1138 }
1139
nrf_802154_received_timestamp(uint8_t * p_data,uint8_t length,int8_t power,uint8_t lqi,uint32_t time)1140 __WEAK void nrf_802154_received_timestamp(uint8_t * p_data,
1141 uint8_t length,
1142 int8_t power,
1143 uint8_t lqi,
1144 uint32_t time)
1145 {
1146 (void)length;
1147 (void)power;
1148 (void)lqi;
1149 (void)time;
1150
1151 nrf_802154_buffer_free(p_data);
1152 }
1153
1154 #endif // !NRF_802154_USE_RAW_API
1155
nrf_802154_receive_failed(nrf_802154_rx_error_t error,uint32_t id)1156 __WEAK void nrf_802154_receive_failed(nrf_802154_rx_error_t error, uint32_t id)
1157 {
1158 (void)error;
1159 (void)id;
1160 }
1161
nrf_802154_tx_started(const uint8_t * p_frame)1162 __WEAK void nrf_802154_tx_started(const uint8_t * p_frame)
1163 {
1164 (void)p_frame;
1165 }
1166
1167 #if NRF_802154_USE_RAW_API
nrf_802154_transmitted_raw(uint8_t * p_frame,const nrf_802154_transmit_done_metadata_t * p_metadata)1168 __WEAK void nrf_802154_transmitted_raw(uint8_t * p_frame,
1169 const nrf_802154_transmit_done_metadata_t * p_metadata)
1170 {
1171 (void)p_frame;
1172
1173 uint8_t * p_ack = p_metadata->data.transmitted.p_ack;
1174
1175 if (p_ack != NULL)
1176 {
1177 nrf_802154_buffer_free_raw(p_ack);
1178 }
1179 }
1180
1181 #else // NRF_802154_USE_RAW_API
1182
nrf_802154_transmitted(uint8_t * p_frame,const nrf_802154_transmit_done_metadata_t * p_metadata)1183 __WEAK void nrf_802154_transmitted(uint8_t * p_frame,
1184 const nrf_802154_transmit_done_metadata_t * p_metadata)
1185
1186 {
1187 (void)p_frame;
1188
1189 uint8_t * p_ack = p_metadata->data.transmitted.p_ack;
1190
1191 if (p_ack != NULL)
1192 {
1193 nrf_802154_buffer_free(p_ack);
1194 }
1195 }
1196
1197 #endif // NRF_802154_USE_RAW_API
1198
nrf_802154_transmit_failed(uint8_t * p_frame,nrf_802154_tx_error_t error,const nrf_802154_transmit_done_metadata_t * p_metadata)1199 __WEAK void nrf_802154_transmit_failed(uint8_t * p_frame,
1200 nrf_802154_tx_error_t error,
1201 const nrf_802154_transmit_done_metadata_t * p_metadata)
1202 {
1203 (void)p_frame;
1204 (void)error;
1205 (void)p_metadata;
1206 }
1207
nrf_802154_energy_detected(uint8_t result)1208 __WEAK void nrf_802154_energy_detected(uint8_t result)
1209 {
1210 (void)result;
1211 }
1212
nrf_802154_energy_detection_failed(nrf_802154_ed_error_t error)1213 __WEAK void nrf_802154_energy_detection_failed(nrf_802154_ed_error_t error)
1214 {
1215 (void)error;
1216 }
1217
nrf_802154_cca_done(bool channel_free)1218 __WEAK void nrf_802154_cca_done(bool channel_free)
1219 {
1220 (void)channel_free;
1221 }
1222
nrf_802154_cca_failed(nrf_802154_cca_error_t error)1223 __WEAK void nrf_802154_cca_failed(nrf_802154_cca_error_t error)
1224 {
1225 (void)error;
1226 }
1227
1228 #if NRF_802154_TEST_MODES_ENABLED
1229
nrf_802154_test_mode_csmaca_backoff_get(void)1230 nrf_802154_test_mode_csmaca_backoff_t nrf_802154_test_mode_csmaca_backoff_get(void)
1231 {
1232 return nrf_802154_pib_test_mode_csmaca_backoff_get();
1233 }
1234
nrf_802154_test_mode_csmaca_backoff_set(nrf_802154_test_mode_csmaca_backoff_t value)1235 void nrf_802154_test_mode_csmaca_backoff_set(nrf_802154_test_mode_csmaca_backoff_t value)
1236 {
1237 nrf_802154_pib_test_mode_csmaca_backoff_set(value);
1238 }
1239
1240 #endif // NRF_802154_TEST_MODES_ENABLED
1241