Fixed build error

This commit is contained in:
Enmanuel Parache 2024-11-07 15:24:23 -04:00
parent 084bb95811
commit 3c1c1d6b93

View File

@ -1509,12 +1509,7 @@ fn set_baudrate(info: &Info, kernel_clock: Hertz, baudrate: u32) -> Result<(), C
Ok(()) Ok(())
} }
fn find_and_set_brr( fn find_and_set_brr(r: Regs, kind: Kind, kernel_clock: Hertz, baudrate: u32) -> Result<bool, ConfigError> {
r: stm32_metapac::usart::Usart,
kind: Kind,
kernel_clock: Hertz,
baudrate: u32,
) -> Result<bool, ConfigError> {
#[cfg(not(usart_v4))] #[cfg(not(usart_v4))]
static DIVS: [(u16, ()); 1] = [(1, ())]; static DIVS: [(u16, ()); 1] = [(1, ())];
@ -1547,7 +1542,11 @@ fn find_and_set_brr(
}; };
let mut found_brr = None; let mut found_brr = None;
#[cfg(not(usart_v1))]
let mut over8 = false; let mut over8 = false;
#[cfg(usart_v1)]
let over8 = false;
for &(presc, _presc_val) in &DIVS { for &(presc, _presc_val) in &DIVS {
let brr = calculate_brr(baudrate, kernel_clock.0, presc as u32, mul); let brr = calculate_brr(baudrate, kernel_clock.0, presc as u32, mul);
trace!( trace!(
@ -1604,7 +1603,11 @@ fn set_usart_baudrate(info: &Info, kernel_clock: Hertz, baudrate: u32) -> Result
// disable uart // disable uart
w.set_ue(false); w.set_ue(false);
}); });
#[cfg(not(usart_v1))]
let over8 = find_and_set_brr(r, info.kind, kernel_clock, baudrate)?; 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| { r.cr1().modify(|w| {
// enable uart // enable uart
@ -1636,7 +1639,10 @@ fn configure(
w.set_ue(false); w.set_ue(false);
}); });
#[cfg(not(usart_v1))]
let over8 = find_and_set_brr(r, kind, kernel_clock, config.baudrate)?; let over8 = find_and_set_brr(r, kind, kernel_clock, config.baudrate)?;
#[cfg(usart_v1)]
let _over8 = find_and_set_brr(r, kind, kernel_clock, config.baudrate)?;
r.cr2().write(|w| { r.cr2().write(|w| {
w.set_stop(match config.stop_bits { w.set_stop(match config.stop_bits {