embedded-hal icon indicating copy to clipboard operation
embedded-hal copied to clipboard

Proposal for Configure baudrate trait

Open unizippro opened this issue 5 years ago • 3 comments
trafficstars

This trait lets the implementer choose the type for Baudrate as this is done in different ways in different crates. Returning a result lets the implementer sort out bad, incompatible or impossible bauds, or simply return an unsupported error. An implementation can be seen at stm32l4xx-hal/feature/change-baud/ In this implementation the clock freq is saved with the Uart struct, and the used to change the baud. If the clock frequency were to change the Uart would have to be reinitialized anyway.

unizippro avatar May 13 '20 10:05 unizippro

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @therealprof (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

rust-highfive avatar May 13 '20 10:05 rust-highfive

Thank you for tackling this issue. Could you please provide an example on how to use the new Trait in a generic driver?

timokroeger avatar May 14 '20 05:05 timokroeger

I see now that this function should be able to be called from tx and rx. But since they don't hold any reference to registers I'll leave this as a draft for now. A solution may be to return (tx, rx, config) from split, but i won't be investigating this for now.

unizippro avatar May 14 '20 08:05 unizippro