Skip to content

Commit 00467cd

Browse files
committed
Make InterruptNumber Copy; replace references with copies in some armv6m-only functions
1 parent b7c3ebc commit 00467cd

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/interrupt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub use bare_metal::{CriticalSection, Mutex};
1616
/// and must always return the same value (do not change at runtime).
1717
///
1818
/// These requirements ensure safe nesting of critical sections.
19-
pub unsafe trait InterruptNumber: Into<u16> {}
19+
pub unsafe trait InterruptNumber: Into<u16> + Copy {}
2020

2121
/// Disables all interrupts
2222
#[inline]

src/peripheral/nvic.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ impl NVIC {
139139
#[cfg(armv6m)]
140140
{
141141
// NOTE(unsafe) atomic read with no side effects
142-
let ipr_n = unsafe { (*Self::ptr()).ipr[Self::ipr_index(&interrupt)].read() };
143-
let prio = (ipr_n >> Self::ipr_shift(&interrupt)) & 0x0000_00ff;
142+
let ipr_n = unsafe { (*Self::ptr()).ipr[Self::ipr_index(interrupt)].read() };
143+
let prio = (ipr_n >> Self::ipr_shift(interrupt)) & 0x0000_00ff;
144144
prio as u8
145145
}
146146
}
@@ -222,9 +222,9 @@ impl NVIC {
222222

223223
#[cfg(armv6m)]
224224
{
225-
self.ipr[Self::ipr_index(&interrupt)].modify(|value| {
226-
let mask = 0x0000_00ff << Self::ipr_shift(&interrupt);
227-
let prio = u32::from(prio) << Self::ipr_shift(&interrupt);
225+
self.ipr[Self::ipr_index(interrupt)].modify(|value| {
226+
let mask = 0x0000_00ff << Self::ipr_shift(interrupt);
227+
let prio = u32::from(prio) << Self::ipr_shift(interrupt);
228228

229229
(value & !mask) | prio
230230
})
@@ -245,7 +245,7 @@ impl NVIC {
245245

246246
#[cfg(armv6m)]
247247
#[inline]
248-
fn ipr_index<I>(interrupt: &I) -> usize
248+
fn ipr_index<I>(interrupt: I) -> usize
249249
where
250250
I: InterruptNumber,
251251
{
@@ -254,7 +254,7 @@ impl NVIC {
254254

255255
#[cfg(armv6m)]
256256
#[inline]
257-
fn ipr_shift<I>(interrupt: &I) -> usize
257+
fn ipr_shift<I>(interrupt: I) -> usize
258258
where
259259
I: InterruptNumber,
260260
{

0 commit comments

Comments
 (0)