-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add gpio_init_mask64 function
#2907
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
Open
FLyrfors-MI
wants to merge
3
commits into
raspberrypi:develop
Choose a base branch
from
FLyrfors-MI:gpio_init_mask64
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -281,8 +281,17 @@ void gpio_deinit(uint gpio) { | |
| gpio_set_function(gpio, GPIO_FUNC_NULL); | ||
| } | ||
|
|
||
| void gpio_init_mask(uint gpio_mask) { | ||
| for(uint i=0;i<NUM_BANK0_GPIOS;i++) { | ||
| void gpio_init_mask(uint32_t gpio_mask) { | ||
| for(uint32_t i=0;i<NUM_BANK0_GPIOS;i++) { | ||
| if (gpio_mask & 1) { | ||
| gpio_init(i); | ||
| } | ||
| gpio_mask >>= 1; | ||
| } | ||
| } | ||
|
|
||
| void gpio_init_mask64(uint64_t gpio_mask) { | ||
| for(uint64_t i=0;i<NUM_BANK0_GPIOS;i++) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, for (uint i = 0; i < MIN(NUM_BANK0_GPIOS, 64u); i++) { |
||
| if (gpio_mask & 1) { | ||
| gpio_init(i); | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -41,23 +41,23 @@ extern "C" { | |||||||||
| * \brief General Purpose Input/Output (GPIO) API | ||||||||||
| * | ||||||||||
| * RP-series microcontrollers have two banks of General Purpose Input / Output (GPIO) pins, which are assigned as follows: | ||||||||||
| * | ||||||||||
| * | ||||||||||
| * \if rp2040_specific | ||||||||||
| * RP2040 has 30 user GPIO pins in bank 0, and 6 QSPI pins in the QSPI bank 1 (QSPI_SS, QSPI_SCLK and QSPI_SD0 to QSPI_SD3). The QSPI | ||||||||||
| * pins are used to execute code from an external flash device, leaving the User bank (GPIO0 to GPIO29) for the programmer to use. | ||||||||||
| * RP2040 has 30 user GPIO pins in bank 0, and 6 QSPI pins in the QSPI bank 1 (QSPI_SS, QSPI_SCLK and QSPI_SD0 to QSPI_SD3). The QSPI | ||||||||||
| * pins are used to execute code from an external flash device, leaving the User bank (GPIO0 to GPIO29) for the programmer to use. | ||||||||||
| * \endif | ||||||||||
| * | ||||||||||
| * | ||||||||||
| * \if rp2350_specific | ||||||||||
| * The number of GPIO pins available depends on the package. There are 30 user GPIOs in bank 0 in the QFN-60 package (RP2350A), or 48 user GPIOs | ||||||||||
| * The number of GPIO pins available depends on the package. There are 30 user GPIOs in bank 0 in the QFN-60 package (RP2350A), or 48 user GPIOs | ||||||||||
| * in the QFN-80 package. Bank 1 contains the 6 QSPI pins and the USB DP/DM pins. | ||||||||||
|
Comment on lines
+51
to
52
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| * \endif | ||||||||||
| * | ||||||||||
| * | ||||||||||
| * All GPIOs support digital input and output, but a subset can also be used as inputs to the chip’s Analogue to Digital | ||||||||||
| * Converter (ADC). The allocation of GPIO pins to the ADC depends on the packaging. | ||||||||||
| * | ||||||||||
| * | ||||||||||
| * RP2040 and RP2350 QFN-60 GPIO, ADC pins are 26-29. | ||||||||||
| * RP2350 QFN-80, ADC pins are 40-47. | ||||||||||
| * | ||||||||||
| * | ||||||||||
| * Each GPIO can be controlled directly by software running on the processors, or by a number of other functional blocks. | ||||||||||
| * | ||||||||||
| * The function allocated to each GPIO is selected by calling the \ref gpio_set_function function. \note Not all functions | ||||||||||
|
|
@@ -858,7 +858,17 @@ void gpio_deinit(uint gpio); | |||||||||
| * | ||||||||||
| * \param gpio_mask Mask with 1 bit per GPIO number to initialize | ||||||||||
| */ | ||||||||||
| void gpio_init_mask(uint gpio_mask); | ||||||||||
| void gpio_init_mask(uint32_t gpio_mask); | ||||||||||
|
|
||||||||||
| /*! \brief Initialise multiple GPIOs (enabled I/O and set func to GPIO_FUNC_SIO) | ||||||||||
| * \ingroup hardware_gpio | ||||||||||
| * | ||||||||||
| * Clear the output enable (i.e. set to input). | ||||||||||
| * Clear any output value. | ||||||||||
| * | ||||||||||
| * \param gpio_mask Mask with 1 bit per GPIO number to initialize | ||||||||||
| */ | ||||||||||
| void gpio_init_mask64(uint64_t gpio_mask); | ||||||||||
| // ---------------------------------------------------------------------------- | ||||||||||
| // Input | ||||||||||
| // ---------------------------------------------------------------------------- | ||||||||||
|
|
||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gpio_set_function_maskeddoesProbably makes sense to do the same here?