QUERY · ISSUE
rp2 asm_pio parameterization
enhancementport-rp2
Hi,
I would like to pass parameters into the RP2 assembler to configure the generated code, eg adjust a delay loop, change number of bits shifted etc.
I propose an additional parameter to the asm_pio function decorator 'vars' that takes a dictionary, that gets added to the global context that assembler runs in eg:
@asm_pio(vars={"DELAY":10})
def statemachine():
label("wait")
set(x,DELAY)
jmp(x_dec,"wait")
with an addition of gl.update(vars) in the asp_pio dec function
CANDIDATE · ISSUE
rp2: rp2.asm_pio_encode incorrectly accepts 'pins' as src for 'wait'
bugport-rp2
- 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