Skip to content

Commit

Permalink
Fix, allow (pseudo)unused unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
little-arhat committed Oct 20, 2022
1 parent 7875712 commit 7567eac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#![deny(missing_docs)]
#![deny(warnings)]
#![allow(unused_unsafe)]
#![no_std]

#[cfg(feature = "stm32f301")]
Expand Down
28 changes: 17 additions & 11 deletions src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,24 +288,30 @@ macro_rules! tim {
fn write_ccr(&mut self, value: u32) {
let index = CN::channel_number();
let tim = unsafe { &(*$TIMSRC::ptr()) };
unsafe {
match index {
U2::B00 => tim.ccr1.write(|w| w.bits(value)),
U2::B01 => tim.ccr2.write(|w| w.bits(value)),
U2::B10 => tim.ccr3.write(|w| w.bits(value)),
U2::B11 => tim.ccr4.write(|w| w.bits(value)),
}
match index {
U2::B00 => tim.ccr1().write(|w| unsafe {
w.bits(value)
}),
U2::B01 => tim.ccr2().write(|w| unsafe {
w.bits(value)
}),
U2::B10 => tim.ccr3().write(|w| unsafe {
w.bits(value)
}),
U2::B11 => tim.ccr4().write(|w| unsafe {
w.bits(value)
}),
}
}

fn read_ccr(&self) -> u32 {
let index = CN::channel_number();
let tim = unsafe { &(*$TIMSRC::ptr()) };
match index {
U2::B00 => tim.ccr1.read().bits(),
U2::B01 => tim.ccr2.read().bits(),
U2::B10 => tim.ccr3.read().bits(),
U2::B11 => tim.ccr4.read().bits(),
U2::B00 => tim.ccr1().read().bits(),
U2::B01 => tim.ccr2().read().bits(),
U2::B10 => tim.ccr3().read().bits(),
U2::B11 => tim.ccr4().read().bits(),
}
}

Expand Down

0 comments on commit 7567eac

Please sign in to comment.