From e4d9284e258a34b10cac2eff47ca2ccb470b460c Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Sat, 11 Mar 2023 20:47:39 +0100 Subject: rtic-monotonics: Add interrupt tokens to make sure users bind interrupts --- rtic-monotonics/src/systick.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'rtic-monotonics/src/systick.rs') 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, + ) { // + 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 + for SystickToken + { + } + + SystickToken + } }; } -- cgit v1.2.3