[SX126x] Generalize IRQ checks

pull/1188/head
StevenCellist 2024-08-16 00:04:42 +02:00
rodzic 0eb987a83c
commit 3a73ed8c1f
2 zmienionych plików z 32 dodań i 7 usunięć

Wyświetl plik

@ -1466,10 +1466,35 @@ int16_t SX126x::irqRxDoneRxTimeout(uint32_t &irqFlags, uint32_t &irqMask) {
return(RADIOLIB_ERR_NONE);
}
bool SX126x::isRxTimeout() {
uint16_t irq = getIrqStatus();
bool rxTimedOut = irq & RADIOLIB_SX126X_IRQ_TIMEOUT;
return(rxTimedOut);
bool SX126x::isIrqSet(uint8_t irq) {
uint16_t flags = getIrqStatus();
switch(irq) {
case RADIOLIB_IRQ_TX_DONE:
return(flags & RADIOLIB_SX126X_IRQ_TX_DONE);
case RADIOLIB_IRQ_RX_DONE:
return(flags & RADIOLIB_SX126X_IRQ_RX_DONE);
case RADIOLIB_IRQ_PREAMBLE_DETECTED:
return(flags & RADIOLIB_SX126X_IRQ_PREAMBLE_DETECTED);
case RADIOLIB_IRQ_SYNC_WORD_VALID:
return(flags & RADIOLIB_SX126X_IRQ_SYNC_WORD_VALID);
case RADIOLIB_IRQ_HEADER_VALID:
return(flags & RADIOLIB_SX126X_IRQ_HEADER_VALID);
case RADIOLIB_IRQ_HEADER_ERR:
return(flags & RADIOLIB_SX126X_IRQ_HEADER_ERR);
case RADIOLIB_IRQ_CRC_ERR:
return(flags & RADIOLIB_SX126X_IRQ_CRC_ERR);
case RADIOLIB_IRQ_CAD_DONE:
return(flags & RADIOLIB_SX126X_IRQ_CAD_DONE);
case RADIOLIB_IRQ_CAD_DETECTED:
return(flags & RADIOLIB_SX126X_IRQ_CAD_DETECTED);
case RADIOLIB_IRQ_TIMEOUT:
return(flags & RADIOLIB_SX126X_IRQ_TIMEOUT);
case RADIOLIB_IRQ_LR_FHSS_HOP:
return(flags & RADIOLIB_SX126X_IRQ_LR_FHSS_HOP);
default:
return(false);
}
return(false);
}
int16_t SX126x::implicitHeader(size_t len) {

Wyświetl plik

@ -997,10 +997,10 @@ class SX126x: public PhysicalLayer {
int16_t irqRxDoneRxTimeout(uint32_t &irqFlags, uint32_t &irqMask) override;
/*!
\brief Check whether the IRQ bit for RxTimeout is set
\returns Whether RxTimeout IRQ is set
\brief Check whether a specific IRQ bit is set (e.g. RxTimeout, CadDone).
\returns Whether requested IRQ is set.
*/
bool isRxTimeout() override;
bool isIrqSet(uint8_t irq) override;
/*!
\brief Set implicit header mode for future reception/transmission.