Initial commit
Dependencies: SX127x sx12xx_hal
Revision 1:b277f5a65c1c, committed 2019-03-21
- Comitter:
- LoRaToolbox
- Date:
- Thu Mar 21 10:22:46 2019 +0000
- Parent:
- 0:44fb2db84011
- Commit message:
- Include updated comments
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 44fb2db84011 -r b277f5a65c1c main.cpp --- a/main.cpp Wed Feb 20 07:27:34 2019 +0000 +++ b/main.cpp Thu Mar 21 10:22:46 2019 +0000 @@ -1,5 +1,7 @@ #include "radio.h" +// Semtech radio definitions for SX127x, SX126x and SX128x + #if defined(SX127x_H) #define BW_KHZ 500 #define SPREADING_FACTOR 11 @@ -17,7 +19,9 @@ #define TX_DBM 6 #endif -/**********************************************************************/ +/******************** Setup radio transmitter ****************************/ + + volatile bool txDone; void txDoneCB() @@ -29,6 +33,8 @@ { } + // Define radio events for transmitter + const RadioEvents_t rev = { /* Dio0_top_half */ NULL, /* TxDone_topHalf */ NULL, @@ -43,19 +49,26 @@ int main() { - uint8_t seq = 0; - + uint8_t seq = 0; // Set initial transmit sequence to 0 + printf("\r\nreset-tx "); + + // Start radio transmitter after POR or reset Radio::Init(&rev); + //Set radio properties for transmitter + Radio::Standby(); Radio::LoRaModemConfig(BW_KHZ, SPREADING_FACTOR, 1); Radio::SetChannel(CF_HZ); + // Set transmitter output power + Radio::set_tx_dbm(TX_DBM); - // preambleLen, fixLen, crcOn, invIQ + // Setup transmit packet payload -> preambleLen, fixLen, crcOn, invIQ + Radio::LoRaPacketConfig(8, false, true, false); printf("\n"); @@ -63,21 +76,19 @@ printf("%02d \r\n\n", seq); for (;;) { - Radio::radio.tx_buf[0] = seq; /* set payload */ + Radio::radio.tx_buf[0] = seq; // set payload txDone = false; - Radio::Send(10, 0, 0, 0); /* begin transmission */ + Radio::Send(10, 0, 0, 0); // begin transmission of payload - //printf("sent\r\n\n"); while (!txDone) { Radio::service(); } - //printf("got-tx-done\r\n\n"); + // Transmit payload every 500mS - wait(0.5); /* throttle sending rate */ - seq++; /* change payload */ - printf("%02d \r\n\n", seq); + wait(0.5); // throttle sending rate + seq++; // change payload (increment sequence number) + printf("%02d \r\n\n", seq); // Print sequence number - - } + } }