Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for .side_set ... pindirs #73

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)