pub unsafe trait UartAddress {
// Required methods
unsafe fn write(&self, register: WriteableRegister, value: u8);
unsafe fn read(&self, register: ReadableRegister) -> u8;
}Expand description
Represents an address type for a UART device, allowing idiomatic access to register addresses, and allowing any number of constraints to be encoded based on the hardware implemenation of the UART IO (whether port or memory mapped).
§Safety
- The type implementing this trait should only be constructed with a valid UART base
address (this may be a safety invariant on an
unsafe fnconstructor).
Required Methods§
Sourceunsafe fn write(&self, register: WriteableRegister, value: u8)
unsafe fn write(&self, register: WriteableRegister, value: u8)
Writes value to register.
§Safety
- Writing
valueto the providedregisterhas the potential to change the value of other registers. For instance, writingFifoControl::CLEAR_TXwill change the contents of (in this case, zero out)WriteableRegister::TransmitterHolding.
Sourceunsafe fn read(&self, register: ReadableRegister) -> u8
unsafe fn read(&self, register: ReadableRegister) -> u8
Reads a raw u8 from register.
§Safety
- Reading a value from certain registers will affect the contents of others.
For instance, reading the line status will always clear the
InterruptStatus::INTERRUPT_PENDINGbit. Because of this, any calling context that passesReadableRegister::LineStatusshould be&mut self, or otherwise exclusively alias the address that is being read from.