Commit 60f1f769 authored by Damien George's avatar Damien George

stm32/softtimer: Add soft_timer_reinsert() helper function.

And call mp_pairheap_init_node() in soft_timer_static_init() so that
reinsert can be called after static_init.
Signed-off-by: default avatarDamien George <damien@micropython.org>
parent b3a34dde
......@@ -122,6 +122,7 @@ void soft_timer_gc_mark_all(void) {
}
void soft_timer_static_init(soft_timer_entry_t *entry, uint16_t mode, uint32_t delta_ms, void (*cb)(soft_timer_entry_t *)) {
mp_pairheap_init_node(soft_timer_lt, &entry->pairheap);
entry->flags = 0;
entry->mode = mode;
entry->delta_ms = delta_ms;
......
......@@ -56,4 +56,11 @@ void soft_timer_static_init(soft_timer_entry_t *entry, uint16_t mode, uint32_t d
void soft_timer_insert(soft_timer_entry_t *entry, uint32_t initial_delta_ms);
void soft_timer_remove(soft_timer_entry_t *entry);
// The timer will be reinserted into the heap so that it is called after initial_delta_ms milliseconds.
// After that, if it's periodic, it will continue to be called every entry->delta_ms milliseconds.
static inline void soft_timer_reinsert(soft_timer_entry_t *entry, uint32_t initial_delta_ms) {
soft_timer_remove(entry);
soft_timer_insert(entry, initial_delta_ms);
}
#endif // MICROPY_INCLUDED_STM32_SOFTTIMER_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment