Skip to content

Commit

Permalink
Fixed build error
Browse files Browse the repository at this point in the history
  • Loading branch information
EnmanuelParache committed Nov 7, 2024
1 parent 084bb95 commit 8e570da
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions embassy-stm32/src/usart/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1509,12 +1509,7 @@ fn set_baudrate(info: &Info, kernel_clock: Hertz, baudrate: u32) -> Result<(), C
Ok(())
}

fn find_and_set_brr(
r: stm32_metapac::usart::Usart,
kind: Kind,
kernel_clock: Hertz,
baudrate: u32,
) -> Result<bool, ConfigError> {
fn find_and_set_brr(r: Regs, kind: Kind, kernel_clock: Hertz, baudrate: u32) -> Result<bool, ConfigError> {
#[cfg(not(usart_v4))]
static DIVS: [(u16, ()); 1] = [(1, ())];

Expand Down Expand Up @@ -1547,7 +1542,11 @@ fn find_and_set_brr(
};

let mut found_brr = None;
#[cfg(not(usart_v1))]
let mut over8 = false;
#[cfg(usart_v1)]
let over8 = false;

for &(presc, _presc_val) in &DIVS {
let brr = calculate_brr(baudrate, kernel_clock.0, presc as u32, mul);
trace!(
Expand Down Expand Up @@ -1604,7 +1603,11 @@ fn set_usart_baudrate(info: &Info, kernel_clock: Hertz, baudrate: u32) -> Result
// disable uart
w.set_ue(false);
});

#[cfg(not(usart_v1))]
let over8 = find_and_set_brr(r, info.kind, kernel_clock, baudrate)?;
#[cfg(usart_v1)]
let _over8 = find_and_set_brr(r, info.kind, kernel_clock, baudrate)?;

r.cr1().modify(|w| {
// enable uart
Expand Down Expand Up @@ -1636,7 +1639,10 @@ fn configure(
w.set_ue(false);
});

let over8 = find_and_set_brr(r, kind, kernel_clock, config.baudrate)?;
#[cfg(not(usart_v1))]
let over8 = find_and_set_brr(r, info.kind, kernel_clock, config.baudrate)?;
#[cfg(usart_v1)]
let _over8 = find_and_set_brr(r, info.kind, kernel_clock, config.baudrate)?;

r.cr2().write(|w| {
w.set_stop(match config.stop_bits {
Expand Down

0 comments on commit 8e570da

Please sign in to comment.