atsams-rs / atsamx7x-rust

Rust HAL, PACs, and examples for the Microship SAM E70/S70/V70/V71
Apache License 2.0
24 stars 11 forks source link

USART: Remove mode check in `enter_mode` #43

Closed sundbom-grepit closed 1 year ago

sundbom-grepit commented 1 year ago

This patch addresses issue https://github.com/atsams-rs/atsamx7x-rust/issues/27 wherein USART configuration fails if no other mode was selected prior to that. This is done by permitting the mode to be set multiple times, even if it is the same mode.

Initially, the USART is in the default USART mode but has not actually been configured. Therefore the enter_mode routine will exit early and skip configuration entirely unless care is taken and a dummy reconfiguration step is done before switching to USART.

The consequence of not performing this check is that the bus configuration will reset and possibly glitch momentarily if the same mode is setup twice, but that should not be done anyhow and has not been encouraged as far as I can tell.

tmplt commented 1 year ago

For future references, preferring a rebase-unto over merge improves history readability.