nrf24l01p_ng_registers.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  */
17 #ifndef NRF24L01P_NG_REGISTERS_H
18 #define NRF24L01P_NG_REGISTERS_H
19 
20 #include <stdint.h>
21 
22 #include "nrf24l01p_ng.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
38 #define NRF24L01P_NG_REG_CONFIG (0x00)
42 #define NRF24L01P_NG_FLG_MASK_RX_DR (0x40)
46 #define NRF24L01P_NG_VAL_MASK_RX_DR(reg) (((reg) & \
47  NRF24L01P_NG_FLG_MASK_RX_DR) >> 6)
51 #define NRF24L01P_NG_FLG_MASK_TX_DS (0x20)
55 #define NRF24L01P_NG_VAL_MASK_TX_DS(reg) (((reg) & \
56  NRF24L01P_NG_FLG_MASK_TX_DS) >> 5)
60 #define NRF24L01P_NG_FLG_MASK_MAX_RT (0x10)
64 #define NRF24L01P_NG_VAL_MASK_MAX_RT (((reg) & \
65  NRF24L01P_NG_FLG_MASK_MAX_RT) >> 4)
69 #define NRF24L01P_NG_FLG_EN_CRC (0x08)
73 #define NRF24L01P_NG_VAL_EN_CRC(reg) (((reg) & \
74  NRF24L01P_NG_FLG_EN_CRC) >> 3)
78 #define NRF24L01P_NG_FLG_CRCO_1_BYTE (0x00)
82 #define NRF24L01P_NG_FLG_CRCO_2_BYTE (0x04)
86 #define NRF24L01P_NG_MSK_CRC (0x0c)
90 #define NRF24L01P_NG_FLG_CRCO(val) (((val) << 2) & \
91  NRF24L01P_NG_MSK_CRC)
95 #define NRF24L01P_NG_VAL_CRCO(reg) (((reg) & \
96  NRF24L01P_NG_FLG_CRCO_2_BYTE) >> 2)
100 #define NRF24L01P_NG_FLG_PWR_UP (0x02)
104 #define NRF24L01P_NG_VAL_PWR_UP(reg) (((reg) & \
105  NRF24L01P_NG_FLG_PWR_UP) >> 1)
109 #define NRF24L01P_NG_FLG_PRIM_RX (0x01)
113 #define NRF24L01P_NG_VAL_PRIM_RX(reg) ((reg) & NRF24L01P_NG_FLG_PRIM_RX)
125 #define NRF24L01P_NG_REG_EN_AA (0x01)
129 #define NRF24L01P_NG_FLG_ENAA_P5 (0x20)
133 #define NRF24L01P_NG_VAL_ENAA_P5(reg) (((reg) & \
134  NRF24L01P_NG_FLG_ENAA_P5) >> 5)
138 #define NRF24L01P_NG_FLG_ENAA_P4 (0x10)
142 #define NRF24L01P_NG_VAL_ENAA_P4(reg) (((reg) & \
143  NRF24L01P_NG_FLG_ENAA_P4) >> 4)
147 #define NRF24L01P_NG_FLG_ENAA_P3 (0x08)
151 #define NRF24L01P_NG_VAL_ENAA_P3(reg) (((reg) & \
152  NRF24L01P_NG_FLG_ENAA_P3) >> 3)
156 #define NRF24L01P_NG_FLG_ENAA_P2 (0x04)
160 #define NRF24L01P_NG_VAL_ENAA_P2(reg) (((reg) & \
161  NRF24L01P_NG_FLG_ENAA_P2) >> 2)
165 #define NRF24L01P_NG_FLG_ENAA_P1 (0x02)
169 #define NRF24L01P_NG_VAL_ENAA_P1(reg) (((reg) & \
170  NRF24L01P_NG_FLG_ENAA_P1) >> 1)
174 #define NRF24L01P_NG_FLG_ENAA_P0 (0x01)
178 #define NRF24L01P_NG_VAL_ENAA_P0(reg) ((reg) & NRF24L01P_NG_FLG_ENAA_P0)
190 #define NRF24L01P_NG_REG_EN_RXADDR (0x02)
194 #define NRF24L01P_NG_FLG_ERX_P5 (0x20)
198 #define NRF24L01P_NG_VAL_ERX_P5(reg) (((reg) & \
199  NRF24L01P_NG_FLG_ERX_P5) >> 5)
203 #define NRF24L01P_NG_FLG_ERX_P4 (0x10)
207 #define NRF24L01P_NG_VAL_ERX_P4(reg) (((reg) & \
208  NRF24L01P_NG_FLG_ERX_P4) >> 4)
212 #define NRF24L01P_NG_FLG_ERX_P3 (0x08)
216 #define NRF24L01P_NG_VAL_ERX_P3(reg) (((reg) & \
217  NRF24L01P_NG_FLG_ERX_P3) >> 3)
221 #define NRF24L01P_NG_FLG_ERX_P2 (0x04)
225 #define NRF24L01P_NG_VAL_ERX_P2(reg) (((reg) & \
226  NRF24L01P_NG_FLG_ERX_P2) >> 2)
230 #define NRF24L01P_NG_FLG_ERX_P1 (0x02)
234 #define NRF24L01P_NG_VAL_ERX_P1(reg) (((reg) & \
235  NRF24L01P_NG_FLG_ERX_P1) >> 1)
239 #define NRF24L01P_NG_FLG_ERX_P0 (0x01)
243 #define NRF24L01P_NG_VAL_ERX_P0(reg) ((reg) & NRF24L01P_NG_FLG_ERX_P0)
255 #define NRF24L01P_NG_REG_SETUP_AW (0x03)
259 #define NRF24L01P_NG_FLG_AW_3 (0x01)
263 #define NRF24L01P_NG_FLG_AW_4 (0x02)
267 #define NRF24L01P_NG_FLG_AW_5 (0x03)
271 #define NRF24L01P_NG_MSK_AW (0x03)
275 #define NRF24L01P_NG_FLG_AW(val) ((val) & NRF24L01P_NG_MSK_AW)
279 #define NRF24L01P_NG_VAL_AW(reg) ((reg) & NRF24L01P_NG_MSK_AW)
291 #define NRF24L01P_NG_REG_SETUP_RETR (0x04)
295 #define NRF24L01P_NG_FLG_ARD_250_US (0x00)
299 #define NRF24L01P_NG_FLG_ARD_500_US (0x10)
303 #define NRF24L01P_NG_FLG_ARD_750_US (0x20)
307 #define NRF24L01P_NG_FLG_ARD_1000_US (0x30)
311 #define NRF24L01P_NG_FLG_ARD_1250_US (0x40)
315 #define NRF24L01P_NG_FLG_ARD_1500_US (0x50)
319 #define NRF24L01P_NG_FLG_ARD_1750_US (0x60)
323 #define NRF24L01P_NG_FLG_ARD_2000_US (0x70)
327 #define NRF24L01P_NG_FLG_ARD_2250_US (0x80)
331 #define NRF24L01P_NG_FLG_ARD_2500_US (0x90)
335 #define NRF24L01P_NG_FLG_ARD_2750_US (0xa0)
339 #define NRF24L01P_NG_FLG_ARD_3000_US (0xb0)
343 #define NRF24L01P_NG_FLG_ARD_3250_US (0xc0)
347 #define NRF24L01P_NG_FLG_ARD_3500_US (0xd0)
351 #define NRF24L01P_NG_FLG_ARD_3750_US (0xe0)
355 #define NRF24L01P_NG_FLG_ARD_4000_US (0xf0)
359 #define NRF24L01P_NG_MSK_ARD (0xf0)
363 #define NRF24L01P_NG_FLG_ARD(val) (((val) << 4) & \
364  NRF24L01P_NG_MSK_ARD)
368 #define NRF24L01P_NG_VAL_ARD(reg) (((reg) & \
369  NRF24L01P_NG_MSK_ARD) >> 4)
373 #define NRF24L01P_NG_MSK_ARC (0x0f)
377 #define NRF24L01P_NG_FLG_ARC(val) ((val) & NRF24L01P_NG_MSK_ARC)
381 #define NRF24L01P_NG_VAL_ARC(reg) ((reg) & NRF24L01P_NG_MSK_ARC)
393 #define NRF24L01P_NG_REG_RF_CH (0x05)
397 #define NRF24L01P_NG_MSK_RF_CH (0x7f)
401 #define NRF24L01P_NG_FLG_RF_CH(val) ((val) & NRF24L01P_NG_MSK_RF_CH)
405 #define NRF24L01P_NG_VAL_RF_CH(reg) ((reg) & NRF24L01P_NG_MSK_RF_CH)
417 #define NRF24L01P_NG_REG_RF_SETUP (0x06)
421 #define NRF24L01P_NG_FLG_CONT_WAVE (0x80)
425 #define NRF24L01P_NG_VAL_CONT_WAVE(reg) (((reg) & \
426  NRF24L01P_NG_FLG_CONT_WAVE) >> 7)
430 #define NRF24L01P_NG_FLG_RF_DR_LOW (0x20)
434 #define NRF24L01P_NG_VAL_RF_DR_LOW(reg) (((reg) & \
435  NRF24L01P_NG_FLG_RF_DR_LOW) >> 5)
439 #define NRF24L01P_NG_FLG_PLL_LOCK (0x10)
443 #define NRF24L01P_NG_VAL_PLL_LOCK(reg) (((reg) & \
444  NRF24L01P_NG_FLG_PLL_LOCK) >> 4)
448 #define NRF24L01P_NG_FLG_RF_DR_HIGH (0x08)
452 #define NRF24L01P_NG_VAL_RF_DR_HIGH(reg) (((reg) & \
453  NRF24L01P_NG_FLG_RF_DR_HIGH) >> 3)
457 #define NRF24L01P_NG_FLG_RF_DR_250_KBPS (0x08)
461 #define NRF24L01P_NG_FLG_RF_DR_1_MBPS (0x00)
465 #define NRF24L01P_NG_FLG_RF_DR_2_MBPS (0x20)
469 #define NRF24L01P_NG_MSK_RF_DR (0x28)
473 #define NRF24L01P_NG_FLG_RF_DR(val) ((((val) & 1) << 5) | \
474  (((val) & 2) << 2))
478 #define NRF24L01P_NG_VAL_RF_DR(reg) ((((reg) & \
479  NRF24L01P_NG_FLG_RF_DR_LOW) >> 5) \
480  | \
481  (((reg) & \
482  NRF24L01P_NG_FLG_RF_DR_HIGH) >> 2))
486 #define NRF24L01P_NG_FLG_RF_PWR_MINUS_18 (0x00)
490 #define NRF24L01P_NG_FLG_RF_PWR_MINUS_12 (0x02)
494 #define NRF24L01P_NG_FLG_RF_PWR_MINUS_6 (0x04)
498 #define NRF24L01P_NG_FLG_RF_PWR_0 (0x06)
502 #define NRF24L01P_NG_MSK_RF_PWR (0x06)
506 #define NRF24L01P_NG_FLG_RF_PWR(val) (((val) << 1) & \
507  NRF24L01P_NG_MSK_RF_PWR)
511 #define NRF24L01P_NG_VAL_RF_PWR(reg) (((reg) & \
512  NRF24L01P_NG_MSK_RF_PWR) >> 1)
524 #define NRF24L01P_NG_REG_STATUS (0x07)
528 #define NRF24L01P_NG_FLG_RX_DR (0x40)
532 #define NRF24L01P_NG_VAL_RX_DR(reg) (((reg) & \
533  NRF24L01P_NG_FLG_RX_DR) >> 6)
537 #define NRF24L01P_NG_FLG_TX_DS (0x20)
541 #define NRF24L01P_NG_VAL_TX_DS(reg) (((reg) & \
542  NRF24L01P_NG_FLG_TX_DS) >> 5)
546 #define NRF24L01P_NG_FLG_MAX_RT (0x10)
550 #define NRF24L01P_NG_VAL_MAX_RT(reg) (((reg) & \
551  NRF24L01P_NG_FLG_MAX_RT) >> 4)
552 
556 #define NRF24L01P_NG_FLG_RX_P_NO_NONE (0x0e)
560 #define NRF24L01P_NG_MSK_RX_P_NO (0x0e)
564 #define NRF24L01P_NG_FLG_RX_P_NO(val) (((val) << 1) & \
565  NRF24L01P_NG_MSK_RX_P_NO)
569 #define NRF24L01P_NG_VAL_RX_P_NO(reg) (((reg) & \
570  NRF24L01P_NG_MSK_RX_P_NO) >> 1)
571 
575 #define NRF24L01P_NG_FLG_TX_FULL (0x01)
579 #define NRF24L01P_NG_VAL_TX_FULL(reg) ((reg) & NRF24L01P_NG_FLG_TX_FULL)
591 #define NRF24L01P_NG_REG_OBSERVE_TX (0x08)
595 #define NRF24L01P_NG_MSK_PLOS_CNT (0xf0)
599 #define NRF24L01P_NG_FLG_PLOS_CNT(val) (((val) << 4) & \
600  NRF24L01P_NG_MSK_PLOS_CNT)
604 #define NRF24L01P_NG_VAL_PLOS_CNT(reg) (((reg) & \
605  NRF24L01P_NG_MSK_PLOS_CNT) >> 4)
606 
610 #define NRF24L01P_NG_MSK_ARC_CNT (0x0f)
614 #define NRF24L01P_NG_FLG_ARC_CNT(val) ((val) & NRF24L01P_NG_MSK_ARC_CNT)
618 #define NRF24L01P_NG_VAL_ARC_CNT(reg) ((reg) & NRF24L01P_NG_MSK_ARC_CNT)
630 #define NRF24L01P_NG_REG_RPD (0x09)
634 #define NRF24L01P_NG_FLG_RPD (0x01)
638 #define NRF24L01P_NG_VAL_RPD(reg) ((reg) & NRF24L01P_NG_FLG_RPD)
650 #define NRF24L01P_NG_REG_RX_ADDR_P0 (0x0A)
654 #define NRF24L01P_NG_REG_RX_ADDR_P1 (0x0B)
658 #define NRF24L01P_NG_REG_RX_ADDR_P2 (0x0C)
662 #define NRF24L01P_NG_REG_RX_ADDR_P3 (0x0D)
666 #define NRF24L01P_NG_REG_RX_ADDR_P4 (0x0E)
670 #define NRF24L01P_NG_REG_RX_ADDR_P5 (0x0F)
674 #define NRF24L01P_NG_REG_TX_ADDR (0x10)
686 #define NRF24L01P_NG_REG_RX_PW_P0 (0x11)
690 #define NRF24L01P_NG_REG_RX_PW_P1 (0x12)
694 #define NRF24L01P_NG_REG_RX_PW_P2 (0x13)
698 #define NRF24L01P_NG_REG_RX_PW_P3 (0x14)
702 #define NRF24L01P_NG_REG_RX_PW_P4 (0x15)
706 #define NRF24L01P_NG_REG_RX_PW_P5 (0x16)
710 #define NRF24L01P_NG_MSK_RX_PW_PX (0x1f)
714 #define NRF24L01P_NG_FLG_RX_PW_PX(val) ((val) & NRF24L01P_NG_MSK_RX_PW_PX)
718 #define NRF24L01P_NG_VAL_RX_PW_PX(reg) ((reg) & NRF24L01P_NG_MSK_RX_PW_PX)
730 #define NRF24L01P_NG_REG_FIFO_STATUS (0x17)
734 #define NRF24L01P_NG_FLG_TX_REUSE (0x40)
738 #define NRF24L01P_NG_VAL_TX_REUSE(reg) (((reg) & \
739  NRF24L01P_NG_FLG_TX_REUSE) >> 6)
744 #define NRF24L01P_NG_FLG_TX_FULL_ (0x20)
748 #define NRF24L01P_NG_VAL_TX_FULL_(reg) (((reg) & \
749  NRF24L01P_NG_FLG_TX_FULL_) >> 5)
753 #define NRF24L01P_NG_FLG_TX_EMPTY (0x10)
757 #define NRF24L01P_NG_VAL_TX_EMPTY(reg) (((reg) & \
758  NRF24L01P_NG_FLG_TX_EMPTY) >> 4)
762 #define NRF24L01P_NG_FLG_RX_FULL (0x02)
766 #define NRF24L01P_NG_VAL_RX_FULL(reg) (((reg) & \
767  NRF24L01P_NG_FLG_RX_FULL) >> 1)
771 #define NRF24L01P_NG_FLG_RX_EMPTY (0x01)
775 #define NRF24L01P_NG_VAL_RX_EMPTY(reg) ((reg) & NRF24L01P_NG_FLG_RX_EMPTY)
787 #define NRF24L01P_NG_REG_DYNPD (0x1C)
791 #define NRF24L01P_NG_FLG_DPL_P5 (0x20)
795 #define NRF24L01P_NG_VAL_DPL_P5(reg) (((reg) & \
796  NRF24L01P_NG_FLG_DPL_P5) >> 5)
800 #define NRF24L01P_NG_FLG_DPL_P4 (0x10)
804 #define NRF24L01P_NG_VAL_DPL_P4(reg) (((reg) & \
805  NRF24L01P_NG_FLG_DPL_P4) >> 4)
809 #define NRF24L01P_NG_FLG_DPL_P3 (0x08)
813 #define NRF24L01P_NG_VAL_DPL_P3(reg) (((reg) & \
814  NRF24L01P_NG_FLG_DPL_P3) >> 3)
818 #define NRF24L01P_NG_FLG_DPL_P2 (0x04)
822 #define NRF24L01P_NG_VAL_DPL_P2(reg) (((reg) & \
823  NRF24L01P_NG_FLG_DPL_P2) >> 2)
827 #define NRF24L01P_NG_FLG_DPL_P1 (0x02)
831 #define NRF24L01P_NG_VAL_DPL_P1(reg) (((reg) & \
832  NRF24L01P_NG_FLG_DPL_P1) >> 1)
836 #define NRF24L01P_NG_FLG_DPL_P0 (0x01)
840 #define NRF24L01P_NG_VAL_DPL_P0(reg) ((reg) & NRF24L01P_NG_FLG_DPL_P0)
852 #define NRF24L01P_NG_REG_FEATURES (0x1D)
856 #define NRF24L01P_NG_FLG_EN_DPL (0x04)
860 #define NRF24L01P_NG_VAL_EN_DPL(reg) (((reg) & \
861  NRF24L01P_NG_FLG_EN_DPL) >> 2)
865 #define NRF24L01P_NG_FLG_EN_ACK_PAY (0x02)
869 #define NRF24L01P_NG_VAL_EN_ACK_PAY(reg) (((reg) & \
870  NRF24L01P_NG_FLG_EN_ACK_PAY) >> 1)
874 #define NRF24L01P_NG_FLG_EN_DYN_ACK (0x01)
878 #define NRF24L01P_NG_VAL_EN_DYN_ACK(reg) ((reg) & \
879  NRF24L01P_NG_FLG_EN_DYN_ACK)
890 static inline
891 uint8_t nrf24l01p_ng_reg8_read(const nrf24l01p_ng_t *dev, uint8_t reg_addr) {
892  uint8_t reg_val;
893  nrf24l01p_ng_read_reg(dev, reg_addr, &reg_val, 1);
894  return reg_val;
895 }
896 
906 static inline
908  uint8_t reg_addr, uint8_t reg_val) {
909  return nrf24l01p_ng_write_reg(dev, reg_addr, &reg_val, 1);
910 }
911 
921 static inline
923  uint8_t reg_addr, uint8_t *reg_val) {
924  uint8_t reg_val_old;
925  nrf24l01p_ng_read_reg(dev, reg_addr, &reg_val_old, sizeof(reg_val_old));
926  *reg_val = reg_val_old | *reg_val;
927  return nrf24l01p_ng_write_reg(dev, reg_addr, reg_val, sizeof(*reg_val));
928 }
938 static inline
940  uint8_t reg_addr, uint8_t *reg_val) {
941  uint8_t reg_val_old;
942  nrf24l01p_ng_read_reg(dev, reg_addr, &reg_val_old, sizeof(reg_val_old));
943  *reg_val = reg_val_old &= ~(*reg_val);
944  return nrf24l01p_ng_write_reg(dev, reg_addr, reg_val, sizeof(*reg_val));
945 }
946 
957 static inline
958 uint8_t nrf24l01p_ng_reg8_mod(const nrf24l01p_ng_t *dev, uint8_t reg_addr,
959  uint8_t mask, uint8_t *reg_val) {
960  uint8_t reg_val_old;
961  nrf24l01p_ng_read_reg(dev, reg_addr, &reg_val_old, sizeof(reg_val_old));
962  reg_val_old &= ~mask;
963  *reg_val = reg_val_old | *reg_val;
964  return nrf24l01p_ng_write_reg(dev, reg_addr, reg_val, sizeof(*reg_val));
965 }
966 
967 #ifdef __cplusplus
968 }
969 #endif
970 
971 #endif /* NRF24L01P_NG_REGISTERS_H */
Public interface for NRF24L01+ (NG) devices.
Functions to communicate with the NRF24L01+ (NG) transceiver via SPI.
uint8_t nrf24l01p_ng_write_reg(const nrf24l01p_ng_t *dev, uint8_t reg, const uint8_t *src, size_t len)
Write a register value.
uint8_t nrf24l01p_ng_read_reg(const nrf24l01p_ng_t *dev, uint8_t reg, uint8_t *dest, size_t len)
Read a register value.
static uint8_t nrf24l01p_ng_reg8_set(const nrf24l01p_ng_t *dev, uint8_t reg_addr, uint8_t *reg_val)
Set bits in a certain 8-bit register.
static uint8_t nrf24l01p_ng_reg8_read(const nrf24l01p_ng_t *dev, uint8_t reg_addr)
Read the contents of an 8 bit register.
static uint8_t nrf24l01p_ng_reg8_clear(const nrf24l01p_ng_t *dev, uint8_t reg_addr, uint8_t *reg_val)
Clear bits in a certain 8-bit register.
static uint8_t nrf24l01p_ng_reg8_mod(const nrf24l01p_ng_t *dev, uint8_t reg_addr, uint8_t mask, uint8_t *reg_val)
Modify bits in a certain 8-bit register.
static uint8_t nrf24l01p_ng_reg8_write(const nrf24l01p_ng_t *dev, uint8_t reg_addr, uint8_t reg_val)
Write the contents of an 8 bit register.
NRF24L01+ device struct.
Definition: nrf24l01p_ng.h:142