Hardware Abstraction Layer, permitting any LoRa application to use any LoRa radio chip

Dependents:   alarm_slave alarm_master lora_p2p lorawan1v1 ... more

radio chip selection

Radio chip driver is not included, allowing choice of radio device.
If you're using SX1272 or SX1276, then import sx127x driver into your program.
if you're using SX1261 or SX1262, then import sx126x driver into your program.
if you're using SX1280, then import sx1280 driver into your program.
if you're using LR1110, then import LR1110 driver into your program.
If you're using NAmote72 or Murata discovery, then you must import only sx127x driver.
If you're using Type1SJ select target DISCO_L072CZ_LRWAN1 and import sx126x driver into your program.

Pin assigned to arduino LoRa radio shield form-factor

Revision:
5:ab124d3842a8
Parent:
4:57080d572494
Child:
7:ba81f66e56d1
--- a/radio_sx126x.cpp	Mon Aug 20 14:07:47 2018 -0700
+++ b/radio_sx126x.cpp	Sun Nov 25 17:12:03 2018 -0800
@@ -4,6 +4,7 @@
 
 LowPowerTimer Radio::lpt;
 volatile us_timestamp_t Radio::irqAt;
+bool Radio::paOff;
 
 #ifdef TARGET_FF_ARDUINO
     SPIu spi(D11, D12, D13); // mosi, miso, sclk
@@ -93,7 +94,23 @@
 
 void Radio::set_tx_dbm(int8_t dbm)
 {
-    radio.set_tx_dbm(chipType == CHIP_TYPE_SX1262, dbm);
+    unsigned v = radio.readReg(REG_ADDR_ANACTRL16, 1);
+
+    if (dbm == PA_OFF_DBM) {
+        /* bench test: prevent overloading receiving station (very low tx power) */
+        if ((v & 0x10) == 0) {
+            v |= 0x10;
+            radio.writeReg(REG_ADDR_ANACTRL16, v, 1);
+        }
+        paOff = true;
+    } else {
+        radio.set_tx_dbm(chipType == CHIP_TYPE_SX1262, dbm);
+        if (v & 0x10) {
+            v &= ~0x10;
+            radio.writeReg(REG_ADDR_ANACTRL16, v, 1);
+        }
+        paOff = false;
+    }
 }
 
 void Radio::SetTxContinuousWave(unsigned hz, int8_t dbm, unsigned timeout_us)
@@ -360,6 +377,13 @@
         } while ((now - chFreeAt) < channelFreeTime);
     } 
 
+    if (paOff) {
+        unsigned v = radio.readReg(REG_ADDR_ANACTRL16, 1);
+        if ((v & 0x10) == 0) {
+            v |= 0x10;
+            radio.writeReg(REG_ADDR_ANACTRL16, v, 1);
+        }
+    }
     radio.start_tx(size);
 
     return 0;