Add support for changing USART settings - #266
Merged
Merged
Conversation
Settings that require further API changes have been left out at this point.
I think this is already nicer as-is, but it will become even better once more modes (which require more enable methods) are added.
Default states have been remove from some other peripherals already, and the same reasons, namely there no longer being a clear default, are soon going to apply here too.
The general `init_state::Enabled` struct is flexible, but it can lead to some unpleasantness, as seen with the whole clock configuration stuff in the I2C API, that involves `PhantomData` in the type signature. I am about to make some changes that would introduce the same kind of ugliness in the USART API. Adding a bespoke `Enabled` type will make this a bit nicer.
This required adding support for `u16` as another word type. Some code (namely `write_str` and anything DMA-related) is still hardcoded to `u8`, preventing the use of 9-bit data in those scenarios. This can be rectified later, as required.
Member
Author
|
There were conflicts with #263 that I was unaware of. Rebased. |
david-sawatzke
approved these changes
Aug 2, 2020
david-sawatzke
left a comment
Member
There was a problem hiding this comment.
I'm not too happy about the added complexity in the trivial case, but it's not too bad
Member
Author
We can always make improvements later, if you have any ideas. This is the best I could come up with at this time. I don't think we can do much better without losing type safety. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is mostly restricted to settings that don't require new modes (like synchronous or RS-485 mode) to be added.