radiolib: RADIO_DIAG reads the SX1262 status byte by hand
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
812b3bb9ac
commit
e31cd00a53
1 file changed
+17
-1
@@ -166,7 +166,23 @@ class CustomSX1262 : public SX1262 {
|
|||||||
#ifdef RADIO_DIAG
|
#ifdef RADIO_DIAG
|
||||||
// CUSTOM (TeTeHacko): public views of SX126x commands RadioLib keeps
|
// CUSTOM (TeTeHacko): public views of SX126x commands RadioLib keeps
|
||||||
// protected, for `radiostat` (RadioLibWrappers.cpp). Reads only.
|
// protected, for `radiostat` (RadioLibWrappers.cpp). Reads only.
|
||||||
uint8_t diagStatus() { return getStatus(); }
|
// SX126x::getStatus() reads ZERO data bytes and so always returns 0 (RadioLib
|
||||||
|
// 7.7.1); the status comes back on the NOP after the opcode, done by hand.
|
||||||
|
uint8_t diagStatus() {
|
||||||
|
#ifdef P_LORA_NSS
|
||||||
|
uint8_t out[2] = { RADIOLIB_SX126X_CMD_GET_STATUS, RADIOLIB_SX126X_CMD_NOP }, in[2] = { 0, 0 };
|
||||||
|
uint32_t t0 = millis();
|
||||||
|
while (mod->hal->digitalRead(mod->getGpio()) && millis() - t0 < 20) { } // BUSY
|
||||||
|
mod->hal->spiBeginTransaction();
|
||||||
|
mod->hal->digitalWrite(P_LORA_NSS, mod->hal->GpioLevelLow);
|
||||||
|
mod->hal->spiTransfer(out, 2, in);
|
||||||
|
mod->hal->digitalWrite(P_LORA_NSS, mod->hal->GpioLevelHigh);
|
||||||
|
mod->hal->spiEndTransaction();
|
||||||
|
return in[1];
|
||||||
|
#else
|
||||||
|
return getStatus();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
uint16_t diagDeviceErrors() { return getDeviceErrors(); }
|
uint16_t diagDeviceErrors() { return getDeviceErrors(); }
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user