Repository navigation
Conversation
StateMachine.write() and write_readinto() wait for the written data to be sent, not just queued: with the default wait_for_txstall=True they return once the TX FIFO and OSR are empty and the state machine has stalled. This was only mentioned under the constructor's wait_for_txstall parameter, so it was easy to add a redundant "wait for the FIFO to drain" sleep after write(). The txstall docstring said the flag is set on a full TX FIFO. TXSTALL is set when the state machine stalls on an empty TX FIFO (blocking pull or autopull), which is what write() relies on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a documentation-only change to
rp2pio.StateMachine. No code changes.write()/write_readinto(): both wait for the written data to be sent, not just queued. With the defaultwait_for_txstall=Truethey return once the TX FIFO and OSR are empty and the state machine has stalled (common-hal/rp2pio/StateMachine.c, the wait loop after the transfer). Until now this was only described under the constructor'swait_for_txstallparameter. Thewrite()docstring didn't mention it, and MicroPython'srp2.StateMachine.put()and the Pico SDK'spio_sm_put_blocking()return as soon as the data is queued. That makes it easy to add a redundant "wait for the FIFO to drain" sleep afterwrite(). I did exactly that in a 433 MHz OOK transmitter, and it doubled the time between frames: an SDR measured a 150 ms frame period where 55 ms was intended. The new paragraph:wait_for_txstallmodeswait_for_txstall=Falseif the program never stalls on a blocking pull (pull noblock)background_writefor sending without blockingtxstall: the docstring said the flag is set when the state machine stalls "due to a full TX FIFO". TXSTALL is set when it stalls on an empty TX FIFO, during a blockingpullor an autopull (RP2040 datasheet, FDEBUG register). The docstring now says that, and notes thatwriteclears the flag once its data is queued and then uses it to detect when transmission has finished.Testing
tools/extract_pyi.py ports/raspberrypi/bindings. The result was0 failed, 3 passed, and the new text appears inrp2pio/__init__.pyi.pre-commit run --files ports/raspberrypi/bindings/rp2pio/StateMachine.c:translationsandformattinghooks needmake/xgettext/uncrustify, which weren't available on this Windows machine. The change only touches//|comment lines and adds noMP_ERROR_TEXTstrings.write()from returning for its full length.🤖 Generated with Claude Code