[][src]Crate ruspiro_uart

UART API for Raspberry Pi

This crate provides access to the Uart0 (PL011) and the Uart1 (miniUART) peripheral of the Raspberry Pi. It is quite helpful during bare metal development to use a terminal console connected to the miniUART of the Raspberry Pi to get some debug information printed while the program is executed on the device. Especialy if the program is in a state where there is no other output option or blinking LEDs are not sufficient.


The proposed usage of the UART is to attach it to a generic console as an output channel instead of using it directly. To do so, please refer to the ruspiro-console crate.

But in case you would like to use the uart without the console abstraction it is recommended to wrap it into a singleton to guaranty safe cross core access and ensure only one time initialization. In the example we pass a fixed core clock rate to the initialization function. However, the real core clock rate could be optained with a call to the mailbox property tag interface of the Raspberry Pi (see ruspiro-mailbox crate for details.).

This example is not tested
use ruspiro_singleton::Singleton; // don't forget the dependency to be setup in ``Cargo.toml``
use ruspiro_uart::Uart1;

static UART: Singleton<Uart1> = Singleton::new(Uart1::new());

fn main() {
    let _ = UART.take_for(|uart| uart.initialize(250_000_000, 115_200));
    // initialize(...) gives a [Result], you may want to panic if there is an Error returned.

    print_something("Hello Uart...");

fn print_something(s: &str) {
    UART.take_for(|uart| uart.send_string(s));



Uart0 (Pl011) API


Uart1 (miniUart) API



Uart0 peripheral representation


Uart1 (miniUART) peripheral representation



The different types of interrupts that can be raised from an Uart peripheral.