From 08de95e15e019ab4dee0486c935b5b35099275d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 5 Dec 2022 11:17:59 +0100 Subject: [PATCH] Access getIrqStatus() without Godmode and change the flag setting like SX126x handles it. --- src/modules/SX128x/SX128x.cpp | 7 ++++++- src/modules/SX128x/SX128x.h | 8 +++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/modules/SX128x/SX128x.cpp b/src/modules/SX128x/SX128x.cpp index 3e084090..a9e2deb0 100644 --- a/src/modules/SX128x/SX128x.cpp +++ b/src/modules/SX128x/SX128x.cpp @@ -529,7 +529,12 @@ int16_t SX128x::startReceive(uint16_t timeout) { } // set DIO mapping - 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, RADIOLIB_SX128X_IRQ_RX_DONE); + uint16_t mask = RADIOLIB_SX128X_IRQ_RX_DONE; + + if(timeout != RADIOLIB_SX128X_RX_TIMEOUT_INF) + mask |= 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); RADIOLIB_ASSERT(state); // set buffer pointers diff --git a/src/modules/SX128x/SX128x.h b/src/modules/SX128x/SX128x.h index d3006ab0..5c169fe2 100644 --- a/src/modules/SX128x/SX128x.h +++ b/src/modules/SX128x/SX128x.h @@ -564,11 +564,18 @@ class SX128x: public PhysicalLayer { \brief Interrupt-driven receive method. DIO1 will be activated when full packet is received. \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. \returns \ref status_codes */ int16_t startReceive(uint16_t timeout = RADIOLIB_SX128X_RX_TIMEOUT_INF); + /*! + \brief Reads the current IRQ status. + \returns IRQ status bits + */ + uint16_t getIrqStatus(); + /*! \brief Reads data received after calling startReceive method. @@ -874,7 +881,6 @@ class SX128x: public PhysicalLayer { int16_t setPacketParamsBLE(uint8_t connState, uint8_t crcLen, uint8_t bleTestPayload, uint8_t whitening); int16_t setPacketParamsLoRa(uint8_t preambleLen, uint8_t headerType, uint8_t payloadLen, uint8_t crc, uint8_t invertIQ = RADIOLIB_SX128X_LORA_IQ_STANDARD); int16_t setDioIrqParams(uint16_t irqMask, uint16_t dio1Mask, uint16_t dio2Mask = RADIOLIB_SX128X_IRQ_NONE, uint16_t dio3Mask = RADIOLIB_SX128X_IRQ_NONE); - uint16_t getIrqStatus(); int16_t clearIrqStatus(uint16_t clearIrqParams = RADIOLIB_SX128X_IRQ_ALL); int16_t setRangingRole(uint8_t role); int16_t setPacketType(uint8_t type);