Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gpio_set_function_mask function #1462

Merged
merged 3 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/rp2_common/hardware_gpio/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
9 changes: 9 additions & 0 deletions src/rp2_common/hardware_gpio/include/hardware/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
Loading