stm32: fix set_config for buffered uart

In reconfigure() cr1 register is initialised with write (not modify) which means rxneie and idleneie are disabled after reconfiguration.
This commit is contained in:
Andres Vahter 2023-10-23 22:43:15 +03:00
parent 188ee59ba6
commit 7f72dbdaf2

View File

@ -233,7 +233,7 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> {
configure(r, &config, T::frequency(), T::KIND, true, true)?;
r.cr1().modify(|w| {
#[cfg(lpuart_v2)]
#[cfg(usart_v4)]
w.set_fifoen(true);
w.set_rxneie(true);
@ -254,7 +254,17 @@ impl<'d, T: BasicInstance> BufferedUart<'d, T> {
}
pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> {
reconfigure::<T>(config)
reconfigure::<T>(config)?;
T::regs().cr1().modify(|w| {
#[cfg(usart_v4)]
w.set_fifoen(true);
w.set_rxneie(true);
w.set_idleie(true);
});
Ok(())
}
}
@ -334,7 +344,17 @@ impl<'d, T: BasicInstance> BufferedUartRx<'d, T> {
}
pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> {
reconfigure::<T>(config)
reconfigure::<T>(config)?;
T::regs().cr1().modify(|w| {
#[cfg(usart_v4)]
w.set_fifoen(true);
w.set_rxneie(true);
w.set_idleie(true);
});
Ok(())
}
}
@ -408,7 +428,17 @@ impl<'d, T: BasicInstance> BufferedUartTx<'d, T> {
}
pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> {
reconfigure::<T>(config)
reconfigure::<T>(config)?;
T::regs().cr1().modify(|w| {
#[cfg(usart_v4)]
w.set_fifoen(true);
w.set_rxneie(true);
w.set_idleie(true);
});
Ok(())
}
}