Skip to content

Commit 7c5b426

Browse files
authored
Add gpio_set_function_mask function (#1462)
1 parent af9b47c commit 7c5b426

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/rp2_common/hardware_gpio/gpio.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,11 @@ void gpio_init_mask(uint gpio_mask) {
270270
}
271271
}
272272

273+
void gpio_set_function_mask(uint gpio_mask, enum gpio_function fn) {
274+
for (uint i = 0; i < NUM_BANK0_GPIOS; i++) {
275+
if (gpio_mask & 1) {
276+
gpio_set_function(i, fn);
277+
}
278+
gpio_mask >>= 1;
279+
}
280+
}

src/rp2_common/hardware_gpio/include/hardware/gpio.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ static inline void check_gpio_param(__unused uint gpio) {
185185
*/
186186
void gpio_set_function(uint gpio, enum gpio_function fn);
187187

188+
/*! \brief Select the function for multiple GPIOs
189+
* \ingroup hardware_gpio
190+
*
191+
* \sa gpio_set_function
192+
* \param gpio_mask Mask with 1 bit per GPIO number to set the function for
193+
* \param fn Which GPIO function select to use from list \ref gpio_function
194+
*/
195+
void gpio_set_function_mask(uint gpio_mask, enum gpio_function fn);
196+
188197
/*! \brief Determine current GPIO function
189198
* \ingroup hardware_gpio
190199
*

0 commit comments

Comments
 (0)