From c416d02d04fa6abbab1295153cd164ac6c8bbed8 Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Mon, 21 Jul 2025 17:28:56 -0500 Subject: [PATCH 1/3] better document the GPIO_BASE requirements of pio_encode_gpio_wait, and move the recently added main documentation, since i think this is the only such function --- .../hardware_pio/include/hardware/pio_instructions.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h b/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h index edb0ef31a..eb2d31c89 100644 --- a/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h +++ b/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h @@ -18,10 +18,6 @@ * parameters. * * For fuller descriptions of the instructions in question see the "RP2040 Datasheet" - * - * NOTE: These are helper functions for the raw instruction encoding, and thus - * only provide support for pins numbered 0-31. You should adjust your encoding - * according to your expected GPIO_BASE (see \ref pio_set_gpio_base) */ // PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_PIO_INSTRUCTIONS, Enable/disable assertions in the PIO instructions, type=bool, default=0, group=pio_instructions @@ -271,8 +267,12 @@ static inline uint _pio_encode_irq(bool relative, uint irq) { * * This is the equivalent of `WAIT GPIO ` * + * \note gpio here refers to the raw instruction encoding, which only supports 32 GPIOs. so, if you had a PIO + * program with `WAIT GPIO 42` and a GPIO_BASE (see \ref pio_set_gpio_base) of 16, then you'd want to do + * `pio_encode_wait_gpio(polarity, 42-16)` + * * \param polarity true for `WAIT 1`, false for `WAIT 0` - * \param gpio The real GPIO number 0-31 + * \param gpio The GPIO number 0-31 relative to the state machine's GPIO_BASE (see \ref pio_set_gpio_base) * \return The instruction encoding with 0 delay and no side set value * \see pio_encode_delay, pio_encode_sideset, pio_encode_sideset_opt */ From f84f2e17e15127ccf45906204020857c931f6c8c Mon Sep 17 00:00:00 2001 From: graham sanderson Date: Mon, 21 Jul 2025 17:34:45 -0500 Subject: [PATCH 2/3] add proviso --- src/rp2_common/hardware_pio/include/hardware/pio_instructions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h b/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h index eb2d31c89..82559e9bc 100644 --- a/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h +++ b/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h @@ -269,7 +269,7 @@ static inline uint _pio_encode_irq(bool relative, uint irq) { * * \note gpio here refers to the raw instruction encoding, which only supports 32 GPIOs. so, if you had a PIO * program with `WAIT GPIO 42` and a GPIO_BASE (see \ref pio_set_gpio_base) of 16, then you'd want to do - * `pio_encode_wait_gpio(polarity, 42-16)` + * `pio_encode_wait_gpio(polarity, 42-16)` assuming you are using this function to craft instructions for \ref pio_sm_exec. * * \param polarity true for `WAIT 1`, false for `WAIT 0` * \param gpio The GPIO number 0-31 relative to the state machine's GPIO_BASE (see \ref pio_set_gpio_base) From b2c3287798bdb950f320e2bd5f6604f11a412a7c Mon Sep 17 00:00:00 2001 From: Graham Sanderson Date: Fri, 25 Jul 2025 09:19:35 -0500 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Andrew Scheller --- src/rp2_common/hardware_pio/include/hardware/pio_instructions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h b/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h index 82559e9bc..e990a7284 100644 --- a/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h +++ b/src/rp2_common/hardware_pio/include/hardware/pio_instructions.h @@ -267,7 +267,7 @@ static inline uint _pio_encode_irq(bool relative, uint irq) { * * This is the equivalent of `WAIT GPIO ` * - * \note gpio here refers to the raw instruction encoding, which only supports 32 GPIOs. so, if you had a PIO + * \note gpio here refers to the raw instruction encoding, which only supports 32 GPIOs. So, if you had a PIO * program with `WAIT GPIO 42` and a GPIO_BASE (see \ref pio_set_gpio_base) of 16, then you'd want to do * `pio_encode_wait_gpio(polarity, 42-16)` assuming you are using this function to craft instructions for \ref pio_sm_exec. *