event_periodic_callback: add getter for user context, one-shot event #18656
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
event_periodic_callback_get_arg()
This is a purely aesthetic addition: When initializing an event, e.g. to measure a sensor, I want to have a locally visible
static lm75_t lm75_dev
that I use as the event argument.I can access this in the callback, but if I want to access it outside the callback, e.g. to re-init the sensor after the callback was suspended, I have to access
event->event.arg
which feels dirty.Instead, add a nice getter function that does the same.
event_callback_oneshot()
An easy helper to execute a function by the event thread, to be called e.g. in an interrupt or by another function that is not supposed to block.
Testing procedure
Issues/PRs references