-
Notifications
You must be signed in to change notification settings - Fork 139
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 support #295
USB support #295
Conversation
the addresses look like MMIO registers
or at least they seem to work
to ensure the external oscillator has been enabled
Fixes compilation by pointing to current versions and takes in @unrelentingtech's fork of usb-device and suggestion in nrf-rs#144 (review) I folded in the hello world portion from japaric's PR summary text. refs: rust-embedded-community/usb-device#51 closes: nrf-rs#144
Current problems:
|
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.
Looks like you're making great progress! I got about 60% of the way that you did; I'm pleased to see some similarities with the stuff in my local hack branch, and happy that spending the time on that means that I can more easily reason about your PR!
nrf-hal-common/src/usbd/mod.rs
Outdated
return true; | ||
} | ||
|
||
if ep0_state.direction == UsbDirection::Out { |
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.
makes sense!
Co-authored-by: Wez Furlong <[email protected]>
Current status: serial stress test works better but still fails. One of the IN packets is not followed by EPDATASTATUS change, so "busy" flag is not erased and driver ends up in a locked state. |
This helps in a situation when `poll()` is not called periodically, for example, when main loop is busy writing data to an endpoint. This situation happens in the usb_serial example.
There was a problem in the serial example: it doesn't call |
I tested this version of the driver:
|
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.
Did a first pass, this looks pretty good so far!
nrf-hal-common/src/usbd/mod.rs
Outdated
regs.events_endepout[i].reset(); | ||
dma_end(); | ||
|
||
// TODO: ISO |
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.
What's the current behavior when trying to use an ISO endpoint?
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.
Looks great! Excited to finally have USB support in :)
Commented a few minor nits
nrf-hal-common/src/usbd.rs
Outdated
|
||
pub use nrf_usbd::Usbd; | ||
|
||
#[allow(dead_code)] // fields are unused and only hold ownership |
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.
minor nit: I think if you name the field _clocks
the warning goes away
nrf-hal-common/src/usbd.rs
Outdated
#[allow(dead_code)] // fields are unused and only hold ownership | ||
pub struct UsbPeripheral<'a> { | ||
usbd: USBD, | ||
clocks: &'a (), |
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.
&()
is not ZST even if ()
is. Maybe use PhantomData<&'a ()>
?
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.
🚀
bors r+
Build succeeded: |
This PR is based on #144 and previous attempts.