rp2 asm_pio parameterization
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
rp2: Make rp2_state_machine_exec accept integers.
Currently rp2.StateMachine.exec(instr_in) requires that the instr_in parameter be a string representing the PIO assembly language instruction to be encoded by rp2.asm_pio_encode(). This commit allows the parameter to also be of integral type. This is useful if the exec() method is being called often where the use of pre-encoded machine code is desireable.
This PR still supports calls like:
sm.exec("set(0, 1)")
It also now supports calls like:
# Performed once earlier, maybe in __init__()
assembled_instr = rp2.asm_pio_encode("out(y, 8)", 0)
# Performed multiple times later as the PIO state machine is
# configured for its next run.
sm.exec(assembled_instr)
I didn't find any rp2 specific tests to run or extend but I did find 2 rp2 examples (examples/rp2/pio_exec.py and examples/rp2/pio_pwm.py) that exercise the rp2.StateMachine.exec() method. I ran those 2 examples to make sure that they weren't broken by my change.
I look forward to any feedback which helps improve this PR and its suitableness for merging.