kernel::bsp::device_driver::bcm::bcm2xxx_pl011_uart

Struct PL011UartInner

Source
struct PL011UartInner {
    registers: MMIODerefWrapper<RegisterBlock>,
    chars_written: usize,
    chars_read: usize,
}

Fields§

§registers: MMIODerefWrapper<RegisterBlock>§chars_written: usize§chars_read: usize

Implementations§

Source§

impl PL011UartInner

Create an instance.

§Safety

  • The user must ensure to provide a correct MMIO start address.
Source

pub const unsafe fn new(mmio_start_addr: usize) -> Self

Source

pub fn init(&mut self)

Set up baud rate and characteristics.

This result in 8N1 and 921_600 baud.

The calculation for the BRD is (we set the clock to 48 MHz in config.txt): (48_000_000 / 16) / 921_600 = 3.2552083.

This means the integer part is 3 and goes into the IBRD. The fractional part is 0.2552083.

FBRD calculation according to the PL011 Technical Reference Manual: INTEGER((0.2552083 * 64) + 0.5) = 16.

Therefore, the generated baud rate divdier is: 3 + 16/64 = 3.25. Which results in a generated baud rate of 48_000_000 / (16 * 3.25) = 923_077.

Error = ((923_077 - 921_600) / 921_600) * 100 = 0.16%.

Source

fn write_char(&mut self, c: char)

Send a character.

Source

fn flush(&self)

Block execution until the last bufferred character has been physically put on the TX wire.

Source

fn read_char_converting(&mut self, blocking_mode: BlockingMode) -> Option<char>

Retrieve a character.

Trait Implementations§

Source§

impl Write for PL011UartInner

Implementing core::fmt::Write enables usage of the format_args! macros, which in turn are used to implement the kernel’s print! and println! macros. By implementing write_str(), we get write_fmt() automatically.

The function takes an &mut self, so it must be implemented for the inner struct.

See src/print.rs.

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
1.1.0 · Source§

fn write_char(&mut self, c: char) -> Result<(), Error>

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.