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 peripheral support #135

Merged
merged 9 commits into from
Oct 31, 2024
Merged

USB peripheral support #135

merged 9 commits into from
Oct 31, 2024

Conversation

liamkinne
Copy link
Contributor

Adds the required implementation to support USB device with usb-device and stm32-usbd.

@liamkinne
Copy link
Contributor Author

@usbalbin I have mostly ripped this implementation from the F3 repo. However I'm not sure if it is not working correctly or if I have a hardware issue since the G4 board I'm using doesn't feature a USB connector.

If you have the ability to test using the example that would be great. Otherwise wait until I can get my hands on the correct hardware before merging.

src/usb.rs Outdated
const EP_MEMORY_ACCESS_2X16: bool = true;

fn enable() {
critical_section::with(|_| unsafe {

This comment was marked as resolved.

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

What is the different between critical_section::with (requiring a new dependency) and cortex_m::interrupt::free as used in src/serial/usart.rs?

Copy link
Contributor

Choose a reason for hiding this comment

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

If there would be no downside, I would prefer to avoid the extra dependency

@usbalbin
Copy link
Contributor

Note there is also #50 . @kevswims what is the status and/or plans of #50?

@usbalbin
Copy link
Contributor

@usbalbin I have mostly ripped this implementation from the F3 repo. However I'm not sure if it is not working correctly or if I have a hardware issue since the G4 board I'm using doesn't feature a USB connector.

If you have the ability to test using the example that would be great. Otherwise wait until I can get my hands on the correct hardware before merging.

I do not have access to such hardware right now. Might in several months, maybe, but not now.

BTW, thanks!

@liamkinne
Copy link
Contributor Author

@usbalbin didn't see #50 but I will have a look at it an see if there's anything to bring across.

I'll go ahead and order the expansion board to give my dev board USB. If that doesn't fix it, my best guess is there's a clocking issue causing the host to reject the connection.

@usbalbin
Copy link
Contributor

@usbalbin didn't see #50 but I will have a look at it an see if there's anything to bring across.

I'll go ahead and order the expansion board to give my dev board USB. If that doesn't fix it, my best guess is there's a clocking issue causing the host to reject the connection.

Awesome!

Correct me if I am wrong, have not looked into USB, but I believe I read about some sort of clock recovery system in #50 for running without a crystal in case that helps.

@kevswims
Copy link
Contributor

Note there is also #50 . @kevswims what is the status and/or plans of #50?

I have switched my project over to use embassy which is why I haven't done anything more with that PR. As far as I remember with a bit of cleanup it should be good to go in if someone wants to use the work from it. I'm happy to answer questions or assist with that if someone wants to take it over.

@liamkinne
Copy link
Contributor Author

@usbalbin with the correct hardware, all is working now.

@liamkinne
Copy link
Contributor Author

@usbalbin this is ready to merge. The failing CI is unrelated.

@usbalbin
Copy link
Contributor

Great!

Perhaps not a huge deal, but would you mind having a look at my earlier comment :)

@liamkinne
Copy link
Contributor Author

@usbalbin sorry didn't see that. Fixed now.

@usbalbin
Copy link
Contributor

Thanks a lot for this!

@usbalbin usbalbin merged commit 69a9c70 into stm32-rs:main Oct 31, 2024
23 checks passed
@liamkinne liamkinne deleted the feature/usb branch October 31, 2024 11:03
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