UartAddress

Trait UartAddress 

Source
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 fn constructor).

Required Methods§

Source

unsafe fn write(&self, register: WriteableRegister, value: u8)

Writes value to register.

§Safety
Source

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_PENDING bit. Because of this, any calling context that passes ReadableRegister::LineStatus should be &mut self, or otherwise exclusively alias the address that is being read from.

Implementors§