Allow any gpio pin to be used (not just the first 32) #117
Allow any gpio pin to be used (not just the first 32) #117georgeharker wants to merge 6 commits intoraspberrypi:sdk-2.0.0from
Conversation
Just used gpio number to decode register locations
| case ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL: | ||
| if (value) | ||
| GPIO_SET = 1 << gpio_config->gpio_num; | ||
| GPIO_SET(gpio_config->gpio_num) = 1 << (gpio_config->gpio_num & 0x1f); |
There was a problem hiding this comment.
IMHO it looks a bit weird seeing gpio_config->gpio_num repeated on both sides of the = sign? But perhaps "fixing" that would be too much of a departure from the way the existing code was working? 🤷
There was a problem hiding this comment.
I agree - could rewrite entirely if you'd like and make set an entire macro?
There was a problem hiding this comment.
Not really my call to make. What does @P33M think?
There was a problem hiding this comment.
Please rewrite to be a generic "operate on this gpio pin" - e.g. I call GPIO_SET_PIN(n) and it computes the offset and writes the correct bit index. This then would collapse the branch in bcm2835gpio_write into a choice for each pin's desired state.
|
Is the motivation for this PR to be able to use this with the additional GPIO pins that are exposed on the Compute Modules? |
|
I've just noticed that this PR introduces a mix of tabs vs. spaces for indentation. IMHO it's best to be consistent (so stick to tabs, as that's what the original code was using). |
Yes, I have a board which is pin constrained and I needed to be able to use GPIO 44 as the reset pin... it wasn't initially clear that the request to do so was silently ignored. In theory any pin should be usable... hence the PR |
Thanks, fixed. I usually have my editor set up to auto convert, missed that in the diff. |
this should now be fixed |
|
If this is still required, please
|
Previous implementation disallowed using higher pin numbers for srst etc, this removes that restriction
replaces #113