micropython-stubs icon indicating copy to clipboard operation
micropython-stubs copied to clipboard

Update rp2.asm_pio decorator typestub with execctrl and side_pindir parameters

Open Copilot opened this issue 2 months ago • 0 comments

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 like PIO.STATUS_TXLEVEL + n to trigger status checks based on FIFO thresholds.
  • side_pindir: Optional[bool] = None - When set to True, configures .side() modifiers to be used for pin directions instead of pin values (the default when False).

New PIO constants:

  • PIO.STATUS_TXLEVEL = 0 - Status value for TX FIFO level threshold
  • PIO.STATUS_RXLEVEL = 32 - Status value for RX FIFO level threshold
  • PIO.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 typestub
  • reference/micropython/rp2/PIO.pyi - Added STATUS constants
  • stubs/micropython-v1_27_0_preview-docstubs/rp2/__init__.pyi - Future version consistency
  • stubs/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.

Copilot avatar Sep 24 '25 22:09 Copilot