drivers/sgp30: use event_timeout, to avoid long ISR code block#22149
Open
fjmolinas wants to merge 4 commits intoRIOT-OS:masterfrom
Open
drivers/sgp30: use event_timeout, to avoid long ISR code block#22149fjmolinas wants to merge 4 commits intoRIOT-OS:masterfrom
fjmolinas wants to merge 4 commits intoRIOT-OS:masterfrom
Conversation
crasbe
reviewed
Mar 22, 2026
benpicco
reviewed
Mar 23, 2026
drivers/sgp30/sgp30.c
Outdated
| dev->_timer.callback = _read_cb; | ||
| dev->_timer.arg = dev; | ||
| event_callback_init(&dev->_event, _read_cb, dev); | ||
| event_timeout_init(&dev->_timeout, EVENT_PRIO_LOWEST, (event_t *)&dev->_event); |
Contributor
There was a problem hiding this comment.
better make the queue configurable
Suggested change
| event_timeout_init(&dev->_timeout, EVENT_PRIO_LOWEST, (event_t *)&dev->_event); | |
| event_timeout_init(&dev->_timeout, CONFIG_SGP30_EVENT_QUEUE, (event_t *)&dev->_event); |
#ifndef CONFIG_SGP30_EVENT_QUEUE
#define CONFIG_SGP30_EVENT_QUEUE EVENT_PRIO_LOWEST
#endifWhy EVENT_PRIO_LOWEST instead of EVENT_PRIO_MEDIUM?
Contributor
Author
There was a problem hiding this comment.
None, Is EVENT_PRIO_MEDIUM the best default?
Contributor
There was a problem hiding this comment.
I still think it makes sense to make it configurable
Contributor
Author
There was a problem hiding this comment.
Done, Ok to squash?
9 tasks
benpicco
reviewed
Mar 28, 2026
| extern "C" { | ||
| #endif | ||
|
|
||
|
|
benpicco
reviewed
Mar 28, 2026
Comment on lines
+65
to
+66
| #ifndef SGP30_STRICT_EVENT_THREAD_QUEUE | ||
| #define SGP30_STRICT_EVENT_THREAD_QUEUE EVENT_PRIO_MEDIUM |
Contributor
There was a problem hiding this comment.
Suggested change
| #ifndef SGP30_STRICT_EVENT_THREAD_QUEUE | |
| #define SGP30_STRICT_EVENT_THREAD_QUEUE EVENT_PRIO_MEDIUM | |
| #ifndef CONFIG_SGP30_STRICT_EVENT_THREAD_QUEUE | |
| #define CONFIG_SGP30_STRICT_EVENT_THREAD_QUEUE EVENT_PRIO_MEDIUM |
Contributor
There was a problem hiding this comment.
Please also add indentation to the #define here.
crasbe
reviewed
Mar 28, 2026
| dev->_timer.arg = dev; | ||
| event_callback_init(&dev->_event, _read_cb, dev); | ||
| event_timeout_init(&dev->_timeout, SGP30_STRICT_EVENT_THREAD_QUEUE, (event_t *)&dev->_event); | ||
| #error |
Contributor
There was a problem hiding this comment.
This would unconditionally error out when MODULE_SGP30_STRICT is defined?
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
This avoid reading measurements in ISR context, which will behave differently depending on the ISR context size. To avoid this use events posting to the lowest priority event loop.
I've been away for a while so maybe there is a better way of handling this now?
Testing procedure
I have an
nrf52840-mdkwith the ansgp30connected, after waiting for 15s I get readings:Without this PR hardfault:
Issues/PRs references
None