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.
Dependents: alarm_slave iq_sx126x sx126x_simple_TX_shield_2020a sx126x_simple_RX_shield_2020a ... more
Revision 4:b941bceb401d, committed 2018-07-05
- Comitter:
- Wayne Roberts
- Date:
- Thu Jul 05 13:38:27 2018 -0700
- Parent:
- 3:f6f2f8adcd22
- Child:
- 5:8b75387af4e0
- Commit message:
- add callback for indication operate mode of radio chip
Changed in this revision
| sx126x.cpp | Show annotated file Show diff for this revision Revisions of this file |
| sx12xx.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/sx126x.cpp Tue Jul 03 15:38:55 2018 -0700
+++ b/sx126x.cpp Thu Jul 05 13:38:27 2018 -0700
@@ -61,7 +61,6 @@
printf("\r\n");
}
-extern RawSerial pc;
void SX126x::service()
{
IrqFlags_t irqFlags, clearIrqFlags;
@@ -81,6 +80,8 @@
txDone.call();
clearIrqFlags.bits.TxDone = 1;
chipMode = CHIPMODE_NONE;
+ if (chipModeChange)
+ chipModeChange.call();
}
if (irqFlags.bits.RxDone) {
if (rxDone) {
@@ -104,6 +105,8 @@
timeout(chipMode == CHIPMODE_TX);
}
chipMode = CHIPMODE_NONE;
+ if (chipModeChange)
+ chipModeChange.call();
clearIrqFlags.bits.Timeout = 1;
}
@@ -185,6 +188,8 @@
xfer(OPCODE_SET_TX, 3, 0, buf);
chipMode = CHIPMODE_TX;
+ if (chipModeChange)
+ chipModeChange.call();
}
void SX126x::start_rx(unsigned timeout)
@@ -197,6 +202,8 @@
xfer(OPCODE_SET_RX, 3, 0, buf);
chipMode = CHIPMODE_RX;
+ if (chipModeChange)
+ chipModeChange.call();
}
uint8_t SX126x::setMHz(float MHz)
@@ -315,6 +322,17 @@
xfer(OPCODE_SET_STANDBY, 1, 0, &octet);
chipMode = CHIPMODE_NONE;
+ if (chipModeChange)
+ chipModeChange.call();
+}
+
+void SX126x::setFS()
+{
+ xfer(OPCODE_SET_FS, 0, 0, NULL);
+
+ chipMode = CHIPMODE_NONE;
+ if (chipModeChange)
+ chipModeChange.call();
}
void SX126x::setSleep(bool warmStart, bool rtcWakeup)
@@ -327,6 +345,8 @@
xfer(OPCODE_SET_SLEEP, 1, 0, &sc.octet);
chipMode = CHIPMODE_NONE;
+ if (chipModeChange)
+ chipModeChange.call();
}
void SX126x::hw_reset(PinName pin)
--- a/sx12xx.h Tue Jul 03 15:38:55 2018 -0700
+++ b/sx12xx.h Thu Jul 05 13:38:27 2018 -0700
@@ -42,6 +42,7 @@
#define OPCODE_SET_DIO2_AS_RFSWITCH 0x9d
#define OPCODE_SET_LORA_SYMBOL_TIMEOUT 0xa0
#define OPCODE_GET_STATUS 0xc0
+#define OPCODE_SET_FS 0xc1
#define OPCODE_SET_TX_CONTINUOUS 0xd1
/***************************************************************/
#define PACKET_TYPE_GFSK 0
@@ -428,10 +429,12 @@
void writeReg(uint16_t addr, uint32_t data, uint8_t len);
void setStandby(stby_t);
void setSleep(bool warmStart, bool rtcWakeup);
+ void setFS(void);
static Callback<void()> dio1_topHalf; // low latency ISR context
void service(void);
Callback<void()> txDone; // user context
+ Callback<void()> chipModeChange; // read chipMode_e chipMode
void (*rxDone)(uint8_t size, float rssi, float snr); // user context
void (*timeout)(bool tx); // user context