Loading...
Searching...
No Matches
nrf24l01p_ng_types.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Otto-von-Guericke-Universität Magdeburg
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#include <stdint.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
29#define NRF24L01P_NG_TRANSITION_TO_POWER_DOWN (1 << 3)
34#define NRF24L01P_NG_TRANSITION_TO_STANDBY_1 (1 << 4)
39#define NRF24L01P_NG_TRANSITION_TO_STANDBY_2 (1 << 5)
44#define NRF24L01P_NG_TRANSITION_TO_RX_MODE (1 << 6)
49#define NRF24L01P_NG_TRANSITION_TO_TX_MODE (1 << 7)
50
81
94
105
129
138
150
161
162struct nrf24l01p_ng;
165
173static inline
175{
176 if (address_width <= NRF24L01P_NG_AW_3BYTE) {
177 return 3;
178 }
179 if (address_width == NRF24L01P_NG_AW_4BYTE) {
180 return 4;
181 }
182 return 5;
183}
184
192static inline
194{
195 if (address_width <= 3) {
197 }
198 if (address_width == 4) {
200 }
202}
203
211static inline
213{
214 if (retr_delay >= NRF24L01P_NG_ARD_4000US) {
215 return 4000;
216 }
217 return (retr_delay + 1) * 250;
218}
219
227static inline
229{
230 if (retr_delay >= 4000) {
232 }
233 if (retr_delay < 250) {
235 }
236 return (nrf24l01p_ng_ard_t)((retr_delay / 250) - 1);
237}
238
246static inline
248{
249 if (crc_len <= NRF24L01P_NG_CRC_0BYTE) {
250 return 0;
251 }
252 if (crc_len == NRF24L01P_NG_CRC_1BYTE) {
253 return 1;
254 }
255 return 2;
256}
257
265static inline
267{
268 if (!crc_len) {
270 }
271 if (crc_len == 1) {
273 }
275}
276
284static inline
286{
288 return -18;
289 }
291 return -12;
292 }
294 return -6;
295 }
296 return 0;
297}
298
306static inline
308{
309 if (power <= -18) {
311 }
312 if (power <= -12) {
314 }
315 if (power <= -6) {
317 }
319}
320
328static inline
330{
331 if (data_rate == NRF24L01P_NG_RF_DR_1MBPS) {
332 return 1000;
333 }
334 if (data_rate == NRF24L01P_NG_RF_DR_250KBPS) {
335 return 250;
336 }
337 return 2000;
338}
339
347static inline
349{
350 if (data_rate <= 250) {
352 }
353 if (data_rate <= 1000) {
355 }
357}
358
359#ifdef __cplusplus
360}
361#endif
362
enum nrf24l01p_ng_rfdr nrf24l01p_ng_rfdr_t
Possible values to configure the data rate.
nrf24l01p_ng_pipe
Enumeration of NRF24L01+ data pipes.
@ NRF24L01P_NG_P0
Pipe 0.
@ NRF24L01P_NG_P5
Pipe 5.
@ NRF24L01P_NG_P3
Pipe 3.
@ NRF24L01P_NG_P2
Pipe 2.
@ NRF24L01P_NG_PX_NUM_OF
Number of supported pipes.
@ NRF24L01P_NG_P1
Pipe 1.
@ NRF24L01P_NG_P4
Pipe 4.
#define NRF24L01P_NG_TRANSITION_TO_STANDBY_2
Flag that indicates that a state transition to STANDBY_2 can be done.
nrf24l01p_ng_rfdr
Possible values to configure the data rate.
@ NRF24L01P_NG_RF_DR_250KBPS
250 kbit/s
@ NRF24L01P_NG_RF_DR_2MBPS
2 Mbit/s
@ NRF24L01P_NG_RF_DR_NUM_OF
Number of possible values to configure the data rate.
@ NRF24L01P_NG_RF_DR_1MBPS
1 Mbit/s
#define NRF24L01P_NG_TRANSITION_TO_POWER_DOWN
Flag that indicates that a state transition to POWER_DOWN can be done.
nrf24l01p_ng_crc
Possible values to configure the CRC length.
@ NRF24L01P_NG_CRC_2BYTE
2 bytes CRC length
@ NRF24L01P_NG_CRC_0BYTE
0 bytes CRC length
@ NRF24L01P_NG_CRC_1BYTE
1 byte CRC length
#define NRF24L01P_NG_TRANSITION_TO_RX_MODE
Flag that indicates that a state transition to RX_MODE can be done.
static nrf24l01p_ng_tx_power_t nrf24l01p_ng_valtoe_tx_power(int16_t power)
Convert RF power in [dbm] to nrf24l01p_ng_tx_power_t.
#define NRF24L01P_NG_TRANSITION_TO_STANDBY_1
Flag that indicates that a state transition to STANDBY_1 can be done.
static nrf24l01p_ng_aw_t nrf24l01p_ng_valtoe_aw(uint8_t address_width)
Convert address width in [bytes] to nrf24l01p_ng_aw_t.
struct nrf24l01p_ng nrf24l01p_ng_t
typedef of forward declaration
static uint16_t nrf24l01p_ng_etoval_rfdr(nrf24l01p_ng_rfdr_t data_rate)
Convert nrf24l01p_ng_rfdr_t to actual air data rate.
enum nrf24l01p_ng_aw nrf24l01p_ng_aw_t
Possible values to configure the layer-2 address width.
nrf24l01p_ng_state
NRF24L01+ operation states.
@ NRF24L01P_NG_STATE_RX_MODE
Constantly search for a valid packet.
@ NRF24L01P_NG_STATE_POWER_DOWN
Register values are available and maintained, SPI active.
@ NRF24L01P_NG_STATE_STANDBY_2
TX FIFO empty, fill up TX FIFO again.
@ NRF24L01P_NG_STATE_STANDBY_1
Idle.
@ NRF24L01P_NG_STATE_UNDEFINED
State right after voltage supply.
@ NRF24L01P_NG_STATE_TX_MODE
Transmit next packet.
enum nrf24l01p_ng_pipe nrf24l01p_ng_pipe_t
Enumeration of NRF24L01+ data pipes.
static uint8_t nrf24l01p_ng_etoval_aw(nrf24l01p_ng_aw_t address_width)
Convert nrf24l01p_ng_aw_t to actual address width.
nrf24l01p_ng_aw
Possible values to configure the layer-2 address width.
@ NRF24L01P_NG_AW_NUM_OF
Number of possible values to configure the layer-2 address width.
@ NRF24L01P_NG_AW_4BYTE
Use a 4 bytes long layer-2 address.
@ NRF24L01P_NG_AW_5BYTE
Use a 5 bytes long layer-2 address.
@ NRF24L01P_NG_AW_3BYTE
Use a 3 bytes long layer-2 address.
static nrf24l01p_ng_ard_t nrf24l01p_ng_valtoe_ard(uint16_t retr_delay)
Convert retransmission delay in [us] to nrf24l01p_ng_ard_t.
enum nrf24l01p_ng_ard nrf24l01p_ng_ard_t
Possible values to configure the retransmission delay in ESB.
nrf24l01p_ng_tx_power
Possible values to configure the radio power.
@ NRF24L01P_NG_TX_POWER_MINUS_6DBM
-6 dBm
@ NRF24L01P_NG_TX_POWER_0DBM
0 dBm
@ NRF24L01P_NG_TX_POWER_NUM_OF
Number of possible values to configure the radio power.
@ NRF24L01P_NG_TX_POWER_MINUS_18DBM
-18 dBm
@ NRF24L01P_NG_TX_POWER_MINUS_12DBM
-12 dBm
static nrf24l01p_ng_crc_t nrf24l01p_ng_valtoe_crc(uint8_t crc_len)
Convert CRC length in [bytes] to nrf24l01p_ng_crc_t.
enum nrf24l01p_ng_state nrf24l01p_ng_state_t
NRF24L01+ operation states.
enum nrf24l01p_ng_crc nrf24l01p_ng_crc_t
Possible values to configure the CRC length.
#define NRF24L01P_NG_TRANSITION_TO_TX_MODE
Flag that indicates that a state transition to TX_MODE can be done.
nrf24l01p_ng_ard
Possible values to configure the retransmission delay in ESB.
@ NRF24L01P_NG_ARD_2000US
2000 us
@ NRF24L01P_NG_ARD_3000US
3000 us
@ NRF24L01P_NG_ARD_3750US
3750 us
@ NRF24L01P_NG_ARD_1750US
1750 us
@ NRF24L01P_NG_ARD_3250US
3250 us
@ NRF24L01P_NG_ARD_NUM_OF
Number of possible values to configure the retransmission delay.
@ NRF24L01P_NG_ARD_2750US
2750 us
@ NRF24L01P_NG_ARD_250US
250 us
@ NRF24L01P_NG_ARD_750US
750 us
@ NRF24L01P_NG_ARD_4000US
4000 us
@ NRF24L01P_NG_ARD_2250US
2250 us
@ NRF24L01P_NG_ARD_2500US
2500 us
@ NRF24L01P_NG_ARD_3500US
3500 us
@ NRF24L01P_NG_ARD_1250US
1250 us
@ NRF24L01P_NG_ARD_1000US
1000 us
@ NRF24L01P_NG_ARD_500US
500 us
@ NRF24L01P_NG_ARD_1500US
1500 us
static uint16_t nrf24l01p_ng_etoval_ard(nrf24l01p_ng_ard_t retr_delay)
Convert nrf24l01p_ng_ard_t to actual retransmission delay.
static int8_t nrf24l01p_ng_etoval_tx_power(nrf24l01p_ng_tx_power_t power)
Convert nrf24l01p_ng_tx_power_t to actual Tx power.
static nrf24l01p_ng_rfdr_t nrf24l01p_ng_valtoe_rfdr(uint16_t data_rate)
Convert Air data rate in [kbit/s] to nrf24l01p_ng_rfdr_t.
enum nrf24l01p_ng_tx_power nrf24l01p_ng_tx_power_t
Possible values to configure the radio power.
static uint8_t nrf24l01p_ng_etoval_crc(nrf24l01p_ng_crc_t crc_len)
Convert nrf24l01p_ng_crc_t to actual CRC length.
NRF24L01+ device struct.