From 64ac686430751ec072e6733bcee276b9379c80d0 Mon Sep 17 00:00:00 2001 From: George Peppard Date: Sun, 23 Jul 2023 14:38:51 +0100 Subject: [PATCH 1/3] feat: add function definition --- src/rp2_common/hardware_gpio/include/hardware/gpio.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/rp2_common/hardware_gpio/include/hardware/gpio.h b/src/rp2_common/hardware_gpio/include/hardware/gpio.h index ae4807516..e683a0496 100644 --- a/src/rp2_common/hardware_gpio/include/hardware/gpio.h +++ b/src/rp2_common/hardware_gpio/include/hardware/gpio.h @@ -185,6 +185,15 @@ static inline void check_gpio_param(__unused uint gpio) { */ void gpio_set_function(uint gpio, enum gpio_function fn); +/*! \brief Select the function for multiple GPIOs + * \ingroup hardware_gpio + * + * \sa gpio_set_function + * \param gpio_mask Mask with 1 bit per GPIO number to set the function for + * \param fn Which GPIO function select to use from list \ref gpio_function +*/ +void gpio_set_function_mask(uint gpio_mask, enum gpio_function fn); + /*! \brief Determine current GPIO function * \ingroup hardware_gpio * From 4621a9fbbcd76c51828124fb9d18626ace6cc9be Mon Sep 17 00:00:00 2001 From: George Peppard Date: Sun, 23 Jul 2023 14:40:21 +0100 Subject: [PATCH 2/3] feat: add gpio_set_function_mask implementation --- src/rp2_common/hardware_gpio/gpio.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rp2_common/hardware_gpio/gpio.c b/src/rp2_common/hardware_gpio/gpio.c index 4945738df..d51870e5d 100644 --- a/src/rp2_common/hardware_gpio/gpio.c +++ b/src/rp2_common/hardware_gpio/gpio.c @@ -262,3 +262,11 @@ void gpio_init_mask(uint gpio_mask) { } } +void gpio_set_function_mask(uint gpio_mask, enum gpio_function fn) { + for (uint i = 0; i < NUM_BANK0_GPIOS; i++) { + if (gpio_mask & 1) { + gpio_set_function(i, fn); + } + gpio_mask >>= 1; + } +} From 53b1073e98e1868671735a32058b2d79fc8b5e89 Mon Sep 17 00:00:00 2001 From: Peter Harper Date: Mon, 22 Jul 2024 14:31:09 +0100 Subject: [PATCH 3/3] Fix line ending --- src/rp2_common/hardware_gpio/include/hardware/gpio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rp2_common/hardware_gpio/include/hardware/gpio.h b/src/rp2_common/hardware_gpio/include/hardware/gpio.h index e683a0496..47b170e60 100644 --- a/src/rp2_common/hardware_gpio/include/hardware/gpio.h +++ b/src/rp2_common/hardware_gpio/include/hardware/gpio.h @@ -190,7 +190,7 @@ void gpio_set_function(uint gpio, enum gpio_function fn); * * \sa gpio_set_function * \param gpio_mask Mask with 1 bit per GPIO number to set the function for - * \param fn Which GPIO function select to use from list \ref gpio_function + * \param fn Which GPIO function select to use from list \ref gpio_function */ void gpio_set_function_mask(uint gpio_mask, enum gpio_function fn);