Merge pull request #59 from jepler/offset-pseudo

support .offset pseudo-op
This commit is contained in:
Scott Shawcroft 2023-08-07 09:29:34 -07:00 committed by GitHub
commit 7ec05cdee3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View file

@ -52,6 +52,7 @@ class Program: # pylint: disable=too-few-public-methods
sideset_enable = 0
wrap = None
wrap_target = None
offset = -1
for i, line in enumerate(text_program.split("\n")):
line = line.strip()
if not line:
@ -62,6 +63,8 @@ class Program: # pylint: disable=too-few-public-methods
if program_name:
raise RuntimeError("Multiple programs not supported")
program_name = line.split()[1]
elif line.startswith(".offset"):
offset = int(line.split()[1], 0)
elif line.startswith(".wrap_target"):
wrap_target = len(instructions)
elif line.startswith(".wrap"):
@ -227,6 +230,9 @@ class Program: # pylint: disable=too-few-public-methods
"sideset_enable": sideset_enable,
}
if offset != -1:
self.pio_kwargs["offset"] = offset
if sideset_count != 0:
self.pio_kwargs["sideset_pin_count"] = sideset_count

13
tests/test_pseudo.py Normal file
View file

@ -0,0 +1,13 @@
# SPDX-FileCopyrightText: 2021 Jeff Epler, written for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Tests pseudo-ops
"""
from pytest_helpers import assert_pio_kwargs
def test_offset():
assert_pio_kwargs(".offset 7", offset=7, sideset_enable=False)