diff options
author | Damien George <damien.p.george@gmail.com> | 2019-02-08 15:10:13 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-02-08 15:31:02 +1100 |
commit | 4d214edae89ce178765c63f83b67c099019ef5db (patch) | |
tree | d0eb207653670a2ec9c27f966f704d61edb00acf | |
parent | 18cfa156d628873dfe0e12bcaad19bd802f32994 (diff) |
stm32/systick: Provide better compile-time configurability of slots.
-rw-r--r-- | ports/stm32/systick.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/ports/stm32/systick.h b/ports/stm32/systick.h index d1b59c574..3ae6be7e0 100644 --- a/ports/stm32/systick.h +++ b/ports/stm32/systick.h @@ -26,9 +26,18 @@ #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) +// Works for x between 0 and 16 inclusive +#define POW2_CEIL(x) ((((x) - 1) | ((x) - 1) >> 1 | ((x) - 1) >> 2 | ((x) - 1) >> 3) + 1) + +enum { + SYSTICK_DISPATCH_DMA = 0, + #if MICROPY_HW_ENABLE_STORAGE + SYSTICK_DISPATCH_STORAGE, + #endif + SYSTICK_DISPATCH_MAX +}; + +#define SYSTICK_DISPATCH_NUM_SLOTS POW2_CEIL(SYSTICK_DISPATCH_MAX) typedef void (*systick_dispatch_t)(uint32_t); |