Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set i2c frequency using Hertz #128

Merged
merged 2 commits into from
Nov 16, 2019
Merged

Conversation

TheZoq2
Copy link
Member

@TheZoq2 TheZoq2 commented Oct 27, 2019

In #127 I realised that i2c doesn't use the Hertz structs to set freuency. This seems strange, so I fixed it.

Unlike the other peripherals, this doesn't allow construction from KiloHertz or MegaHertz as that would have required making the mode struct generic, which would propagate a lot. It might still be a good idea to do so, though perhaps it's better to pass the frequency separately to the i2c "constructor". This would require less generics.

@TheZoq2 TheZoq2 force-pushed the i2c_frequency_unit branch from d150398 to 6e46559 Compare October 27, 2019 14:47
@TeXitoi
Copy link
Contributor

TeXitoi commented Nov 14, 2019

Any blocker on this or can it be merged?

@TheZoq2
Copy link
Member Author

TheZoq2 commented Nov 14, 2019

I think it can be merged, unless we want to allow KiloHertz and MegaHertz

@TeXitoi
Copy link
Contributor

TeXitoi commented Nov 14, 2019

True, Into<Hertz> as in rcc.CFGR could be great.

@TheZoq2
Copy link
Member Author

TheZoq2 commented Nov 16, 2019

I added methods to construct Mode from impl Into<Hertz> to avoid spreading generics everywhere and still give the option to construct from other frequency types. @TeXitoi Any conceerns with that implementation?

Copy link
Contributor

@TeXitoi TeXitoi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@TheZoq2 TheZoq2 merged commit 9a4d5bd into stm32-rs:master Nov 16, 2019
@TheZoq2 TheZoq2 deleted the i2c_frequency_unit branch November 17, 2019 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants