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

USB: Add support for external ULPI PHYs #184

Merged
merged 3 commits into from
Feb 14, 2021
Merged

Conversation

mattico
Copy link
Contributor

@mattico mattico commented Feb 12, 2021

Tested with an STM32H743BIT6 and a USB3300-EZK on a custom board.

@mattico mattico marked this pull request as ready for review February 12, 2021 16:21
@richardeoin
Copy link
Member

This looks great. I also tested your example (https://github.com/mattico/test-ulpi-usb) on a STM32H747I-DISCO board and it works fine, only the DIR and NXT pins are different.

Thanks for adding the clippy directive, this must have been upgraded to an error recently.

Potentially the USB API could be reworked slightly, so instead of filling in a structure, the user would call a constructor method like USB1_ULPI::new(...). I think that would be more idiomatic and match the rest of the HAL. But it should be added for all USB peripherals, so better tackled in a different PR.

Feel free to add your name to Cargo.toml/authors if you like!

@richardeoin
Copy link
Member

Do you need the #[cfg(not(feature = "rm0455"))] on the USB1_ULPI declarations? The USB1_ULPI implementation should be valid for RM0455 parts also, so you can remove it

@mattico
Copy link
Contributor Author

mattico commented Feb 13, 2021

This looks great. I also tested your example (https://github.com/mattico/test-ulpi-usb) on a STM32H747I-DISCO board and it works fine, only the DIR and NXT pins are different.

Good to hear! Had a lot of trouble getting this to work, then the result was fairly simple. Always a bit worried I missed something.

Thanks for adding the clippy directive, this must have been upgraded to an error recently.

You know, it was probably upgraded to an error due to LLVM removing infinite loops with no bodies. (rust-lang/rust#28728) Maybe we should use asm::nop() in the loops instead.

Potentially the USB API could be reworked slightly, so instead of filling in a structure, the user would call a constructor method like USB1_ULPI::new(...). I think that would be more idiomatic and match the rest of the HAL. But it should be added for all USB peripherals, so better tackled in a different PR.

Yeah, like the Pins traits. I don't have the energy for that right now, but I'll keep it in mind.

Do you need the #[cfg(not(feature = "rm0455"))] on the USB1_ULPI declarations? The USB1_ULPI implementation should be valid for RM0455 parts also, so you can remove it

Good catch.

@richardeoin
Copy link
Member

You know, it was probably upgraded to an error due to LLVM removing infinite loops with no bodies. (rust-lang/rust#28728) Maybe we should use asm::nop() in the loops instead.

This is a better fix, thanks!

bors r+

@bors bors bot merged commit 08231e3 into stm32-rs:master Feb 14, 2021
@richardeoin
Copy link
Member

Yeah, like the Pins traits.

I don't think it needs any new traits, the existing implementations are fine. I've tried this in #187, do you have any comments @mattico ?

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