Skip to content

Commit

Permalink
Add support for .side_set ... pindirs
Browse files Browse the repository at this point in the history
This also requires a core change to set the respective bit in the
PIO hardware.
  • Loading branch information
jepler committed Dec 1, 2024
1 parent de37174 commit 23bd1b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions adafruit_pioasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __init__(self, text_program: str, *, build_debuginfo: bool = False) -> None:
instructions: List[str] = []
sideset_count = 0
sideset_enable = 0
sideset_pindirs = False
wrap = None
wrap_target = None
offset = -1
Expand Down Expand Up @@ -144,6 +145,7 @@ def parse_rxfifo_brackets(arg, fifo_dir):
elif line.startswith(".side_set"):
sideset_count = int(line.split()[1], 0)
sideset_enable = "opt" in line
sideset_pindirs = "pindirs" in line
elif line.startswith(".fifo"):
require_before_instruction()
fifo_type = line.split()[1]
Expand Down Expand Up @@ -470,6 +472,8 @@ def parse_rxfifo_brackets(arg, fifo_dir):

if sideset_count != 0:
self.pio_kwargs["sideset_pin_count"] = sideset_count
if sideset_pindirs:
self.pio_kwargs["sideset_pindirs"] = sideset_pindirs

if wrap is not None:
self.pio_kwargs["wrap"] = wrap
Expand Down
17 changes: 17 additions & 0 deletions tests/test_pseudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,20 @@
def test_offset() -> None:
assert_pio_kwargs(".origin 7", offset=7, sideset_enable=False)
assert_assembly_fails("nop\n.origin 7")


def test_sideset_pindirs() -> None:
assert_pio_kwargs(
".side_set 2 opt pindirs",
sideset_pin_count=2,
sideset_enable=True,
sideset_pindirs=True,
)
assert_pio_kwargs(
".side_set 2 pindirs",
sideset_pin_count=2,
sideset_enable=False,
sideset_pindirs=True,
)
# Setting not emitted (as =False) for backwards compat
assert_pio_kwargs(".side_set 2", sideset_pin_count=2, sideset_enable=False)

0 comments on commit 23bd1b1

Please sign in to comment.