nrf24l01p_ng_types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Otto-von-Guericke-Universität Magdeburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
22 #include <stdint.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
32 #define NRF24L01P_NG_TRANSITION_TO_POWER_DOWN (1 << 3)
37 #define NRF24L01P_NG_TRANSITION_TO_STANDBY_1 (1 << 4)
42 #define NRF24L01P_NG_TRANSITION_TO_STANDBY_2 (1 << 5)
47 #define NRF24L01P_NG_TRANSITION_TO_RX_MODE (1 << 6)
52 #define NRF24L01P_NG_TRANSITION_TO_TX_MODE (1 << 7)
53 
57 typedef enum nrf24l01p_ng_state {
84 
88 typedef enum nrf24l01p_ng_pipe {
97 
101 typedef enum nrf24l01p_ng_aw {
108 
112 typedef enum nrf24l01p_ng_ard {
132 
136 typedef enum nrf24l01p_ng_crc {
141 
145 typedef enum nrf24l01p_ng_tx_power {
153 
157 typedef enum nrf24l01p_ng_rfdr {
164 
165 struct nrf24l01p_ng;
166 typedef struct nrf24l01p_ng nrf24l01p_ng_t;
176 static inline
178 {
179  if (address_width <= NRF24L01P_NG_AW_3BYTE) {
180  return 3;
181  }
182  if (address_width == NRF24L01P_NG_AW_4BYTE) {
183  return 4;
184  }
185  return 5;
186 }
187 
195 static inline
197 {
198  if (address_width <= 3) {
199  return NRF24L01P_NG_AW_3BYTE;
200  }
201  if (address_width == 4) {
202  return NRF24L01P_NG_AW_4BYTE;
203  }
204  return NRF24L01P_NG_AW_5BYTE;
205 }
206 
214 static inline
216 {
217  if (retr_delay >= NRF24L01P_NG_ARD_4000US) {
218  return 4000;
219  }
220  return (retr_delay + 1) * 250;
221 }
222 
230 static inline
232 {
233  if (retr_delay >= 4000) {
235  }
236  if (retr_delay < 250) {
237  return NRF24L01P_NG_ARD_250US;
238  }
239  return (nrf24l01p_ng_ard_t)((retr_delay / 250) - 1);
240 }
241 
249 static inline
251 {
252  if (crc_len <= NRF24L01P_NG_CRC_0BYTE) {
253  return 0;
254  }
255  if (crc_len == NRF24L01P_NG_CRC_1BYTE) {
256  return 1;
257  }
258  return 2;
259 }
260 
268 static inline
270 {
271  if (!crc_len) {
272  return NRF24L01P_NG_CRC_0BYTE;
273  }
274  if (crc_len == 1) {
275  return NRF24L01P_NG_CRC_1BYTE;
276  }
277  return NRF24L01P_NG_CRC_2BYTE;
278 }
279 
287 static inline
289 {
290  if (power == NRF24L01P_NG_TX_POWER_MINUS_18DBM) {
291  return -18;
292  }
293  if (power == NRF24L01P_NG_TX_POWER_MINUS_12DBM) {
294  return -12;
295  }
296  if (power == NRF24L01P_NG_TX_POWER_MINUS_6DBM) {
297  return -6;
298  }
299  return 0;
300 }
301 
309 static inline
311 {
312  if (power <= -18) {
314  }
315  if (power <= -12) {
317  }
318  if (power <= -6) {
320  }
322 }
323 
331 static inline
333 {
334  if (data_rate == NRF24L01P_NG_RF_DR_1MBPS) {
335  return 1000;
336  }
337  if (data_rate == NRF24L01P_NG_RF_DR_250KBPS) {
338  return 250;
339  }
340  return 2000;
341 }
342 
350 static inline
352 {
353  if (data_rate <= 250) {
355  }
356  if (data_rate <= 1000) {
358  }
360 }
361 
362 #ifdef __cplusplus
363 }
364 #endif
365 
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.
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.
Definition: nrf24l01p_ng.h:143