-
Notifications
You must be signed in to change notification settings - Fork 8.2k
[TOPIC-GPIO] drivers: gpio_esp32: update to use new GPIO API #19753
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
[TOPIC-GPIO] drivers: gpio_esp32: update to use new GPIO API #19753
Conversation
172ac81 to
8db0677
Compare
|
@ExtremeGTX I quickly tested the following samples/test on odroid_go: samples/basic/blinky -> works |
8db0677 to
1bb0294
Compare
|
All checks passed. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
|
tests/drivers/gpio/gpio_basic_api The following tests still fails:
The problem with LEVEL interrupts is clearing the interrupt, dunno why clearing status register is not working. |
mnkp
left a comment
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.
When the issues are fixed, could you also try to run tests/drivers/gpio/gpio_api_1pin/ testcase. It will use the pin where LED0 is connected to perform the test. The test requires pin to work in simultaneous input/output mode. According to the documentation and comments in the pinmux_esp32.c file this is supported.
|
I think I've resolved the core problem; at least in a way that makes sense to me: you can't support both edge and level interrupts simultaneously on this hardware.
If I set There are no CPU interrupts that are listed as both edge and level triggered. Now it's possible all that is wrong, and in fact you can use any CPU interrupt line for both edge and level interrupts, but it doesn't look that way to me. So in https://github.com/pabigot/zephyr/commits/pr/19753 I've added a commit that detects the supported trigger type of the configured GPIO interrupt line and rejects attempts to configure for unsupported interrupt types. I also tweaked some macros/comments, and moved the interrupt acknowledge before the callback. I have verified that this does in fact clear the status register, so the fact that it didn't may be because the level configuration conflicted with the interrupt support. @ExtremeGTX you are welcome to cherry-pick and squash that into your work. This passes the two-pin test with line 10 (edge) and line 12 (level) (or will once #19784 gets merged). However: I cannot make the both-edge case work, so I've just disabled support for that. |
Well spotted, that indeed seems to be the culprit. It is possible to attach more than one "Peripheral Interrupt Source" to the same CPU IRQ, e.g. we can have SPI and I2C modules trigger interrupt on the same IRQ line, however it doesn't seem possible to attach the same "Peripheral Interrupt Source" to two different CPU IRQ lines. In this case, the GPIO module can indeed respond either to edge or level interrupts but not both since any given IRQ line is predefined as either edge or level. That complicates the driver. One clean way to handle this situation would be to add a function which would take IRQ line number as a parameter and return the type of the interrupt this line supports: edge, level or invalid (since some IRQs are internal to the CPU). Then the driver would need to return |
Like this, perhaps. |
Looks good. But maybe we should put |
|
@pabigot Good Catch 👍 |
Without the
That'd be why. There may be circumstances where it works, but it's not reliable. |
|
@ExtremeGTX can you cherry-pick @pabigot's commit and squash it into yours and then the PR will be ready for merging. |
|
@carlescufi sure, will do it tomorrow morning. In the end, it is up to you |
|
@ExtremeGTX The general position when discussed today was that if the test doesn't pass we can't enable it, because something's clearly not right. We can continue to investigate and enable it later if we can figure out what's going on. I may find some time for that, or you can look at it, but we'd really like to get the basic driver in ASAP. |
|
ok, i will update this PR tomorrow morning |
I don't know the evaluation board in question. However - unless there is some extra circuitry - signal from the button will bounce / won't be clean. It's not a reliable way to verify edge interrupts. Having passing testcase would be preferable. |
1bb0294 to
b606129
Compare
pabigot
left a comment
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.
Code looks good. No need for acknowledgment for such a small change.
The commit message is a little unusual, but except for the subject line including [TOPIC-GPIO] I don't think it violates any standards. There are existing merged PRs that have that same prefix though, so it can be fixed in a cleanup pass over the branch after it's merged.
|
@mnkp if you are interested, here is the code i use for testing Pins 16,17 gpio0 (Connect both pins using a jumper) - no external circuitry required |
mnkp
left a comment
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.
LGTM with minor comment.
- Updates gpio driver and device tree files to the new GPIO Config flags - Implements the new port_* APIs - Update I2C and PWM Drivers to use new GPIO config - Add esp32.overlay to gpio_basic_api test - refactor convert_int_type, regs struct - remove config_polarity - add kConfig notes Tests: - samples/basic/blinky - samples/basic/button - tests/drivers/gpio/gpio_basic_api - tests/drivers/gpio/gpio_api_1pin Board: - esp32 DevKitC V4 Note about interrupts: The ESP32 requires specifying a CPU interrupt to be used for GPIO interrupt signals. CPU interrupts can be either level or edge (or special) triggered, but not both. Please check gpio/Kconfig.esp32 for more info. Signed-off-by: Mohamed ElShahawi <[email protected]>
b606129 to
4a4ec61
Compare
Tests:
Board:
Known issues:
part of
callback_variantstests are failingwill continue working on it and update this PR
Signed-off-by: Mohamed ElShahawi [email protected]