5#if defined(NRF52832_XXAA) || defined(NRF52832_XXAB) || defined(NRF52811_XXAA) || defined(NRF52810_XXAA) || defined(NRF52805_XXAA)
7 #define TXPOWER_PA_MIN 0xF4
8 #define TXPOWER_PA_LOW 0xFC
9 #define TXPOWER_PA_HIGH 0x00
10 #define TXPOWER_PA_MAX 0x04
13 #define TXPOWER_PA_MIN 0xF4
14 #define TXPOWER_PA_LOW 0x02
15 #define TXPOWER_PA_HIGH 0x06
16 #define TXPOWER_PA_MAX 0x08
21#ifndef RADIO_MODE_MODE_Nrf_250Kbit
22 #define RADIO_MODE_MODE_Nrf_250Kbit (2UL)
30 uint32_t inp = (p_inp[3] << 24) | (p_inp[2] << 16) | (p_inp[1] << 8) | (p_inp[0]);
31 inp = (inp & 0xF0F0F0F0) >> 4 | (inp & 0x0F0F0F0F) << 4;
32 inp = (inp & 0xCCCCCCCC) >> 2 | (inp & 0x33333333) << 2;
33 inp = (inp & 0xAAAAAAAA) >> 1 | (inp & 0x55555555) << 1;
52 buffer[0] = addr & 0xFF;
53 buffer[1] = (addr >> 8) & 0xFF;
54 buffer[2] = (addr >> 16) & 0xFF;
55 buffer[3] = (addr >> 24) & 0xFF;
65 staticPayloadSize = 32;
70 ackPayloadsEnabled =
false;
76 payloadAvailable =
false;
78#if defined CCM_ENCRYPTION_ENABLED
79 NRF_CCM->INPTR = (uint32_t)inBuffer;
81 NRF_CCM->CNFPTR = (uint32_t)&ccmData;
82 NRF_CCM->SCRATCHPTR = (uint32_t)scratchPTR;
83 ccmData.counter = 12345;
85 NRF_CCM->MODE = 1 << 24 | 1 << 16;
91 NRF_RNG->TASKS_START = 1;
100 NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
101 NRF_CLOCK->TASKS_HFCLKSTART = 1;
104 while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {
108 NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
109 NRF_CLOCK->TASKS_LFCLKSTART = 1;
112 while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {
116 NRF_RADIO->POWER = 1;
118 NRF_RADIO->PCNF0 = (1 << RADIO_PCNF0_S0LEN_Pos) | (0 << RADIO_PCNF0_LFLEN_Pos) | (1 << RADIO_PCNF0_S1LEN_Pos);
120 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | (4 << RADIO_PCNF1_BALEN_Pos) | (staticPayloadSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
122 NRF_RADIO->BASE0 = 0xE7E7E7E7;
123 NRF_RADIO->BASE1 = 0x43434343;
124 NRF_RADIO->PREFIX0 = 0x23C343E7;
125 NRF_RADIO->PREFIX1 = 0x13E363A3;
126 NRF_RADIO->RXADDRESSES = 0x01;
127 NRF_RADIO->TXADDRESS = 0x00;
129 txBase = NRF_RADIO->BASE0;
130 txPrefix = NRF_RADIO->PREFIX0;
131 rxBase = NRF_RADIO->BASE0;
132 rxPrefix = NRF_RADIO->PREFIX0;
134 NRF_RADIO->CRCCNF = RADIO_CRCCNF_LEN_Two;
135 NRF_RADIO->CRCINIT = 0xFFFFUL;
136 NRF_RADIO->CRCPOLY = 0x11021UL;
138 NRF_RADIO->PACKETPTR = (uint32_t)
radioData;
139 NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos);
140 NRF_RADIO->MODECNF0 = 0x200;
141 NRF_RADIO->MODECNF0 |= 1;
142 NRF_RADIO->TXPOWER = (
TXPOWER_PA_MAX << RADIO_TXPOWER_TXPOWER_Pos);
143 NRF_RADIO->SHORTS = 1 << 19;
144 NRF_RADIO->FREQUENCY = 0x4C;
152#ifdef NRF_HAS_ENERGY_DETECT
153 #define ED_RSSISCALE 4
154uint8_t nrf_to_nrf::sample_ed(
void)
157 NRF_RADIO->TASKS_EDSTART = 1;
158 while (NRF_RADIO->EVENTS_EDEND != 1) {
162 val = NRF_RADIO->EDSAMPLE;
163 return (uint8_t)(val > 63
165 : val * ED_RSSISCALE);
173 uint8_t pipe_num = 0;
182 if (payloadAvailable) {
183 *pipe_num = (uint8_t)NRF_RADIO->RXMATCH;
188 if (ackPayloadAvailable) {
189 *pipe_num = ackAvailablePipeNo;
193 if (NRF_RADIO->EVENTS_CRCOK) {
194 uint32_t counter = 0;
195#if defined CCM_ENCRYPTION_ENABLED
198 NRF_RADIO->EVENTS_CRCOK = 0;
214 *pipe_num = (uint8_t)NRF_RADIO->RXMATCH;
215 if (!DPL && acksEnabled(*pipe_num) ==
false) {
216#if defined CCM_ENCRYPTION_ENABLED
224 memcpy(&rxBuffer[1], &
radioData[0], staticPayloadSize);
225#if defined CCM_ENCRYPTION_ENABLED
230#if defined CCM_ENCRYPTION_ENABLED
247 memcpy(&rxBuffer[1], &
radioData[2], staticPayloadSize);
249#if defined CCM_ENCRYPTION_ENABLED
254 rxFifoAvailable =
true;
255 uint8_t packetCtr = 0;
264 uint16_t packetData = NRF_RADIO->RXCRC;
266 if (acksEnabled(NRF_RADIO->RXMATCH)) {
268 uint32_t txAddress = NRF_RADIO->TXADDRESS;
269 NRF_RADIO->TXADDRESS = NRF_RADIO->RXMATCH;
270 delayMicroseconds(75);
271 if (ackPayloadsEnabled) {
272 if (*pipe_num == ackPipe) {
273 write(&ackBuffer[1], ackBuffer[0], 1, 0);
280 uint8_t payloadSize = 0;
290 NRF_RADIO->TXADDRESS = txAddress;
295 if (NRF_RADIO->CRCCNF != 0) {
296 if (packetCtr == lastPacketCounter && packetData == lastData) {
303#if defined CCM_ENCRYPTION_ENABLED
305 ccmData.counter = counter;
309 Serial.println(
"DECRYPT FAIL");
316 Serial.println(
"DECRYPT FAIL");
322 memset(&rxBuffer[1], 0,
sizeof(rxBuffer) - 1);
333 lastPacketCounter = packetCtr;
334 lastData = packetData;
335 payloadAvailable =
true;
337 NRF_RADIO->TASKS_START = 1;
341 if (NRF_RADIO->EVENTS_CRCERROR) {
342 NRF_RADIO->EVENTS_CRCERROR = 0;
343 NRF_RADIO->TASKS_START = 1;
350void nrf_to_nrf::restartReturnRx()
353 NRF_RADIO->TASKS_START = 1;
361 memcpy(buf, &rxBuffer[1], len);
362 ackPayloadAvailable =
false;
363 payloadAvailable =
false;
371 uint8_t PID = ackPID;
373 PID = ((ackPID += 1) % 7) << 1;
378 uint8_t payloadSize = 0;
380#if defined CCM_ENCRYPTION_ENABLED
382 uint32_t tmpCounter = 0;
389 while (!NRF_RNG->EVENTS_VALRDY) {
391 NRF_RNG->EVENTS_VALRDY = 0;
392 tmpIV[i] = NRF_RNG->VALUE;
393 ccmData.iv[i] = tmpIV[i];
395 tmpCounter = packetCounter;
396 ccmData.counter = tmpCounter;
405 if (packetCounter > 200000) {
412 for (
int i = 0; i < (retries + 1); i++) {
423 uint8_t dataStart = 0;
425#if defined CCM_ENCRYPTION_ENABLED
432 dataStart = (!DPL && acksEnabled(0) ==
false) ? 0 : 2;
433#if defined CCM_ENCRYPTION_ENABLED
437#if defined CCM_ENCRYPTION_ENABLED
446#if defined CCM_ENCRYPTION_ENABLED
450 if (NRF_RADIO->STATE < 9) {
451 NRF_RADIO->EVENTS_TXREADY = 0;
452 NRF_RADIO->TASKS_TXEN = 1;
453 while (NRF_RADIO->EVENTS_TXREADY == 0) {
455 NRF_RADIO->EVENTS_TXREADY = 0;
458 NRF_RADIO->EVENTS_END = 0;
459 NRF_RADIO->TASKS_START = 1;
460 while (NRF_RADIO->EVENTS_END == 0) {
462 NRF_RADIO->EVENTS_END = 0;
463 if (!multicast && acksPerPipe[NRF_RADIO->TXADDRESS] ==
true) {
464 uint32_t rxAddress = NRF_RADIO->RXADDRESSES;
465 NRF_RADIO->RXADDRESSES = 1 << NRF_RADIO->TXADDRESS;
472 uint32_t realAckTimeout = ackTimeout;
474 if (NRF_RADIO->MODE == (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos)) {
486 realAckTimeout += 200;
492 uint32_t ack_timeout = micros();
493 while (!NRF_RADIO->EVENTS_CRCOK && !NRF_RADIO->EVENTS_CRCERROR) {
494 if (micros() - ack_timeout > realAckTimeout) {
498 if (NRF_RADIO->EVENTS_CRCOK) {
499 if (ackPayloadsEnabled &&
radioData[0] > 0) {
500#if defined CCM_ENCRYPTION_ENABLED
511#if defined CCM_ENCRYPTION_ENABLED
517 Serial.println(
"DECRYPT FAIL");
527 ackPayloadAvailable =
true;
528 ackAvailablePipeNo = NRF_RADIO->RXMATCH;
530 NRF_RADIO->EVENTS_CRCOK = 0;
535 NRF_RADIO->RXADDRESSES = rxAddress;
539 else if (NRF_RADIO->EVENTS_CRCERROR) {
540 NRF_RADIO->EVENTS_CRCERROR = 0;
542 uint32_t duration = 258 * retryDuration;
543 delayMicroseconds(duration);
548 NRF_RADIO->RXADDRESSES = rxAddress;
555 lastTxResult =
false;
564 uint8_t PID = ackPID;
566 PID = ((ackPID += 1) % 7) << 1;
572#if defined CCM_ENCRYPTION_ENABLED
574 uint32_t tmpCounter = 0;
581 while (!NRF_RNG->EVENTS_VALRDY) {
583 NRF_RNG->EVENTS_VALRDY = 0;
584 tmpIV[i] = NRF_RNG->VALUE;
585 ccmData.iv[i] = tmpIV[i];
587 tmpCounter = packetCounter;
588 ccmData.counter = tmpCounter;
597 if (packetCounter > 200000) {
615 uint8_t dataStart = 0;
617#if defined CCM_ENCRYPTION_ENABLED
624 dataStart = (!DPL && acksEnabled(0) ==
false) ? 0 : 2;
625#if defined CCM_ENCRYPTION_ENABLED
629#if defined CCM_ENCRYPTION_ENABLED
638#if defined CCM_ENCRYPTION_ENABLED
642 if (NRF_RADIO->STATE < 9) {
643 NRF_RADIO->EVENTS_TXREADY = 0;
644 NRF_RADIO->TASKS_TXEN = 1;
645 while (NRF_RADIO->EVENTS_TXREADY == 0) {
647 NRF_RADIO->EVENTS_TXREADY = 0;
650 NRF_RADIO->EVENTS_END = 0;
651 NRF_RADIO->TASKS_START = 1;
662#if defined CCM_ENCRYPTION_ENABLED
667 while (!NRF_RNG->EVENTS_VALRDY) {
669 NRF_RNG->EVENTS_VALRDY = 0;
670 ccmData.iv[i] = NRF_RNG->VALUE;
671 ackBuffer[i + 1] = ccmData.iv[i];
674 ccmData.counter = packetCounter;
684 if (packetCounter > 200000) {
691 memcpy(&ackBuffer[1], buf, len);
692#if defined CCM_ENCRYPTION_ENABLED
713 NRF_RADIO->EVENTS_DISABLED = 0;
714 NRF_RADIO->TASKS_DISABLE = 1;
715 while (NRF_RADIO->EVENTS_DISABLED == 0) {
717 NRF_RADIO->EVENTS_DISABLED = 0;
718 if (resetAddresses ==
true) {
720 NRF_RADIO->BASE0 = rxBase;
721 NRF_RADIO->PREFIX0 = rxPrefix;
725 NRF_RADIO->EVENTS_RXREADY = 0;
726 NRF_RADIO->EVENTS_CRCOK = 0;
727 NRF_RADIO->TASKS_RXEN = 1;
736 NRF_RADIO->EVENTS_DISABLED = 0;
737 NRF_RADIO->TASKS_DISABLE = 1;
738 while (NRF_RADIO->EVENTS_DISABLED == 0) {
740 NRF_RADIO->EVENTS_DISABLED = 0;
741 if (resetAddresses) {
742 NRF_RADIO->BASE0 = txBase;
743 NRF_RADIO->PREFIX0 = txPrefix;
745 if (setWritingPipe) {
746 NRF_RADIO->TXADDRESS = 0x00;
759 uint8_t size = min(staticPayloadSize, rxBuffer[0]);
768 uint32_t freq = NRF_RADIO->FREQUENCY;
769 NRF_RADIO->FREQUENCY = 0x4C;
770 if (NRF_RADIO->FREQUENCY == 0x4C) {
771 NRF_RADIO->FREQUENCY = freq;
790 for (
int i = 0; i < 8; i++) {
791 acksPerPipe[i] = enable;
803 acksPerPipe[pipe] = enable;
816 staticPayloadSize = payloadSize;
818 if (payloadSize <= 32) {
819 NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S0LEN_Pos) | (6 << RADIO_PCNF0_LFLEN_Pos) | (3 << RADIO_PCNF0_S1LEN_Pos);
823 NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S0LEN_Pos) | (8 << RADIO_PCNF0_LFLEN_Pos) | (3 << RADIO_PCNF0_S1LEN_Pos);
825 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((addressWidth - 1) << RADIO_PCNF1_BALEN_Pos) | (0 << RADIO_PCNF1_STATLEN_Pos) | (payloadSize << RADIO_PCNF1_MAXLEN_Pos);
835 uint8_t lenConfig = 0;
836 if (acksEnabled(0)) {
839 NRF_RADIO->PCNF0 = (lenConfig << RADIO_PCNF0_S0LEN_Pos) | (0 << RADIO_PCNF0_LFLEN_Pos) | (lenConfig << RADIO_PCNF0_S1LEN_Pos);
841 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((addressWidth - 1) << RADIO_PCNF1_BALEN_Pos) | (staticPayloadSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
848 staticPayloadSize = size;
851 uint8_t lenConfig = 0;
852 if (acksEnabled(0)) {
855 NRF_RADIO->PCNF0 = (lenConfig << RADIO_PCNF0_S0LEN_Pos) | (0 << RADIO_PCNF0_LFLEN_Pos) | (lenConfig << RADIO_PCNF0_S1LEN_Pos);
857 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((addressWidth - 1) << RADIO_PCNF1_BALEN_Pos) | (staticPayloadSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
864 return staticPayloadSize;
873 retryDuration = retryVar;
882 uint32_t base = address >> 8;
883 uint32_t prefix = address & 0xFF;
891 NRF_RADIO->PREFIX0 = rxPrefix;
892 NRF_RADIO->BASE0 = base;
893 NRF_RADIO->PREFIX0 &= ~(0xFF);
894 NRF_RADIO->PREFIX0 |= prefix;
895 rxBase = NRF_RADIO->BASE0;
896 rxPrefix = NRF_RADIO->PREFIX0;
898 else if (child < 4) {
899 NRF_RADIO->PREFIX0 = rxPrefix;
900 NRF_RADIO->BASE1 = base;
901 NRF_RADIO->PREFIX0 &= ~(0xFF << (8 * child));
902 NRF_RADIO->PREFIX0 |= prefix << (8 * child);
903 rxPrefix = NRF_RADIO->PREFIX0;
906 NRF_RADIO->BASE1 = base;
907 NRF_RADIO->PREFIX1 &= ~(0xFF << (8 * (child - 4)));
908 NRF_RADIO->PREFIX1 |= prefix << (8 * (child - 4));
910 NRF_RADIO->RXADDRESSES |= 1 << child;
921 uint32_t base = address >> 8;
922 uint32_t prefix = address & 0xFF;
928 NRF_RADIO->BASE0 = base;
929 NRF_RADIO->PREFIX0 &= 0xFFFFFF00;
930 NRF_RADIO->PREFIX0 |= prefix;
931 NRF_RADIO->TXADDRESS = 0x00;
932 txBase = NRF_RADIO->BASE0;
933 txPrefix = NRF_RADIO->PREFIX0;
947 uint8_t prefixArray[5];
948 prefixArray[0] = address[0];
954 NRF_RADIO->PREFIX0 = rxPrefix;
955 NRF_RADIO->BASE0 = base;
956 NRF_RADIO->PREFIX0 &= ~(0xFF);
957 NRF_RADIO->PREFIX0 |= prefix;
958 rxBase = NRF_RADIO->BASE0;
959 rxPrefix = NRF_RADIO->PREFIX0;
961 else if (child < 4) {
962 NRF_RADIO->PREFIX0 = rxPrefix;
963 NRF_RADIO->BASE1 = base;
964 NRF_RADIO->PREFIX0 &= ~(0xFF << (8 * child));
965 NRF_RADIO->PREFIX0 |= prefix << (8 * child);
966 rxPrefix = NRF_RADIO->PREFIX0;
969 NRF_RADIO->BASE1 = base;
970 NRF_RADIO->PREFIX1 &= ~(0xFF << (8 * (child - 4)));
971 NRF_RADIO->PREFIX1 |= prefix << (8 * (child - 4));
973 NRF_RADIO->RXADDRESSES |= 1 << child;
990 prefix = prefix >> 24;
992 NRF_RADIO->BASE0 = base;
993 NRF_RADIO->PREFIX0 &= 0xFFFFFF00;
994 NRF_RADIO->PREFIX0 |= prefix;
995 NRF_RADIO->TXADDRESS = 0x00;
996 txBase = NRF_RADIO->BASE0;
997 txPrefix = NRF_RADIO->PREFIX0;
1005 if (NRF_RADIO->STATE == 11) {
1006 while (NRF_RADIO->EVENTS_END == 0) {
1008 NRF_RADIO->EVENTS_END = 0;
1011 NRF_RADIO->EVENTS_DISABLED = 0;
1012 NRF_RADIO->TASKS_DISABLE = 1;
1013 while (NRF_RADIO->EVENTS_DISABLED == 0) {
1015 NRF_RADIO->EVENTS_DISABLED = 0;
1017 return lastTxResult;
1025 if (NRF_RADIO->STATE == 11) {
1026 while (NRF_RADIO->EVENTS_END == 0) {
1028 NRF_RADIO->EVENTS_END = 0;
1031 NRF_RADIO->EVENTS_DISABLED = 0;
1032 NRF_RADIO->TASKS_DISABLE = 1;
1033 while (NRF_RADIO->EVENTS_DISABLED == 0) {
1035 NRF_RADIO->EVENTS_DISABLED = 0;
1037 return lastTxResult;
1044 lastTxResult =
write((
void*)buf, len, multicast);
1045 return lastTxResult;
1050bool nrf_to_nrf::acksEnabled(uint8_t pipe)
1053 if (acksPerPipe[pipe]) {
1069 NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos);
1077 NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_2Mbit << RADIO_MODE_MODE_Pos);
1089 uint8_t paLevel = 0x00;
1103 NRF_RADIO->TXPOWER = paLevel;
1111 uint8_t paLevel = NRF_RADIO->TXPOWER;
1143 NRF_RADIO->CRCCNF = RADIO_CRCCNF_LEN_Two;
1144 NRF_RADIO->CRCINIT = 0xFFFFUL;
1145 NRF_RADIO->CRCPOLY = 0x11021UL;
1148 NRF_RADIO->CRCCNF = RADIO_CRCCNF_LEN_One;
1149 NRF_RADIO->CRCINIT = 0xFFUL;
1150 NRF_RADIO->CRCPOLY = 0x107UL;
1153 NRF_RADIO->CRCCNF = 0;
1154 NRF_RADIO->CRCINIT = 0x00L;
1155 NRF_RADIO->CRCPOLY = 0x00UL;
1163 if (NRF_RADIO->CRCCNF == 0) {
1166 else if (NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_One) {
1179 NRF_RADIO->EVENTS_RSSIEND = 0;
1180 NRF_RADIO->TASKS_RSSISTART = 1;
1181 while (!NRF_RADIO->EVENTS_RSSIEND) {
1183 if (NRF_RADIO->RSSISAMPLE < RSSI) {
1200 NRF_RADIO->EVENTS_RSSIEND = 0;
1201 NRF_RADIO->TASKS_RSSISTART = 1;
1202 while (!NRF_RADIO->EVENTS_RSSIEND) {
1204 return (uint8_t)NRF_RADIO->RSSISAMPLE;
1211 NRF_RADIO->POWER = 1;
1218 NRF_RADIO->POWER = 0;
1225 addressWidth = a_width;
1229 pSize = staticPayloadSize;
1232 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((a_width - 1) << RADIO_PCNF1_BALEN_Pos) | (pSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
1240 Serial.println(
"================ Radio Configuration ================");
1241 Serial.print(
"STATUS\t\t= ");
1242 Serial.println(NRF_RADIO->STATE);
1245 Serial.print(
"RX_ADDR_P0-1\t= 0x");
1246 uint32_t base =
addrConv32(NRF_RADIO->BASE0);
1247 for (
int i = addressWidth - 2; i > -1; i--) {
1248 Serial.print((base >> (i * 8)) & 0xFF, HEX);
1250 uint32_t prefixes =
addrConv32(NRF_RADIO->PREFIX0);
1251 uint8_t prefix = (prefixes >> 24) & 0xFF;
1252 Serial.print(prefix, HEX);
1253 Serial.print(
" 0x");
1255 for (
int i = addressWidth - 2; i > -1; i--) {
1256 Serial.print((base >> (i * 8)) & 0xFF, HEX);
1258 prefix = (prefixes >> 16) & 0xFF;
1259 Serial.println(prefix, HEX);
1261 Serial.print(
"RX_ADDR_P2-7\t= 0x");
1262 prefix = (prefixes >> 8) & 0xFF;
1263 Serial.print(prefix, HEX);
1264 Serial.print(
" 0x");
1265 prefix = (prefixes)&0xFF;
1266 Serial.print(prefix, HEX);
1267 Serial.print(
" 0x");
1269 prefix = (prefixes >> 24) & 0xFF;
1270 Serial.print(prefix, HEX);
1271 Serial.print(
" 0x");
1272 prefix = (prefixes >> 16) & 0xFF;
1273 Serial.print(prefix, HEX);
1274 Serial.print(
" 0x");
1275 prefix = (prefixes >> 8) & 0xFF;
1276 Serial.print(prefix, HEX);
1277 Serial.print(
" 0x");
1278 prefix = (prefixes)&0xFF;
1279 Serial.println(prefix, HEX);
1282 for (
int i = 0; i < 6; i++) {
1283 enAA |= acksPerPipe[i] << i;
1285 Serial.print(
"EN_AA\t\t= 0x");
1286 Serial.println(enAA, HEX);
1287 Serial.print(
"EN_RXADDR\t= 0x");
1288 Serial.println(NRF_RADIO->RXADDRESSES, HEX);
1289 Serial.print(
"RF_CH\t\t= 0x");
1290 Serial.println(NRF_RADIO->FREQUENCY, HEX);
1291 Serial.println(
"DYNPD/FEATURE\t= 0x");
1292 Serial.print(
"Data Rate\t= ");
1293 Serial.println(NRF_RADIO->MODE ?
"2 MBPS" :
"1MBPS");
1294 Serial.println(
"Model\t\t= NRF52");
1295 Serial.print(
"CRC Length\t= ");
1298 Serial.println(
"16 bits");
1301 Serial.println(
"8 bits");
1304 Serial.println(
"Disabled");
1306 Serial.print(
"PA Power\t= ");
1309 Serial.println(
"PA_MAX");
1312 Serial.println(
"PA_HIGH");
1315 Serial.println(
"PA_LOW");
1318 Serial.println(
"PA_MIN");
1321 Serial.println(
"?");
1323 Serial.print(
"ARC\t\t= ");
1324 Serial.println(ARC);
1329#if defined CCM_ENCRYPTION_ENABLED
1349 NRF_CCM->EVENTS_ENDKSGEN = 0;
1350 NRF_CCM->EVENTS_ENDCRYPT = 0;
1351 NRF_CCM->TASKS_KSGEN = 1;
1352 while (!NRF_CCM->EVENTS_ENDCRYPT) {
1355 if (NRF_CCM->EVENTS_ERROR) {
1373 memcpy(&inBuffer[3], bufferIn, size);
1381 NRF_CCM->EVENTS_ENDKSGEN = 0;
1382 NRF_CCM->EVENTS_ENDCRYPT = 0;
1383 NRF_CCM->TASKS_KSGEN = 1;
1385 while (!NRF_CCM->EVENTS_ENDCRYPT) {
1388 if (NRF_CCM->EVENTS_ERROR) {
1407 ccmData.counter = counter;
1408 packetCounter = counter;
1416 ccmData.iv[i] = IV[i];
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 RADIO_MODE_MODE_Nrf_250Kbit
static uint32_t bytewise_bit_swap(uint8_t const *p_inp)
static uint32_t addr_conv(uint8_t const *p_addr)
#define ACK_TIMEOUT_1MBPS_OFFSET
#define DEFAULT_MAX_PAYLOAD_SIZE
#define ACK_PAYLOAD_TIMEOUT_OFFSET
#define ACK_TIMEOUT_250KBPS_OFFSET
#define ACK_TIMEOUT_250KBPS
#define ACK_TIMEOUT_2MBPS
#define ACTUAL_MAX_PAYLOAD_SIZE
#define ACK_TIMEOUT_2MBPS_OFFSET
#define ACK_TIMEOUT_1MBPS