File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,14 +62,17 @@ impl<USB: UsbPeripheral> EndpointBuffer<USB> {
6262 }
6363 }
6464
65+ /// # Safety
66+ ///
67+ /// Caller must ensure that while the returned reference exists, no mutable references to the section of EP memory covered by this slice exist.
6568 #[ inline( always) ]
66- fn get_mem_slice < T > ( & self ) -> & mut [ VolatileCell < T > ] {
67- unsafe { slice:: from_raw_parts_mut ( self . mem_ptr . cast ( ) , self . mem_len ) }
69+ unsafe fn get_mem_slice < T > ( & self ) -> & [ VolatileCell < T > ] {
70+ unsafe { slice:: from_raw_parts ( self . mem_ptr . cast ( ) , self . mem_len ) }
6871 }
6972
7073 pub fn read ( & self , mut buf : & mut [ u8 ] ) {
7174 if USB :: EP_MEMORY_ACCESS == MemoryAccess :: Word32x1 {
72- let mem = self . get_mem_slice :: < u32 > ( ) ;
75+ let mem = unsafe { self . get_mem_slice :: < u32 > ( ) } ;
7376
7477 let mut index = 0 ;
7578
@@ -86,7 +89,7 @@ impl<USB: UsbPeripheral> EndpointBuffer<USB> {
8689 buf. copy_from_slice ( & value[ 0 ..buf. len ( ) ] ) ;
8790 }
8891 } else {
89- let mem = self . get_mem_slice :: < u16 > ( ) ;
92+ let mem = unsafe { self . get_mem_slice :: < u16 > ( ) } ;
9093
9194 let mut index = 0 ;
9295
You can’t perform that action at this time.
0 commit comments