Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 24, 2025

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 #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 AI and others added 2 commits September 24, 2025 23:01
Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
Co-authored-by: Josverl <981654+Josverl@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Update typestub for rp2.asm_pio decorator Update rp2.asm_pio decorator typestub with execctrl and side_pindir parameters Sep 24, 2025
@Copilot Copilot AI requested a review from Josverl September 24, 2025 23:05
Copilot finished work on behalf of Josverl September 24, 2025 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update typestub for rp2.asm_pio decorator
2 participants