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

Committer:
Wayne Roberts
Date:
Mon Jun 01 15:59:56 2020 -0700
Revision:
17:5f34cbe2ac53
Child:
21:96db08266089
support platforms without LowPowerTimer, add LR1110

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wayne Roberts 17:5f34cbe2ac53 1 #include "radio.h"
Wayne Roberts 17:5f34cbe2ac53 2 #ifdef SX1265_H
Wayne Roberts 17:5f34cbe2ac53 3 #include "SPIu.h"
Wayne Roberts 17:5f34cbe2ac53 4
Wayne Roberts 17:5f34cbe2ac53 5 #ifdef TARGET_FF_ARDUINO
Wayne Roberts 17:5f34cbe2ac53 6 SPI spi(D11, D12, D13); // mosi, miso, sclk
Wayne Roberts 17:5f34cbe2ac53 7 //spi, nss, busy, dio9, nreset
Wayne Roberts 17:5f34cbe2ac53 8 SX1265 Radio::radio(spi, D7, D3, D5, A0);
Wayne Roberts 17:5f34cbe2ac53 9
Wayne Roberts 17:5f34cbe2ac53 10 static void initRfSwDIO()
Wayne Roberts 17:5f34cbe2ac53 11 {
Wayne Roberts 17:5f34cbe2ac53 12 /*stat_t stat;*/
Wayne Roberts 17:5f34cbe2ac53 13 uint8_t dioBuf[8];
Wayne Roberts 17:5f34cbe2ac53 14 /* antenna truth table
Wayne Roberts 17:5f34cbe2ac53 15 * V1 V2 port
Wayne Roberts 17:5f34cbe2ac53 16 * 0 0 shutdown
Wayne Roberts 17:5f34cbe2ac53 17 * 1 0 J2 rx RFI
Wayne Roberts 17:5f34cbe2ac53 18 * 0 1 J1 HP tx RFO
Wayne Roberts 17:5f34cbe2ac53 19 * 1 1 J3 LP tx RFO
Wayne Roberts 17:5f34cbe2ac53 20 * DIO5 DIO6
Wayne Roberts 17:5f34cbe2ac53 21 */
Wayne Roberts 17:5f34cbe2ac53 22 dioBuf[ DIO_en_IDX] = DIO5_BIT | DIO6_BIT;
Wayne Roberts 17:5f34cbe2ac53 23 dioBuf[DIO_stby_IDX] = 0;
Wayne Roberts 17:5f34cbe2ac53 24 dioBuf[ DIO_rx_IDX] = DIO5_BIT;
Wayne Roberts 17:5f34cbe2ac53 25 dioBuf[ DIO_tx_IDX] = DIO5_BIT | DIO6_BIT;
Wayne Roberts 17:5f34cbe2ac53 26 dioBuf[DIO_txhp_IDX] = DIO6_BIT;
Wayne Roberts 17:5f34cbe2ac53 27 dioBuf[DIO_gnss_IDX] = 0;
Wayne Roberts 17:5f34cbe2ac53 28 dioBuf[DIO_wifi_IDX] = 0;
Wayne Roberts 17:5f34cbe2ac53 29 /*stat.word =*/ Radio::radio.xfer(OPCODE_SET_DIO_AS_RFSWITCH, 8, 0, dioBuf);
Wayne Roberts 17:5f34cbe2ac53 30 }
Wayne Roberts 17:5f34cbe2ac53 31 #else
Wayne Roberts 17:5f34cbe2ac53 32 /* declare pins for form-factor */
Wayne Roberts 17:5f34cbe2ac53 33 #error non-ardiuno-form-factor
Wayne Roberts 17:5f34cbe2ac53 34 #endif /* TARGET_FF_ARDUINO */
Wayne Roberts 17:5f34cbe2ac53 35
Wayne Roberts 17:5f34cbe2ac53 36 uint8_t gfsk_pp_buf[9];
Wayne Roberts 17:5f34cbe2ac53 37 uint8_t gfsk_mp_buf[10];
Wayne Roberts 17:5f34cbe2ac53 38 uint8_t lora_pp_buf[6];
Wayne Roberts 17:5f34cbe2ac53 39 uint8_t lora_mp_buf[4];
Wayne Roberts 17:5f34cbe2ac53 40
Wayne Roberts 17:5f34cbe2ac53 41 const RadioEvents_t* RadioEvents;
Wayne Roberts 17:5f34cbe2ac53 42 LowPowerTimer Radio::lpt;
Wayne Roberts 17:5f34cbe2ac53 43 volatile us_timestamp_t Radio::irqAt;
Wayne Roberts 17:5f34cbe2ac53 44 uint8_t Radio::loraTimeoutSymbols;
Wayne Roberts 17:5f34cbe2ac53 45
Wayne Roberts 17:5f34cbe2ac53 46 void Radio::LoRaPacketConfig(unsigned preambleLen, bool fixLen, bool crcOn, bool invIQ)
Wayne Roberts 17:5f34cbe2ac53 47 {
Wayne Roberts 17:5f34cbe2ac53 48 /*stat_t stat;*/
Wayne Roberts 17:5f34cbe2ac53 49 if (radio.getPacketType() != PACKET_TYPE_LORA)
Wayne Roberts 17:5f34cbe2ac53 50 radio.setPacketType(PACKET_TYPE_LORA);
Wayne Roberts 17:5f34cbe2ac53 51
Wayne Roberts 17:5f34cbe2ac53 52 radio.to_big_endian16(preambleLen, lora_pp_buf);
Wayne Roberts 17:5f34cbe2ac53 53 lora_pp_buf[2] = fixLen;
Wayne Roberts 17:5f34cbe2ac53 54 /* lora_pp_buf[3] = set when txing, initialized to zero in Init */
Wayne Roberts 17:5f34cbe2ac53 55 lora_pp_buf[4] = crcOn;
Wayne Roberts 17:5f34cbe2ac53 56 lora_pp_buf[5] = invIQ;
Wayne Roberts 17:5f34cbe2ac53 57 /*stat.word =*/ radio.xfer(OPCODE_SET_PACKET_PARAM, 6, 0, lora_pp_buf);
Wayne Roberts 17:5f34cbe2ac53 58 }
Wayne Roberts 17:5f34cbe2ac53 59
Wayne Roberts 17:5f34cbe2ac53 60 void Radio::set_tx_dbm(int8_t dbm)
Wayne Roberts 17:5f34cbe2ac53 61 {
Wayne Roberts 17:5f34cbe2ac53 62 /*stat_t stat;*/
Wayne Roberts 17:5f34cbe2ac53 63 uint8_t buf[4];
Wayne Roberts 17:5f34cbe2ac53 64 int8_t txpower;
Wayne Roberts 17:5f34cbe2ac53 65 unsigned PaSel, RegPaSupply, PaDutyCycle, PaHPSel;
Wayne Roberts 17:5f34cbe2ac53 66
Wayne Roberts 17:5f34cbe2ac53 67 if (dbm > 20) {
Wayne Roberts 17:5f34cbe2ac53 68 txpower = 22;
Wayne Roberts 17:5f34cbe2ac53 69 PaSel = 1;
Wayne Roberts 17:5f34cbe2ac53 70 RegPaSupply = 1;
Wayne Roberts 17:5f34cbe2ac53 71 PaDutyCycle = 4;
Wayne Roberts 17:5f34cbe2ac53 72 PaHPSel = 7;
Wayne Roberts 17:5f34cbe2ac53 73 } else if (dbm > 17) {
Wayne Roberts 17:5f34cbe2ac53 74 txpower = 22;
Wayne Roberts 17:5f34cbe2ac53 75 PaSel = 1;
Wayne Roberts 17:5f34cbe2ac53 76 RegPaSupply = 1;
Wayne Roberts 17:5f34cbe2ac53 77 PaDutyCycle = 2;
Wayne Roberts 17:5f34cbe2ac53 78 PaHPSel = 7;
Wayne Roberts 17:5f34cbe2ac53 79 } else if (dbm > 15) {
Wayne Roberts 17:5f34cbe2ac53 80 txpower = 22;
Wayne Roberts 17:5f34cbe2ac53 81 PaSel = 1;
Wayne Roberts 17:5f34cbe2ac53 82 RegPaSupply = 1;
Wayne Roberts 17:5f34cbe2ac53 83 PaDutyCycle = 4;
Wayne Roberts 17:5f34cbe2ac53 84 PaHPSel = 3;
Wayne Roberts 17:5f34cbe2ac53 85 } else {
Wayne Roberts 17:5f34cbe2ac53 86 txpower = 14;
Wayne Roberts 17:5f34cbe2ac53 87 PaSel = 0;
Wayne Roberts 17:5f34cbe2ac53 88 RegPaSupply = 0;
Wayne Roberts 17:5f34cbe2ac53 89 if (dbm > 14)
Wayne Roberts 17:5f34cbe2ac53 90 PaDutyCycle = 7;
Wayne Roberts 17:5f34cbe2ac53 91 else if (dbm > 10)
Wayne Roberts 17:5f34cbe2ac53 92 PaDutyCycle = 4;
Wayne Roberts 17:5f34cbe2ac53 93 else
Wayne Roberts 17:5f34cbe2ac53 94 PaDutyCycle = 0;
Wayne Roberts 17:5f34cbe2ac53 95 PaHPSel = 0;
Wayne Roberts 17:5f34cbe2ac53 96 }
Wayne Roberts 17:5f34cbe2ac53 97
Wayne Roberts 17:5f34cbe2ac53 98 buf[0] = PaSel;
Wayne Roberts 17:5f34cbe2ac53 99 buf[1] = RegPaSupply;
Wayne Roberts 17:5f34cbe2ac53 100 buf[2] = PaDutyCycle;
Wayne Roberts 17:5f34cbe2ac53 101 buf[3] = PaHPSel;
Wayne Roberts 17:5f34cbe2ac53 102 /*stat.word =*/ radio.xfer(OPCODE_SET_PA_CONFIG, 4, 0, buf);
Wayne Roberts 17:5f34cbe2ac53 103
Wayne Roberts 17:5f34cbe2ac53 104 buf[0] = txpower;
Wayne Roberts 17:5f34cbe2ac53 105 buf[1] = 4;
Wayne Roberts 17:5f34cbe2ac53 106 /*stat.word =*/ radio.xfer(OPCODE_SET_TXPARAMS, 2, 0, buf);
Wayne Roberts 17:5f34cbe2ac53 107 }
Wayne Roberts 17:5f34cbe2ac53 108
Wayne Roberts 17:5f34cbe2ac53 109 void Radio::SetChannel(unsigned hz)
Wayne Roberts 17:5f34cbe2ac53 110 {
Wayne Roberts 17:5f34cbe2ac53 111 /*stat_t stat;*/
Wayne Roberts 17:5f34cbe2ac53 112 uint8_t buf[4];
Wayne Roberts 17:5f34cbe2ac53 113 radio.to_big_endian32(hz, buf);
Wayne Roberts 17:5f34cbe2ac53 114 /*stat.word =*/ radio.xfer(OPCODE_SET_RF_FREQ_HZ, 4, 0, buf);
Wayne Roberts 17:5f34cbe2ac53 115 }
Wayne Roberts 17:5f34cbe2ac53 116
Wayne Roberts 17:5f34cbe2ac53 117 void Radio::Standby()
Wayne Roberts 17:5f34cbe2ac53 118 {
Wayne Roberts 17:5f34cbe2ac53 119 /*stat_t stat;*/
Wayne Roberts 17:5f34cbe2ac53 120 uint8_t buf = 0; // 0=rc, 1=xosc
Wayne Roberts 17:5f34cbe2ac53 121 /*stat.word =*/ radio.xfer(OPCODE_SET_STANDBY, 1, 0, &buf);
Wayne Roberts 17:5f34cbe2ac53 122 }
Wayne Roberts 17:5f34cbe2ac53 123
Wayne Roberts 17:5f34cbe2ac53 124 void Radio::LoRaModemConfig(unsigned bwKHz, uint8_t sf, uint8_t cr)
Wayne Roberts 17:5f34cbe2ac53 125 {
Wayne Roberts 17:5f34cbe2ac53 126 /*stat_t stat;*/
Wayne Roberts 17:5f34cbe2ac53 127 uint8_t buf[4];
Wayne Roberts 17:5f34cbe2ac53 128 uint8_t ldro = 0;
Wayne Roberts 17:5f34cbe2ac53 129
Wayne Roberts 17:5f34cbe2ac53 130 if (radio.getPacketType() != PACKET_TYPE_LORA)
Wayne Roberts 17:5f34cbe2ac53 131 radio.setPacketType(PACKET_TYPE_LORA);
Wayne Roberts 17:5f34cbe2ac53 132
Wayne Roberts 17:5f34cbe2ac53 133 if (bwKHz > 500)
Wayne Roberts 17:5f34cbe2ac53 134 buf[1] = LORA_BW_1000KHz;
Wayne Roberts 17:5f34cbe2ac53 135 else if (bwKHz > 250)
Wayne Roberts 17:5f34cbe2ac53 136 buf[1] = LORA_BW_500KHz;
Wayne Roberts 17:5f34cbe2ac53 137 else if (bwKHz > 125) {
Wayne Roberts 17:5f34cbe2ac53 138 buf[1] = LORA_BW_250KHz;
Wayne Roberts 17:5f34cbe2ac53 139 } else if (bwKHz > 80) {
Wayne Roberts 17:5f34cbe2ac53 140 buf[1] = LORA_BW_125KHz;
Wayne Roberts 17:5f34cbe2ac53 141 if (sf > 11)
Wayne Roberts 17:5f34cbe2ac53 142 ldro = 1;
Wayne Roberts 17:5f34cbe2ac53 143 } else if (bwKHz > 16) {
Wayne Roberts 17:5f34cbe2ac53 144 buf[1] = LORA_BW_31_25KHz;
Wayne Roberts 17:5f34cbe2ac53 145 if (sf > 10)
Wayne Roberts 17:5f34cbe2ac53 146 ldro = 1;
Wayne Roberts 17:5f34cbe2ac53 147 } else if (bwKHz > 8) {
Wayne Roberts 17:5f34cbe2ac53 148 buf[1] = LORA_BW_15_6KHz;
Wayne Roberts 17:5f34cbe2ac53 149 if (sf > 9)
Wayne Roberts 17:5f34cbe2ac53 150 ldro = 1;
Wayne Roberts 17:5f34cbe2ac53 151 } else {
Wayne Roberts 17:5f34cbe2ac53 152 buf[1] = LORA_BW_7_8KHz;
Wayne Roberts 17:5f34cbe2ac53 153 if (sf > 8)
Wayne Roberts 17:5f34cbe2ac53 154 ldro = 1;
Wayne Roberts 17:5f34cbe2ac53 155 }
Wayne Roberts 17:5f34cbe2ac53 156
Wayne Roberts 17:5f34cbe2ac53 157 buf[0] = sf;
Wayne Roberts 17:5f34cbe2ac53 158 buf[2] = cr;
Wayne Roberts 17:5f34cbe2ac53 159 buf[3] = ldro;
Wayne Roberts 17:5f34cbe2ac53 160 /*stat.word =*/ radio.xfer(OPCODE_SET_MODULATION, 4, 0, buf);
Wayne Roberts 17:5f34cbe2ac53 161 }
Wayne Roberts 17:5f34cbe2ac53 162
Wayne Roberts 17:5f34cbe2ac53 163 int Radio::Send(uint8_t size, timestamp_t maxListenTime, timestamp_t channelFreeTime, int rssiThresh)
Wayne Roberts 17:5f34cbe2ac53 164 {
Wayne Roberts 17:5f34cbe2ac53 165 /*stat_t stat;*/
Wayne Roberts 17:5f34cbe2ac53 166 uint8_t pktType;
Wayne Roberts 17:5f34cbe2ac53 167
Wayne Roberts 17:5f34cbe2ac53 168 pktType = radio.getPacketType();
Wayne Roberts 17:5f34cbe2ac53 169 if (pktType == PACKET_TYPE_LORA) {
Wayne Roberts 17:5f34cbe2ac53 170 lora_pp_buf[3] = size;
Wayne Roberts 17:5f34cbe2ac53 171 /*stat.word =*/ radio.xfer(OPCODE_SET_PACKET_PARAM, 6, 0, lora_pp_buf);
Wayne Roberts 17:5f34cbe2ac53 172 } else if (pktType == PACKET_TYPE_GFSK) {
Wayne Roberts 17:5f34cbe2ac53 173 gfsk_pp_buf[6] = size;
Wayne Roberts 17:5f34cbe2ac53 174 /*stat.word =*/ radio.xfer(OPCODE_SET_PACKET_PARAM, 9, 0, gfsk_pp_buf);
Wayne Roberts 17:5f34cbe2ac53 175 }
Wayne Roberts 17:5f34cbe2ac53 176
Wayne Roberts 17:5f34cbe2ac53 177 /* TODO: LBT */
Wayne Roberts 17:5f34cbe2ac53 178
Wayne Roberts 17:5f34cbe2ac53 179 radio.start_tx(size);
Wayne Roberts 17:5f34cbe2ac53 180 return 0;
Wayne Roberts 17:5f34cbe2ac53 181 }
Wayne Roberts 17:5f34cbe2ac53 182
Wayne Roberts 17:5f34cbe2ac53 183 void Radio::service()
Wayne Roberts 17:5f34cbe2ac53 184 {
Wayne Roberts 17:5f34cbe2ac53 185 irq_t irq;
Wayne Roberts 17:5f34cbe2ac53 186 irq.dword = radio.service();
Wayne Roberts 17:5f34cbe2ac53 187 if (irq.dword != 0) {
Wayne Roberts 17:5f34cbe2ac53 188 }
Wayne Roberts 17:5f34cbe2ac53 189 }
Wayne Roberts 17:5f34cbe2ac53 190
Wayne Roberts 17:5f34cbe2ac53 191 void Radio::dio9_top_half()
Wayne Roberts 17:5f34cbe2ac53 192 {
Wayne Roberts 17:5f34cbe2ac53 193 irqAt = lpt.read_us();
Wayne Roberts 17:5f34cbe2ac53 194
Wayne Roberts 17:5f34cbe2ac53 195 if (RadioEvents->DioPin_top_half)
Wayne Roberts 17:5f34cbe2ac53 196 RadioEvents->DioPin_top_half();
Wayne Roberts 17:5f34cbe2ac53 197
Wayne Roberts 17:5f34cbe2ac53 198 if (radio.chipMode == CHIPMODE_TX) {
Wayne Roberts 17:5f34cbe2ac53 199 /* TxDone handling requires low latency */
Wayne Roberts 17:5f34cbe2ac53 200 if (RadioEvents->TxDone_topHalf) {
Wayne Roberts 17:5f34cbe2ac53 201 RadioEvents->TxDone_topHalf();
Wayne Roberts 17:5f34cbe2ac53 202 }
Wayne Roberts 17:5f34cbe2ac53 203 } else {
Wayne Roberts 17:5f34cbe2ac53 204 #ifdef RX_INDICATION
Wayne Roberts 17:5f34cbe2ac53 205 RX_INDICATION = 0;
Wayne Roberts 17:5f34cbe2ac53 206 #endif
Wayne Roberts 17:5f34cbe2ac53 207 }
Wayne Roberts 17:5f34cbe2ac53 208 }
Wayne Roberts 17:5f34cbe2ac53 209
Wayne Roberts 17:5f34cbe2ac53 210 void Radio::timeout_callback(bool tx)
Wayne Roberts 17:5f34cbe2ac53 211 {
Wayne Roberts 17:5f34cbe2ac53 212 if (!tx) {
Wayne Roberts 17:5f34cbe2ac53 213 if (RadioEvents->RxTimeout)
Wayne Roberts 17:5f34cbe2ac53 214 RadioEvents->RxTimeout();
Wayne Roberts 17:5f34cbe2ac53 215 } // else TODO tx timeout
Wayne Roberts 17:5f34cbe2ac53 216 }
Wayne Roberts 17:5f34cbe2ac53 217
Wayne Roberts 17:5f34cbe2ac53 218 void Radio::rx_done(uint8_t size, float rssi, float snr)
Wayne Roberts 17:5f34cbe2ac53 219 {
Wayne Roberts 17:5f34cbe2ac53 220 RadioEvents->RxDone(size, rssi, snr);
Wayne Roberts 17:5f34cbe2ac53 221 }
Wayne Roberts 17:5f34cbe2ac53 222
Wayne Roberts 17:5f34cbe2ac53 223 void Radio::txDoneBottom()
Wayne Roberts 17:5f34cbe2ac53 224 {
Wayne Roberts 17:5f34cbe2ac53 225 if (RadioEvents->TxDone_botHalf)
Wayne Roberts 17:5f34cbe2ac53 226 RadioEvents->TxDone_botHalf();
Wayne Roberts 17:5f34cbe2ac53 227 }
Wayne Roberts 17:5f34cbe2ac53 228
Wayne Roberts 17:5f34cbe2ac53 229 void Radio::Init(const RadioEvents_t* e, unsigned spi_hz)
Wayne Roberts 17:5f34cbe2ac53 230 {
Wayne Roberts 17:5f34cbe2ac53 231 /* initialize payload length to zero in packet params */
Wayne Roberts 17:5f34cbe2ac53 232 lora_pp_buf[3] = 0;
Wayne Roberts 17:5f34cbe2ac53 233 gfsk_pp_buf[6] = 0;
Wayne Roberts 17:5f34cbe2ac53 234
Wayne Roberts 17:5f34cbe2ac53 235 radio.txDone = txDoneBottom;
Wayne Roberts 17:5f34cbe2ac53 236 radio.rxDone = rx_done;
Wayne Roberts 17:5f34cbe2ac53 237 radio.timeout = timeout_callback;
Wayne Roberts 17:5f34cbe2ac53 238 //radio.chipModeChange = chipModeChange;
Wayne Roberts 17:5f34cbe2ac53 239 radio.dio9_topHalf = dio9_top_half;
Wayne Roberts 17:5f34cbe2ac53 240
Wayne Roberts 17:5f34cbe2ac53 241 RadioEvents = e;
Wayne Roberts 17:5f34cbe2ac53 242 lpt.start();
Wayne Roberts 17:5f34cbe2ac53 243
Wayne Roberts 17:5f34cbe2ac53 244 spi.frequency(spi_hz);
Wayne Roberts 17:5f34cbe2ac53 245
Wayne Roberts 17:5f34cbe2ac53 246 radio.hw_reset();
Wayne Roberts 17:5f34cbe2ac53 247
Wayne Roberts 17:5f34cbe2ac53 248 initRfSwDIO();
Wayne Roberts 17:5f34cbe2ac53 249 }
Wayne Roberts 17:5f34cbe2ac53 250
Wayne Roberts 17:5f34cbe2ac53 251 void Radio::SetLoRaSymbolTimeout(uint16_t symbs)
Wayne Roberts 17:5f34cbe2ac53 252 {
Wayne Roberts 17:5f34cbe2ac53 253 /*stat_t stat;*/
Wayne Roberts 17:5f34cbe2ac53 254 if (radio.getPacketType() != PACKET_TYPE_LORA)
Wayne Roberts 17:5f34cbe2ac53 255 radio.setPacketType(PACKET_TYPE_LORA);
Wayne Roberts 17:5f34cbe2ac53 256
Wayne Roberts 17:5f34cbe2ac53 257 loraTimeoutSymbols = symbs;
Wayne Roberts 17:5f34cbe2ac53 258 /*stat.word =*/ radio.xfer(OPCODE_SET_LORA_SYNC_TIMEOUT, 1, 0, &loraTimeoutSymbols);
Wayne Roberts 17:5f34cbe2ac53 259 }
Wayne Roberts 17:5f34cbe2ac53 260
Wayne Roberts 17:5f34cbe2ac53 261 void Radio::Rx(unsigned timeout)
Wayne Roberts 17:5f34cbe2ac53 262 {
Wayne Roberts 17:5f34cbe2ac53 263 /*stat_t stat;*/
Wayne Roberts 17:5f34cbe2ac53 264 uint8_t buf[3];
Wayne Roberts 17:5f34cbe2ac53 265 unsigned rx_timeout;
Wayne Roberts 17:5f34cbe2ac53 266
Wayne Roberts 17:5f34cbe2ac53 267 if (radio.getPacketType() == PACKET_TYPE_LORA) {
Wayne Roberts 17:5f34cbe2ac53 268 /*stat.word =*/ radio.xfer(OPCODE_SET_LORA_SYNC_TIMEOUT, 1, 0, &loraTimeoutSymbols);
Wayne Roberts 17:5f34cbe2ac53 269 }
Wayne Roberts 17:5f34cbe2ac53 270
Wayne Roberts 17:5f34cbe2ac53 271 if (timeout == 0)
Wayne Roberts 17:5f34cbe2ac53 272 rx_timeout = 0xffffff; // receive until instructed otherwise
Wayne Roberts 17:5f34cbe2ac53 273 else
Wayne Roberts 17:5f34cbe2ac53 274 rx_timeout = timeout;
Wayne Roberts 17:5f34cbe2ac53 275
Wayne Roberts 17:5f34cbe2ac53 276 radio.to_big_endian24(rx_timeout, buf);
Wayne Roberts 17:5f34cbe2ac53 277 /*stat.word =*/ radio.xfer(OPCODE_SET_RX, 3, 0, buf);
Wayne Roberts 17:5f34cbe2ac53 278
Wayne Roberts 17:5f34cbe2ac53 279 }
Wayne Roberts 17:5f34cbe2ac53 280
Wayne Roberts 17:5f34cbe2ac53 281 #endif /* ..SX126x_H */