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

Add USB driver and example #24

Merged
merged 4 commits into from
Nov 14, 2019
Merged

Add USB driver and example #24

merged 4 commits into from
Nov 14, 2019

Conversation

Disasm
Copy link
Member

@Disasm Disasm commented Nov 13, 2019

@Disasm
Copy link
Member Author

Disasm commented Nov 13, 2019

Note that any of the stm32f303x* features implicitly activate stm32-usbd feature. It's not good in terms of the size of a dependency tree, but I don't know how to workaround this.

pub use stm32_usbd::UsbBus;

pub struct Peripheral {
pub usb: USB,
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like it’s more common (though I’m still fairly new to embedded rust) to keep structs opaque and then use “smart” constructor” functions that return them.

It seems like it might be worth doing so to keep the fields out of the public API, so it could be modified later.

Copy link
Member

Choose a reason for hiding this comment

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

While that's true, this is also a very non-complicated struct that has properties publicly available through other interfaces. I think folks can expect breaking changes whilst we've yet to get to v1.0. A sister create stm32f1xx-hal has already merged a similar struct so there's bit of precedent now to use something like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Your approach is more compact in terms of code, but you have to keep in mind the order of the arguments. With this structure, you have named entities that you can set in any order.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed on all counts, especially if there’s precedence already—more curiosity than anything else!

@dfrankland
Copy link
Member

I was able to test these changes successfully with a simple keyboard example: dfrankland/proton-c@7e1d54e

@dfrankland dfrankland merged commit c710c38 into stm32-rs:master Nov 14, 2019
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.

3 participants