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
- SX1272 shield.
- SX1276 shield.
- SX126x kit with color touch screen, or sx126x radio-only shield.
- Exceptions with their own pin assignments: NAMote-72 and Murata discovery board.
- TODO: pin assign XDOT.
Diff: radio_sx128x.cpp
- Revision:
- 15:e1c04ec39aa4
- Parent:
- 14:94993ae5b164
- Parent:
- 13:a354f82d12d9
- Child:
- 16:34de2ab7eb32
--- a/radio_sx128x.cpp Wed Sep 11 13:20:21 2019 -0700 +++ b/radio_sx128x.cpp Wed Sep 11 13:23:37 2019 -0700 @@ -296,7 +296,7 @@ RadioEvents->TxDone_botHalf(); } -void Radio::Init(const RadioEvents_t* e) +void Radio::Init(const RadioEvents_t* e, unsigned spi_hz) { uint64_t sa; @@ -306,6 +306,7 @@ radio.chipModeChange = chipModeChange; radio.diox_topHalf = diox_top_half; + spi.frequency(spi_hz); readChip(); radio.setRegulator(0); // default to LDO @@ -538,7 +539,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); @@ -549,15 +550,18 @@ if (radio.getPacketType() != PACKET_TYPE_LORA) radio.setPacketType(PACKET_TYPE_LORA); - if (bwKHz > 800) { + if (bwKHz > 800) mpLORA.lora.bandwidth = LORA_BW_1600; - } if (bwKHz > 400) { + else if (bwKHz > 400) mpLORA.lora.bandwidth = LORA_BW_800; - } if (bwKHz > 200) { + else if (bwKHz > 200) mpLORA.lora.bandwidth = LORA_BW_400; - } else { + else if (bwKHz > 100) mpLORA.lora.bandwidth = LORA_BW_200; - } + else if (bwKHz > 50) + mpLORA.lora.bandwidth = LORA_BW_100; + else + mpLORA.lora.bandwidth = LORA_BW_50; mpLORA.lora.codingRate = cr; @@ -627,12 +631,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); } }