Skip to content

Commit 44b6fca

Browse files
committed
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. Signed-off-by: Angus Gratton <angus@redyak.com.au>
1 parent 607e903 commit 44b6fca

2 files changed

Lines changed: 18 additions & 15 deletions

File tree

micropython/lora/lora-sx126x/lora/sx126x.py

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -224,21 +224,24 @@ def __init__(
224224

225225
# If DIO1 is set, mask in just the IRQs that the driver may need to be
226226
# interrupted by. This is important because otherwise an unrelated IRQ
227-
# can trigger the ISR and may not be reset by the driver, leaving DIO1 high.
228-
#
229-
# If DIO1 is not set, all IRQs can stay masked which is the power-on state.
227+
# can trigger the ISR and may not be reset by the driver, leaving DIO1
228+
# high.
230229
if dio1:
231-
# Note: we set both Irq mask and DIO1 mask to the same value, which is redundant
232-
# (one could be 0xFFFF) but may save a few bytes of bytecode.
233-
self._cmd(
234-
">BHHHH",
235-
_CMD_CFG_DIO_IRQ,
236-
(_IRQ_RX_DONE | _IRQ_TX_DONE | _IRQ_TIMEOUT | _IRQ_CRC_ERR), # IRQ mask
237-
(_IRQ_RX_DONE | _IRQ_TX_DONE | _IRQ_TIMEOUT), # DIO1 mask
238-
0x0, # DIO2Mask, not used
239-
0x0, # DIO3Mask, not used
240-
)
241-
dio1.irq(self._radio_isr, Pin.IRQ_RISING)
230+
dio1_mask = _IRQ_RX_DONE | _IRQ_TX_DONE | _IRQ_TIMEOUT
231+
else:
232+
dio1_mask = 0
233+
234+
self._cmd(
235+
">BHHHH",
236+
_CMD_CFG_DIO_IRQ,
237+
# The Irq Mask byte needs to be set so that _CMD_GET_IRQ_STATUS returns all
238+
# relevant flags that driver might check
239+
_IRQ_TX_DONE | _IRQ_DRIVER_RX_MASK,
240+
dio1_mask, # DIO1Mask
241+
0x0, # DIO2Mask, not used
242+
0x0, # DIO3Mask, not used
243+
)
244+
dio1.irq(self._radio_isr, Pin.IRQ_RISING)
242245

243246
self._clear_irq()
244247

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
metadata(version="0.1.5")
1+
metadata(version="0.1.6")
22
require("lora")
33
package("lora")

0 commit comments

Comments
 (0)