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.
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.