1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
| #include <RF24_config.h>
| #include <nRF24L01.h>
| #include <RF24.h>
| #include <printf.h>
|
| #define IRQ_PIN 17
|
|
| RF24 radio(22, 21); // CE, CSN
| const byte address[6] = {'R','E','C','V', '1'};
| char val[4];
|
|
| void isrCallbackFunction() {
| bool tx_ds, tx_df, rx_dr;
| radio.whatHappened(tx_ds, tx_df, rx_dr); // resets the IRQ pin to HIGH
| if ( radio.available()) {
| while (radio.available()) {
| radio.read(&val, sizeof(val));
| Serial.print("Received = ");
| Serial.println(val);
| }
| }
| }
|
| void setup() {
| pinMode(IRQ_PIN, INPUT);
| attachInterrupt(digitalPinToInterrupt(IRQ_PIN), isrCallbackFunction, FALLING);
| Serial.begin(115200);
| radio.begin();
| radio.openReadingPipe(0, address);
| radio.setPALevel(RF24_PA_MAX);
| radio.maskIRQ(1, 1, 0);
| radio.startListening();
| }
|
| void loop() {
| // put your main code here, to run repeatedly:
|
| }
|
|