diff options
| author | nitroxis <[email protected]> | 2023-01-27 07:19:34 +0100 |
|---|---|---|
| committer | nitroxis <[email protected]> | 2023-01-27 07:24:49 +0100 |
| commit | 1e60c60afdfc2a4677a3312d7af8d065af6c50ac (patch) | |
| tree | cd9476d30da51b0e197decb1c63f0caf8e0ade89 | |
| parent | ffa75e1e39949807317ee75459ae9d18b5376578 (diff) | |
rp: allow isochronous USB endpoints to be up to 1023 in size
| -rw-r--r-- | embassy-rp/src/usb.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/embassy-rp/src/usb.rs b/embassy-rp/src/usb.rs index 2710c4ad9..8eec55b49 100644 --- a/embassy-rp/src/usb.rs +++ b/embassy-rp/src/usb.rs | |||
| @@ -219,14 +219,16 @@ impl<'d, T: Instance> Driver<'d, T> { | |||
| 219 | let (index, ep) = index.ok_or(EndpointAllocError)?; | 219 | let (index, ep) = index.ok_or(EndpointAllocError)?; |
| 220 | assert!(!ep.used); | 220 | assert!(!ep.used); |
| 221 | 221 | ||
| 222 | if max_packet_size > 64 { | 222 | // as per datasheet, the maximum buffer size is 64, except for isochronous |
| 223 | // endpoints, which are allowed to be up to 1023 bytes. | ||
| 224 | if (ep_type != EndpointType::Isochronous && max_packet_size > 64) || max_packet_size > 1023 { | ||
| 223 | warn!("max_packet_size too high: {}", max_packet_size); | 225 | warn!("max_packet_size too high: {}", max_packet_size); |
| 224 | return Err(EndpointAllocError); | 226 | return Err(EndpointAllocError); |
| 225 | } | 227 | } |
| 226 | 228 | ||
| 227 | // ep mem addrs must be 64-byte aligned, so there's no point in trying | 229 | // ep mem addrs must be 64-byte aligned, so there's no point in trying |
| 228 | // to allocate smaller chunks to save memory. | 230 | // to allocate smaller chunks to save memory. |
| 229 | let len = 64; | 231 | let len = (max_packet_size + 63) / 64 * 64; |
| 230 | 232 | ||
| 231 | let addr = self.ep_mem_free; | 233 | let addr = self.ep_mem_free; |
| 232 | if addr + len > EP_MEMORY_SIZE as _ { | 234 | if addr + len > EP_MEMORY_SIZE as _ { |
