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

Support devices with SetAddress handled in hardware (Nordic nRF52) #51

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/bus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ pub trait UsbBus: Sync + Sized {
///
/// The default value for this constant is `false`, which corresponds to the USB 2.0 spec, 9.4.6
const QUIRK_SET_ADDRESS_BEFORE_STATUS: bool = false;

/// Indicates that the `UsbDevice` should not send a response to `SetAddress` control transfers.
///
/// This defaults to `false`, meaning that `UsbDevice` will handle `SetAddress` transfers. It
/// needs to be set to `true` when the device hardware handles `SetAddress`.
const INHIBIT_SET_ADDRESS_RESPONSE: bool = false;
}

struct AllocatorState {
Expand Down Expand Up @@ -329,4 +335,4 @@ pub enum PollResult {
/// A USB resume request has been detected after being suspended or, in the case of self-powered
/// devices, the device has been connected to the USB bus.
Resume,
}
}
5 changes: 5 additions & 0 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ impl<B: UsbBus> UsbDevice<'_, B> {
} else {
self.pending_address = req.value as u8;
}

if B::INHIBIT_SET_ADDRESS_RESPONSE {
return;
}

xfer.accept().ok();
},

Expand Down