diff options
Diffstat (limited to 'embassy-usb-synopsys-otg/src/lib.rs')
| -rw-r--r-- | embassy-usb-synopsys-otg/src/lib.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/embassy-usb-synopsys-otg/src/lib.rs b/embassy-usb-synopsys-otg/src/lib.rs index b226bc8af..6b4a87bdf 100644 --- a/embassy-usb-synopsys-otg/src/lib.rs +++ b/embassy-usb-synopsys-otg/src/lib.rs | |||
| @@ -76,10 +76,16 @@ pub unsafe fn on_interrupt<const MAX_EP_COUNT: usize>(r: Otg, state: &State<MAX_ | |||
| 76 | let buf = | 76 | let buf = |
| 77 | unsafe { core::slice::from_raw_parts_mut(*state.ep_states[ep_num].out_buffer.get(), len) }; | 77 | unsafe { core::slice::from_raw_parts_mut(*state.ep_states[ep_num].out_buffer.get(), len) }; |
| 78 | 78 | ||
| 79 | for chunk in buf.chunks_mut(4) { | 79 | let mut chunks = buf.chunks_exact_mut(4); |
| 80 | for chunk in &mut chunks { | ||
| 80 | // RX FIFO is shared so always read from fifo(0) | 81 | // RX FIFO is shared so always read from fifo(0) |
| 81 | let data = r.fifo(0).read().0; | 82 | let data = r.fifo(0).read().0; |
| 82 | chunk.copy_from_slice(&data.to_ne_bytes()[0..chunk.len()]); | 83 | chunk.copy_from_slice(&data.to_ne_bytes()); |
| 84 | } | ||
| 85 | let rem = chunks.into_remainder(); | ||
| 86 | if !rem.is_empty() { | ||
| 87 | let data = r.fifo(0).read().0; | ||
| 88 | rem.copy_from_slice(&data.to_ne_bytes()[0..rem.len()]); | ||
| 83 | } | 89 | } |
| 84 | 90 | ||
| 85 | state.ep_states[ep_num].out_size.store(len as u16, Ordering::Release); | 91 | state.ep_states[ep_num].out_size.store(len as u16, Ordering::Release); |
