fn transfer_slice<'w>(sercom: &RegisterBlock, buf: &'w mut [u8]) -> Result<&'w [u8], Error> {
    let cells = core::cell::Cell::from_mut(buf).as_slice_of_cells();
    let mut to_send = cells.iter();
    let mut to_recv = cells.iter();
    while to_recv.len() > 0 {
        let errors = sercom.spim().status.read();
        if errors.bufovf().bit_is_set() {
            return Err(Error::Overflow);
        }
        if errors.lenerr().bit_is_set() {
            return Err(Error::LengthError);
        }
        let flags = sercom.spim().intflag.read();
        if to_send.len() > 0 && flags.dre().bit_is_set() {
            let mut bytes = [0; 4];
            for byte in &mut bytes {
                match to_send.next() {
                    Some(cell) => *byte = cell.get(),
                    None => break,
                }
            }
            let word = u32::from_le_bytes(bytes);
            sercom.spim().data.write(|w| unsafe { w.data().bits(word) });
        }
        if to_recv.len() > to_send.len() && flags.rxc().bit_is_set() {
            let word = sercom.spim().data.read().data().bits();
            let bytes = word.to_le_bytes();
            for byte in bytes.iter() {
                match to_recv.next() {
                    Some(cell) => cell.set(*byte),
                    None => break,
                }
            }
        }
    }
    Ok(buf)
}
/// Transfer a `[u8]` slice four bytes at a time
///
/// This function exists to avoid both code duplication and monomorphization
/// bloat. It will take a `[u8]` and transfer it four bytes at a time.
Transfer a `[u8]` slice four bytes at a time
This function exists to avoid both code duplication and monomorphization
bloat. It will take a `[u8]` and transfer it four bytes at a time.
Transfer a ` [ u8 ] ` slice four bytes at a time This function exists to avoid both code duplication and monomorphization bloat . It will take a ` [ u8 ] ` and transfer it four bytes at a time .
fn transfer_slice<'w>(sercom: &RegisterBlock, buf: &'w mut [u8]) -> Result<&'w [u8], Error> {
    let cells = core::cell::Cell::from_mut(buf).as_slice_of_cells();
    let mut to_send = cells.iter();
    let mut to_recv = cells.iter();
    while to_recv.len() > 0 {
        let errors = sercom.spim().status.read();
        if errors.bufovf().bit_is_set() {
            return Err(Error::Overflow);
        }
        if errors.lenerr().bit_is_set() {
            return Err(Error::LengthError);
        }
        let flags = sercom.spim().intflag.read();
        if to_send.len() > 0 && flags.dre().bit_is_set() {
            let mut bytes = [0; 4];
            for byte in &mut bytes {
                match to_send.next() {
                    Some(cell) => *byte = cell.get(),
                    None => break,
                }
            }
            let word = u32::from_le_bytes(bytes);
            sercom.spim().data.write(|w| unsafe { w.data().bits(word) });
        }
        if to_recv.len() > to_send.len() && flags.rxc().bit_is_set() {
            let word = sercom.spim().data.read().data().bits();
            let bytes = word.to_le_bytes();
            for byte in bytes.iter() {
                match to_recv.next() {
                    Some(cell) => cell.set(*byte),
                    None => break,
                }
            }
        }
    }
    Ok(buf)
}
fn transfer_slice < ' w > ( sercom : & RegisterBlock , buf : & ' w mut [ u8 ] ) -> Result < & ' w [ u8 ] , Error > { let cells = core :: cell :: Cell :: from_mut ( buf ) . as_slice_of_cells ( ) ; let mut to_send = cells . iter ( ) ; let mut to_recv = cells . iter ( ) ; while to_recv . len ( ) > 0 { let errors = sercom . spim ( ) . status . read ( ) ; if errors . bufovf ( ) . bit_is_set ( ) { return Err ( Error :: Overflow ) ; } if errors . lenerr ( ) . bit_is_set ( ) { return Err ( Error :: LengthError ) ; } let flags = sercom . spim ( ) . intflag . read ( ) ; if to_send . len ( ) > 0 && flags . dre ( ) . bit_is_set ( ) { let mut bytes = [ 0 ; 4 ] ; for byte in & mut bytes { match to_send . next ( ) { Some ( cell ) => * byte = cell . get ( ) , None => break , } } let word = u32 :: from_le_bytes ( bytes ) ; sercom . spim ( ) . data . write ( | w | unsafe { w . data ( ) . bits ( word ) } ) ; } if to_recv . len ( ) > to_send . len ( ) && flags . rxc ( ) . bit_is_set ( ) { let word = sercom . spim ( ) . data . read ( ) . data ( ) . bits ( ) ; let bytes = word . to_le_bytes ( ) ; for byte in bytes . iter ( ) { match to_recv . next ( ) { Some ( cell ) => cell . set ( * byte ) , None => break , } } } } Ok ( buf ) }
Transfer a `[u8]` slice four bytes at a time
This function exists to avoid both code duplication and monomorphization
bloat.
Transfer a ` [ u8 ] ` slice four bytes at a time This function exists to avoid both code duplication and monomorphization bloat .
sercom
&RegisterBlock
buf
&'w mut [u8]
sercom
&RegisterBlock
buf
&'w mut [u8]