diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-11-09 10:15:11 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-09 10:15:11 +0000 |
| commit | b4929032d5f013985becb88faf9b847236afe172 (patch) | |
| tree | bbdd1ccb6ebda2e4be8362709a8188ae1bed895a /macros/src/codegen/module.rs | |
| parent | 4f3c5baf49bde675dfa8faf6e5311d38cbb5d654 (diff) | |
| parent | 5ab5112271a9dbef6d875ad89706fc726e126b95 (diff) | |
Merge #547
547: New monotonic trait r=AfoHT a=korken89
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
Diffstat (limited to 'macros/src/codegen/module.rs')
| -rw-r--r-- | macros/src/codegen/module.rs | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index c59a814..996af64 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -266,7 +266,6 @@ pub fn codegen( let tq = util::tq_ident(&monotonic.ident.to_string()); let t = util::schedule_t_ident(); let m = &monotonic.ident; - let mono_type = &monotonic.ident; let m_ident = util::monotonic_ident(&monotonic_name); let m_isr = &monotonic.args.binds; let enum_ = util::interrupt_ident(); @@ -349,15 +348,17 @@ pub fn codegen( } #[inline] - pub fn reschedule_after<D>(self, duration: D) -> Result<Self, ()> - where D: rtic::time::duration::Duration + rtic::time::fixed_point::FixedPoint, - D::T: Into<<#mono_type as rtic::time::Clock>::T>, - { + pub fn reschedule_after( + self, + duration: <#m as rtic::Monotonic>::Duration + ) -> Result<Self, ()> { self.reschedule_at(monotonics::#m::now() + duration) } - pub fn reschedule_at(self, instant: rtic::time::Instant<#mono_type>) -> Result<Self, ()> - { + pub fn reschedule_at( + self, + instant: <#m as rtic::Monotonic>::Instant + ) -> Result<Self, ()> { rtic::export::interrupt::free(|_| unsafe { let marker = #tq_marker.get().read(); #tq_marker.get_mut().write(marker.wrapping_add(1)); @@ -375,19 +376,12 @@ pub fn codegen( /// This will use the time `Instant::new(0)` as baseline if called in `#[init]`, /// so if you use a non-resetable timer use `spawn_at` when in `#[init]` #[allow(non_snake_case)] - pub fn #internal_spawn_after_ident<D>( - duration: D + pub fn #internal_spawn_after_ident( + duration: <#m as rtic::Monotonic>::Duration #(,#args)* ) -> Result<#name::#m::SpawnHandle, #ty> - where D: rtic::time::duration::Duration + rtic::time::fixed_point::FixedPoint, - D::T: Into<<#mono_type as rtic::time::Clock>::T>, { - - let instant = if rtic::export::interrupt::free(|_| unsafe { (&*#m_ident.get()).is_none() }) { - rtic::time::Instant::new(0) - } else { - monotonics::#m::now() - }; + let instant = monotonics::#m::now(); #internal_spawn_at_ident(instant + duration #(,#untupled)*) } @@ -396,7 +390,7 @@ pub fn codegen( /// Spawns the task at a fixed time instant #[allow(non_snake_case)] pub fn #internal_spawn_at_ident( - instant: rtic::time::Instant<#mono_type> + instant: <#m as rtic::Monotonic>::Instant #(,#args)* ) -> Result<#name::#m::SpawnHandle, #ty> { unsafe { |
