diff options
| -rw-r--r-- | embassy-usb-synopsys-otg/src/lib.rs | 8 |
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. | ||
| 227 | unsafe impl Send for EpState {} | ||
| 228 | unsafe impl Sync for EpState {} | ||
| 229 | |||
| 224 | struct ControlPipeSetupState { | 230 | struct 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 | ||
