Driver library for SX1272/SX1276 transceivers
Dependents: LORA_RX LORA_TX WindConcentrator hid_test ... more
Driver library for SX1272 and SX1276 radio transceivers.
This device uses CSS modulation to provide much improved link budget. The RF hardware is same as in FSK devices, just with added LoRa spread-spectrum modem.
This library provides functions to configure radio chip and transmit & receive packets.
Using This Library
Library function service_radio()
must be called continuously from main loop, to service interrupts from radio.
Board Specific implementation
FunctionPointer for rf_switch
callback allows the program to implement control of RF switch unique to their board.
Example options are:
- SKY13373 for external power amplifier implementation. Requires two DigitalOut pins.
- SKY13350 using PA_BOOST. requires two DigitalOut pins.
- PE4259-63: controlled directly by radio chip, no software function needed. However, in the case of SX1276MB1xAS, the RXTX pin on IO2 should be driven by this callback function when R16 is installed (without R15) on this shield board.
Some configurations may need to force the use of RFO or PA_BOOST, or a board could offer both options. The rf_switch
function pointer callback should support the implementation choice on the board.
further reading
- LoRa modulation basics (dropbox PDF)
- OpenLoRa forum
Revision 36:af9b41b1e285, committed 2020-07-10
- Comitter:
- Wayne Roberts
- Date:
- Fri Jul 10 09:23:52 2020 -0700
- Parent:
- 35:cd54c52c6003
- Commit message:
- run on mbed-6
Changed in this revision
sx127x.cpp | Show annotated file Show diff for this revision Revisions of this file |
sx127x_fsk.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r cd54c52c6003 -r af9b41b1e285 sx127x.cpp --- a/sx127x.cpp Sun Nov 25 13:34:04 2018 -0800 +++ b/sx127x.cpp Fri Jul 10 09:23:52 2020 -0700 @@ -61,10 +61,18 @@ /* SX1272 starts in FSK mode on powerup, RegOpMode bit3 will be set for BT1.0 in FSK */ if (!RegOpMode.bits.LongRangeMode) { set_opmode(RF_OPMODE_SLEEP); - wait(0.01); +#if (MBED_MAJOR_VERSION < 6) + ThisThread::sleep_for(10); +#else + ThisThread::sleep_for(10ms); +#endif RegOpMode.bits.LongRangeMode = 1; write_reg(REG_OPMODE, RegOpMode.octet); - wait(0.01); +#if (MBED_MAJOR_VERSION < 6) + ThisThread::sleep_for(10); +#else + ThisThread::sleep_for(10ms); +#endif RegOpMode.octet = read_reg(REG_OPMODE); } @@ -262,12 +270,22 @@ int in = reset_pin.read(); reset_pin.output(); reset_pin.write(1); - wait(0.05); +#if (MBED_MAJOR_VERSION < 6) + ThisThread::sleep_for(50); if (in == 1) { /* pin is pulled up somewhere? */ reset_pin.write(0); - wait(0.005); + ThisThread::sleep_for(5); } reset_pin.input(); - wait(0.005); + ThisThread::sleep_for(5); +#else + ThisThread::sleep_for(50ms); + if (in == 1) { /* pin is pulled up somewhere? */ + reset_pin.write(0); + ThisThread::sleep_for(5ms); + } + reset_pin.input(); + ThisThread::sleep_for(5ms); +#endif }
diff -r cd54c52c6003 -r af9b41b1e285 sx127x_fsk.cpp --- a/sx127x_fsk.cpp Sun Nov 25 13:34:04 2018 -0800 +++ b/sx127x_fsk.cpp Fri Jul 10 09:23:52 2020 -0700 @@ -305,7 +305,11 @@ if (m_xcvr.RegOpMode.bits.Mode == RF_OPMODE_RECEIVER) { // was already receiving, restart it m_xcvr.set_opmode(RF_OPMODE_STANDBY); - wait(0.01); +#if (MBED_MAJOR_VERSION < 6) + ThisThread::sleep_for(10); +#else + ThisThread::sleep_for(10ms); +#endif } config_dio0_for_pktmode_rx();