Skip to content

Commit

Permalink
fmt + lint
Browse files Browse the repository at this point in the history
  • Loading branch information
playfulFence committed Feb 4, 2025
1 parent 48d1182 commit 8fb6c69
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions esp-hal/src/spi/master.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,15 +616,16 @@ impl Config {
return Err(ConfigError::UnsupportedFrequency)
}
FrequencyTolerance::ErrorPercent(percent) => {
let deviation = ((raw_desired_freq as i64 - actual_freq as i64).unsigned_abs() * 100)
let deviation = ((raw_desired_freq as i64 - actual_freq as i64).unsigned_abs()
* 100)
/ actual_freq as u64;
if deviation > percent as u64 {
return Err(ConfigError::UnsupportedFrequency);
}
}
_ => {}
}
}
}

Ok(reg_val)
}
Expand Down
11 changes: 7 additions & 4 deletions esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2463,7 +2463,8 @@ impl Info {
return Err(ConfigError::UnachievableBaudrate)
}
BaudrateTolerance::ErrorPercent(percent) => {
let deviation = ((config.baudrate as i64 - actual_baud as i64).unsigned_abs() * 100)
let deviation = ((config.baudrate as i64 - actual_baud as i64).unsigned_abs()
* 100)
/ actual_baud as u64;
if deviation > percent as u64 {
return Err(ConfigError::UnachievableBaudrate);
Expand Down Expand Up @@ -2547,7 +2548,8 @@ impl Info {
return Err(ConfigError::UnachievableBaudrate)
}
BaudrateTolerance::ErrorPercent(percent) => {
let deviation = ((config.baudrate as i64 - actual_baud as i64).unsigned_abs() * 100)
let deviation = ((config.baudrate as i64 - actual_baud as i64).unsigned_abs()
* 100)
/ actual_baud as u64;
if deviation > percent as u64 {
return Err(ConfigError::UnachievableBaudrate);
Expand Down Expand Up @@ -2585,7 +2587,8 @@ impl Info {
return Err(ConfigError::UnachievableBaudrate)
}
BaudrateTolerance::ErrorPercent(percent) => {
let deviation = ((config.baudrate as i64 - actual_baud as i64).unsigned_abs() * 100)
let deviation = ((config.baudrate as i64 - actual_baud as i64).unsigned_abs()
* 100)
/ actual_baud as u64;
if deviation > percent as u64 {
return Err(ConfigError::UnachievableBaudrate);
Expand Down Expand Up @@ -2658,7 +2661,7 @@ impl Info {
cfg_if::cfg_if! {
if #[cfg(any(esp32, esp32s2))] {
let clkdiv_reg = self.regs().clkdiv().read();
let clkdiv = clkdiv_reg.clkdiv().bits() as u32;
let clkdiv = clkdiv_reg.clkdiv().bits();
let clkdiv_frag = clkdiv_reg.frag().bits() as u32;
(clk << 4) / ((clkdiv << 4) | clkdiv_frag)
} else if #[cfg(any(esp32c2, esp32c3, esp32s3))] {
Expand Down

0 comments on commit 8fb6c69

Please sign in to comment.