nrfxlib API 3.3.99
Loading...
Searching...
No Matches
nrf_802154_facade_helpers.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025, 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_FACADE_HELPERS_H__
36#define NRF_802154_FACADE_HELPERS_H__
37
38#include "nrfx.h"
39#include "nrf_802154.h"
40#include "nrf_802154_config.h"
41#include "nrf_802154_types.h"
42
43#ifdef __STATIC_INLINE__
44#undef __STATIC_INLINE__
45#endif
46
47#ifdef NRF_802154_FACADE_HELPERS_DECLARE_ONLY
48#define __STATIC_INLINE__
49#else
50#define __STATIC_INLINE__ __STATIC_INLINE
51#endif
52
58__STATIC_INLINE__ const nrf_802154_transmit_metadata_t *
60
68__STATIC_INLINE__ bool nrf_802154_transmit_metadata_is_valid(
69 const nrf_802154_transmit_metadata_t * p_metadata);
70
77
85__STATIC_INLINE__ bool nrf_802154_transmit_at_metadata_is_valid(
86 const nrf_802154_transmit_at_metadata_t * p_metadata);
87
88#if NRF_802154_CSMA_CA_ENABLED
89
95__STATIC_INLINE__ const nrf_802154_transmit_csma_ca_metadata_t *
96nrf_802154_transmit_csma_ca_metadata_default_ptr_get(void);
97
105__STATIC_INLINE__ bool nrf_802154_transmit_csma_ca_metadata_is_valid(
106 const nrf_802154_transmit_csma_ca_metadata_t * p_metadata);
107
108#endif /* NRF_802154_CSMA_CA_ENABLED */
109
110#ifndef NRF_802154_FACADE_HELPERS_DECLARE_ONLY
111
113{
114 return p_props->dynamic_data_is_set || !(p_props->is_secured);
115}
116
118 const nrf_802154_transmit_at_metadata_t * p_metadata)
119{
120 return !p_metadata->cca || (p_metadata->extra_cca_attempts < UINT8_MAX);
121}
122
123static inline bool is_tx_timestamp_request_valid(const bool tx_timestamp_encode)
124{
125#if NRF_802154_TX_TIMESTAMP_PROVIDER_ENABLED
126 return true;
127#else
128 return !tx_timestamp_encode;
129#endif
130}
131
132__STATIC_INLINE__ const nrf_802154_transmit_metadata_t *
134{
135 static const nrf_802154_transmit_metadata_t metadata = {
137 .cca = true,
138 .tx_power = {.use_metadata_value = false},
139 .tx_channel = {.use_metadata_value = false},
140 .tx_timestamp_encode = false,
141 };
142
143 return &metadata;
144}
145
147 const nrf_802154_transmit_metadata_t * p_metadata)
148{
149 return are_frame_properties_valid(&p_metadata->frame_props) &&
151}
152
155{
156 static const nrf_802154_transmit_at_metadata_t initial_metadata =
157 {
159 .cca = true,
160 .tx_power = {.use_metadata_value = false},
161 .extra_cca_attempts = 0,
162 .tx_timestamp_encode = false,
163 };
164
165 *p_metadata = initial_metadata;
166 p_metadata->channel = nrf_802154_channel_get();
167}
168
170 const nrf_802154_transmit_at_metadata_t * p_metadata)
171{
172 return are_frame_properties_valid(&p_metadata->frame_props) &&
173 are_extra_cca_attempts_valid(p_metadata) &&
175}
176
177#if NRF_802154_CSMA_CA_ENABLED
178
179__STATIC_INLINE__ const nrf_802154_transmit_csma_ca_metadata_t *
180nrf_802154_transmit_csma_ca_metadata_default_ptr_get(void)
181{
182 static const nrf_802154_transmit_csma_ca_metadata_t metadata =
183 {
185 .tx_power = {.use_metadata_value = false},
186 .tx_channel = {.use_metadata_value = false},
187 .tx_timestamp_encode = false,
188 };
189
190 return &metadata;
191}
192
193__STATIC_INLINE__ bool nrf_802154_transmit_csma_ca_metadata_is_valid(
195{
196 return are_frame_properties_valid(&p_metadata->frame_props) &&
198}
199
200#endif /* NRF_802154_CSMA_CA_ENABLED */
201
202#endif /* NRF_802154_FACADE_HELPERS_DECLARE_ONLY */
203
204#endif // NRF_802154_FACADE_HELPERS_H__
#define NRF_802154_TRANSMITTED_FRAME_PROPS_DEFAULT_INIT
Default initializer for nrf_802154_transmitted_frame_props_t.
Definition nrf_802154_types.h:421
uint8_t nrf_802154_channel_get(void)
Gets the channel on which the radio operates.
__STATIC_INLINE bool nrf_802154_transmit_at_metadata_is_valid(const nrf_802154_transmit_at_metadata_t *p_metadata)
Checks if transmit metadata for timed transmissions is valid.
Definition nrf_802154_facade_helpers.h:169
static bool are_frame_properties_valid(const nrf_802154_transmitted_frame_props_t *p_props)
Definition nrf_802154_facade_helpers.h:112
static bool is_tx_timestamp_request_valid(const bool tx_timestamp_encode)
Definition nrf_802154_facade_helpers.h:123
__STATIC_INLINE void nrf_802154_transmit_at_metadata_default_prepare(nrf_802154_transmit_at_metadata_t *p_metadata)
Prepares a default transmit metadata for timed transmissions.
Definition nrf_802154_facade_helpers.h:153
__STATIC_INLINE const nrf_802154_transmit_metadata_t * nrf_802154_transmit_metadata_default_ptr_get(void)
Gets a pointer to the default transmit metadata.
Definition nrf_802154_facade_helpers.h:133
static bool are_extra_cca_attempts_valid(const nrf_802154_transmit_at_metadata_t *p_metadata)
Definition nrf_802154_facade_helpers.h:117
__STATIC_INLINE bool nrf_802154_transmit_metadata_is_valid(const nrf_802154_transmit_metadata_t *p_metadata)
Checks if transmit metadata is valid.
Definition nrf_802154_facade_helpers.h:146
uint8_t extra_cca_attempts
Definition nrf_802154_types.h:448
bool cca
Definition nrf_802154_types.h:445
nrf_802154_transmitted_frame_props_t frame_props
Definition nrf_802154_types.h:444
bool tx_timestamp_encode
Definition nrf_802154_types.h:449
uint8_t channel
Definition nrf_802154_types.h:446
Structure with transmit request metadata for scheduling transmission at a specific time.
Definition nrf_802154_types.h:443
bool tx_timestamp_encode
Definition nrf_802154_types.h:460
nrf_802154_transmitted_frame_props_t frame_props
Definition nrf_802154_types.h:457
Structure with transmit request metadata for transmission preceded by CSMA-CA procedure.
Definition nrf_802154_types.h:456
nrf_802154_transmitted_frame_props_t frame_props
Definition nrf_802154_types.h:432
bool tx_timestamp_encode
Definition nrf_802154_types.h:436
Structure with transmit request metadata for simple transmission request.
Definition nrf_802154_types.h:431
bool dynamic_data_is_set
Definition nrf_802154_types.h:390
bool is_secured
Definition nrf_802154_types.h:389
Structure with frame properties associated with the transmission operation.
Definition nrf_802154_types.h:388