1

Revision:
13:a354f82d12d9
Parent:
12:fcfafd17ae1b
Child:
15:e1c04ec39aa4
diff -r fcfafd17ae1b -r a354f82d12d9 radio_sx128x.cpp
--- a/radio_sx128x.cpp	Wed May 29 09:55:12 2019 -0700
+++ b/radio_sx128x.cpp	Fri May 31 10:21:30 2019 -0700
@@ -293,7 +293,7 @@
         RadioEvents->TxDone_botHalf();
 }
 
-void Radio::Init(const RadioEvents_t* e)
+void Radio::Init(const RadioEvents_t* e, unsigned spi_hz)
 {
     uint64_t sa;
 
@@ -303,6 +303,7 @@
     radio.chipModeChange = chipModeChange;
     radio.diox_topHalf = diox_top_half;
 
+    spi.frequency(spi_hz);
     readChip();
 
     radio.setRegulator(0);  // default to LDO
@@ -535,7 +536,7 @@
     radio.xfer(OPCODE_SET_PACKET_PARAMS, 7, 0, ppGFSK.buf);
 }
 
-void Radio::SetLoRaSymbolTimeout(uint8_t symbs)
+void Radio::SetLoRaSymbolTimeout(uint16_t symbs)
 {
     nSymbs = symbs;
     rxTimeoutMs = nSymbs * (symbolPeriodUs / 1000.0);
@@ -627,12 +628,15 @@
     radio.setStandby(STDBY_RC);
 }
 
+#define TX_PWR_OFFSET           18
 void Radio::set_tx_dbm(int8_t dbm)
 {
     if (dbm == PA_OFF_DBM) {
         /* TODO: shut off PA */
+        radio.set_tx_dbm(0);
     } else {
-        radio.set_tx_dbm(dbm);
+        /* power range -18dBm to +13dBm */
+        radio.set_tx_dbm(dbm + TX_PWR_OFFSET);
     }
 }