diff options
| author | Emil Fresk <emil.fresk@gmail.com> | 2023-03-11 20:47:39 +0100 |
|---|---|---|
| committer | Emil Fresk <emil.fresk@gmail.com> | 2023-03-11 20:59:26 +0100 |
| commit | e4d9284e258a34b10cac2eff47ca2ccb470b460c (patch) | |
| tree | ea1895b33480484bbc44771efdff33c7e5b6dd25 /rtic-monotonics/src/systick.rs | |
| parent | 7c7d6558f6d9c50fbb4d2487c98c9a5be15f2f7b (diff) | |
rtic-monotonics: Add interrupt tokens to make sure users bind interrupts
Diffstat (limited to 'rtic-monotonics/src/systick.rs')
| -rw-r--r-- | rtic-monotonics/src/systick.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/rtic-monotonics/src/systick.rs b/rtic-monotonics/src/systick.rs index 691d7c7..feefc7e 100644 --- a/rtic-monotonics/src/systick.rs +++ b/rtic-monotonics/src/systick.rs @@ -36,7 +36,11 @@ impl Systick { /// `sysclk` and `TIMER_HZ`. /// /// Note: Give the return value to `TimerQueue::initialize()` to initialize the timer queue. - pub fn start(mut systick: cortex_m::peripheral::SYST, sysclk: u32) { + pub fn start( + mut systick: cortex_m::peripheral::SYST, + sysclk: u32, + _interrupt_token: impl crate::InterruptToken<Self>, + ) { // + TIMER_HZ / 2 provides round to nearest instead of round to 0. // - 1 as the counter range is inclusive [0, reload] let reload = (sysclk + TIMER_HZ / 2) / TIMER_HZ - 1; @@ -154,10 +158,21 @@ impl embedded_hal_async::delay::DelayUs for Systick { #[macro_export] macro_rules! make_systick_handler { () => { + { #[no_mangle] #[allow(non_snake_case)] unsafe extern "C" fn SysTick() { rtic_monotonics::systick::Systick::__tq().on_monotonic_interrupt(); } + + pub struct SystickToken; + + unsafe impl rtic_monotonics::InterruptToken<rtic_monotonics::systick::Systick> + for SystickToken + { + } + + SystickToken + } }; } |
