Driver for the SX1276 RF Transceiver

Fork of SX1276Lib by Gregory Cristian

Revision:
19:8b8d591025bf
Parent:
18:71a47bb03fbb
--- a/sx1276/sx1276.cpp	Wed Aug 12 14:34:03 2015 +0000
+++ b/sx1276/sx1276.cpp	Wed Sep 16 05:16:16 2015 +0000
@@ -1151,6 +1151,13 @@
                         {
                             this->settings.State = IDLE;
                         }
+                        // For Continuous reception, we remain in Receive mode. Delete current packet, it can contain corrupt data.
+                        else {
+                            //Get start address of next packet
+                            uint8_t startAddNxtPckt = Read(REG_LR_FIFORXBYTEADDR);
+                            //Set SPI pointer to address of next packet we will receive = Delete current packet!
+                            Write(REG_LR_FIFOADDRPTR, startAddNxtPckt);
+                        }
                         rxTimeoutTimer.detach( );
 
                         if( ( rxError != NULL ) )
@@ -1199,6 +1206,11 @@
                         }
                     }
 
+                    // Ensure we read the last packet received. Without doing this, the bytes read can get out of sync
+                    // with the last packet received after errors occur!
+                    // RegFifoRxCurrentAddr contains start address of last packet received.
+                    Write(REG_LR_FIFOADDRPTR, Read(REG_LR_FIFORXCURRENTADDR));
+
                     this->settings.LoRaPacketHandler.Size = Read( REG_LR_RXNBBYTES );
                     ReadFifo( rxBuffer, this->settings.LoRaPacketHandler.Size );