mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 19:20:22 +01:00
stm32/systick: Make periodic systick callbacks use a cyclic func table.
Instead of checking each callback (currently storage and dma) explicitly for each SysTick IRQ, use a simple circular function table indexed by the lower bits of the millisecond tick counter. This allows callbacks to be easily enabled/disabled at runtime, and scales well to a large number of callbacks.
This commit is contained in:
@@ -26,6 +26,22 @@
|
||||
#ifndef MICROPY_INCLUDED_STM32_SYSTICK_H
|
||||
#define MICROPY_INCLUDED_STM32_SYSTICK_H
|
||||
|
||||
#define SYSTICK_DISPATCH_NUM_SLOTS (2)
|
||||
#define SYSTICK_DISPATCH_DMA (0)
|
||||
#define SYSTICK_DISPATCH_STORAGE (1)
|
||||
|
||||
typedef void (*systick_dispatch_t)(uint32_t);
|
||||
|
||||
extern systick_dispatch_t systick_dispatch_table[SYSTICK_DISPATCH_NUM_SLOTS];
|
||||
|
||||
static inline void systick_enable_dispatch(size_t slot, systick_dispatch_t f) {
|
||||
systick_dispatch_table[slot] = f;
|
||||
}
|
||||
|
||||
static inline void systick_disable_dispatch(size_t slot) {
|
||||
systick_dispatch_table[slot] = NULL;
|
||||
}
|
||||
|
||||
void systick_wait_at_least(uint32_t stc, uint32_t delay_ms);
|
||||
bool systick_has_passed(uint32_t stc, uint32_t delay_ms);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user