Skip to content

Commit

Permalink
stm32: fix set_config for buffered uart
Browse files Browse the repository at this point in the history
In reconfigure() cr1 register is initialised with write (not modify) which means rxneie and idleneie are disabled after reconfiguration.
  • Loading branch information
andresv committed Oct 23, 2023
1 parent 188ee59 commit ca27590
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions embassy-stm32/src/usart/buffered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(lpuart_v2)]
w.set_fifoen(true);

w.set_rxneie(true);
w.set_idleie(true);
});

Ok(())
}
}

Expand Down Expand Up @@ -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(lpuart_v2)]
w.set_fifoen(true);

w.set_rxneie(true);
w.set_idleie(true);
});

Ok(())
}
}

Expand Down Expand Up @@ -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(lpuart_v2)]
w.set_fifoen(true);

w.set_rxneie(true);
w.set_idleie(true);
});

Ok(())
}
}

Expand Down

0 comments on commit ca27590

Please sign in to comment.