123

Revision:
27:da6341d9d5b1
Parent:
26:4876e515ff4c
Child:
31:b66d7a057b22
--- a/sx127x_lora.cpp	Mon Jul 18 21:13:50 2016 +0000
+++ b/sx127x_lora.cpp	Thu Jul 28 00:57:22 2016 +0000
@@ -23,7 +23,6 @@
         
     RegModemConfig.octet = m_xcvr.read_reg(REG_LR_MODEMCONFIG);
     RegModemConfig2.octet = m_xcvr.read_reg(REG_LR_MODEMCONFIG2);
-    RegTest31.octet = m_xcvr.read_reg(REG_LR_TEST31);
     RegTest33.octet = m_xcvr.read_reg(REG_LR_TEST33);     // invert_i_q
     RegDriftInvert.octet = m_xcvr.read_reg(REG_LR_DRIFT_INVERT);
     RegGainDrift.octet = m_xcvr.read_reg(REG_LR_GAIN_DRIFT);
@@ -31,6 +30,8 @@
     if (m_xcvr.type == SX1276) {
         RegAutoDrift.octet = m_xcvr.read_reg(REG_LR_SX1276_AUTO_DRIFT);
     }
+    
+
 }
 
 SX127x_lora::~SX127x_lora()
@@ -72,6 +73,10 @@
     m_xcvr.RegDioMapping1.bits.Dio0Mapping = 0;    // DIO0 to RxDone
     m_xcvr.RegDioMapping1.bits.Dio1Mapping = 0;
     m_xcvr.write_reg(REG_DIOMAPPING1, m_xcvr.RegDioMapping1.octet);
+    
+    RegTest31.octet = m_xcvr.read_reg(REG_LR_TEST31);    
+    RegTest31.bits.if_freq_auto = 0;    // improved RX spurious rejection
+    m_xcvr.write_reg(REG_LR_TEST31, RegTest31.octet);    
         
     m_xcvr.set_opmode(RF_OPMODE_STANDBY);            
 }
@@ -392,7 +397,7 @@
     m_xcvr.set_opmode(RF_OPMODE_TRANSMITTER);
 }
 
-void SX127x_lora::start_rx()
+void SX127x_lora::start_rx(chip_mode_e mode)
 {
     if (!m_xcvr.RegOpMode.bits.LongRangeMode)
         return; // fsk mode
@@ -440,7 +445,7 @@
             break;
     }   
         
-    m_xcvr.set_opmode(RF_OPMODE_RECEIVER);
+    m_xcvr.set_opmode(mode);
 
     if (m_xcvr.RegDioMapping1.bits.Dio0Mapping != 0) {
         m_xcvr.RegDioMapping1.bits.Dio0Mapping = 0;    // DIO0 to RxDone