Usb fixes (#104)

* Remove check for ep0 buffer.len == 64

* Simplify EP buffer check
This commit is contained in:
9names 2021-09-11 18:31:45 +10:00 committed by GitHub
parent 0e5d582363
commit 7afa19a82b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -133,7 +133,7 @@ impl Inner {
let is_ep0 = ep_addr.index() == 0;
let is_ctrl_ep = ep_type == EndpointType::Control;
if !(is_ep0 ^ !is_ctrl_ep) || (is_ep0 && (max_packet_size != 64)) {
if !(is_ep0 ^ !is_ctrl_ep) {
return Err(UsbError::Unsupported);
}
@ -149,10 +149,12 @@ impl Inner {
return Err(UsbError::InvalidEndpoint);
}
// validate buffer size
if let (EndpointType::Isochronous, true) = (ep_type, max_packet_size > 1023) {
return Err(UsbError::Unsupported);
} else if max_packet_size > 64 {
// Validate buffer size. From datasheet (4.1.2.5):
// Data Buffers are typically 64 bytes long as this is the max normal packet size for most FS packets.
// For Isochronous endpoints a maximum buffer size of 1023 bytes is supported.
// For other packet types the maximum size is 64 bytes per buffer.
if (ep_type != EndpointType::Isochronous && max_packet_size > 64) || max_packet_size > 1023
{
return Err(UsbError::Unsupported);
}