drivers/periph_gpio_ll: Fix GPIO_DISCONNECT handling and add compile time feature checks#20290
Merged
maribu merged 7 commits intoRIOT-OS:masterfrom Feb 5, 2024
Merged
Conversation
Member
Author
ATmega
|
This adds the features
- periph_gpio_ll_input_pull_down:
To indicate support for input mode with internal pull down
- periph_gpio_ll_input_pull_keep:
To indicate support for input mode with internal resistor
pulling towards current level
- periph_gpio_ll_input_pull_up:
To indicate support for input mode with internal pull up
- periph_gpio_ll_disconnect:
To indicate a GPIO can be disconnected
- periph_gpio_ll_open_drain:
To indicate support for open drain mode
- periph_gpio_ll_open_drain_pull_up:
To indicate support for open drain mode with internal pull up
- periph_gpio_ll_open_source:
To indicate support for open source mode
- periph_gpio_ll_open_source_pull_down:
To indicate support for open source mode with internal pull down
Since on ATmega GPIOs cannot be disconnected and the reset state is them being an input, this may help making code more portable.
When it is difficult to navigate a function, it is overdue to split it up :D Also, no need to test for feature `gpio_ll_irq` in `test_irq()` *and* before calling `test_irq()`.
Test that features implemented match the features claimed to be supported.
d9fcdb8 to
ac2f3b9
Compare
2 tasks
benpicco
approved these changes
Feb 4, 2024
The separate Schmitt trigger bit in the configuration is dropped, as the Schmitt trigger is only every disabled when in `GPIO_DISCONNECT` mode. So no need to encode the same information twice. The `gpio_state_t` is improved to be a bitmask that holds the MODER register value and a flag indicating whether open-drain mode should be enabled. Finally, `GPIO_DISCONNECT` is implemented. This is done by placing the GPIO in analog mode, which by disabling the Schmitt trigger reduces power consumption.
Allow enabling the pull on on `GPIO_DISCONNECT` and query that correctly.
Use analog mode for GPIO_DISCONNECT, as this is said to have the lowest current leakage due to disabling the Schmitt trigger and correctly detect this in `gpio_ll_query_conf()`. Also drop the `schmitt_trigger_disabled` member in `gpio_conf_t`, as the Schmitt trigger is only ever disabled in Analog mode anyway and cannot be freely configured.
ac2f3b9 to
f10a994
Compare
Member
Author
|
Thx :) |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Contribution description
#20189 enhanced the GPIO LL test to check if
GPIO_DISCONNECTis also the stategpio_ll_query_conf()detects after applying this state usinggpio_ll_init(). A number of GPIO LL implementation failed this tests, include STM32 (except for F1) and ATmega.For ATmega the issue was that no dedicated "disconnected" state exists in hardware. Hence,
GPIO_DISCONNECTwas defined to have the same numeric value isGPIO_INPUT, which is the reset state for ATmega. This in turn resulted in compilation issues in code withswitch()for the GPIO state in the commongpio_ll_print_conf()function. To address this, a compile time check was needed, which was done by introducing the featuregpio_ll_disconnect. While at it, the following features were all added:periph_gpio_ll_input_pull_down:To indicate support for input mode with internal pull down
periph_gpio_ll_input_pull_keep:To indicate support for input mode with internal resistor pulling towards current level
periph_gpio_ll_input_pull_up:To indicate support for input mode with internal pull up
periph_gpio_ll_disconnect:To indicate a GPIO can be disconnected
periph_gpio_ll_open_drain:To indicate support for open drain mode
periph_gpio_ll_open_drain_pull_up:To indicate support for open drain mode with internal pull up
periph_gpio_ll_open_source:To indicate support for open source mode
periph_gpio_ll_open_source_pull_down:To indicate support for open source mode with internal pull down
Testing procedure
The test app has been extended to check if features supported match features claimed. It will (as before) just query feature support at run time even if the features are not claimed to be supported. Then, it will
expect()the support detected at run time match what features are claimed to be supported at compile time.Note: For some MCUs the test currently are failing in
master, due toGPIO_DISCONNECTnot being correctly implemented.Issues/PRs references
#20189 improved the test app that "introduced" the test failures by properly checking