From 8e570da963beec6a1f57e93a1f7b83f0608e7188 Mon Sep 17 00:00:00 2001 From: Enmanuel Parache Date: Thu, 7 Nov 2024 15:17:09 -0400 Subject: [PATCH] Fixed build error --- embassy-stm32/src/usart/mod.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs index f22a4b13b1..d64399e44f 100644 --- a/embassy-stm32/src/usart/mod.rs +++ b/embassy-stm32/src/usart/mod.rs @@ -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 { +fn find_and_set_brr(r: Regs, kind: Kind, kernel_clock: Hertz, baudrate: u32) -> Result { #[cfg(not(usart_v4))] static DIVS: [(u16, ()); 1] = [(1, ())]; @@ -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!( @@ -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 @@ -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 {