pub fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Error> {
        // Conservative compiler fence to prevent optimizations that do not
        // take in to account actions by DMA. The fence has been placed here,
        // before any DMA action has started.
        compiler_fence(SeqCst);

        self.0
            .address
            .write(|w| unsafe { w.address().bits(address) });

        // Set up the DMA read.
        unsafe { self.set_rx_buffer(buffer)? };

        // Clear events
        self.0.events_stopped.reset();
        self.0.events_error.reset();
        self.clear_errorsrc();

        // Start read operation.
        self.0.shorts.write(|w| w.lastrx_stop().enabled());
        self.0.tasks_startrx.write(|w|
            // `1` is a valid value to write to task registers.
            unsafe { w.bits(1) });

        self.wait();

        // Conservative compiler fence to prevent optimizations that do not
        // take in to account actions by DMA. The fence has been placed here,
        // after all possible DMA actions have completed.
        compiler_fence(SeqCst);

        self.read_errorsrc()?;

        if self.0.rxd.amount.read().bits() != buffer.len() as u32 {
            return Err(Error::Receive);
        }

        Ok(())
    }
/// Read from an I2C slave.
///
/// The buffer must have a length of at most 255 bytes on the nRF52832
/// and at most 65535 bytes on the nRF52840.
Read from an I2C slave.
The buffer must have a length of at most 255 bytes on the nRF52832
and at most 65535 bytes on the nRF52840.
Read from an I2C slave . The buffer must have a length of at most 255 bytes on the nRF52832 and at most 65535 bytes on the nRF52840 .
pub fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Error> {
        // Conservative compiler fence to prevent optimizations that do not
        // take in to account actions by DMA. The fence has been placed here,
        // before any DMA action has started.
        compiler_fence(SeqCst);
        self.0
            .address
            .write(|w| unsafe { w.address().bits(address) });
        // Set up the DMA read.
        unsafe { self.set_rx_buffer(buffer)? };
        // Clear events
        self.0.events_stopped.reset();
        self.0.events_error.reset();
        self.clear_errorsrc();
        // Start read operation.
        self.0.shorts.write(|w| w.lastrx_stop().enabled());
        self.0.tasks_startrx.write(|w|
            // `1` is a valid value to write to task registers.
            unsafe { w.bits(1) });
        self.wait();
        // Conservative compiler fence to prevent optimizations that do not
        // take in to account actions by DMA. The fence has been placed here,
        // after all possible DMA actions have completed.
        compiler_fence(SeqCst);
        self.read_errorsrc()?;
        if self.0.rxd.amount.read().bits() != buffer.len() as u32 {
            return Err(Error::Receive);
        }
        Ok(())
    }
pub fn read ( & mut self , address : u8 , buffer : & mut [ u8 ] ) -> Result < ( ) , Error > { // Conservative compiler fence to prevent optimizations that do not // take in to account actions by DMA. The fence has been placed here, // before any DMA action has started. compiler_fence ( SeqCst ) ; self . 0 . address . write ( | w | unsafe { w . address ( ) . bits ( address ) } ) ; // Set up the DMA read. unsafe { self . set_rx_buffer ( buffer ) ? } ; // Clear events self . 0 . events_stopped . reset ( ) ; self . 0 . events_error . reset ( ) ; self . clear_errorsrc ( ) ; // Start read operation. self . 0 . shorts . write ( | w | w . lastrx_stop ( ) . enabled ( ) ) ; self . 0 . tasks_startrx . write ( | w | // `1` is a valid value to write to task registers. unsafe { w . bits ( 1 ) } ) ; self . wait ( ) ; // Conservative compiler fence to prevent optimizations that do not // take in to account actions by DMA. The fence has been placed here, // after all possible DMA actions have completed. compiler_fence ( SeqCst ) ; self . read_errorsrc ( ) ? ; if self . 0 . rxd . amount . read ( ) . bits ( ) != buffer . len ( ) as u32 { return Err ( Error :: Receive ) ; } Ok ( ( ) ) }
Read from an I2C slave.
Read from an I2C slave .
&mut self
address
u8
buffer
&mut [u8]
&mut self
address
u8
buffer
&mut [u8]