basic LoRa transmitter example
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.
Use project simple_rx on receiving end.
Diff: main.cpp
- Revision:
- 2:3f4dfcc3bab6
- Parent:
- 0:83bfd3e3c4c4
- Child:
- 4:938655f1726c
--- a/main.cpp Tue Jul 17 16:26:01 2018 -0700 +++ b/main.cpp Thu Sep 12 15:52:01 2019 -0700 @@ -18,19 +18,45 @@ #endif /**********************************************************************/ -volatile bool txDone; +EventQueue queue(4 * EVENTS_EVENT_SIZE); + +void tx_test() +{ + uint8_t seq = 0; + + Radio::radio.tx_buf[0] = seq++; /* set payload */ + Radio::Send(1, 0, 0, 0); /* begin transmission */ + printf("sent\r\n"); + +/* { + mbed_stats_cpu_t stats; + mbed_stats_cpu_get(&stats); + printf("canDeep:%u ", sleep_manager_can_deep_sleep()); + printf("Uptime: %llu ", stats.uptime / 1000); + printf("Sleep time: %llu ", stats.sleep_time / 1000); + printf("Deep Sleep: %llu\r\n", stats.deep_sleep_time / 1000); + }*/ +} void txDoneCB() { - txDone = true; + printf("got-tx-done\r\n"); + queue.call_in(500, tx_test); } void rxDoneCB(uint8_t size, float rssi, float snr) { } + +void radio_irq_callback() +{ + queue.call(Radio::service); +} + + const RadioEvents_t rev = { - /* Dio0_top_half */ NULL, + /* DioPin_top_half */ radio_irq_callback, /* TxDone_topHalf */ NULL, /* TxDone_botHalf */ txDoneCB, /* TxTimeout */ NULL, @@ -43,7 +69,7 @@ int main() { - uint8_t seq = 0; + //uint8_t seq = 0; printf("\r\nreset-tx "); @@ -58,20 +84,8 @@ // preambleLen, fixLen, crcOn, invIQ Radio::LoRaPacketConfig(8, false, true, false); - for (;;) { - Radio::radio.tx_buf[0] = seq; /* set payload */ - txDone = false; - Radio::Send(1, 0, 0, 0); /* begin transmission */ + queue.call_in(500, tx_test); - printf("sent\r\n"); - while (!txDone) { - Radio::service(); - } - - printf("got-tx-done\r\n"); - - wait(0.5); /* throttle sending rate */ - seq++; /* change payload */ - } + queue.dispatch(); }