-
Notifications
You must be signed in to change notification settings - Fork 23
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
feat(otgfs): Implement OTG_FS USB Driver #51
Conversation
Ideally this should address some of the concern in #40 as this will now provide a USB_FS example in |
Looks like there is a few things failing because some metapac updates aren't done correctly yet. Let me address those soon and get this in a clean state. |
Test should pass once ch32-rs/ch32-data#9 is merged and I will update the dependency commit hash. |
The primary purpose of this change is to introduce an initial implementation of the USB OTG FS device driver. Although this should also applie to other SKUs that have the USB FS (without OTG) but those are currently untested due to the lack of said hardware for testing. In the process of implementing support for USB, we noticed that the WFI instruction in the Qingke IP has significant flaws causing the USB peripheral unable to access memory correctly while the CPU is under WFI. The exact reason behind this is unclear, but a workaround has been put inplace by using a new executor we added to embassy named `arch-spin` which avoids the use of WFI instruction altogether. Also there were several updates to the peripheral access crate (PAC) to ensure the USB driver code is as readable as possible. The update may have not been applied to all device families, especially those using USB_FS instead of having the full OTG peripheral. The code has been tested on CH32V307 and CH32V305 with the following applications: - USB DFU: mostly to exercise usb control transfer - USB HID: mostly to exercise usb interrupt transfer We will also provide a simple USB DFU example in the `examples/ch32v307` directory for those who want to just quickly verify any functionalities. Co-authored-by: Dummyc0m <[email protected]> Co-authored-by: Codetector <[email protected]>
Looks like there will be more features than chip families so looks like it would make more sense to have the table be transposed so on a normal monitor it would be easier to read.
This patch removes the defmt feature from ch32-hal in the example. - Using defmt requires that special linker script setup, and it is not present - I also don't believe that these simple examples should depend on defmt anyways, especially that we can't do defmt over rtt currently.
Cool now everything should be fixed :) perfect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work on implementing the USB driver. Let's ship this!
The primary purpose of this change is to introduce an initial
implementation of the USB OTG FS device driver. Although this should
also applie to other SKUs that have the USB FS (without OTG) but those
are currently untested due to the lack of said hardware for testing.
In the process of implementing support for USB, we noticed that the WFI
instruction in the Qingke IP has significant flaws causing the USB
peripheral unable to access memory correctly while the CPU is under WFI.
The exact reason behind this is unclear, but a workaround has been put
inplace by using a new executor we added to embassy named
arch-spin
which avoids the use of WFI instruction altogether.
Also there were several updates to the peripheral access crate (PAC) to
ensure the USB driver code is as readable as possible. The update may
have not been applied to all device families, especially those using
USB_FS instead of having the full OTG peripheral.
The code has been tested on CH32V307 and CH32V305 with the following
applications:
We also provided a simple USB DFU example in the
examples/ch32v307
directory for those who want to just quickly verify any functionalities.