Skip to content

Conversation

@Keybinder
Copy link
Contributor

@Keybinder Keybinder commented Nov 13, 2025

  1. Exposes tx_invert() and rx_invert() USART/serial configuration options, which correspond to setting the TXINV and RXINV bits in USART_CR2 respectively.
  2. Exposes a wordlength_7() configuration option, which corresponds to having a word length of 7.
  3. Fixes a mistake in the peripheral initialisation where the M[1:0] bits were set incorrectly for word lengths of 7 and 9.

.m0()
.bit(config.wordlength == WordLength::DataBits7)
.m1()
.bit(config.wordlength == WordLength::DataBits7)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for note. You can rewrite this more compact:

                usart.cr1().modify(|_, w| {
                    w.ue().set_bit();
                    w.te().set_bit();
                    w.re().set_bit();
                    w.m1().bit(config.wordlength == WordLength::DataBits7);
                    w.m0().bit(config.wordlength == WordLength::DataBits9);
                    w.pce().bit(config.parity != Parity::ParityNone);
                    w.ps().bit(config.parity == Parity::ParityOdd);
                    w.fifoen().bit(config.fifo_enable)
                });

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know, thanks. I just didn't want to change it too much from how it was originally.

@usbalbin
Copy link
Member

Thank you for your contribution!

Would you mind rebasing over the latest changes where the clippy issue should be resolved?

@Keybinder
Copy link
Contributor Author

Is this ok now?

@usbalbin usbalbin added this pull request to the merge queue Nov 15, 2025
Merged via the queue into stm32-rs:main with commit 1ecd76c Nov 15, 2025
34 checks passed
@usbalbin
Copy link
Member

Great, Thank you!

@Keybinder Keybinder deleted the usart branch November 16, 2025 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants