Skip to content

Commit

Permalink
[Fixes #27] USART: Remove mode check in enter_mode (#43)
Browse files Browse the repository at this point in the history
This patch addresses issue #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.

Co-authored-by: Michał Fita <4925040+michalfita@users.noreply.github.com>
  • Loading branch information
sundbom-grepit and michalfita authored Oct 26, 2022
1 parent f674c1c commit 8342e73
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

### Fixed

- `Usart::enter_mode`: initial configuration of port as USART is now permitted.

## [v0.4.0] 2022-10-19

### Added
Expand Down
5 changes: 0 additions & 5 deletions hal/src/serial/usart/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,6 @@ impl<M: UsartMeta> Usart<M> {
// successful as_*, meaning that we do not need to check for
// support again.

if self.mode() == H::MODE {
// Already in the requested mode
return;
}

self.disable();

// Wipe current config and reset target mode.
Expand Down

0 comments on commit 8342e73

Please sign in to comment.