rp2: rp2.asm_pio_encode incorrectly accepts 'pins' as src for 'wait'
- https://docs.micropython.org/en/latest/library/rp2.html#module-rp2 specifies the pio asm syntax for 'wait' as
wait(polarity, src, index) where 'src' one of (gpio, pin, irq) - The rp2040-datasheet.pdf similary uses (GPIO, PIN, IRQ)
The bug is that rp2.asm_pio_encode silently accepts the invalid src value 'pins'. It should raise an exception.
Incidentaly it encodes "wait(1, pins, 0)" the same as "wait(1, gpio, 0)"
demo code
import rp2
try:
rp2.asm_pio_encode("wait(1, pins, 0)")
exception_raised = False
except Exception:
exception_raised = True
assert exception_raised
rp2: Add RP2350 PIO v1 assembler support.
Add support for new PIO v1 instruction features on RP2350:
- wait: add jmp_pin source (PINCTRL_JMP_PIN, src=3) with a
2-bit offset argument. - irq: add next_pio/prev_pio index modifiers for cross-PIO IRQ
targeting. - asm_pio: add in_count parameter encoding SHIFTCTRL.IN_COUNT
(bits [4:0]) to mask unneeded IN-mapped pins to zero. - asm_pio: fix fifo_join encoding to support RP2350 TXGET(4),
TXPUT(8) and PUTGET(12) modes via SHIFTCTRL bits [15:14].
All changes are backward-compatible with RP2040 PIO v0.
Also update RP2 docs to cover new changes.
Signed-off-by: NED KONZ NED@METAMAGIX.TECH
Summary
The RP2350 added a number of improvements to the PIO hardware in the RP2040.
This PR is the first of three that will bring MicroPython's RP2 PIO support up to date.
Testing
Tested on a RPI_PICO2 board using #18974: all encoding tests passed,
covering new instructions, RP2350 FIFO join modes, in_count,
and regression checks for all existing instruction encodings.
I also tested on a RPI_PICO board and there were no regressions.
Generative AI
I used generative AI tools when creating this PR, but a human has checked the
code and is responsible for the code and the description above.