diff options
author | 2020-10-15 17:13:37 +0000 | |
---|---|---|
committer | 2020-10-15 17:13:37 +0000 | |
commit | 8b53b9d10cd5fee85d98cd337b478cf3d3305b12 (patch) | |
tree | 896d527bfd204f788eacc3dc791966fb88e287be /src | |
parent | 355cb82d0693fe108ac28ec8a0d77e8aab4e6e06 (diff) | |
parent | 21253297e4a11a1d9f9c5069578cf9c69a3de31b (diff) | |
download | rtic-8b53b9d10cd5fee85d98cd337b478cf3d3305b12.tar.gz rtic-8b53b9d10cd5fee85d98cd337b478cf3d3305b12.tar.zst rtic-8b53b9d10cd5fee85d98cd337b478cf3d3305b12.zip |
Merge #393
393: Implement all clippy suggestions r=korken89 a=AfoHT
Co-authored-by: Henrik Tjäder <henrik@tjaders.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/export.rs | 21 | ||||
-rw-r--r-- | src/tq.rs | 15 |
2 files changed, 33 insertions, 3 deletions
diff --git a/src/export.rs b/src/export.rs index 27f7f5fb..72d954ab 100644 --- a/src/export.rs +++ b/src/export.rs @@ -72,6 +72,11 @@ pub struct Priority { } impl Priority { + /// Create a new Priority + /// + /// # Safety + /// + /// Will overwrite the current Priority #[inline(always)] pub unsafe fn new(value: u8) -> Self { Priority { @@ -79,12 +84,14 @@ impl Priority { } } + /// Change the current priority to `value` // These two methods are used by `lock` (see below) but can't be used from the RTIC application #[inline(always)] fn set(&self, value: u8) { self.inner.set(value) } + /// Get the current priority #[inline(always)] fn get(&self) -> u8 { self.inner.get() @@ -105,6 +112,13 @@ where { } +/// Lock the resource proxy by setting the BASEPRI +/// and running the closure with interrupt::free +/// +/// # Safety +/// +/// Writing to the BASEPRI +/// Dereferencing a raw pointer #[cfg(armv7m)] #[inline(always)] pub unsafe fn lock<T, R>( @@ -135,6 +149,13 @@ pub unsafe fn lock<T, R>( } } +/// Lock the resource proxy by setting the PRIMASK +/// and running the closure with interrupt::free +/// +/// # Safety +/// +/// Writing to the PRIMASK +/// Dereferencing a raw pointer #[cfg(not(armv7m))] #[inline(always)] pub unsafe fn lock<T, R>( @@ -24,18 +24,26 @@ where N: ArrayLength<NotReady<M, T>>, T: Copy, { + /// # Safety + /// + /// Writing to memory with a transmute in order to enable + /// interrupts of the SysTick timer + /// + /// Enqueue a task without checking if it is full #[inline] pub unsafe fn enqueue_unchecked(&mut self, nr: NotReady<M, T>) { let mut is_empty = true; - if self + // Check if the top contains a non-empty element and if that element is + // greater than nr + let if_heap_max_greater_than_nr = self .0 .peek() .map(|head| { is_empty = false; nr.instant < head.instant }) - .unwrap_or(true) - { + .unwrap_or(true); + if if_heap_max_greater_than_nr { if is_empty { mem::transmute::<_, SYST>(()).enable_interrupt(); } @@ -47,6 +55,7 @@ where self.0.push_unchecked(nr); } + /// Dequeue a task from the TimerQueue #[inline] pub fn dequeue(&mut self) -> Option<(T, u8)> { unsafe { |