1
Diff: radio_sx126x.cpp
- Revision:
- 18:78c5e644d37a
- Parent:
- 17:5f34cbe2ac53
- Child:
- 20:75635d50262e
diff -r 5f34cbe2ac53 -r 78c5e644d37a radio_sx126x.cpp --- a/radio_sx126x.cpp Mon Jun 01 15:59:56 2020 -0700 +++ b/radio_sx126x.cpp Fri Jun 12 11:27:45 2020 -0700 @@ -12,6 +12,17 @@ bool Radio::paOff; #ifdef TARGET_FF_ARDUINO +#ifdef TARGET_DISCO_L072CZ_LRWAN1 + /* murata type1SJ */ + SPIu spi(PB_15, PB_14, PB_13); // mosi, miso, sclk + //spi, nss, busy, dio1 + SX126x Radio::radio(spi, PB_12, PC_2, PB_0); + + DigitalOut antswPower(PA_15); + void Radio::chipModeChange() { } + const uint8_t chipType = CHIP_TYPE_SX1262; +#else + /* sx126x arduino shield */ SPIu spi(D11, D12, D13); // mosi, miso, sclk //spi, nss, busy, dio1 SX126x Radio::radio(spi, D7, D3, D5); @@ -41,6 +52,7 @@ rx_led = LED_ON; } } +#endif /* !TARGET_DISCO_L072CZ_LRWAN1 */ #endif /* TARGET_FF_ARDUINO */ const RadioEvents_t* RadioEvents; @@ -466,6 +478,15 @@ RadioEvents->TxDone_botHalf(); } +void to_big_endian24(uint32_t in, uint8_t *out) +{ + out[2] = in & 0xff; + in >>= 8; + out[1] = in & 0xff; + in >>= 8; + out[0] = in & 0xff; +} + void Radio::Init(const RadioEvents_t* e, unsigned spi_hz) { radio.txDone = txDoneBottom; @@ -479,6 +500,21 @@ spi.frequency(spi_hz); radio.SetDIO2AsRfSwitchCtrl(1); +#ifdef TARGET_DISCO_L072CZ_LRWAN1 + /* murata type1SJ */ + { + unsigned tcxoDelayTicks = 3200; + uint8_t buf[4]; + + radio.hw_reset(PB_1); + ThisThread::sleep_for(50); + + buf[0] = 1; // 1 = 1.7v + to_big_endian24(tcxoDelayTicks, buf+1); + + radio.xfer(OPCODE_SET_DIO3_AS_TCXO_CTRL, 4, 0, buf); + } +#endif } void Radio::service()