Skip to content

Commit f2a3729

Browse files
committed
write() should not exit early on TX FIFO full
1 parent 7d1c05a commit f2a3729

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

circuitpython_nrf24l01/rf24.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,10 @@ def write(
837837
elif not buf or len(buf) > 32:
838838
raise ValueError("buffer must have a length in range [1, 32]")
839839
self.clear_status_flags()
840-
if self._in[0] & 1:
841-
return False
842840
self._reg_write_bytes(0xA0 | (bool(ask_no_ack) << 4), buf)
843841
if not write_only:
844842
self._ce_pin.value = True
845-
return True
843+
return bool(self._in[0] & 1)
846844

847845
def flush_rx(self):
848846
"""Flush all 3 levels of the RX FIFO."""

examples/nrf24l01_stream_test.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,14 @@ def master_fifo(count=1, size=32):
112112
for buf in payloads:
113113
while not nrf.write(buf) and failures <= 99:
114114
# NOTE write() returns False if TX FIFO is already full
115-
while nrf.update() and nrf.tx_full:
116-
# just wait while TX FIFO is full or error occurs
117-
if nrf.irq_df:
118-
# reception failed; TX FIFO is locked
119-
failures += 1 # increment manual retries
120-
# we need to reset the irq_rf flag and the radio's CE pin
121-
nrf.ce_pin = False # fall back to Standby-I mode
122-
# NOTE next call to nrf.write() will
123-
# nrf.clear_status_flags() # clear the irq_df flag
124-
# nrf.ce_pin = True # restart transmissions
125-
break # exit `while tx_full` and call write()
115+
if nrf.irq_df:
116+
# reception failed; TX FIFO is locked
117+
failures += 1 # increment manual retries
118+
# we need to reset the irq_rf flag and the radio's CE pin
119+
nrf.ce_pin = False # fall back to Standby-I mode
120+
# NOTE next call to nrf.write() will
121+
# nrf.clear_status_flags() # clear the irq_df flag
122+
# nrf.ce_pin = True # restart transmissions
126123
if failures > 99:
127124
# exit early because RX side seems absent
128125
nrf.flush_tx() # discard all payloads in TX FIFO

0 commit comments

Comments
 (0)