pub fn write(&mut self, offset: u8, value: u8) -> Result<(), Error<T::E>> {
        match offset {
            DLAB_LOW_OFFSET if self.is_dlab_set() => self.baud_divisor_low = value,
            DLAB_HIGH_OFFSET if self.is_dlab_set() => self.baud_divisor_high = value,
            DATA_OFFSET => {
                if self.is_in_loop_mode() {
                    // In loopback mode, what is written in the transmit register
                    // will be immediately found in the receive register, so we
                    // simulate this behavior by adding in `in_buffer` the
                    // transmitted bytes and letting the driver know there is some
                    // pending data to be read, by setting RDA bit and its
                    // corresponding interrupt.
                    if self.in_buffer.len() < FIFO_SIZE {
                        self.in_buffer.push_back(value);
                        self.set_lsr_rda_bit();
                        self.received_data_interrupt().map_err(Error::Trigger)?;
                    }
                } else {
                    self.out.write_all(&[value]).map_err(Error::IOError)?;
                    self.out.flush().map_err(Error::IOError)?;
                    self.thr_empty_interrupt().map_err(Error::Trigger)?;
                }
            }
            // We want to enable only the interrupts that are available for 16550A (and below).
            IER_OFFSET => self.interrupt_enable = value & IER_UART_VALID_BITS,
            LCR_OFFSET => self.line_control = value,
            MCR_OFFSET => self.modem_control = value,
            SCR_OFFSET => self.scratch = value,
            // We are not interested in writing to other offsets (such as FCR offset).
            _ => {}
        }
        Ok(())
    }
/// Handles a write request from the driver at `offset` offset from the
/// base Port I/O address.
///
/// # Arguments
/// * `offset` - The offset that will be added to the base PIO address
///              for writing to a specific register.
/// * `value` - The byte that should be written.
///
/// # Example
///
/// You can see an example of how to use this function in the
/// [`Example` section from `Serial`](struct.Serial.html#example).
Handles a write request from the driver at `offset` offset from the
base Port I/O address.
Handles a write request from the driver at ` offset ` offset from the base Port I / O address .
pub fn write(&mut self, offset: u8, value: u8) -> Result<(), Error<T::E>> {
        match offset {
            DLAB_LOW_OFFSET if self.is_dlab_set() => self.baud_divisor_low = value,
            DLAB_HIGH_OFFSET if self.is_dlab_set() => self.baud_divisor_high = value,
            DATA_OFFSET => {
                if self.is_in_loop_mode() {
                    // In loopback mode, what is written in the transmit register
                    // will be immediately found in the receive register, so we
                    // simulate this behavior by adding in `in_buffer` the
                    // transmitted bytes and letting the driver know there is some
                    // pending data to be read, by setting RDA bit and its
                    // corresponding interrupt.
                    if self.in_buffer.len() < FIFO_SIZE {
                        self.in_buffer.push_back(value);
                        self.set_lsr_rda_bit();
                        self.received_data_interrupt().map_err(Error::Trigger)?;
                    }
                } else {
                    self.out.write_all(&[value]).map_err(Error::IOError)?;
                    self.out.flush().map_err(Error::IOError)?;
                    self.thr_empty_interrupt().map_err(Error::Trigger)?;
                }
            }
            // We want to enable only the interrupts that are available for 16550A (and below).
            IER_OFFSET => self.interrupt_enable = value & IER_UART_VALID_BITS,
            LCR_OFFSET => self.line_control = value,
            MCR_OFFSET => self.modem_control = value,
            SCR_OFFSET => self.scratch = value,
            // We are not interested in writing to other offsets (such as FCR offset).
            _ => {}
        }
        Ok(())
    }
pub fn write ( & mut self , offset : u8 , value : u8 ) -> Result < ( ) , Error < T :: E > > { match offset { DLAB_LOW_OFFSET if self . is_dlab_set ( ) => self . baud_divisor_low = value , DLAB_HIGH_OFFSET if self . is_dlab_set ( ) => self . baud_divisor_high = value , DATA_OFFSET => { if self . is_in_loop_mode ( ) { // In loopback mode, what is written in the transmit register // will be immediately found in the receive register, so we // simulate this behavior by adding in `in_buffer` the // transmitted bytes and letting the driver know there is some // pending data to be read, by setting RDA bit and its // corresponding interrupt. if self . in_buffer . len ( ) < FIFO_SIZE { self . in_buffer . push_back ( value ) ; self . set_lsr_rda_bit ( ) ; self . received_data_interrupt ( ) . map_err ( Error :: Trigger ) ? ; } } else { self . out . write_all ( & [ value ] ) . map_err ( Error :: IOError ) ? ; self . out . flush ( ) . map_err ( Error :: IOError ) ? ; self . thr_empty_interrupt ( ) . map_err ( Error :: Trigger ) ? ; } } // We want to enable only the interrupts that are available for 16550A (and below). IER_OFFSET => self . interrupt_enable = value & IER_UART_VALID_BITS , LCR_OFFSET => self . line_control = value , MCR_OFFSET => self . modem_control = value , SCR_OFFSET => self . scratch = value , // We are not interested in writing to other offsets (such as FCR offset). _ => { } } Ok ( ( ) ) }
Handles a write request from the driver at `offset` offset from the
base Port I/O address.
Handles a write request from the driver at ` offset ` offset from the base Port I / O address .
&mut self
offset
u8
value
u8
&mut self
offset
u8
value
u8
example
You can see an example of how to use this function in the
[`Example` section from `Serial`](struct.Serial.html#example).
You can see an example of how to use this function in the [ ` Example ` section from ` Serial ` ] ( struct . Serial . html#example ) .