Fork of SX1276 library, with setLowDataRateOptimize() function added to configure "Low Datarate Optimize" setting of chip.

Dependents:   SX1276_terminal SX1276_Semtech_GUI

Fork of SX127x by wayne roberts

Revision:
8:8db8fc2ea650
Parent:
6:5d94ee847016
diff -r 5d94ee847016 -r 8db8fc2ea650 sx127x_lora.cpp
--- a/sx127x_lora.cpp	Mon Jun 30 17:05:12 2014 +0000
+++ b/sx127x_lora.cpp	Sat Feb 14 10:31:57 2015 +0000
@@ -182,6 +182,18 @@
 }
 
 
+//MODTRONIX added
+void SX127x_lora::setLowDataRateOptimize(bool val)
+{
+    if (m_xcvr.type == SX1272) {
+        RegModemConfig.sx1272bits.LowDataRateOptimize = val;
+        m_xcvr.write_reg(REG_LR_MODEMCONFIG, RegModemConfig.octet);
+    } else if (m_xcvr.type == SX1276) {
+        RegModemConfig3.sx1276bits.LowDataRateOptimize = val;
+        m_xcvr.write_reg(REG_LR_MODEMCONFIG3, RegModemConfig3.octet);
+    }
+}
+
 void SX127x_lora::setSf(uint8_t sf)
 {
     if (!m_xcvr.RegOpMode.bits.LongRangeMode)
@@ -216,7 +228,7 @@
             RegModemConfig.sx1272bits.LowDataRateOptimize = 0;
         m_xcvr.write_reg(REG_LR_MODEMCONFIG, RegModemConfig.octet);
     } else if (m_xcvr.type == SX1276) {
-        if (sf > 10 && RegModemConfig.sx1272bits.Bw == 0)   // if bw=125KHz and sf11 or sf12
+        if (sf > 10 && RegModemConfig.sx1276bits.Bw == 0)   // if bw=125KHz and sf11 or sf12
             RegModemConfig3.sx1276bits.LowDataRateOptimize = 1;
         else
             RegModemConfig3.sx1276bits.LowDataRateOptimize = 0;