diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2023-03-11 20:18:58 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-11 20:18:58 +0000 |
| commit | 534d42edf5505950a87f2621df883ceac4957156 (patch) | |
| tree | 1636806eebc89750e199ebaa5e021d83041a01cd /rtic-monotonics/src/systick.rs | |
| parent | dd899ab77f3d95ebb04fb8b02eadf6275d7524ac (diff) | |
| parent | e4d9284e258a34b10cac2eff47ca2ccb470b460c (diff) | |
Merge #702
702: Monotonics interrupt token r=AfoHT a=korken89
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
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 + } }; } |
