periph/gpio: add gpio_update_int() class of functions#13925
Closed
benpicco wants to merge 4 commits intoRIOT-OS:masterfrom
Closed
periph/gpio: add gpio_update_int() class of functions#13925benpicco wants to merge 4 commits intoRIOT-OS:masterfrom
benpicco wants to merge 4 commits intoRIOT-OS:masterfrom
Conversation
Allow to re-configure the interrupt callback without re-configuring the interrupt pin.
Contributor
Contributor
|
What is the reason for having three different functions? |
Contributor
Author
|
Was suggested by @maribu to make the API easier to use / implement: #12082 (comment) But at that point function pointers in RAM were not a concern yet, with the old API if a function was not used by the application the linker would just throw it out. |
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
It can be desirable to change the function or behavior associated with a GPIO interrupt.
Currently this can only be achieved by calling
gpio_init_int()again, which not only does lots of unnecessary and possibly time-consuming work, but also forces to expose the GPIO configuration to callers that only want to change the callback argument.As proposed in #12082 (comment) this introduces three new functions:
gpio_init_int()must have been called successfully before onpin, so no error checking is needed which greatly simplifies the implementation.If the API is acceptable, I will update the remaining GPIO drivers.
stm32f1/periph/gpio.cmips_pic32_common/periph/gpio.clpc1768/periph/gpio.cstm32_common/periph/gpio.cefm32/periph/gpio.cnative/periph/gpio.clm4f120/periph/gpio.cfe310/periph/gpio.cesp8266/periph/gpio.cmsp430fxyz/periph/gpio.ccc26xx_cc13xx/periph/gpio.ccc2538/periph/gpio.cesp32/periph/gpio.clpc2387/periph/gpio.ckinetis/periph/gpio.catmega_common/periph/gpio.csam0_common/periph/gpio.cnrf5x_common/periph/gpio.csam3/periph/gpio.cezr32wg/periph/gpio.cTesting procedure
The following program should alternate between the two messages with each press of a button.
Issues/PRs references
alternative to #12082