Loading...
Searching...
No Matches
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 */
18#ifndef NRF24L01P_NG_TYPES_H
19#define NRF24L01P_NG_TYPES_H
20
21#include <stdint.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
31#define NRF24L01P_NG_TRANSITION_TO_POWER_DOWN (1 << 3)
36#define NRF24L01P_NG_TRANSITION_TO_STANDBY_1 (1 << 4)
41#define NRF24L01P_NG_TRANSITION_TO_STANDBY_2 (1 << 5)
46#define NRF24L01P_NG_TRANSITION_TO_RX_MODE (1 << 6)
51#define NRF24L01P_NG_TRANSITION_TO_TX_MODE (1 << 7)
52
83
96
107
131
140
152
163
164struct nrf24l01p_ng;
175static inline
177{
178 if (address_width <= NRF24L01P_NG_AW_3BYTE) {
179 return 3;
180 }
181 if (address_width == NRF24L01P_NG_AW_4BYTE) {
182 return 4;
183 }
184 return 5;
185}
186
194static inline
196{
197 if (address_width <= 3) {
199 }
200 if (address_width == 4) {
202 }
204}
205
213static inline
215{
216 if (retr_delay >= NRF24L01P_NG_ARD_4000US) {
217 return 4000;
218 }
219 return (retr_delay + 1) * 250;
220}
221
229static inline
231{
232 if (retr_delay >= 4000) {
234 }
235 if (retr_delay < 250) {
237 }
238 return (nrf24l01p_ng_ard_t)((retr_delay / 250) - 1);
239}
240
248static inline
250{
251 if (crc_len <= NRF24L01P_NG_CRC_0BYTE) {
252 return 0;
253 }
254 if (crc_len == NRF24L01P_NG_CRC_1BYTE) {
255 return 1;
256 }
257 return 2;
258}
259
267static inline
269{
270 if (!crc_len) {
272 }
273 if (crc_len == 1) {
275 }
277}
278
286static inline
288{
290 return -18;
291 }
293 return -12;
294 }
296 return -6;
297 }
298 return 0;
299}
300
308static inline
310{
311 if (power <= -18) {
313 }
314 if (power <= -12) {
316 }
317 if (power <= -6) {
319 }
321}
322
330static inline
332{
333 if (data_rate == NRF24L01P_NG_RF_DR_1MBPS) {
334 return 1000;
335 }
336 if (data_rate == NRF24L01P_NG_RF_DR_250KBPS) {
337 return 250;
338 }
339 return 2000;
340}
341
349static inline
351{
352 if (data_rate <= 250) {
354 }
355 if (data_rate <= 1000) {
357 }
359}
360
361#ifdef __cplusplus
362}
363#endif
364
365#endif /* NRF24L01P_NG_TYPES_H */
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.