Fix ADR channel mask handling

Dependents:  

Fork of lmic_MOTE_L152RC by canuck lehead

Revision:
2:edb5d1f3deeb
Parent:
0:f2716e543d97
Child:
3:d87012f45bf6
diff -r 04fd63382b03 -r edb5d1f3deeb radio.cpp
--- a/radio.cpp	Wed Jun 03 23:17:59 2015 +0000
+++ b/radio.cpp	Thu Jun 04 20:00:55 2015 +0000
@@ -10,6 +10,7 @@
  *******************************************************************************/
 
 #include "lmic.h"
+#include "debug.h"  // wbr
 
 // ---------------------------------------- 
 // Registers Mapping
@@ -414,15 +415,25 @@
 #elif defined(CFG_sx1272_radio)
     // set PA config (2-17 dBm using PA_BOOST)
     s1_t pw = (s1_t)LMIC.txpow;
-    if(pw > 17) {
+    /*if(pw > 17) {
         pw = 17;
     } else if(pw < 2) {
         pw = 2;
+    }*/
+    /* NA-mote TX power config: */
+    if (pw > 23) {
+        // use RFO with external amplifier
+        PaSelect = 0x00;    // use RFO
+        writeReg(RegPaConfig, (u1_t)(PaSelect|(pw-25)));
+    } else {
+        // use PA_BOOST directo to antenna
+        PaSelect = 0x80;    // use PA_BOOST 
+        if (pw > 17)
+            pw = 17;
+        writeReg(RegPaConfig, (u1_t)(PaSelect|(pw-2)));
     }
     
-    PaSelect = 0x80;    // use PA_BOOST 
-    //PaSelect = 0x00;    // use RFO for external amplifier
-    writeReg(RegPaConfig, (u1_t)(PaSelect|(pw-2)));
+    
 #else
 #error Missing CFG_sx1272_radio/CFG_sx1276_radio
 #endif /* CFG_sx1272_radio */
@@ -465,7 +476,7 @@
     writeBuf(RegFifo, LMIC.frame, LMIC.dataLen);
 
     // enable antenna switch for TX
-    //hal_pin_rxtx(1);
+    //hal_pin_rxtx(1); usint hal_opmode
     
     // now we actually start the transmission
     opmode(OPMODE_TX);
@@ -505,7 +516,7 @@
     writeBuf(RegFifo, LMIC.frame, LMIC.dataLen);
 
     // enable antenna switch for TX
-    //hal_pin_rxtx(1);
+    //hal_pin_rxtx(1); using hal_opmode
     
     // now we actually start the transmission
     opmode(OPMODE_TX);
@@ -567,7 +578,7 @@
     writeReg(LORARegIrqFlagsMask, ~rxlorairqmask[rxmode]);
 
     // enable antenna switch for RX
-    //hal_pin_rxtx(0);
+    //hal_pin_rxtx(0); using hal_opmode
 
     // now instruct the radio to receive
     if (rxmode == RXMODE_SINGLE) { // single rx
@@ -622,7 +633,7 @@
     writeReg(RegDioMapping1, MAP_DIO0_FSK_READY|MAP_DIO1_FSK_NOP|MAP_DIO2_FSK_TIMEOUT);
 
     // enable antenna switch for RX
-    //hal_pin_rxtx(0);
+    //hal_pin_rxtx(0); using hal_opmode
     
     // now instruct the radio to receive
     hal_waitUntil(LMIC.rxtime); // busy wait until exact rx time