From cade8a41d0e613711d98e8e3d3c997fbe7532ef8 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 27 May 2026 09:31:28 +1000 Subject: [PATCH] lora-sx126x: Enable all IRQ Mask bits unconditionally. Expands _IRQ_CRC_ERR fix in the parent commit by always enabling all the Irq Mask bits that the driver may want to read back later, i.e. also including the header error bit. Signed-off-by: Angus Gratton --- micropython/lora/lora-sx126x/lora/sx126x.py | 24 +++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/micropython/lora/lora-sx126x/lora/sx126x.py b/micropython/lora/lora-sx126x/lora/sx126x.py index e442ad564..c34900669 100644 --- a/micropython/lora/lora-sx126x/lora/sx126x.py +++ b/micropython/lora/lora-sx126x/lora/sx126x.py @@ -227,15 +227,21 @@ def __init__( # can trigger the ISR and may not be reset by the driver, leaving DIO1 # high. if dio1: - self._cmd( - ">BHHHH", - _CMD_CFG_DIO_IRQ, - (_IRQ_RX_DONE | _IRQ_TX_DONE | _IRQ_TIMEOUT | _IRQ_CRC_ERR), # IRQ mask - (_IRQ_RX_DONE | _IRQ_TX_DONE | _IRQ_TIMEOUT), # DIO1 mask - 0x0, # DIO2Mask, not used - 0x0, # DIO3Mask, not used - ) - dio1.irq(self._radio_isr, Pin.IRQ_RISING) + dio1_mask = _IRQ_RX_DONE | _IRQ_TX_DONE | _IRQ_TIMEOUT + else: + dio1_mask = 0 + + self._cmd( + ">BHHHH", + _CMD_CFG_DIO_IRQ, + # The Irq Mask byte needs to be set so that _CMD_GET_IRQ_STATUS returns all + # relevant flags that driver might check + _IRQ_TX_DONE | _IRQ_DRIVER_RX_MASK, + dio1_mask, # DIO1Mask + 0x0, # DIO2Mask, not used + 0x0, # DIO3Mask, not used + ) + dio1.irq(self._radio_isr, Pin.IRQ_RISING) self._clear_irq()