diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 3a852300..b5aeed31 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -546,20 +546,18 @@ int16_t SX128x::finishTransmit() { return(standby()); } -int16_t SX128x::startReceive(uint16_t timeout) { +int16_t SX128x::startReceive(uint16_t timeout, uint16_t irqFlags, uint16_t irqMask) { // check active modem if(getPacketType() == RADIOLIB_SX128X_PACKET_TYPE_RANGING) { return(RADIOLIB_ERR_WRONG_MODEM); } // set DIO mapping - uint16_t mask = RADIOLIB_SX128X_IRQ_RX_DONE; - if(timeout != RADIOLIB_SX128X_RX_TIMEOUT_INF) { - mask |= RADIOLIB_SX128X_IRQ_RX_TX_TIMEOUT; + irqMask |= RADIOLIB_SX128X_IRQ_RX_TX_TIMEOUT; } - int16_t state = setDioIrqParams(RADIOLIB_SX128X_IRQ_RX_DONE | RADIOLIB_SX128X_IRQ_RX_TX_TIMEOUT | RADIOLIB_SX128X_IRQ_CRC_ERROR | RADIOLIB_SX128X_IRQ_HEADER_ERROR, mask); + int16_t state = setDioIrqParams(irqFlags, irqMask); RADIOLIB_ASSERT(state); // set buffer pointers diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index 271c321f..b3dcfa84 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -327,6 +327,7 @@ #define RADIOLIB_SX128X_IRQ_SYNC_WORD_VALID 0x0004 // 2 2 sync word valid #define RADIOLIB_SX128X_IRQ_RX_DONE 0x0002 // 1 1 Rx done #define RADIOLIB_SX128X_IRQ_TX_DONE 0x0001 // 0 0 Tx done +#define RADIOLIB_SX128X_IRQ_RX_DEFAULT 0x4062 // 15 0 default for Rx (RX_DONE, RX_TX_TIMEOUT, CRC_ERROR and HEADER_ERROR) #define RADIOLIB_SX128X_IRQ_NONE 0x0000 // 15 0 none #define RADIOLIB_SX128X_IRQ_ALL 0xFFFF // 15 0 all @@ -566,9 +567,13 @@ class SX128x: public PhysicalLayer { \param timeout Raw timeout value, expressed as multiples of 15.625 us. Defaults to RADIOLIB_SX128X_RX_TIMEOUT_INF for infinite timeout (Rx continuous mode), set to RADIOLIB_SX128X_RX_TIMEOUT_NONE for no timeout (Rx single mode). If timeout other than infinite is set, signal will be generated on DIO1. + \param irqFlags Sets the IRQ flags, defaults to RADIOLIB_SX128X_IRQ_RX_DEFAULT. + + \param irqMask Sets the mask of IRQ flags that will trigger DIO1, defaults to RADIOLIB_SX128X_IRQ_RX_DONE. + \returns \ref status_codes */ - int16_t startReceive(uint16_t timeout = RADIOLIB_SX128X_RX_TIMEOUT_INF); + int16_t startReceive(uint16_t timeout = RADIOLIB_SX128X_RX_TIMEOUT_INF, uint16_t irqFlags = RADIOLIB_SX128X_IRQ_RX_DEFAULT, uint16_t irqMask = RADIOLIB_SX128X_IRQ_RX_DONE); /*! \brief Reads the current IRQ status.