From efa800b0d30d567559983e56150a655ed8307a19 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Fri, 24 Jan 2025 18:11:02 -0600 Subject: [PATCH 1/3] add extra assertions to pio.h --- src/rp2_common/hardware_pio/include/hardware/pio.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/rp2_common/hardware_pio/include/hardware/pio.h b/src/rp2_common/hardware_pio/include/hardware/pio.h index 9d1f5ce09..e95bec132 100644 --- a/src/rp2_common/hardware_pio/include/hardware/pio.h +++ b/src/rp2_common/hardware_pio/include/hardware/pio.h @@ -215,6 +215,10 @@ static_assert(DREQ_PIO0_TX2 == DREQ_PIO0_TX0 + 2, ""); static_assert(DREQ_PIO0_TX3 == DREQ_PIO0_TX0 + 3, ""); static_assert(DREQ_PIO0_RX0 == DREQ_PIO0_TX0 + NUM_PIO_STATE_MACHINES, ""); static_assert(DREQ_PIO1_RX0 == DREQ_PIO1_TX0 + NUM_PIO_STATE_MACHINES, ""); +#if NUM_PIOS > 2 +static_assert(DREQ_PIO2_TX0 == DREQ_PIO1_RX0 + NUM_PIO_STATE_MACHINES, ""); +static_assert(DREQ_PIO2_RX0 == DREQ_PIO2_TX0 + NUM_PIO_STATE_MACHINES, ""); +#endif #define PIO_DREQ_NUM(pio, sm, is_tx) ((sm) + (((is_tx) ? 0 : NUM_PIO_STATE_MACHINES) + PIO_NUM(pio) * (DREQ_PIO1_TX0 - DREQ_PIO0_TX0))) #endif From a9fe6e06ad2bf43a8ff181782bc43413ca27d5e9 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Sun, 2 Feb 2025 11:47:02 -0600 Subject: [PATCH 2/3] add another assert --- src/rp2_common/hardware_pio/include/hardware/pio.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rp2_common/hardware_pio/include/hardware/pio.h b/src/rp2_common/hardware_pio/include/hardware/pio.h index e95bec132..537a0d7dc 100644 --- a/src/rp2_common/hardware_pio/include/hardware/pio.h +++ b/src/rp2_common/hardware_pio/include/hardware/pio.h @@ -214,6 +214,7 @@ static_assert(DREQ_PIO0_TX1 == DREQ_PIO0_TX0 + 1, ""); static_assert(DREQ_PIO0_TX2 == DREQ_PIO0_TX0 + 2, ""); static_assert(DREQ_PIO0_TX3 == DREQ_PIO0_TX0 + 3, ""); static_assert(DREQ_PIO0_RX0 == DREQ_PIO0_TX0 + NUM_PIO_STATE_MACHINES, ""); +static_assert(DREQ_PIO1_TX0 == DREQ_PIO0_RX0 + NUM_PIO_STATE_MACHINES, ""); static_assert(DREQ_PIO1_RX0 == DREQ_PIO1_TX0 + NUM_PIO_STATE_MACHINES, ""); #if NUM_PIOS > 2 static_assert(DREQ_PIO2_TX0 == DREQ_PIO1_RX0 + NUM_PIO_STATE_MACHINES, ""); From 6c62ca14c111fa75f1e0dfe8b4f52768c57c3ac5 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Sun, 2 Feb 2025 12:56:49 -0600 Subject: [PATCH 3/3] minor clarifications --- src/rp2_common/hardware_pio/include/hardware/pio.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rp2_common/hardware_pio/include/hardware/pio.h b/src/rp2_common/hardware_pio/include/hardware/pio.h index 537a0d7dc..b11733092 100644 --- a/src/rp2_common/hardware_pio/include/hardware/pio.h +++ b/src/rp2_common/hardware_pio/include/hardware/pio.h @@ -172,6 +172,9 @@ typedef pio_hw_t *PIO; */ #ifndef PIO_NUM static_assert(PIO1_BASE - PIO0_BASE == (1u << 20), "hardware layout mismatch"); +#if NUM_PIOS > 2 +static_assert(PIO2_BASE - PIO0_BASE == (2u << 20), "hardware layout mismatch"); +#endif #define PIO_NUM(pio) (((uintptr_t)(pio) - PIO0_BASE) >> 20) #endif @@ -185,6 +188,9 @@ static_assert(PIO1_BASE - PIO0_BASE == (1u << 20), "hardware layout mismatch"); */ #ifndef PIO_INSTANCE static_assert(PIO1_BASE - PIO0_BASE == (1u << 20), "hardware layout mismatch"); +#if NUM_PIOS > 2 +static_assert(PIO2_BASE - PIO0_BASE == (2u << 20), "hardware layout mismatch"); +#endif #define PIO_INSTANCE(instance) ((pio_hw_t *)(PIO0_BASE + (instance) * (1u << 20))) #endif @@ -220,7 +226,7 @@ static_assert(DREQ_PIO1_RX0 == DREQ_PIO1_TX0 + NUM_PIO_STATE_MACHINES, ""); static_assert(DREQ_PIO2_TX0 == DREQ_PIO1_RX0 + NUM_PIO_STATE_MACHINES, ""); static_assert(DREQ_PIO2_RX0 == DREQ_PIO2_TX0 + NUM_PIO_STATE_MACHINES, ""); #endif -#define PIO_DREQ_NUM(pio, sm, is_tx) ((sm) + (((is_tx) ? 0 : NUM_PIO_STATE_MACHINES) + PIO_NUM(pio) * (DREQ_PIO1_TX0 - DREQ_PIO0_TX0))) +#define PIO_DREQ_NUM(pio, sm, is_tx) (DREQ_PIO0_TX0 + (sm) + (((is_tx) ? 0 : NUM_PIO_STATE_MACHINES) + PIO_NUM(pio) * (DREQ_PIO1_TX0 - DREQ_PIO0_TX0))) #endif /**