Detect modem communication timeouts for sx126x chips
This commit is contained in:
parent
5807cfdb96
commit
d61d14e117
11
sx126x.cpp
11
sx126x.cpp
|
@ -485,22 +485,31 @@ int sx126x::endPacket()
|
||||||
|
|
||||||
executeOpcodeRead(OP_GET_IRQ_STATUS_6X, buf, 2);
|
executeOpcodeRead(OP_GET_IRQ_STATUS_6X, buf, 2);
|
||||||
|
|
||||||
|
bool timed_out = false;
|
||||||
|
uint32_t w_timeout = millis()+LORA_MODEM_TIMEOUT_MS;
|
||||||
// wait for TX done
|
// wait for TX done
|
||||||
while ((buf[1] & IRQ_TX_DONE_MASK_6X) == 0) {
|
while ((millis() < w_timeout) && ((buf[1] & IRQ_TX_DONE_MASK_6X) == 0)) {
|
||||||
buf[0] = 0x00;
|
buf[0] = 0x00;
|
||||||
buf[1] = 0x00;
|
buf[1] = 0x00;
|
||||||
executeOpcodeRead(OP_GET_IRQ_STATUS_6X, buf, 2);
|
executeOpcodeRead(OP_GET_IRQ_STATUS_6X, buf, 2);
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(millis() < w_timeout)) { timed_out = true; }
|
||||||
|
|
||||||
// clear IRQ's
|
// clear IRQ's
|
||||||
|
|
||||||
uint8_t mask[2];
|
uint8_t mask[2];
|
||||||
mask[0] = 0x00;
|
mask[0] = 0x00;
|
||||||
mask[1] = IRQ_TX_DONE_MASK_6X;
|
mask[1] = IRQ_TX_DONE_MASK_6X;
|
||||||
executeOpcode(OP_CLEAR_IRQ_STATUS_6X, mask, 2);
|
executeOpcode(OP_CLEAR_IRQ_STATUS_6X, mask, 2);
|
||||||
|
|
||||||
|
if (timed_out) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t sx126x::modemStatus() {
|
uint8_t sx126x::modemStatus() {
|
||||||
// imitate the register status from the sx1276 / 78
|
// imitate the register status from the sx1276 / 78
|
||||||
|
|
1
sx126x.h
1
sx126x.h
|
@ -17,6 +17,7 @@
|
||||||
#define LORA_DEFAULT_RXEN_PIN -1
|
#define LORA_DEFAULT_RXEN_PIN -1
|
||||||
#define LORA_DEFAULT_TXEN_PIN -1
|
#define LORA_DEFAULT_TXEN_PIN -1
|
||||||
#define LORA_DEFAULT_BUSY_PIN -1
|
#define LORA_DEFAULT_BUSY_PIN -1
|
||||||
|
#define LORA_MODEM_TIMEOUT_MS 20E3
|
||||||
|
|
||||||
#define PA_OUTPUT_RFO_PIN 0
|
#define PA_OUTPUT_RFO_PIN 0
|
||||||
#define PA_OUTPUT_PA_BOOST_PIN 1
|
#define PA_OUTPUT_PA_BOOST_PIN 1
|
||||||
|
|
Loading…
Reference in New Issue