micropython-stubs
micropython-stubs copied to clipboard
Update rp2.asm_pio decorator typestub with execctrl and side_pindir parameters
Updates the reference typestub for rp2.asm_pio decorator to include the new parameters proposed in MicroPython PR #18133.
Changes
New asm_pio decorator parameters:
execctrl=0- Configures additional execution control options. Can be used with constants likePIO.STATUS_TXLEVEL + nto trigger status checks based on FIFO thresholds.side_pindir: Optional[bool] = None- When set toTrue, configures.side()modifiers to be used for pin directions instead of pin values (the default whenFalse).
New PIO constants:
PIO.STATUS_TXLEVEL = 0- Status value for TX FIFO level thresholdPIO.STATUS_RXLEVEL = 32- Status value for RX FIFO level thresholdPIO.STATUS_IRQ = 64- Status value for IRQ flags
Usage Example
With these updates, developers can now use advanced PIO features like:
@rp2.asm_pio(execctrl=rp2.PIO.STATUS_TXLEVEL + 5, side_pindir=True)
def advanced_program():
mov(y, status)
jmp(not_y, "skip")
irq(rel(0))
label("skip")
This enables interrupt generation when the TX FIFO has fewer than 5 words left, and configures side-set pins to control directions rather than values.
Backward Compatibility
All existing code remains fully compatible - these are optional parameters with sensible defaults that match the current behavior.
Files Updated
reference/micropython/rp2/__init__.pyi- Main reference typestubreference/micropython/rp2/PIO.pyi- Added STATUS constantsstubs/micropython-v1_27_0_preview-docstubs/rp2/__init__.pyi- Future version consistencystubs/micropython-v1_27_0_preview-docstubs/rp2/PIO.pyi- Future version constants
Fixes the issue by providing proper type hints for the enhanced PIO assembler functionality that will be available in future MicroPython releases.
Fixes Josverl/micropython-stubs#834
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.