stm32: Support static soft timer instances. #7143
Merged
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.
This adds support for making static (ie not on the Python GC heap) soft timers. This can be useful for a board to define some custom background handler, or eventually for BLE/network processing to use instead of systick slots; it will be more efficient using soft timer for this.
The main issue with using the existing code for static soft timers is that it would combine heap allocated and statically allocated
soft_timer_entry_t
instances in the same pairing heap data structure. This would prevent the GC from tracing some of the heap allocated entries (because the GC won't follow pointers outside the heap).This PR makes it so that soft timer entries are explicitly marked, instead of relying on implicit marking by having the root of the pairing heap in the root pointer section. This PR also deletes only the heap-allocated soft timers from the pairing heap on soft reset, leaving the statically allocated ones.
An alternative to this approach would be to have two separate pairing heaps, one for static and one for heap allocated entries, but for execution efficiency it's better to just have a single pairing heap.