Page 1 of 1

PIO in Python with with multiple IOs

Posted: Sun Apr 11, 2021 10:20 am
by smoorby
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.

Re: PIO in Python with with multiple IOs

Posted: Thu Apr 22, 2021 12:16 am
by taPIQoLEHUMA
It seems to work OK if you remove the spaces from the list:

Source line:

Code: Select all

.lang_opt python out_init = (rp2.PIO.OUT_LOW,rp2.PIO.OUT_HIGH,rp2.PIO.OUT_LOW)
Generated python code:

Code: Select all

@rp2.asm_pio(out_init=(rp2.PIO.OUT_LOW,rp2.PIO.OUT_HIGH,rp2.PIO.OUT_LOW))
Original error pointing to the space (sort-of):

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)
      |                                               ^~~~~~~~~~~~~~~~~