diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index b98fad59..12b6f5f0 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -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) { diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 63169519..1a4fd2ca 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -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.