diff --git a/adafruit_pioasm.py b/adafruit_pioasm.py index 2a4df32..f1484a3 100644 --- a/adafruit_pioasm.py +++ b/adafruit_pioasm.py @@ -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 @@ -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] @@ -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 diff --git a/tests/test_pseudo.py b/tests/test_pseudo.py index 1bf89f8..a5049ec 100644 --- a/tests/test_pseudo.py +++ b/tests/test_pseudo.py @@ -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)