@@ -26,6 +26,10 @@ static const uint8_t config[] PROGMEM = {
26
26
27
27
inline uint8_t nRF905::cselect ()
28
28
{
29
+ #if defined(ESP32) || defined(ESP8266)
30
+ if (!isrBusy)
31
+ noInterrupts ();
32
+ #endif
29
33
spi.beginTransaction (spiSettings);
30
34
digitalWrite (csn, LOW);
31
35
return 1 ;
@@ -35,6 +39,10 @@ inline uint8_t nRF905::cdeselect()
35
39
{
36
40
digitalWrite (csn, HIGH);
37
41
spi.endTransaction ();
42
+ #if defined(ESP32) || defined(ESP8266)
43
+ if (!isrBusy)
44
+ interrupts ();
45
+ #endif
38
46
return 0 ;
39
47
}
40
48
@@ -209,8 +217,13 @@ void nRF905::begin(
209
217
if (pwr != NRF905_PIN_UNUSED)
210
218
pinMode (pwr, OUTPUT);
211
219
212
- spi.usingInterrupt (digitalPinToInterrupt (dr));
213
- spi.usingInterrupt (digitalPinToInterrupt (am));
220
+ #if !defined(ESP32) && !defined(ESP8266)
221
+ // SPI.usingInterrupts() is not supported on ESP platforms. More info: https://github.com/zkemble/nRF905-arduino/issues/1
222
+ if (dr != NRF905_PIN_UNUSED)
223
+ spi.usingInterrupt (digitalPinToInterrupt (dr));
224
+ if (am != NRF905_PIN_UNUSED)
225
+ spi.usingInterrupt (digitalPinToInterrupt (am));
226
+ #endif
214
227
215
228
powerOn (false );
216
229
standbyMode (true );
@@ -230,7 +243,9 @@ void nRF905::begin(
230
243
231
244
void nRF905::otherSPIinterrupts ()
232
245
{
246
+ #if !defined(ESP32) && !defined(ESP8266)
233
247
spi.usingInterrupt (255 );
248
+ #endif
234
249
}
235
250
236
251
void nRF905::events (
@@ -580,6 +595,10 @@ void nRF905::interrupt_dr()
580
595
{
581
596
// If DR && AM = RX new packet
582
597
// If DR && !AM = TX finished
598
+
599
+ #if defined(ESP32) || defined(ESP8266)
600
+ isrBusy = 1 ;
601
+ #endif
583
602
584
603
if (addressMatched ())
585
604
{
@@ -592,12 +611,20 @@ void nRF905::interrupt_dr()
592
611
if (onTxComplete != NULL )
593
612
onTxComplete (this );
594
613
}
614
+
615
+ #if defined(ESP32) || defined(ESP8266)
616
+ isrBusy = 0 ;
617
+ #endif
595
618
}
596
619
597
620
void nRF905::interrupt_am ()
598
621
{
599
622
// If AM goes HIGH then LOW without DR going HIGH then we got a bad packet
600
623
624
+ #if defined(ESP32) || defined(ESP8266)
625
+ isrBusy = 1 ;
626
+ #endif
627
+
601
628
if (addressMatched ())
602
629
{
603
630
if (onAddrMatch != NULL )
@@ -609,6 +636,10 @@ void nRF905::interrupt_am()
609
636
onRxInvalid (this );
610
637
}
611
638
validPacket = 0 ;
639
+
640
+ #if defined(ESP32) || defined(ESP8266)
641
+ isrBusy = 0 ;
642
+ #endif
612
643
}
613
644
614
645
void nRF905::poll ()
0 commit comments