Driver for the SX1276 RF Transceiver(Updated to work with nucleo, tested with L073RZ)

Fork of SX1276Lib by Semtech

Revision:
27:4fa62fc82e92
Parent:
26:d09a8ef807e2
--- a/sx1276/sx1276.cpp	Mon Apr 24 09:26:23 2017 +0000
+++ b/sx1276/sx1276.cpp	Tue Nov 28 18:50:30 2017 +0000
@@ -825,7 +825,7 @@
     this->settings.State = RF_RX_RUNNING;
     if( timeout != 0 )
     {
-        rxTimeoutTimer.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ), timeout * 1e3 );
+         rxTimeoutTimer.attach_us( this, &SX1276::OnTimeoutIrq, timeout );
     }
 
     if( this->settings.Modem == MODEM_FSK )
@@ -834,8 +834,11 @@
 
         if( rxContinuous == false )
         {
-            rxTimeoutSyncWord.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ),
-                                         this->settings.Fsk.RxSingleTimeout * 1e3 );
+            rxTimeoutSyncWord.attach_us( this, &SX1276::OnTimeoutIrq, ceil( ( 8.0 * ( this->settings.Fsk.PreambleLen +
+                                                             ( ( Read( REG_SYNCCONFIG ) &
+                                                                ~RF_SYNCCONFIG_SYNCSIZE_MASK ) +
+                                                                1.0 ) + 10.0 ) /
+                                                             ( double )this->settings.Fsk.Datarate ) * 1e6 ) + 4000 );
         }
     }
     else
@@ -909,7 +912,7 @@
     }
 
     this->settings.State = RF_TX_RUNNING;
-    txTimeoutTimer.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ), timeout * 1e3 );
+    txTimeoutTimer.attach_us( this, &SX1276::OnTimeoutIrq, timeout );
     SetOpMode( RF_OPMODE_TRANSMITTER );
 }
 
@@ -960,7 +963,7 @@
     Write( REG_DIOMAPPING2, RF_DIOMAPPING2_DIO4_10 | RF_DIOMAPPING2_DIO5_10 );
 
     this->settings.State = RF_TX_RUNNING;
-    txTimeoutTimer.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ), timeout );
+    txTimeoutTimer.attach_us( this, &SX1276::OnTimeoutIrq, timeout );
     SetOpMode( RF_OPMODE_TRANSMITTER );
 }
 
@@ -1097,8 +1100,11 @@
             {
                 // Continuous mode restart Rx chain
                 Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
-                rxTimeoutSyncWord.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ),
-                                             this->settings.Fsk.RxSingleTimeout * 1e3 );
+                rxTimeoutSyncWord.attach_us( this, &SX1276::OnTimeoutIrq, ceil( ( 8.0 * ( this->settings.Fsk.PreambleLen +
+                                                             ( ( Read( REG_SYNCCONFIG ) &
+                                                                ~RF_SYNCCONFIG_SYNCSIZE_MASK ) +
+                                                             1.0 ) + 10.0 ) /
+                                                            ( double )this->settings.Fsk.Datarate ) * 1e6 ) + 4000 );
             }
             else
             {
@@ -1182,8 +1188,11 @@
                         {
                             // Continuous mode restart Rx chain
                             Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
-                            rxTimeoutSyncWord.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ),
-                                                         this->settings.Fsk.RxSingleTimeout * 1e3 );
+                            rxTimeoutSyncWord.attach_us( this, &SX1276::OnTimeoutIrq, ceil( ( 8.0 * ( this->settings.Fsk.PreambleLen +
+                                                                         ( ( Read( REG_SYNCCONFIG ) &
+                                                                            ~RF_SYNCCONFIG_SYNCSIZE_MASK ) +
+                                                                         1.0 ) + 10.0 ) /
+                                                                        ( double )this->settings.Fsk.Datarate ) * 1e6 ) + 4000 );
                         }
 
                         if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxError != NULL ) )
@@ -1229,8 +1238,11 @@
                 {
                     // Continuous mode restart Rx chain
                     Write( REG_RXCONFIG, Read( REG_RXCONFIG ) | RF_RXCONFIG_RESTARTRXWITHOUTPLLLOCK );
-                    rxTimeoutSyncWord.attach_us( mbed::callback( this, &SX1276::OnTimeoutIrq ),
-                                                 this->settings.Fsk.RxSingleTimeout * 1e3 );
+                    rxTimeoutSyncWord.attach_us( this, &SX1276::OnTimeoutIrq, ceil( ( 8.0 * ( this->settings.Fsk.PreambleLen +
+                                                                         ( ( Read( REG_SYNCCONFIG ) &
+                                                                            ~RF_SYNCCONFIG_SYNCSIZE_MASK ) +
+                                                                         1.0 ) + 10.0 ) /
+                                                                        ( double )this->settings.Fsk.Datarate ) * 1e6 ) + 4000 );
                 }
 
                 if( ( this->RadioEvents != NULL ) && ( this->RadioEvents->RxDone != NULL ) )