nrfxlib API 3.3.99
Loading...
Searching...
No Matches
nrf_802154_procedures_duration.h
Go to the documentation of this file.
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
40#ifndef NRF_802154_PROCEDURES_DURATION_H_
41#define NRF_802154_PROCEDURES_DURATION_H_
42
43#include <stdbool.h>
44#include <stdint.h>
45#include "nrfx.h"
46
47#include "nrf_802154_const.h"
48
49#ifdef __STATIC_INLINE__
50#undef __STATIC_INLINE__
51#endif
52
53#ifdef NRF_802154_PROCEDURES_DURATION_DECLARE_ONLY
54#define __STATIC_INLINE__
55#else
56#define __STATIC_INLINE__ __STATIC_INLINE
57#endif
58
59#define TX_RAMP_UP_TIME 40 // us
60#define RX_RAMP_UP_TIME 40 // us
61#define RX_RAMP_DOWN_TIME 0 // us
62#define MAX_RAMP_DOWN_TIME 6 // us
63#if defined(NRF54L_SERIES)
64#define RX_TX_TURNAROUND_TIME_HW 15 // us
65#else
66#define RX_TX_TURNAROUND_TIME_HW 20 // us
67#endif
68
69#define RX_TX_TURNAROUND_TIME (RX_TX_TURNAROUND_TIME_HW + \
70 NRF_802154_CCAIDLE_TO_TXEN_EXTRA_TIME_US)
71
72#define RX_PHYEND_EVENT_LATENCY_US 23
73#define RSSI_SETTLE_TIME_US 15
74
75#define A_CCA_DURATION_SYMBOLS 8 // sym
76#define A_TURNAROUND_TIME_SYMBOLS 12 // sym
77#define A_UNIT_BACKOFF_SYMBOLS 20 // sym
78
79#define PHY_SYMBOLS_FROM_OCTETS(octets) ((octets) * PHY_SYMBOLS_PER_OCTET)
80#define PHY_US_TIME_FROM_SYMBOLS(symbols) ((symbols) * PHY_US_PER_SYMBOL)
81
82#define IMM_ACK_SYMBOLS (PHY_SHR_SYMBOLS + \
83 PHY_SYMBOLS_FROM_OCTETS(IMM_ACK_LENGTH + PHR_SIZE))
84#define IMM_ACK_DURATION (PHY_US_TIME_FROM_SYMBOLS(IMM_ACK_SYMBOLS))
85
86#define MAC_IMM_ACK_WAIT_SYMBOLS (A_UNIT_BACKOFF_SYMBOLS + \
87 A_TURNAROUND_TIME_SYMBOLS + \
88 IMM_ACK_SYMBOLS)
89
91#define MAX_PHY_FRAME_TIME_US \
92 PHY_US_TIME_FROM_SYMBOLS( \
93 PHY_SHR_SYMBOLS + PHY_SYMBOLS_FROM_OCTETS(PHR_SIZE + MAX_PACKET_SIZE))
94
95__STATIC_INLINE__ uint16_t nrf_802154_frame_duration_get(uint8_t psdu_length,
96 bool shr,
97 bool phr);
98
99__STATIC_INLINE__ uint16_t nrf_802154_tx_duration_get(uint8_t psdu_length,
100 bool cca,
101 bool ack_requested);
102
103__STATIC_INLINE__ uint16_t nrf_802154_cca_before_tx_duration_get(void);
104
105__STATIC_INLINE__ uint16_t nrf_802154_rx_duration_get(uint8_t psdu_length, bool ack_requested);
106
107__STATIC_INLINE__ uint16_t nrf_802154_cca_duration_get(void);
108
109#ifndef NRF_802154_PROCEDURES_DURATION_DECLARE_ONLY
110
111__STATIC_INLINE__ uint16_t nrf_802154_frame_duration_get(uint8_t psdu_length,
112 bool shr,
113 bool phr)
114{
115 uint16_t us_time = PHY_US_TIME_FROM_SYMBOLS(PHY_SYMBOLS_FROM_OCTETS(psdu_length));
116
117 if (phr)
118 {
120 }
121
122 if (shr)
123 {
125 }
126
127 return us_time;
128}
129
130__STATIC_INLINE__ uint16_t nrf_802154_tx_duration_get(uint8_t psdu_length,
131 bool cca,
132 bool ack_requested)
133{
134 // ramp down
135 // if CCA: + RX ramp up + CCA + RX ramp down
136 // + TX ramp up + SHR + PHR + PSDU
137 // if ACK: + macAckWaitDuration
139 psdu_length,
140 true,
141 true);
142
143 if (ack_requested)
144 {
146 }
147
148 if (cca)
149 {
152 }
153
154 return us_time;
155}
156
157__STATIC_INLINE__ uint16_t nrf_802154_cca_before_tx_duration_get(void)
158{
159 // CCA + turnaround time
161
162 return us_time;
163}
164
166__STATIC_INLINE__ uint16_t nrf_802154_ack_duration_with_turnaround_get(void)
167{
168 // aTurnaroundTime + ACK frame duration
172}
173
174__STATIC_INLINE__ uint16_t nrf_802154_rx_duration_get(uint8_t psdu_length, bool ack_requested)
175{
176 // SHR + PHR + PSDU
177 // if ACK: + aTurnaroundTime + ACK frame duration
178 uint16_t us_time = nrf_802154_frame_duration_get(psdu_length, true, true);
179
180 if (ack_requested)
181 {
183 }
184
185 return us_time;
186}
187
188__STATIC_INLINE__ uint16_t nrf_802154_cca_duration_get(void)
189{
190 // ramp down + rx ramp up + CCA
191 uint16_t us_time = MAX_RAMP_DOWN_TIME +
194
195 return us_time;
196}
197
198#endif /* NRF_802154_PROCEDURES_DURATION_DECLARE_ONLY */
199
200#endif /* NRF_802154_PROCEDURES_DURATION_H_ */
#define PHR_SIZE
Definition nrf_802154_const.h:166
#define PHY_SHR_SYMBOLS
Definition nrf_802154_const.h:181
#define IMM_ACK_LENGTH
Definition nrf_802154_const.h:157
#define RX_RAMP_UP_TIME
Definition nrf_802154_procedures_duration.h:60
#define A_TURNAROUND_TIME_SYMBOLS
Definition nrf_802154_procedures_duration.h:76
__STATIC_INLINE uint16_t nrf_802154_frame_duration_get(uint8_t psdu_length, bool shr, bool phr)
Definition nrf_802154_procedures_duration.h:111
__STATIC_INLINE uint16_t nrf_802154_ack_duration_with_turnaround_get(void)
Get the duration of the Ack frame along with turnaround in microseconds.
Definition nrf_802154_procedures_duration.h:166
#define PHY_US_TIME_FROM_SYMBOLS(symbols)
Definition nrf_802154_procedures_duration.h:80
#define A_CCA_DURATION_SYMBOLS
Definition nrf_802154_procedures_duration.h:75
#define PHY_SYMBOLS_FROM_OCTETS(octets)
Definition nrf_802154_procedures_duration.h:79
__STATIC_INLINE uint16_t nrf_802154_rx_duration_get(uint8_t psdu_length, bool ack_requested)
Definition nrf_802154_procedures_duration.h:174
#define RX_RAMP_DOWN_TIME
Definition nrf_802154_procedures_duration.h:61
__STATIC_INLINE uint16_t nrf_802154_cca_before_tx_duration_get(void)
Definition nrf_802154_procedures_duration.h:157
#define RX_TX_TURNAROUND_TIME
Definition nrf_802154_procedures_duration.h:69
#define MAX_RAMP_DOWN_TIME
Definition nrf_802154_procedures_duration.h:62
#define MAC_IMM_ACK_WAIT_SYMBOLS
Definition nrf_802154_procedures_duration.h:86
__STATIC_INLINE uint16_t nrf_802154_cca_duration_get(void)
Definition nrf_802154_procedures_duration.h:188
__STATIC_INLINE uint16_t nrf_802154_tx_duration_get(uint8_t psdu_length, bool cca, bool ack_requested)
Definition nrf_802154_procedures_duration.h:130
#define TX_RAMP_UP_TIME
Definition nrf_802154_procedures_duration.h:59