pub fn write_back(&self, strategy: Strategy) -> Result<(), EI::Error> {
        let mut start_port = 0;
        let mut ports_to_write = self.dirty.load(Ordering::Acquire);
        let mut ok_to_write = match strategy {
            Strategy::Exact => ports_to_write,
            Strategy::StompClean => self.fresh.load(Ordering::Acquire),
            Strategy::StompAny => 0xFFFFFFFC,
        };
        let cache = self.cache.load(Ordering::Acquire);
        while ports_to_write != 0 {
            let skip = ports_to_write.trailing_zeros();
            ports_to_write >>= skip;
            ok_to_write >>= skip;
            start_port += skip;
            if ok_to_write & 0xFF == 0xFF {
                let port_values = (cache >> start_port) as u8;
                self.expander
                    .lock(|ex| ex.write_ports(start_port as u8, port_values))?;
                ports_to_write &= !0xFFusize;
            } else {
                let port_value = cache & (1 << start_port) != 0;
                self.expander
                    .lock(|ex| ex.write_port(start_port as u8, port_value))?;
                ports_to_write &= !0x01usize;
            }
        }
        self.dirty.store(0, Ordering::Release);
        Ok(())
    }
/// Write back any pending `OutputPin` operations to the MAX7301.
///
/// The strategy used to do this is controlled by `strategy` (see [`Strategy`] docs for a
/// description of the available strategies).
Write back any pending `OutputPin` operations to the MAX7301.
The strategy used to do this is controlled by `strategy` (see [`Strategy`] docs for a
description of the available strategies).
Write back any pending ` OutputPin ` operations to the MAX7301 . The strategy used to do this is controlled by ` strategy ` ( see [ ` Strategy ` ] docs for a description of the available strategies ) .
pub fn write_back(&self, strategy: Strategy) -> Result<(), EI::Error> {
        let mut start_port = 0;
        let mut ports_to_write = self.dirty.load(Ordering::Acquire);
        let mut ok_to_write = match strategy {
            Strategy::Exact => ports_to_write,
            Strategy::StompClean => self.fresh.load(Ordering::Acquire),
            Strategy::StompAny => 0xFFFFFFFC,
        };
        let cache = self.cache.load(Ordering::Acquire);
        while ports_to_write != 0 {
            let skip = ports_to_write.trailing_zeros();
            ports_to_write >>= skip;
            ok_to_write >>= skip;
            start_port += skip;
            if ok_to_write & 0xFF == 0xFF {
                let port_values = (cache >> start_port) as u8;
                self.expander
                    .lock(|ex| ex.write_ports(start_port as u8, port_values))?;
                ports_to_write &= !0xFFusize;
            } else {
                let port_value = cache & (1 << start_port) != 0;
                self.expander
                    .lock(|ex| ex.write_port(start_port as u8, port_value))?;
                ports_to_write &= !0x01usize;
            }
        }
        self.dirty.store(0, Ordering::Release);
        Ok(())
    }
pub fn write_back ( & self , strategy : Strategy ) -> Result < ( ) , EI :: Error > { let mut start_port = 0 ; let mut ports_to_write = self . dirty . load ( Ordering :: Acquire ) ; let mut ok_to_write = match strategy { Strategy :: Exact => ports_to_write , Strategy :: StompClean => self . fresh . load ( Ordering :: Acquire ) , Strategy :: StompAny => 0xFFFFFFFC , } ; let cache = self . cache . load ( Ordering :: Acquire ) ; while ports_to_write != 0 { let skip = ports_to_write . trailing_zeros ( ) ; ports_to_write >>= skip ; ok_to_write >>= skip ; start_port += skip ; if ok_to_write & 0xFF == 0xFF { let port_values = ( cache >> start_port ) as u8 ; self . expander . lock ( | ex | ex . write_ports ( start_port as u8 , port_values ) ) ? ; ports_to_write &= ! 0xFFusize ; } else { let port_value = cache & ( 1 << start_port ) != 0 ; self . expander . lock ( | ex | ex . write_port ( start_port as u8 , port_value ) ) ? ; ports_to_write &= ! 0x01usize ; } } self . dirty . store ( 0 , Ordering :: Release ) ; Ok ( ( ) ) }
Write back any pending `OutputPin` operations to the MAX7301.
Write back any pending ` OutputPin ` operations to the MAX7301 .
&self
strategy
Strategy
&self
strategy
Strategy