Hi, Anyone figured out the syntax for multiple outputs (I'm guessing inputs as well) with 'pioasm' when output is for Python?
It works fine in Python, multiple lines are given to the asm_pio() decorator as a tuple, e.g :-
@rp2.asm_pio(
out_init = (
rp2.PIO.OUT_LOW,
rp2.PIO.OUT_HIGH,
rp2.PIO.OUT_LOW))
PIO initialisation can by output from 'pioasm' with the 'lang_opt' directive. For one line the following works
.lang_opt python out_init = rp2.PIO.OUT_LOW
but
.lang_opt python out_init = (rp2.PIO.OUT_LOW, rp2.PIO.OUT_HIGH, rp2.PIO.OUT_LOW)
doesn't work, 'pioasm' sees this as a syntax error. I've tried a few variants like list instead of tuple and just comma separated values. All the examples seem to use just one pin.
PIO in Python with with multiple IOs
-
- Posts: 15
- Joined: Thu Mar 04, 2021 2:59 am
Re: PIO in Python with with multiple IOs
It seems to work OK if you remove the spaces from the list:
Source line:
Generated python code:
Original error pointing to the space (sort-of):
Source line:
Code: Select all
.lang_opt python out_init = (rp2.PIO.OUT_LOW,rp2.PIO.OUT_HIGH,rp2.PIO.OUT_LOW)
Code: Select all
@rp2.asm_pio(out_init=(rp2.PIO.OUT_LOW,rp2.PIO.OUT_HIGH,rp2.PIO.OUT_LOW))
Code: Select all
sb.pio:13.47-63: syntax error, unexpected text, expecting end of file or end of line
13 | .lang_opt python out_init = (rp2.PIO.OUT_LOW, rp2.PIO.OUT_HIGH, rp2.PIO.OUT_LOW)
| ^~~~~~~~~~~~~~~~~