acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

nRF24.h (24247B)

      1 #if !defined(_RADIOLIB_NRF24_H) && !defined(RADIOLIB_EXCLUDE_NRF24)
      2 #define _RADIOLIB_NRF24_H
      3 
      4 #include "../../Module.h"
      5 #include "../../TypeDef.h"
      6 
      7 #include "../../protocols/PhysicalLayer/PhysicalLayer.h"
      8 
      9 // nRF24 physical layer properties
     10 #define RADIOLIB_NRF24_FREQUENCY_STEP_SIZE                     1000000.0
     11 #define RADIOLIB_NRF24_MAX_PACKET_LENGTH                       32
     12 
     13 // nRF24 SPI commands
     14 #define RADIOLIB_NRF24_CMD_READ                                0b00000000
     15 #define RADIOLIB_NRF24_CMD_WRITE                               0b00100000
     16 #define RADIOLIB_NRF24_CMD_READ_RX_PAYLOAD                     0b01100001
     17 #define RADIOLIB_NRF24_CMD_WRITE_TX_PAYLOAD                    0b10100000
     18 #define RADIOLIB_NRF24_CMD_FLUSH_TX                            0b11100001
     19 #define RADIOLIB_NRF24_CMD_FLUSH_RX                            0b11100010
     20 #define RADIOLIB_NRF24_CMD_REUSE_TX_PAXLOAD                    0b11100011
     21 #define RADIOLIB_NRF24_CMD_READ_RX_PAYLOAD_WIDTH               0b01100000
     22 #define RADIOLIB_NRF24_CMD_WRITE_ACK_PAYLOAD                   0b10101000
     23 #define RADIOLIB_NRF24_CMD_WRITE_TX_PAYLOAD_NOACK              0b10110000
     24 #define RADIOLIB_NRF24_CMD_NOP                                 0b11111111
     25 
     26 // nRF24 register map
     27 #define RADIOLIB_NRF24_REG_CONFIG                              0x00
     28 #define RADIOLIB_NRF24_REG_EN_AA                               0x01
     29 #define RADIOLIB_NRF24_REG_EN_RXADDR                           0x02
     30 #define RADIOLIB_NRF24_REG_SETUP_AW                            0x03
     31 #define RADIOLIB_NRF24_REG_SETUP_RETR                          0x04
     32 #define RADIOLIB_NRF24_REG_RF_CH                               0x05
     33 #define RADIOLIB_NRF24_REG_RF_SETUP                            0x06
     34 #define RADIOLIB_NRF24_REG_STATUS                              0x07
     35 #define RADIOLIB_NRF24_REG_OBSERVE_TX                          0x08
     36 #define RADIOLIB_NRF24_REG_RPD                                 0x09
     37 #define RADIOLIB_NRF24_REG_RX_ADDR_P0                          0x0A
     38 #define RADIOLIB_NRF24_REG_RX_ADDR_P1                          0x0B
     39 #define RADIOLIB_NRF24_REG_RX_ADDR_P2                          0x0C
     40 #define RADIOLIB_NRF24_REG_RX_ADDR_P3                          0x0D
     41 #define RADIOLIB_NRF24_REG_RX_ADDR_P4                          0x0E
     42 #define RADIOLIB_NRF24_REG_RX_ADDR_P5                          0x0F
     43 #define RADIOLIB_NRF24_REG_TX_ADDR                             0x10
     44 #define RADIOLIB_NRF24_REG_RX_PW_P0                            0x11
     45 #define RADIOLIB_NRF24_REG_RX_PW_P1                            0x12
     46 #define RADIOLIB_NRF24_REG_RX_PW_P2                            0x13
     47 #define RADIOLIB_NRF24_REG_RX_PW_P3                            0x14
     48 #define RADIOLIB_NRF24_REG_RX_PW_P4                            0x15
     49 #define RADIOLIB_NRF24_REG_RX_PW_P5                            0x16
     50 #define RADIOLIB_NRF24_REG_FIFO_STATUS                         0x17
     51 #define RADIOLIB_NRF24_REG_DYNPD                               0x1C
     52 #define RADIOLIB_NRF24_REG_FEATURE                             0x1D
     53 
     54 // NRF24_REG_CONFIG                                                   MSB   LSB   DESCRIPTION
     55 #define RADIOLIB_NRF24_MASK_RX_DR_IRQ_OFF                      0b01000000  //  6     6     RX_DR will not be reflected on IRQ pin
     56 #define RADIOLIB_NRF24_MASK_RX_DR_IRQ_ON                       0b00000000  //  6     6     RX_DR will be reflected on IRQ pin as active low (default)
     57 #define RADIOLIB_NRF24_MASK_TX_DS_IRQ_OFF                      0b00100000  //  5     5     TX_DS will not be reflected on IRQ pin
     58 #define RADIOLIB_NRF24_MASK_TX_DS_IRQ_ON                       0b00000000  //  5     5     TX_DS will be reflected on IRQ pin as active low (default)
     59 #define RADIOLIB_NRF24_MASK_MAX_RT_IRQ_OFF                     0b00010000  //  4     4     MAX_RT will not be reflected on IRQ pin
     60 #define RADIOLIB_NRF24_MASK_MAX_RT_IRQ_ON                      0b00000000  //  4     4     MAX_RT will be reflected on IRQ pin as active low (default)
     61 #define RADIOLIB_NRF24_CRC_OFF                                 0b00000000  //  3     3     CRC calculation: disabled
     62 #define RADIOLIB_NRF24_CRC_ON                                  0b00001000  //  3     3                      enabled (default)
     63 #define RADIOLIB_NRF24_CRC_8                                   0b00000000  //  2     2     CRC scheme: CRC8 (default)
     64 #define RADIOLIB_NRF24_CRC_16                                  0b00000100  //  2     2                 CRC16
     65 #define RADIOLIB_NRF24_POWER_UP                                0b00000010  //  1     1     power up
     66 #define RADIOLIB_NRF24_POWER_DOWN                              0b00000000  //  1     1     power down
     67 #define RADIOLIB_NRF24_PTX                                     0b00000000  //  0     0     enable primary Tx
     68 #define RADIOLIB_NRF24_PRX                                     0b00000001  //  0     0     enable primary Rx
     69 
     70 // NRF24_REG_EN_AA
     71 #define RADIOLIB_NRF24_AA_ALL_OFF                              0b00000000  //  5     0     auto-ACK on all pipes: disabled
     72 #define RADIOLIB_NRF24_AA_ALL_ON                               0b00111111  //  5     0                         enabled (default)
     73 #define RADIOLIB_NRF24_AA_P5_OFF                               0b00000000  //  5     5     auto-ACK on pipe 5: disabled
     74 #define RADIOLIB_NRF24_AA_P5_ON                                0b00100000  //  5     5                         enabled (default)
     75 #define RADIOLIB_NRF24_AA_P4_OFF                               0b00000000  //  4     4     auto-ACK on pipe 4: disabled
     76 #define RADIOLIB_NRF24_AA_P4_ON                                0b00010000  //  4     4                         enabled (default)
     77 #define RADIOLIB_NRF24_AA_P3_OFF                               0b00000000  //  3     3     auto-ACK on pipe 3: disabled
     78 #define RADIOLIB_NRF24_AA_P3_ON                                0b00001000  //  3     3                         enabled (default)
     79 #define RADIOLIB_NRF24_AA_P2_OFF                               0b00000000  //  2     2     auto-ACK on pipe 2: disabled
     80 #define RADIOLIB_NRF24_AA_P2_ON                                0b00000100  //  2     2                         enabled (default)
     81 #define RADIOLIB_NRF24_AA_P1_OFF                               0b00000000  //  1     1     auto-ACK on pipe 1: disabled
     82 #define RADIOLIB_NRF24_AA_P1_ON                                0b00000010  //  1     1                         enabled (default)
     83 #define RADIOLIB_NRF24_AA_P0_OFF                               0b00000000  //  0     0     auto-ACK on pipe 0: disabled
     84 #define RADIOLIB_NRF24_AA_P0_ON                                0b00000001  //  0     0                         enabled (default)
     85 
     86 // NRF24_REG_EN_RXADDR
     87 #define RADIOLIB_NRF24_P5_OFF                                  0b00000000  //  5     5     receive pipe 5: disabled (default)
     88 #define RADIOLIB_NRF24_P5_ON                                   0b00100000  //  5     5                     enabled
     89 #define RADIOLIB_NRF24_P4_OFF                                  0b00000000  //  4     4     receive pipe 4: disabled (default)
     90 #define RADIOLIB_NRF24_P4_ON                                   0b00010000  //  4     4                     enabled
     91 #define RADIOLIB_NRF24_P3_OFF                                  0b00000000  //  3     3     receive pipe 3: disabled (default)
     92 #define RADIOLIB_NRF24_P3_ON                                   0b00001000  //  3     3                     enabled
     93 #define RADIOLIB_NRF24_P2_OFF                                  0b00000000  //  2     2     receive pipe 2: disabled (default)
     94 #define RADIOLIB_NRF24_P2_ON                                   0b00000100  //  2     2                     enabled
     95 #define RADIOLIB_NRF24_P1_OFF                                  0b00000000  //  1     1     receive pipe 1: disabled
     96 #define RADIOLIB_NRF24_P1_ON                                   0b00000010  //  1     1                     enabled (default)
     97 #define RADIOLIB_NRF24_P0_OFF                                  0b00000000  //  0     0     receive pipe 0: disabled
     98 #define RADIOLIB_NRF24_P0_ON                                   0b00000001  //  0     0                     enabled (default)
     99 
    100 // NRF24_REG_SETUP_AW
    101 #define RADIOLIB_NRF24_ADDRESS_2_BYTES                         0b00000000  //  1     0     address width: 2 bytes
    102 #define RADIOLIB_NRF24_ADDRESS_3_BYTES                         0b00000001  //  1     0                    3 bytes
    103 #define RADIOLIB_NRF24_ADDRESS_4_BYTES                         0b00000010  //  1     0                    4 bytes
    104 #define RADIOLIB_NRF24_ADDRESS_5_BYTES                         0b00000011  //  1     0                    5 bytes (default)
    105 
    106 // NRF24_REG_SETUP_RETR
    107 #define RADIOLIB_NRF24_ARD                                     0b00000000  //  7     4     auto retransmit delay: t[us] = (NRF24_ARD + 1) * 250 us
    108 #define RADIOLIB_NRF24_ARC_OFF                                 0b00000000  //  3     0     auto retransmit count: auto retransmit disabled
    109 #define RADIOLIB_NRF24_ARC                                     0b00000011  //  3     0                            up to 3 retransmits on AA fail (default)
    110 
    111 // NRF24_REG_RF_CH
    112 #define RADIOLIB_NRF24_RF_CH                                   0b00000010  //  6     0     RF channel: f_CH[MHz] = 2400 MHz + NRF24_RF_CH
    113 
    114 // NRF24_REG_RF_SETUP
    115 #define RADIOLIB_NRF24_CONT_WAVE_OFF                           0b00000000  //  7     7     continuous carrier transmit: disabled (default)
    116 #define RADIOLIB_NRF24_CONT_WAVE_ON                            0b10000000  //  7     7                                  enabled
    117 #define RADIOLIB_NRF24_DR_250_KBPS                             0b00100000  //  5     5     data rate: 250 kbps
    118 #define RADIOLIB_NRF24_DR_1_MBPS                               0b00000000  //  3     3                1 Mbps (default)
    119 #define RADIOLIB_NRF24_DR_2_MBPS                               0b00001000  //  3     3                2 Mbps
    120 #define RADIOLIB_NRF24_PLL_LOCK_ON                             0b00010000  //  4     4     force PLL lock: enabled
    121 #define RADIOLIB_NRF24_PLL_LOCK_OFF                            0b00000000  //  4     4                     disabled (default)
    122 #define RADIOLIB_NRF24_RF_PWR_18_DBM                           0b00000000  //  2     1     output power: -18 dBm
    123 #define RADIOLIB_NRF24_RF_PWR_12_DBM                           0b00000010  //  2     1                   -12 dBm
    124 #define RADIOLIB_NRF24_RF_PWR_6_DBM                            0b00000100  //  2     1                   -6 dBm
    125 #define RADIOLIB_NRF24_RF_PWR_0_DBM                            0b00000110  //  2     1                   0 dBm (default)
    126 
    127 // NRF24_REG_STATUS
    128 #define RADIOLIB_NRF24_RX_DR                                   0b01000000  //  6     6     Rx data ready
    129 #define RADIOLIB_NRF24_TX_DS                                   0b00100000  //  5     5     Tx data sent
    130 #define RADIOLIB_NRF24_MAX_RT                                  0b00010000  //  4     4     maximum number of retransmits reached (must be cleared to continue)
    131 #define RADIOLIB_NRF24_RX_FIFO_EMPTY                           0b00001110  //  3     1     Rx FIFO is empty
    132 #define RADIOLIB_NRF24_RX_P_NO                                 0b00000000  //  3     1     number of data pipe that received data
    133 #define RADIOLIB_NRF24_TX_FIFO_FULL                            0b00000001  //  0     0     Tx FIFO is full
    134 
    135 // NRF24_REG_OBSERVE_TX
    136 #define RADIOLIB_NRF24_PLOS_CNT                                0b00000000  //  7     4     number of lost packets
    137 #define RADIOLIB_NRF24_ARC_CNT                                 0b00000000  //  3     0     number of retransmitted packets
    138 
    139 // NRF24_REG_RPD
    140 #define RADIOLIB_NRF24_RP_BELOW_64_DBM                         0b00000000  //  0     0     received power in the current channel: less than -64 dBm
    141 #define RADIOLIB_NRF24_RP_ABOVE_64_DBM                         0b00000001  //  0     0                                            more than -64 dBm
    142 
    143 // NRF24_REG_FIFO_STATUS
    144 #define RADIOLIB_NRF24_TX_REUSE                                0b01000000  //  6     6     reusing last transmitted payload
    145 #define RADIOLIB_NRF24_TX_FIFO_FULL_FLAG                       0b00100000  //  5     5     Tx FIFO is full
    146 #define RADIOLIB_NRF24_TX_FIFO_EMPTY_FLAG                      0b00010000  //  4     4     Tx FIFO is empty
    147 #define RADIOLIB_NRF24_RX_FIFO_FULL_FLAG                       0b00000010  //  1     1     Rx FIFO is full
    148 #define RADIOLIB_NRF24_RX_FIFO_EMPTY_FLAG                      0b00000001  //  0     0     Rx FIFO is empty
    149 
    150 // NRF24_REG_DYNPD
    151 #define RADIOLIB_NRF24_DPL_P5_OFF                              0b00000000  //  5     5     dynamic payload length on pipe 5: disabled (default)
    152 #define RADIOLIB_NRF24_DPL_P5_ON                               0b00100000  //  5     5                                       enabled
    153 #define RADIOLIB_NRF24_DPL_P4_OFF                              0b00000000  //  4     4     dynamic payload length on pipe 4: disabled (default)
    154 #define RADIOLIB_NRF24_DPL_P4_ON                               0b00010000  //  4     4                                       enabled
    155 #define RADIOLIB_NRF24_DPL_P3_OFF                              0b00000000  //  3     3     dynamic payload length on pipe 3: disabled (default)
    156 #define RADIOLIB_NRF24_DPL_P3_ON                               0b00001000  //  3     3                                       enabled
    157 #define RADIOLIB_NRF24_DPL_P2_OFF                              0b00000000  //  2     2     dynamic payload length on pipe 2: disabled (default)
    158 #define RADIOLIB_NRF24_DPL_P2_ON                               0b00000100  //  2     2                                       enabled
    159 #define RADIOLIB_NRF24_DPL_P1_OFF                              0b00000000  //  1     1     dynamic payload length on pipe 1: disabled (default)
    160 #define RADIOLIB_NRF24_DPL_P1_ON                               0b00000010  //  1     1                                       enabled
    161 #define RADIOLIB_NRF24_DPL_P0_OFF                              0b00000000  //  0     0     dynamic payload length on pipe 0: disabled (default)
    162 #define RADIOLIB_NRF24_DPL_P0_ON                               0b00000001  //  0     0                                       enabled
    163 #define RADIOLIB_NRF24_DPL_ALL_OFF                             0b00000000  //  5     0     disable all dynamic payloads
    164 #define RADIOLIB_NRF24_DPL_ALL_ON                              0b00111111  //  5     0     enable all dynamic payloads
    165 
    166 // NRF24_REG_FEATURE
    167 #define RADIOLIB_NRF24_DPL_OFF                                 0b00000000  //  2     2     dynamic payload length: disabled (default)
    168 #define RADIOLIB_NRF24_DPL_ON                                  0b00000100  //  2     2                             enabled
    169 #define RADIOLIB_NRF24_ACK_PAY_OFF                             0b00000000  //  1     1     payload with ACK packets: disabled (default)
    170 #define RADIOLIB_NRF24_ACK_PAY_ON                              0b00000010  //  1     1                               enabled
    171 #define RADIOLIB_NRF24_DYN_ACK_OFF                             0b00000000  //  0     0     payloads without ACK: disabled (default)
    172 #define RADIOLIB_NRF24_DYN_ACK_ON                              0b00000001  //  0     0                           enabled
    173 
    174 /*!
    175   \class nRF24
    176 
    177   \brief Control class for %nRF24 module.
    178 */
    179 class nRF24: public PhysicalLayer {
    180   public:
    181     // introduce PhysicalLayer overloads
    182     using PhysicalLayer::transmit;
    183     using PhysicalLayer::receive;
    184     using PhysicalLayer::startTransmit;
    185     using PhysicalLayer::readData;
    186 
    187     /*!
    188       \brief Default constructor.
    189 
    190       \param mod Instance of Module that will be used to communicate with the radio.
    191     */
    192     nRF24(Module* mod);
    193 
    194     Module* getMod();
    195 
    196     // basic methods
    197 
    198     /*!
    199       \brief Initialization method.
    200 
    201       \param freq Carrier frequency in MHz. Defaults to 2400 MHz.
    202 
    203       \param dataRate Data rate to be used in kbps. Defaults to 1000 kbps.
    204 
    205       \param power Output power in dBm. Defaults to -12 dBm.
    206 
    207       \param addrWidth Address width in bytes. Defaults to 5 bytes.
    208 
    209       \returns \ref status_codes
    210     */
    211     int16_t begin(int16_t freq = 2400, int16_t dataRate = 1000, int8_t power = -12, uint8_t addrWidth = 5);
    212 
    213     /*!
    214       \brief Sets the module to sleep mode.
    215 
    216       \returns \ref status_codes
    217     */
    218     int16_t sleep();
    219 
    220     /*!
    221       \brief Sets the module to standby mode.
    222 
    223       \returns \ref status_codes
    224     */
    225     int16_t standby() override;
    226 
    227     /*!
    228       \brief Blocking binary transmit method.
    229       Overloads for string-based transmissions are implemented in PhysicalLayer.
    230 
    231       \param data Binary data to be sent.
    232 
    233       \param len Number of bytes to send.
    234 
    235       \param addr Dummy address parameter, to ensure PhysicalLayer compatibility.
    236 
    237       \returns \ref status_codes
    238     */
    239     int16_t transmit(uint8_t* data, size_t len, uint8_t addr) override;
    240 
    241     /*!
    242       \brief Blocking binary receive method.
    243       Overloads for string-based transmissions are implemented in PhysicalLayer.
    244 
    245       \param data Binary data to be sent.
    246 
    247       \param len Number of bytes to send.
    248 
    249       \returns \ref status_codes
    250     */
    251     int16_t receive(uint8_t* data, size_t len) override;
    252 
    253     /*!
    254       \brief Starts direct mode transmission.
    255 
    256       \param frf Raw RF frequency value. Defaults to 0, required for quick frequency shifts in RTTY.
    257 
    258       \returns \ref status_codes
    259     */
    260     int16_t transmitDirect(uint32_t frf = 0) override;
    261 
    262     /*!
    263       \brief Dummy direct mode reception method, to ensure PhysicalLayer compatibility.
    264 
    265       \returns \ref status_codes
    266     */
    267     int16_t receiveDirect() override;
    268 
    269     // interrupt methods
    270 
    271     /*!
    272       \brief Sets interrupt service routine to call when IRQ activates.
    273 
    274       \param func ISR to call.
    275     */
    276     void setIrqAction(void (*func)(void));
    277 
    278     /*!
    279       \brief Interrupt-driven binary transmit method. IRQ will be activated when full packet is transmitted.
    280       Overloads for string-based transmissions are implemented in PhysicalLayer.
    281 
    282       \param data Binary data to be sent.
    283 
    284       \param len Number of bytes to send.
    285 
    286       \param addr Dummy address parameter, to ensure PhysicalLayer compatibility.
    287 
    288       \returns \ref status_codes
    289     */
    290     int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr) override;
    291 
    292     /*!
    293       \brief Interrupt-driven receive method. IRQ will be activated when full packet is received.
    294 
    295       \returns \ref status_codes
    296     */
    297     int16_t startReceive();
    298 
    299     /*!
    300       \brief Reads data received after calling startReceive method.
    301 
    302       \param data Pointer to array to save the received binary data.
    303 
    304       \param len Number of bytes that will be received. Must be known in advance for binary transmissions.
    305 
    306       \returns \ref status_codes
    307     */
    308     int16_t readData(uint8_t* data, size_t len) override;
    309 
    310     // configuration methods
    311 
    312     /*!
    313       \brief Sets carrier frequency. Allowed values range from 2400 MHz to 2525 MHz.
    314 
    315       \param freq Carrier frequency to be set in MHz.
    316 
    317       \returns \ref status_codes
    318     */
    319     int16_t setFrequency(int16_t freq);
    320 
    321     /*!
    322       \brief Sets data rate. Allowed values are 2000, 1000 or 250 kbps.
    323 
    324       \param dataRate Data rate to be set in kbps.
    325 
    326       \returns \ref status_codes
    327     */
    328     int16_t setDataRate(int16_t dataRate);
    329 
    330     /*!
    331       \brief Sets output power. Allowed values are -18, -12, -6 or 0 dBm.
    332 
    333       \param power Output power to be set in dBm.
    334 
    335       \returns \ref status_codes
    336     */
    337     int16_t setOutputPower(int8_t power);
    338 
    339     /*!
    340       \brief Sets address width of transmit and receive pipes in bytes. Allowed values are 3, 4 or 5 bytes.
    341 
    342       \param addrWidth Address width to be set in bytes.
    343 
    344       \returns \ref status_codes
    345     */
    346     int16_t setAddressWidth(uint8_t addrWidth);
    347 
    348     /*!
    349       \brief Sets address of transmit pipe. The address width must be the same as the same as the configured in setAddressWidth.
    350 
    351       \param addr Address to which the next packet shall be transmitted.
    352 
    353       \returns \ref status_codes
    354     */
    355     int16_t setTransmitPipe(uint8_t* addr);
    356 
    357     /*!
    358       \brief Sets address of receive pipes 0 or 1. The address width must be the same as the same as the configured in setAddressWidth.
    359 
    360       \param pipeNum Number of pipe to which the address shall be set. Either 0 or 1, other pipes are handled using overloaded method.
    361 
    362       \param addr Address from which %nRF24 shall receive new packets on the specified pipe.
    363 
    364       \returns \ref status_codes
    365     */
    366     int16_t setReceivePipe(uint8_t pipeNum, uint8_t* addr);
    367 
    368     /*!
    369       \brief Sets address of receive pipes 2 - 5. The first 2 - 4 address bytes for these pipes are the same as for address pipe 1, only the last byte can be set.
    370 
    371       \param pipeNum Number of pipe to which the address shall be set. Allowed values range from 2 to 5.
    372 
    373       \param addrByte LSB of address from which %nRF24 shall receive new packets on the specified pipe.
    374 
    375       \returns \ref status_codes
    376     */
    377     int16_t setReceivePipe(uint8_t pipeNum, uint8_t addrByte);
    378 
    379     /*!
    380       \brief Disables specified receive pipe.
    381 
    382       \param pipeNum Receive pipe to be disabled.
    383 
    384       \returns \ref status_codes
    385     */
    386     int16_t disablePipe(uint8_t pipeNum);
    387 
    388     /*!
    389       \brief Gets nRF24 status register.
    390 
    391       \param mask Bit mask to be used on the returned register value.
    392 
    393       \returns Status register value or \ref status_codes
    394     */
    395     int16_t getStatus(uint8_t mask = 0xFF);
    396 
    397     /*!
    398       \brief Checks if carrier was detected during last RX
    399 
    400       \returns Whatever the carrier was above threshold.
    401     */
    402     bool isCarrierDetected();
    403 
    404     /*!
    405       \brief Dummy configuration method, to ensure PhysicalLayer compatibility.
    406 
    407       \param freqDev Dummy frequency deviation parameter, no configuration will be changed.
    408 
    409       \returns \ref status_codes
    410     */
    411     int16_t setFrequencyDeviation(float freqDev) override;
    412 
    413      /*!
    414       \brief Query modem for the packet length of received payload.
    415 
    416       \param update Update received packet length. Will return cached value when set to false.
    417 
    418       \returns Length of last received packet in bytes.
    419     */
    420     size_t getPacketLength(bool update = true) override;
    421 
    422     /*!
    423      \brief Enable CRC filtering and generation.
    424 
    425      \param crcOn Set or unset CRC check.
    426 
    427      \returns \ref status_codes
    428    */
    429     int16_t setCrcFiltering(bool crcOn = true);
    430 
    431     /*!
    432      \brief Enable or disable auto-acknowledge packets on all pipes
    433 
    434      \param autoAckOn Enable (true) or disable (false) auto-acks.
    435 
    436      \returns \ref status_codes
    437    */
    438     int16_t setAutoAck(bool autoAckOn = true);
    439 
    440     /*!
    441      \brief Enable or disable auto-acknowledge packets on given pipe.
    442 
    443      \param pipeNum Number of pipe to which enable / disable auto-acks.
    444 
    445      \param autoAckOn Enable (true) or disable (false) auto-acks.
    446 
    447      \returns \ref status_codes
    448    */
    449     int16_t setAutoAck(uint8_t pipeNum, bool autoAckOn);
    450 
    451     /*!
    452       \brief Dummy data shaping configuration method, to ensure PhysicalLayer compatibility.
    453 
    454       \param sh Ignored.
    455 
    456       \returns \ref status_codes
    457     */
    458     int16_t setDataShaping(uint8_t sh) override;
    459 
    460     /*!
    461       \brief Dummy encoding configuration method, to ensure PhysicalLayer compatibility.
    462 
    463       \param sh Ignored.
    464 
    465       \returns \ref status_codes
    466     */
    467     int16_t setEncoding(uint8_t encoding) override;
    468 
    469     /*!
    470      \brief Dummy random method, to ensure PhysicalLayer compatibility.
    471 
    472      \returns Always returns 0.
    473    */
    474     uint8_t randomByte();
    475 
    476     #if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
    477     /*!
    478       \brief Dummy method, to ensure PhysicalLayer compatibility.
    479 
    480       \param func Ignored.
    481     */
    482     void setDirectAction(void (*func)(void));
    483 
    484     /*!
    485       \brief Dummy method, to ensure PhysicalLayer compatibility.
    486 
    487       \param pin Ignored.
    488     */
    489     void readBit(RADIOLIB_PIN_TYPE pin);
    490     #endif
    491 
    492 #if !defined(RADIOLIB_GODMODE) && !defined(RADIOLIB_LOW_LEVEL)
    493   protected:
    494 #endif
    495     Module* _mod;
    496 
    497     void SPIreadRxPayload(uint8_t* data, uint8_t numBytes);
    498     void SPIwriteTxPayload(uint8_t* data, uint8_t numBytes);
    499     void SPItransfer(uint8_t cmd, bool write = false, uint8_t* dataOut = NULL, uint8_t* dataIn = NULL, uint8_t numBytes = 0);
    500 
    501 #if !defined(RADIOLIB_GODMODE)
    502   protected:
    503 #endif
    504 
    505     uint8_t _addrWidth = 0;
    506 
    507     int16_t config();
    508     void clearIRQ();
    509 };
    510 
    511 #endif