diff options
| author | Matt Johnston <[email protected]> | 2025-08-11 15:19:51 +0800 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-09-05 16:35:54 +0200 |
| commit | cac396425228464602ab9ee0816f4f9f07d53d77 (patch) | |
| tree | a166d01169ca3fedfa251ffbf1837eac691dcdcf /embassy-usb-synopsys-otg | |
| parent | bc448985d50827bd5c6211739563817795f925ab (diff) | |
otg: Use chunks_exact for more efficient rx copy
Diffstat (limited to 'embassy-usb-synopsys-otg')
| -rw-r--r-- | embassy-usb-synopsys-otg/CHANGELOG.md | 2 | ||||
| -rw-r--r-- | embassy-usb-synopsys-otg/src/lib.rs | 10 |
2 files changed, 10 insertions, 2 deletions
diff --git a/embassy-usb-synopsys-otg/CHANGELOG.md b/embassy-usb-synopsys-otg/CHANGELOG.md index 9ca90f5e9..45353d907 100644 --- a/embassy-usb-synopsys-otg/CHANGELOG.md +++ b/embassy-usb-synopsys-otg/CHANGELOG.md | |||
| @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 10 | 10 | ||
| 11 | ## 0.3.1 - 2025-08-26 | 11 | ## 0.3.1 - 2025-08-26 |
| 12 | 12 | ||
| 13 | - Improve receive performance, more efficient copy from FIFO | ||
| 14 | |||
| 13 | ## 0.3.0 - 2025-07-22 | 15 | ## 0.3.0 - 2025-07-22 |
| 14 | 16 | ||
| 15 | - Bump `embassy-usb-driver` to v0.2.0 | 17 | - Bump `embassy-usb-driver` to v0.2.0 |
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); |
