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