Skip to content

Commit 8a97f71

Browse files
committed
More piov2 updates
* As an extension, ".fifo auto" may be specified to request CircuitPython's auto fifo join behavior * bounds check on `.set` directive improved * redundant kwargs (e.g., out_count vs out_pin_count) fixed
1 parent b379f05 commit 8a97f71

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ To install in a virtual environment in your current project:
5555
source .venv/bin/activate
5656
pip3 install adafruit-circuitpython-pioasm
5757
58+
CircuitPython Extensions
59+
========================
60+
61+
* `.fifo auto`: By default, CircuitPython joins the TX and RX fifos if a PIO program only receives or transmits. The `.fifo auto` directive makes this explicit.
62+
5863
Usage Example
5964
=============
6065

adafruit_pioasm.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,15 @@
3434
MOV_SOURCES = ["pins", "x", "y", "null", None, "status", "isr", "osr"]
3535
MOV_OPS = [None, "~", "::", None]
3636
SET_DESTINATIONS = ["pins", "x", "y", None, "pindirs", None, None, None]
37-
FIFO_TYPES = {"txrx": 0, "tx": 0, "rx": 0, "txput": 1, "txget": 1, "putget": 1}
37+
FIFO_TYPES = {
38+
"auto": 0,
39+
"txrx": 0,
40+
"tx": 0,
41+
"rx": 0,
42+
"txput": 1,
43+
"txget": 1,
44+
"putget": 1,
45+
}
3846

3947

4048
class Program: # pylint: disable=too-few-public-methods
@@ -61,7 +69,7 @@ def __init__(self, text_program: str, *, build_debuginfo: bool = False) -> None:
6169
wrap_target = None
6270
offset = -1
6371
pio_version = 0
64-
fifo_type = None
72+
fifo_type = "auto"
6573
mov_status_type = None
6674
mov_status_n = None
6775
in_count = None
@@ -208,7 +216,7 @@ def parse_rxfifo_brackets(arg, fifo_dir):
208216
elif words[0] == ".set":
209217
require_before_instruction()
210218
set_count = int_in_range(
211-
words[1], 32 if pio_version == 0 else 1, 33, ".set count"
219+
words[1], 5 if pio_version == 0 else 1, 6, ".set count"
212220
)
213221

214222
elif line.endswith(":"):
@@ -443,18 +451,18 @@ def parse_rxfifo_brackets(arg, fifo_dir):
443451
if wrap_target is not None:
444452
self.pio_kwargs["wrap_target"] = wrap_target
445453

446-
if FIFO_TYPES.get(fifo_type):
454+
if fifo_type != "auto":
447455
self.pio_kwargs["fifo_type"] = fifo_type
448456

449457
if mov_status_type is not None:
450458
self.pio_kwargs["mov_status_type"] = mov_status_type
451459
self.pio_kwargs["mov_status_n"] = mov_status_n
452460

453-
if set_count not in (None, 32):
454-
self.pio_kwargs["set_count"] = set_count
461+
if set_count is not None:
462+
self.pio_kwargs["set_pin_count"] = set_count
455463

456464
if out_count not in (None, 32):
457-
self.pio_kwargs["out_count"] = out_count
465+
self.pio_kwargs["out_pin_count"] = out_count
458466

459467
if out_shift_right is not None:
460468
self.pio_kwargs["out_shift_right"] = out_shift_right
@@ -466,7 +474,7 @@ def parse_rxfifo_brackets(arg, fifo_dir):
466474
self.pio_kwargs["pull_threshold"] = pull_threshold
467475

468476
if in_count not in (None, 32):
469-
self.pio_kwargs["in_count"] = in_count
477+
self.pio_kwargs["in_pin_count"] = in_count
470478

471479
if in_shift_right is not None:
472480
self.pio_kwargs["in_shift_right"] = in_shift_right

tests/test_version.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ def test_version() -> None:
1717

1818

1919
def test_fifo() -> None:
20-
assert_pio_kwargs(".fifo txrx", sideset_enable=0)
20+
assert_pio_kwargs(".fifo txrx", sideset_enable=0, fifo_type="txrx")
21+
assert_pio_kwargs(".fifo auto", sideset_enable=0)
2122
assert_assembly_fails(".fifo txput")
2223
assert_pio_kwargs(
2324
".pio_version 1\n.fifo txput",
@@ -80,7 +81,7 @@ def test_dot_in() -> None:
8081
".pio_version 1\n.in 16 right",
8182
pio_version=1,
8283
sideset_enable=0,
83-
in_count=16,
84+
in_pin_count=16,
8485
auto_push=False,
8586
in_shift_right=True,
8687
)
@@ -99,17 +100,19 @@ def test_dot_out() -> None:
99100
".pio_version 1\n.out 16 right",
100101
pio_version=1,
101102
sideset_enable=0,
102-
out_count=16,
103+
out_pin_count=16,
103104
auto_pull=False,
104105
out_shift_right=True,
105106
)
106107

107108

108109
def test_dot_set() -> None:
109-
assert_pio_kwargs(".set 32", sideset_enable=0)
110+
assert_pio_kwargs(".set 5", sideset_enable=0, set_pin_count=5)
110111
assert_assembly_fails(".set 16")
112+
assert_assembly_fails(".pio_version 1\n.set 16")
113+
assert_assembly_fails(".set 3")
111114
assert_pio_kwargs(
112-
".pio_version 1\n.set 16 right", pio_version=1, sideset_enable=0, set_count=16
115+
".pio_version 1\n.set 3 right", pio_version=1, sideset_enable=0, set_pin_count=3
113116
)
114117

115118

0 commit comments

Comments
 (0)