/// Flushes the transmit buffer, ensuring all pending transmissions have completed
Flushes the transmit buffer, ensuring all pending transmissions have completed
Flushes the transmit buffer ensuring all pending transmissions have completed
pub fn flush(&mut self) -> Result<(), Error<E>> {
        if self.txnd != NONE {
            // Wait until transmission finishes
            while common::ECON1(self.read_control_register(common::Register::ECON1)?).txrts() == 1 {
            }
            // NOTE(volatile) to avoid this value being set *before* the transmission is over
            let txnd = self.txnd;
            unsafe { ptr::write_volatile(&mut self.txnd, NONE) }
            // read the transmit status vector
            let mut tx_stat = [0; 7];
            self.read_buffer_memory(Some(txnd + 1), &mut tx_stat)?;
            let stat = common::ESTAT(self.read_control_register(common::Register::ESTAT)?);
            if stat.txabrt() == 1 {
                // work around errata issue 12 by reading the transmit status vector
                if stat.latecol() == 1 || (tx_stat[2] & (1 << 5)) != 0 {
                    Err(Error::LateCollision)
                } else {
                    // TODO check for other error conditions
                    unimplemented!()
                }
            } else {
                Ok(())
            }
        } else {
            Ok(())
        }
    }
pub fn flush ( & mut self ) -> Result < ( ) , Error < E > > { if self . txnd != NONE { // Wait until transmission finishes while common :: ECON1 ( self . read_control_register ( common :: Register :: ECON1 ) ? ) . txrts ( ) == 1 { } // NOTE(volatile) to avoid this value being set *before* the transmission is over let txnd = self . txnd ; unsafe { ptr :: write_volatile ( & mut self . txnd , NONE ) } // read the transmit status vector let mut tx_stat = [ 0 ; 7 ] ; self . read_buffer_memory ( Some ( txnd + 1 ) , & mut tx_stat ) ? ; let stat = common :: ESTAT ( self . read_control_register ( common :: Register :: ESTAT ) ? ) ; if stat . txabrt ( ) == 1 { // work around errata issue 12 by reading the transmit status vector if stat . latecol ( ) == 1 || ( tx_stat [ 2 ] & ( 1 << 5 ) ) != 0 { Err ( Error :: LateCollision ) } else { // TODO check for other error conditions unimplemented ! ( ) } } else { Ok ( ( ) ) } } else { Ok ( ( ) ) } }
Flushes the transmit buffer, ensuring all pending transmissions have completed
Flushes the transmit buffer ensuring all pending transmissions have completed
&mut self