7#ifndef __nrf52840_nrf24l01_H__
8#define __nrf52840_nrf24l01_H__
10#if defined(USE_TINYUSB)
12 #include "Adafruit_TinyUSB.h"
15#if defined(NRF52811_XXAA) || defined(NRF52820_XXAA) || defined(NRF52833_XXAA) || defined(NRF52840_XXAA)
16 #define NRF_HAS_ENERGY_DETECT
19#define NRF52_RADIO_LIBRARY
20#define DEFAULT_MAX_PAYLOAD_SIZE 32
21#define ACTUAL_MAX_PAYLOAD_SIZE 127
22#define ACK_TIMEOUT_1MBPS 600
23#define ACK_TIMEOUT_2MBPS 400
24#define ACK_TIMEOUT_250KBPS 800
25#define ACK_TIMEOUT_1MBPS_OFFSET 300
26#define ACK_TIMEOUT_2MBPS_OFFSET 135
27#define ACK_TIMEOUT_250KBPS_OFFSET 300
28#define ACK_PAYLOAD_TIMEOUT_OFFSET 750
31#if defined NRF_CCM || defined(DOXYGEN)
32 #define CCM_ENCRYPTION_ENABLED
34#if defined CCM_ENCRYPTION_ENABLED || defined(DOXYGEN)
35 #define MAX_PACKET_SIZE ACTUAL_MAX_PAYLOAD_SIZE
36 #define CCM_KEY_SIZE 16
38 #define CCM_IV_SIZE_ACTUAL 8
39 #define CCM_COUNTER_SIZE 3
40 #define CCM_MIC_SIZE 4
41 #define CCM_START_SIZE 3
42 #define CCM_MODE_LENGTH_EXTENDED 16
155 void read(
void* buf, uint8_t len);
160 bool write(
void* buf, uint8_t len,
bool multicast =
false,
bool doEncryption =
true);
173 void stopListening(
bool setWritingPipe =
true,
bool resetAddresses =
true);
209 bool writeFast(
void* buf, uint8_t len,
bool multicast = 0);
219 bool startWrite(
void* buf, uint8_t len,
bool multicast,
bool doEncryption =
true);
274 void setPALevel(uint8_t level,
bool lnaEnable =
true);
331 void setRetries(uint8_t retryVar, uint8_t attempts);
380 bool txStandBy(uint32_t timeout,
bool startTx = 0);
392 bool testRPD(uint8_t RSSI = 65);
406#ifdef NRF_HAS_ENERGY_DETECT
407 uint8_t sample_ed(
void);
422#if defined CCM_ENCRYPTION_ENABLED || defined(DOXYGEN)
427 uint8_t
encrypt(
void* bufferIn, uint8_t size);
432 uint8_t
decrypt(
void* bufferIn, uint8_t size);
475 bool acksEnabled(uint8_t pipe);
478 uint8_t retryDuration;
481 uint8_t rxFifoAvailable;
483 bool ackPayloadsEnabled;
485 uint8_t staticPayloadSize;
494 bool ackPayloadAvailable;
495 uint8_t ackAvailablePipeNo;
496 uint8_t lastPacketCounter;
498 bool dynamicAckEnabled;
500 uint8_t addressWidth;
502 bool payloadAvailable;
503#if defined CCM_ENCRYPTION_ENABLED
514 uint32_t packetCounter;
Driver class for nRF52840 2.4GHz Wireless Transceiver.
void startListening(bool resetAddresses=true)
void openReadingPipe(uint8_t child, const uint8_t *address)
void setPALevel(uint8_t level, bool lnaEnable=true)
bool testCarrier(uint8_t RSSI=65)
uint8_t decrypt(void *bufferIn, uint8_t size)
uint8_t radioData[ACTUAL_MAX_PAYLOAD_SIZE+2]
void setChannel(uint8_t channel)
uint32_t addrConv32(uint32_t addr)
void disableDynamicPayloads()
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
bool testRPD(uint8_t RSSI=65)
void setCounter(uint64_t counter)
void setAddressWidth(uint8_t a_width)
uint8_t getDynamicPayloadSize()
bool setDataRate(uint8_t speed)
void setKey(uint8_t key[CCM_KEY_SIZE])
bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
uint8_t encrypt(void *bufferIn, uint8_t size)
bool startWrite(void *buf, uint8_t len, bool multicast, bool doEncryption=true)
uint8_t outBuffer[MAX_PACKET_SIZE+CCM_MIC_SIZE+CCM_START_SIZE]
void setRetries(uint8_t retryVar, uint8_t attempts)
void openWritingPipe(const uint8_t *address)
void setCRCLength(nrf_crclength_e length)
bool writeFast(void *buf, uint8_t len, bool multicast=0)
void setAutoAck(bool enable)
void read(void *buf, uint8_t len)
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
void setIV(uint8_t IV[CCM_IV_SIZE])
void setPayloadSize(uint8_t size)
nrf_crclength_e getCRCLength()
#define CCM_MODE_LENGTH_EXTENDED
#define DEFAULT_MAX_PAYLOAD_SIZE
#define CCM_IV_SIZE_ACTUAL
#define ACTUAL_MAX_PAYLOAD_SIZE