Skip to content

Commit

Permalink
make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
dotcypress committed Mar 17, 2024
1 parent e6145ef commit ebf0a15
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
8 changes: 6 additions & 2 deletions src/crc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,12 @@ impl Crc {
pub fn feed(&mut self, data: &[u8]) {
let crc = unsafe { &(*CRC::ptr()) };
for byte in data {
let ptr = &crc.dr as *const _;
unsafe { core::ptr::write_volatile(ptr as *mut u8, *byte) };
unsafe {
core::ptr::write_volatile(
core::cell::UnsafeCell::raw_get(&crc.dr as *const _ as _),
byte,
)
}
}
}

Expand Down
18 changes: 9 additions & 9 deletions src/rtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ impl Rtc {

pub fn set_alarm_a(&mut self, alarm: impl Into<Alarm>) {
let alarm = alarm.into();
let (dt, du) = bcd2_encode(alarm.day.unwrap_or_default() as u32);
let (ht, hu) = bcd2_encode(alarm.hours.unwrap_or_default() as u32);
let (mt, mu) = bcd2_encode(alarm.minutes.unwrap_or_default() as u32);
let (st, su) = bcd2_encode(alarm.seconds.unwrap_or_default() as u32);
let (dt, du) = bcd2_encode(alarm.day.unwrap_or_default());
let (ht, hu) = bcd2_encode(alarm.hours.unwrap_or_default());
let (mt, mu) = bcd2_encode(alarm.minutes.unwrap_or_default());
let (st, su) = bcd2_encode(alarm.seconds.unwrap_or_default());

self.modify(|rb| {
rb.alrmassr.write(|w| unsafe {
Expand Down Expand Up @@ -226,10 +226,10 @@ impl Rtc {
}

pub fn set_alarm_b(&mut self, alarm: Alarm) {
let (dt, du) = bcd2_encode(alarm.day.unwrap_or_default() as u32);
let (ht, hu) = bcd2_encode(alarm.hours.unwrap_or_default() as u32);
let (mt, mu) = bcd2_encode(alarm.minutes.unwrap_or_default() as u32);
let (st, su) = bcd2_encode(alarm.seconds.unwrap_or_default() as u32);
let (dt, du) = bcd2_encode(alarm.day.unwrap_or_default());
let (ht, hu) = bcd2_encode(alarm.hours.unwrap_or_default());
let (mt, mu) = bcd2_encode(alarm.minutes.unwrap_or_default());
let (st, su) = bcd2_encode(alarm.seconds.unwrap_or_default());

self.modify(|rb| {
rb.alrmbssr.write(|w| unsafe {
Expand Down Expand Up @@ -387,7 +387,7 @@ fn bcd2_encode(word: u32) -> (u8, u8) {
bcd_high += 1;
value -= 10;
}
let bcd_low = ((bcd_high << 4) | value) as u8;
let bcd_low = (bcd_high << 4) | value;
(bcd_high, bcd_low)
}

Expand Down
7 changes: 4 additions & 3 deletions src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::gpio::*;
use crate::rcc::*;
use crate::stm32::{SPI1, SPI2};
use crate::time::Hertz;
use core::ptr;
use core::{cell, ptr};
pub use hal::spi::{Mode, Phase, Polarity, MODE_0, MODE_1, MODE_2, MODE_3};

/// SPI error
Expand Down Expand Up @@ -264,8 +264,9 @@ macro_rules! spi {
} else if sr.crcerr().bit_is_set() {
nb::Error::Other(Error::Crc)
} else if sr.txe().bit_is_set() {
let ptr = &self.spi.dr as *const _;
unsafe { core::ptr::write_volatile(ptr as *mut u8, byte) };
unsafe {
ptr::write_volatile(cell::UnsafeCell::raw_get(&self.spi.dr as *const _ as _), byte)
}
return Ok(());
} else {
nb::Error::WouldBlock
Expand Down
2 changes: 1 addition & 1 deletion src/timer/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pwm_advanced_hal! {
TIM17: (Channel1, cc1e: cc1ne, ccmr1_output, oc1pe, oc1m, ccr1, moe),
}

#[cfg(any(feature = "stm32g070"))]
#[cfg(feature = "stm32g070")]
pwm_advanced_hal! {
TIM15: (Channel1, cc1e: cc1ne, ccmr1_output, oc1pe, oc1m1, ccr1, moe),
}
Expand Down

0 comments on commit ebf0a15

Please sign in to comment.