drivers/sgp30: use event_timeout, to avoid long ISR code block#22149
drivers/sgp30: use event_timeout, to avoid long ISR code block#22149fjmolinas wants to merge 7 commits intoRIOT-OS:masterfrom
Conversation
| 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); |
There was a problem hiding this comment.
better make the queue configurable
| 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?
There was a problem hiding this comment.
None, Is EVENT_PRIO_MEDIUM the best default?
There was a problem hiding this comment.
I still think it makes sense to make it configurable
There was a problem hiding this comment.
Done, Ok to squash?
| #ifndef SGP30_STRICT_EVENT_THREAD_QUEUE | ||
| #define SGP30_STRICT_EVENT_THREAD_QUEUE EVENT_PRIO_MEDIUM |
There was a problem hiding this comment.
| #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 |
There was a problem hiding this comment.
Please also add indentation to the #define here.
There was a problem hiding this comment.
No problem, sorry that was not part of the coding-standard when I was active, I didn't know it was added, addressed! Thanks for pointing it out
| 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 |
There was a problem hiding this comment.
This would unconditionally error out when MODULE_SGP30_STRICT is defined?
There was a problem hiding this comment.
I guess I was testing something locally, and committed by mistake
…d long ISR code block
…to avoid long ISR code block
|
Ok to squash? |
Good from my side 👍 |
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