Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:a64836ef007e, committed 2018-05-18
- Comitter:
- Wayne Roberts
- Date:
- Fri May 18 10:59:53 2018 -0700
- Child:
- 1:ce312fc7dd18
- Commit message:
- initial commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri May 18 10:59:53 2018 -0700
@@ -0,0 +1,85 @@
+#include "sx126x.h"
+
+#ifdef TARGET_FF_ARDUINO /* pins of SX126xDVK1xAS board */
+ SPI spi(D11, D12, D13); // mosi, miso, sclk
+ // spi, nss, busy, dio1
+ SX126x radio(spi, D7, D3, D5 );
+ #define CHIP_TYPE_SX1262 0
+ #define CHIP_TYPE_SX1261 1
+ DigitalIn chipType(A2);
+ AnalogIn xtalSel(A3);
+ DigitalOut antswPower(D8);
+#endif /* TARGET_FF_ARDUINO */
+
+/**********************************************************************/
+volatile bool txDone;
+
+void txDone_callback()
+{
+ txDone = true;
+}
+
+int main()
+{
+ uint8_t seq = 0;
+
+ printf("\r\nreset-tx ");
+
+ radio.setStandby(STBY_XOSC);
+ radio.setPacketType(PACKET_TYPE_LORA);
+ radio.setMHz(915.0);
+
+ {
+ ModulationParams_t mp;
+
+ mp.lora.spreadingFactor = 7;
+ mp.lora.bandwidth = LORA_BW_125;
+ mp.lora.codingRate = LORA_CR_4_5;
+ mp.lora.LowDatarateOptimize = 0;
+
+ radio.xfer(OPCODE_SET_MODULATION_PARAMS, 4, mp.buf);
+ }
+
+ if (chipType == CHIP_TYPE_SX1262)
+ radio.set_tx_dbm(true, 20);
+ else
+ radio.set_tx_dbm(false, 14);
+
+
+ {
+ PacketParams_t p;
+
+ p.lora.PreambleLengthHi = 0;
+ p.lora.PreambleLengthLo = 8;
+ p.lora.HeaderType = HEADER_TYPE_VARIABLE_LENGTH;
+ /* constant payload length of one byte */
+ p.lora.PayloadLength = 1;
+ p.lora.CRCType = CRC_ON;
+ p.lora.InvertIQ = STANDARD_IQ;
+
+ radio.xfer(OPCODE_SET_PACKET_PARAMS, 6, p.buf);
+ }
+
+
+ antswPower = 1;
+ radio.SetDIO2AsRfSwitchCtrl(1);
+
+ radio.txDone = txDone_callback;
+
+ for (;;) {
+ radio.tx_buf[0] = seq; /* set payload */
+ txDone = false;
+ radio.start_tx(1); /* begin transmission */
+
+ printf("sent\r\n");
+ while (!txDone) {
+ radio.service();
+ }
+
+ printf("got-tx-done\r\n");
+
+ wait(0.5); /* throttle sending rate */
+ seq++; /* change payload */
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Fri May 18 10:59:53 2018 -0700 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#79640c6a885d2006d3cedff3f666f8c253818c27
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sx126x.lib Fri May 18 10:59:53 2018 -0700 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/dudmuck/code/sx126x/#c79a1f70c110