-
Notifications
You must be signed in to change notification settings - Fork 2k
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
periph/gpio_ll: New Peripheral GPIO API #16787
Conversation
Test when run with
In two out of three cases, there still is a speed by one order of magnitude. In the remaining case, the speedup is due the use of a port oriented API (thus being able to set/clear both GPIOs in one function call instead of two). |
On the roadmap: Is the point where you'd like to merge this between 2 and 3, 3 and 4 or 4 and 5? Personally, I'd be happy with this 2-to-3 or even after 1, if it's marked as an experimental API -- provided there's at least a rough demo on 2-4, but none of those need to be in mergable shape. |
I'd say if there are PRs for a common periph/gpio implementation and PRs for two more implementations of periph/gpio_ng which at least pass all the tests this is ready to merge. It might make sense to also see how the expendable API maps to this. I believe there might be some renaming needed to avoid name clashes. But this wouldn't too bad to do after it is in, since the API marked as unstable. But we could just as well wait for this before pushing this forward. |
9663d1b
to
d323595
Compare
Rebased, squashed, and nRF5x backend implemented. It turned out that level triggered IRQs cannot be implemented for the nRF5x, since the approach used for the STM32 (which also don't natively support level triggered IRQs) relies on being able to trigger the GPIO IRQ from software. |
d323595
to
fed2a24
Compare
@maribu Would it make sense to split this PR into a PR defining the API and PRs for each MCU implementation? |
Absolutely! When it is ready for review (I still want at least a non-ARM implementation to make sure I don't overlook any portability issues) I will do so. |
I guess that you want to implement it for AVR by yourself. I could offer to try an implementation for ESP32, although the current GPIO handling is not port based yet. |
That would be nice :-) |
I had a first short look. Following thoughts for short:
I know some of my questions are always with an eye towards making the integration of expanders as seamless as possible, which of course is always in my mind due to the history of our work on this topic 😉 |
Indeed, I'll rename it.
There only is a scalar For a GPIO API on top that would provide again a typedef union {
uint16_t bits;
struct fields {
uint16_t pin : 5;
uint16_t port : 5;
uint16_t device : 6;
}
} gpio_t; And a value of I am aware that using this 16 bit bitmask would be less efficient (in terms of latency) than the current encoding for most implementations, but it often will be a more compact representation. IMO the use case of low latency cannot be reasonable addressed with a high level GPIO API (that does allow uniform access to both GPIO extenders and peripheral GPIOs) anyway, as the dispatching code adds precious CPU cycles. So the (relatively few) applications with that requirement will use
There is no technical reason to have it a separate file. I occasionally see that students are confused by not being able to use the IRQ functions of I will relocate and rename the header as suggested.
Apparently the coding convention was forgotten be be updated in #15793 and #16149 as it still says aim for 80 chars. |
fed2a24
to
82f3869
Compare
@gschorcht Could you confirm that I addressed all your requested changes? I think otherwise this PR is good to get in. |
Since the PR for the API was merged with the PRs for the implementations (I would have preferred to keep them separate), there were a lot of files added for the implementation that I didn't check. Considering the API on its own, the PR seems fine to me. |
Since it is a basic API change, I would prefere a double ACK. |
The API change has its two ACKs with yours and mine. I focused my review on the API and nRF parts. Shall we try to raise someone familiar with STM and AVR for an extra review there? Or merge what had the best review? Personally, I'd be OK with merging with the reviews we have as well -- it is an experimental API, setup mismatches should be caught rather easily (esp. in the tests), and much of the code is being taken over from the original GPIO code. |
Co-authored-by: Gunar Schorcht <[email protected]> Co-authored-by: chrysn <[email protected]> Co-authored-by: Benjamin Valentin <[email protected]>
Co-authored-by: Gunar Schorcht <[email protected]>
Sorry for the delay. I split out the implementations into separate PRs as requested. Should be ready for merge now. |
Thanks for the reviews! |
Thanks for all your work on this! I'm very much looking forward to implementing (EFM32 probably, and maybe hifive1), wrapping (you know for what) and using (for WS2812B and similar LEDs) this. |
@maribu Is file 22a1773#diff-98d165c8005ed5bc1a8eb27fb952e12a1707f5e5dd0a1aeb834eeef51da74635 what it seems to be, a core dump which was provided and merged by mistake? |
Oh shit :/ |
Sorry, this slipped by my review as well.
Oh shit :/
As far as these moments go, I'd put it in the "not great, not terrible"
category: The 21MiB do contribute to the 250MiB checkout visibly, but
once removed will only contribute around 2.5MiB compressed to the 150MiB
git objects we have. (And those very concerned with data have, in recent
git versions, good options around shallow checkouts).
What remains is not having this too often. That means better care by
revieers like me, but in terms of automation: Maybe have `core` added to
.gitignore?
|
Contribution description
This PR proposes a new peripheral GPIO API. It is orthogonal to #14602, which tries to expose GPIO-expanders under the same API. It doesn't intend to replace the pin-based
periph/gpio
API (but on the long term the intention is that this API is implemented on top of this API, to avoid having to maintain two implementations for each MCU).Main differences:
Testing procedure
With
tests/periph_gpio_ll
a test application including a benchmark is provided. However, so for only for STM32 the API is implemented. It likely makes sense to not merge this prior to having at least three implementations ready.Output of the benchmark part of the test on a Nucleo-F767ZI:
As seen, a square wave can be generated at have the clock rate (one CPU cycle for the high part, one CPU cycle for the low part), which is the theoretical option. The current API requires 373 CPU cycles / 193 CPU cycles instead of the 2 CPU cycles of the new API.
Issues/PRs references
Orthogonal to #14602 except for the port-wise interface, which #14602 also introduces.
Suggested Road-Map
periph/gpio
implementation indrivers/periph_common
on top ofperiph/gpio_ll
, so that on long term we don't need to maintain two APIsperiph/gpio
implementation to hook in GPIO extenders periph/gpio: new expandable GPIO API #14602perpih/gpio
implementations (and only keep the one implemented on top ofperiph/gpio_ll