From 769453c7504ebf71d65a57767fbeea41f2de63f4 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 17 Jun 2025 23:17:43 -0400 Subject: [PATCH] rp2/rp2_pio: Fix use of PIO2 in prog data structure. The RP2350 PIO2 State Machines (8, 9, 10, 11) did not work. The data structure used to pass the PIO arguments was missing an entry for PIO2, thus causing the PIO2 instances to write wrong data to wrong locations. Fixes issue #17509. Signed-off-by: Matt Westveld --- ports/rp2/modules/rp2.py | 15 ++++++++------- ports/rp2/rp2_pio.c | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ports/rp2/modules/rp2.py b/ports/rp2/modules/rp2.py index 606892603..442a802b3 100644 --- a/ports/rp2/modules/rp2.py +++ b/ports/rp2/modules/rp2.py @@ -7,12 +7,13 @@ from micropython import const _PROG_DATA = const(0) _PROG_OFFSET_PIO0 = const(1) _PROG_OFFSET_PIO1 = const(2) -_PROG_EXECCTRL = const(3) -_PROG_SHIFTCTRL = const(4) -_PROG_OUT_PINS = const(5) -_PROG_SET_PINS = const(6) -_PROG_SIDESET_PINS = const(7) -_PROG_MAX_FIELDS = const(8) +_PROG_OFFSET_PIO2 = const(3) +_PROG_EXECCTRL = const(4) +_PROG_SHIFTCTRL = const(5) +_PROG_OUT_PINS = const(6) +_PROG_SET_PINS = const(7) +_PROG_SIDESET_PINS = const(8) +_PROG_MAX_FIELDS = const(9) class PIOASMError(Exception): @@ -50,7 +51,7 @@ class PIOASMEmit: | autopull << 17 | autopush << 16 ) - self.prog = [array("H"), -1, -1, execctrl, shiftctrl, out_init, set_init, sideset_init] + self.prog = [array("H"), -1, -1, -1, execctrl, shiftctrl, out_init, set_init, sideset_init] self.wrap_used = False diff --git a/ports/rp2/rp2_pio.c b/ports/rp2/rp2_pio.c index 8fc7c0e78..611e74a15 100644 --- a/ports/rp2/rp2_pio.c +++ b/ports/rp2/rp2_pio.c @@ -212,6 +212,7 @@ enum { PROG_DATA, PROG_OFFSET_PIO0, PROG_OFFSET_PIO1, + PROG_OFFSET_PIO2, PROG_EXECCTRL, PROG_SHIFTCTRL, PROG_OUT_PINS,