aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-01-27 14:44:51 +0000
committerGitHub <[email protected]>2023-01-27 14:44:51 +0000
commit7ec15f2defa63356a5b8be1b8585e1eb1b0d1893 (patch)
treecd9476d30da51b0e197decb1c63f0caf8e0ade89
parentffa75e1e39949807317ee75459ae9d18b5376578 (diff)
parent1e60c60afdfc2a4677a3312d7af8d065af6c50ac (diff)
Merge #1178
1178: rp: allow isochronous USB endpoints to be up to 1023 bytes in size r=Dirbaio a=nitroxis The datasheet allows isochronous USB endpoints to be up to 1023 bytes in size (see "4.1.2.5. DPSRAM"). This PR changes the check to allow this and also changes the length computation to align to 64 bytes (instead of hardcoded 64 bytes). Embassy does not yet support isochronous USB endpoints, however I'm investigating adding support. This change is simple enough and should be correct according to the datasheet, so maybe future implementers don't run into this issue. Co-authored-by: nitroxis <[email protected]>
-rw-r--r--embassy-rp/src/usb.rs6
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 _ {