Elmo board support

Fork of SX1272Lib by Semtech

Revision:
3:5baff45eb3c5
Parent:
0:45c4f0364ca4
Child:
4:90bd79f1b458
--- a/sx1272/sx1272.cpp	Wed Feb 17 09:17:18 2016 +0000
+++ b/sx1272/sx1272.cpp	Thu Mar 10 10:20:44 2016 +0000
@@ -53,7 +53,7 @@
 {
     wait_ms( 10 );
     this->rxTx = 0;
-    this->rxBuffer = new uint8_t[RX_BUFFER_SIZE];
+    this->rxtxBuffer = new uint8_t[RX_BUFFER_SIZE];
     currentOpMode = RF_OPMODE_STANDBY;
     
     this->RadioEvents = events;
@@ -72,7 +72,7 @@
 
 SX1272::~SX1272( )
 {
-    delete this->rxBuffer;
+    delete this->rxtxBuffer;
     delete this->dioIrq;
 }
 
@@ -213,7 +213,11 @@
             {
                 Write( REG_PAYLOADLENGTH, payloadLen );
             }
-
+            else
+            {
+                Write( REG_PAYLOADLENGTH, 0xFF ); // Set payload length to the maximum 
+            }
+            
             Write( REG_PACKETCONFIG1,
                          ( Read( REG_PACKETCONFIG1 ) & 
                            RF_PACKETCONFIG1_CRC_MASK &
@@ -616,6 +620,7 @@
             }
             else
             {
+                memcpy( rxtxBuffer, buffer, size );
                 this->settings.FskPacketHandler.ChunkSize = 32;
             }
 
@@ -698,6 +703,7 @@
             // DIO4=Preamble
             // DIO5=ModeReady
             Write( REG_DIOMAPPING1, ( Read( REG_DIOMAPPING1 ) & RF_DIOMAPPING1_DIO0_MASK &
+                                                                            RF_DIOMAPPING1_DIO1_MASK &
                                                                             RF_DIOMAPPING1_DIO2_MASK ) |
                                                                             RF_DIOMAPPING1_DIO0_00 |
                                                                             RF_DIOMAPPING1_DIO2_11 );
@@ -764,7 +770,7 @@
         break;
     }
 
-    memset( rxBuffer, 0, ( size_t )RX_BUFFER_SIZE );
+    memset( rxtxBuffer, 0, ( size_t )RX_BUFFER_SIZE );
 
     this->settings.State = RF_RX_RUNNING;
     if( timeout != 0 )
@@ -806,13 +812,14 @@
     case MODEM_FSK:
         {
             // DIO0=PacketSent
-            // DIO1=FifoLevel
+            // DIO1=FifoEmpty
             // DIO2=FifoFull
             // DIO3=FifoEmpty
             // DIO4=LowBat
             // DIO5=ModeReady
             Write( REG_DIOMAPPING1, ( Read( REG_DIOMAPPING1 ) & RF_DIOMAPPING1_DIO0_MASK &
-                                                                            RF_DIOMAPPING1_DIO2_MASK ) );
+                                                                RF_DIOMAPPING1_DIO2_MASK ) |
+                                                                RF_DIOMAPPING1_DIO1_01 );
 
             Write( REG_DIOMAPPING2, ( Read( REG_DIOMAPPING2 ) & RF_DIOMAPPING2_DIO4_MASK &
                                                                             RF_DIOMAPPING2_MAP_MASK ) );
@@ -1089,12 +1096,12 @@
                     {
                         this->settings.FskPacketHandler.Size = Read( REG_PAYLOADLENGTH );
                     }
-                    ReadFifo( rxBuffer + this->settings.FskPacketHandler.NbBytes, this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
+                    ReadFifo( rxtxBuffer + this->settings.FskPacketHandler.NbBytes, this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
                     this->settings.FskPacketHandler.NbBytes += ( this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
                 }
                 else
                 {
-                    ReadFifo( rxBuffer + this->settings.FskPacketHandler.NbBytes, this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
+                    ReadFifo( rxtxBuffer + this->settings.FskPacketHandler.NbBytes, this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
                     this->settings.FskPacketHandler.NbBytes += ( this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
                 }
 
@@ -1116,7 +1123,7 @@
 
                 if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) )
                 {
-                    this->RadioEvents->RxDone( rxBuffer, this->settings.FskPacketHandler.Size, this->settings.FskPacketHandler.RssiValue, 0 );
+                    this->RadioEvents->RxDone( rxtxBuffer, this->settings.FskPacketHandler.Size, this->settings.FskPacketHandler.RssiValue, 0 ); 
                 } 
                 this->settings.FskPacketHandler.PreambleDetected = false;
                 this->settings.FskPacketHandler.SyncWordDetected = false;
@@ -1174,7 +1181,7 @@
                     }
 
                     this->settings.LoRaPacketHandler.Size = Read( REG_LR_RXNBBYTES );
-                    ReadFifo( rxBuffer, this->settings.LoRaPacketHandler.Size );
+                    ReadFifo( rxtxBuffer, this->settings.LoRaPacketHandler.Size );
                 
                     if( this->settings.LoRa.RxContinuous == false )
                     {
@@ -1184,7 +1191,7 @@
 
                     if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) )
                     {
-                        this->RadioEvents->RxDone( rxBuffer, this->settings.LoRaPacketHandler.Size, this->settings.LoRaPacketHandler.RssiValue, this->settings.LoRaPacketHandler.SnrValue );
+                        this->RadioEvents->RxDone( rxtxBuffer, this->settings.LoRaPacketHandler.Size, this->settings.LoRaPacketHandler.RssiValue, this->settings.LoRaPacketHandler.SnrValue );
                     }
                 }
                 break;
@@ -1240,12 +1247,12 @@
 
                 if( ( this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes ) > this->settings.FskPacketHandler.FifoThresh )
                 {
-                    ReadFifo( ( rxBuffer + this->settings.FskPacketHandler.NbBytes ), this->settings.FskPacketHandler.FifoThresh );
+                    ReadFifo( ( rxtxBuffer + this->settings.FskPacketHandler.NbBytes ), this->settings.FskPacketHandler.FifoThresh );
                     this->settings.FskPacketHandler.NbBytes += this->settings.FskPacketHandler.FifoThresh;
                 }
                 else
                 {
-                    ReadFifo( ( rxBuffer + this->settings.FskPacketHandler.NbBytes ), this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
+                    ReadFifo( ( rxtxBuffer + this->settings.FskPacketHandler.NbBytes ), this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
                     this->settings.FskPacketHandler.NbBytes += ( this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
                 }
                 break;
@@ -1269,13 +1276,13 @@
                 // FifoLevel interrupt
                 if( ( this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes ) > this->settings.FskPacketHandler.ChunkSize )
                 {
-                    WriteFifo( ( rxBuffer + this->settings.FskPacketHandler.NbBytes ), this->settings.FskPacketHandler.ChunkSize );
+                    WriteFifo( ( rxtxBuffer + this->settings.FskPacketHandler.NbBytes ), this->settings.FskPacketHandler.ChunkSize );
                     this->settings.FskPacketHandler.NbBytes += this->settings.FskPacketHandler.ChunkSize;
                 }
                 else 
                 {
                     // Write the last chunk of data
-                    WriteFifo( rxBuffer + this->settings.FskPacketHandler.NbBytes, this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
+                    WriteFifo( rxtxBuffer + this->settings.FskPacketHandler.NbBytes, this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes );
                     this->settings.FskPacketHandler.NbBytes += this->settings.FskPacketHandler.Size - this->settings.FskPacketHandler.NbBytes;
                 }
                 break;