STM32: combine RccPeripherals reset() and enable() to reset_and_enable()

This commit is contained in:
pbert
2023-10-11 18:06:43 +02:00
parent eb368f77a4
commit f65a96c541
37 changed files with 105 additions and 154 deletions

View File

@ -228,8 +228,7 @@ impl<'d, T: BasicInstance, TxDma> UartTx<'d, T, TxDma> {
tx_dma: impl Peripheral<P = TxDma> + 'd,
config: Config,
) -> Result<Self, ConfigError> {
T::enable();
T::reset();
T::reset_and_enable();
Self::new_inner(peri, tx, tx_dma, config)
}
@ -243,8 +242,7 @@ impl<'d, T: BasicInstance, TxDma> UartTx<'d, T, TxDma> {
) -> Result<Self, ConfigError> {
into_ref!(cts);
T::enable();
T::reset();
T::reset_and_enable();
cts.set_as_af(cts.af_num(), AFType::Input);
T::regs().cr3().write(|w| {
@ -321,8 +319,7 @@ impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma> {
rx_dma: impl Peripheral<P = RxDma> + 'd,
config: Config,
) -> Result<Self, ConfigError> {
T::enable();
T::reset();
T::reset_and_enable();
Self::new_inner(peri, rx, rx_dma, config)
}
@ -337,8 +334,7 @@ impl<'d, T: BasicInstance, RxDma> UartRx<'d, T, RxDma> {
) -> Result<Self, ConfigError> {
into_ref!(rts);
T::enable();
T::reset();
T::reset_and_enable();
rts.set_as_af(rts.af_num(), AFType::OutputPushPull);
T::regs().cr3().write(|w| {
@ -695,9 +691,8 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
config: Config,
) -> Result<Self, ConfigError> {
// UartRx and UartTx have one refcount ea.
T::enable();
T::enable();
T::reset();
T::reset_and_enable();
T::reset_and_enable();
Self::new_inner(peri, rx, tx, tx_dma, rx_dma, config)
}
@ -716,9 +711,8 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
into_ref!(cts, rts);
// UartRx and UartTx have one refcount ea.
T::enable();
T::enable();
T::reset();
T::reset_and_enable();
T::reset_and_enable();
rts.set_as_af(rts.af_num(), AFType::OutputPushPull);
cts.set_as_af(cts.af_num(), AFType::Input);
@ -743,9 +737,8 @@ impl<'d, T: BasicInstance, TxDma, RxDma> Uart<'d, T, TxDma, RxDma> {
into_ref!(de);
// UartRx and UartTx have one refcount ea.
T::enable();
T::enable();
T::reset();
T::reset_and_enable();
T::reset_and_enable();
de.set_as_af(de.af_num(), AFType::OutputPushPull);
T::regs().cr3().write(|w| {