Skip to content

Commit

Permalink
avoid u64 ops
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Feb 5, 2025
1 parent 4151447 commit 4211f88
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2388,10 +2388,8 @@ impl Info {
cfg_if::cfg_if! {
if #[cfg(any(esp32c2, esp32c3, esp32s3, esp32c6, esp32h2))] {

let max_div = 0b1111_1111_1111u64 - 1;
// this operation may exceed u32::MAX at high bauds, convert to u64
let clk_div = (clk as u64).div_ceil(max_div * config.baudrate as u64);
let clk_div = clk_div as u32;
const MAX_DIV: u32 = 0b1111_1111_1111 - 1;
let clk_div = (clk.div_ceil(MAX_DIV)).div_ceil(config.baudrate);

// define `conf` in scope for modification below
cfg_if::cfg_if! {
Expand Down

0 comments on commit 4211f88

Please sign in to comment.