1
Diff: radio_sx126x.cpp
- Revision:
- 15:e1c04ec39aa4
- Parent:
- 14:94993ae5b164
- Parent:
- 13:a354f82d12d9
- Child:
- 17:5f34cbe2ac53
diff -r 94993ae5b164 -r e1c04ec39aa4 radio_sx126x.cpp --- a/radio_sx126x.cpp Wed Sep 11 13:20:21 2019 -0700 +++ b/radio_sx126x.cpp Wed Sep 11 13:23:37 2019 -0700 @@ -41,6 +41,7 @@ const RadioEvents_t* RadioEvents; PacketParams_t Radio::pp; RadioModems_t Radio::_m_; +uint8_t Radio::loraTimeoutSymbols; #if defined(TARGET_FF_MORPHO) && !defined(TARGET_DISCO_L072CZ_LRWAN1) DigitalOut pc3(PC_3); // debug RX indication, for nucleo boards @@ -72,10 +73,18 @@ #ifdef RX_INDICATION RX_INDICATION = 1; #endif - if (timeout == 0) + if (timeout == 0) { + uint8_t symbs = 0; + if (radio.getPacketType() == PACKET_TYPE_LORA) // shut off timeout + radio.xfer(OPCODE_SET_LORA_SYMBOL_TIMEOUT, 1, 0, &symbs); + radio.start_rx(RX_TIMEOUT_CONTINUOUS); - else + } else { + if (radio.getPacketType() == PACKET_TYPE_LORA) + radio.xfer(OPCODE_SET_LORA_SYMBOL_TIMEOUT, 1, 0, &loraTimeoutSymbols); + radio.start_rx(timeout * RC_TICKS_PER_US); + } } void Radio::Standby() @@ -304,12 +313,13 @@ } -void Radio::SetLoRaSymbolTimeout(uint8_t symbs) +void Radio::SetLoRaSymbolTimeout(uint16_t symbs) { if (radio.getPacketType() != PACKET_TYPE_LORA) radio.setPacketType(PACKET_TYPE_LORA); - radio.xfer(OPCODE_SET_LORA_SYMBOL_TIMEOUT, 1, 0, &symbs); + loraTimeoutSymbols = symbs; + radio.xfer(OPCODE_SET_LORA_SYMBOL_TIMEOUT, 1, 0, &loraTimeoutSymbols); } float Radio::GetRssiInst() @@ -451,7 +461,7 @@ RadioEvents->TxDone_botHalf(); } -void Radio::Init(const RadioEvents_t* e) +void Radio::Init(const RadioEvents_t* e, unsigned spi_hz) { radio.txDone = txDoneBottom; radio.rxDone = rx_done; @@ -462,6 +472,7 @@ RadioEvents = e; lpt.start(); + spi.frequency(spi_hz); radio.SetDIO2AsRfSwitchCtrl(1); }