aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb-synopsys-otg
diff options
context:
space:
mode:
authorMatt Ickstadt <[email protected]>2024-05-20 11:55:04 -0500
committerMatt Ickstadt <[email protected]>2024-05-20 12:21:55 -0500
commit5a8ac21f6bc67740d1df956aef6edcfb80376f51 (patch)
tree0ac69cfed5f291c308e1bb9e0317d61af4d9673f /embassy-usb-synopsys-otg
parenta4350e039805e3471949893fc121f0b7e2542494 (diff)
embassy-usb-synopsys-otg: impl Sync for EpState
This restores the Send/Sync impls for EpState, which were incidentally removed in #2881. This allows the Endpoints to be send to tasks, e.g. as part of a custom class implementation.
Diffstat (limited to 'embassy-usb-synopsys-otg')
-rw-r--r--embassy-usb-synopsys-otg/src/lib.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/embassy-usb-synopsys-otg/src/lib.rs b/embassy-usb-synopsys-otg/src/lib.rs
index 42cdfb6e1..34dcd1497 100644
--- a/embassy-usb-synopsys-otg/src/lib.rs
+++ b/embassy-usb-synopsys-otg/src/lib.rs
@@ -221,6 +221,12 @@ struct EpState {
221 out_size: AtomicU16, 221 out_size: AtomicU16,
222} 222}
223 223
224// SAFETY: The EndpointAllocator ensures that the buffer points to valid memory exclusive for each endpoint and is
225// large enough to hold the maximum packet size. Access to the buffer is synchronized between the USB interrupt and the
226// EndpointOut impl using the out_size atomic variable.
227unsafe impl Send for EpState {}
228unsafe impl Sync for EpState {}
229
224struct ControlPipeSetupState { 230struct ControlPipeSetupState {
225 /// Holds received SETUP packets. Available if [Ep0State::setup_ready] is true. 231 /// Holds received SETUP packets. Available if [Ep0State::setup_ready] is true.
226 setup_data: UnsafeCell<[u8; 8]>, 232 setup_data: UnsafeCell<[u8; 8]>,
@@ -1034,7 +1040,7 @@ impl<'d> embassy_usb_driver::EndpointOut for Endpoint<'d, Out> {
1034 return Poll::Ready(Err(EndpointError::BufferOverflow)); 1040 return Poll::Ready(Err(EndpointError::BufferOverflow));
1035 } 1041 }
1036 1042
1037 // SAFETY: exclusive access ensured by `ep_out_size` atomic variable 1043 // SAFETY: exclusive access ensured by `out_size` atomic variable
1038 let data = unsafe { core::slice::from_raw_parts(*self.state.out_buffer.get(), len as usize) }; 1044 let data = unsafe { core::slice::from_raw_parts(*self.state.out_buffer.get(), len as usize) };
1039 buf[..len as usize].copy_from_slice(data); 1045 buf[..len as usize].copy_from_slice(data);
1040 1046