pub fn slave_read_send(&self, buffer: &'static mut [u8], len: u8) {
        self.slave_read_buffer.replace(buffer);
        self.slave_read_buffer_len.set(len);
        self.slave_read_buffer_index.set(0);

        if self.slave_enabled.get() {
            // Check to see if we should send the first byte.
            self.slave_registers.map(|slave_registers| {
                let regs: &TWISRegisters = unsafe { &*slave_registers };

                let status = regs.status.get();
                let imr = regs.interrupt_mask.get();
                let interrupts = status & imr;

                // Address match status bit still set. We got this function
                // call in response to an incoming read. Send the first
                // byte.
                if (interrupts & (1 << 16) > 0) && (status & (1 << 5) > 0) {
                    regs.status_clear.set(1 << 23);

                    let len = self.slave_read_buffer_len.get();

                    if len >= 1 {
                        self.slave_read_buffer.map(|buffer| {
                            regs.transmit_holding.set(buffer[0] as u32);
                        });
                        self.slave_read_buffer_index.set(1);
                    } else {
                        // Send dummy byte
                        regs.transmit_holding.set(0x75);
                    }

                    // Make it happen by clearing status.
                    regs.status_clear.set(status);
                }
            });
        }
    }
/// Prepare a buffer for the I2C master to read from after a read call.
Prepare a buffer for the I2C master to read from after a read call.
Prepare a buffer for the I2C master to read from after a read call .
pub fn slave_read_send(&self, buffer: &'static mut [u8], len: u8) {
        self.slave_read_buffer.replace(buffer);
        self.slave_read_buffer_len.set(len);
        self.slave_read_buffer_index.set(0);
        if self.slave_enabled.get() {
            // Check to see if we should send the first byte.
            self.slave_registers.map(|slave_registers| {
                let regs: &TWISRegisters = unsafe { &*slave_registers };
                let status = regs.status.get();
                let imr = regs.interrupt_mask.get();
                let interrupts = status & imr;
                // Address match status bit still set. We got this function
                // call in response to an incoming read. Send the first
                // byte.
                if (interrupts & (1 << 16) > 0) && (status & (1 << 5) > 0) {
                    regs.status_clear.set(1 << 23);
                    let len = self.slave_read_buffer_len.get();
                    if len >= 1 {
                        self.slave_read_buffer.map(|buffer| {
                            regs.transmit_holding.set(buffer[0] as u32);
                        });
                        self.slave_read_buffer_index.set(1);
                    } else {
                        // Send dummy byte
                        regs.transmit_holding.set(0x75);
                    }
                    // Make it happen by clearing status.
                    regs.status_clear.set(status);
                }
            });
        }
    }
pub fn slave_read_send ( & self , buffer : & ' static mut [ u8 ] , len : u8 ) { self . slave_read_buffer . replace ( buffer ) ; self . slave_read_buffer_len . set ( len ) ; self . slave_read_buffer_index . set ( 0 ) ; if self . slave_enabled . get ( ) { // Check to see if we should send the first byte. self . slave_registers . map ( | slave_registers | { let regs : & TWISRegisters = unsafe { & * slave_registers } ; let status = regs . status . get ( ) ; let imr = regs . interrupt_mask . get ( ) ; let interrupts = status & imr ; // Address match status bit still set. We got this function // call in response to an incoming read. Send the first // byte. if ( interrupts & ( 1 << 16 ) > 0 ) && ( status & ( 1 << 5 ) > 0 ) { regs . status_clear . set ( 1 << 23 ) ; let len = self . slave_read_buffer_len . get ( ) ; if len >= 1 { self . slave_read_buffer . map ( | buffer | { regs . transmit_holding . set ( buffer [ 0 ] as u32 ) ; } ) ; self . slave_read_buffer_index . set ( 1 ) ; } else { // Send dummy byte regs . transmit_holding . set ( 0x75 ) ; } // Make it happen by clearing status. regs . status_clear . set ( status ) ; } } ) ; } }
Prepare a buffer for the I2C master to read from after a read call.
Prepare a buffer for the I2C master to read from after a read call .
&self
buffer
&'static mut [u8]
len
u8
&self
buffer
&'static mut [u8]
len
u8