#uart #baremetal #raspberrypi #RusPiRo

nightly no-std ruspiro-uart

Simple and convinient access API to the Raspberry Pi 3 UART0 (PL011) and UART1 (miniUART) peripherals

5 releases (3 breaking)

new 0.3.1 Sep 13, 2020
0.3.0 Dec 14, 2019
0.2.0 Aug 31, 2019
0.1.0 Aug 4, 2019
0.0.3 Jul 30, 2019

#87 in No standard library

Download history 11/week @ 2020-05-27 11/week @ 2020-06-03 3/week @ 2020-06-10 8/week @ 2020-06-17 2/week @ 2020-06-24 11/week @ 2020-07-01 8/week @ 2020-07-08 7/week @ 2020-07-15 17/week @ 2020-07-22 2/week @ 2020-07-29 16/week @ 2020-08-05 15/week @ 2020-08-12 16/week @ 2020-08-19 17/week @ 2020-08-26 36/week @ 2020-09-02 47/week @ 2020-09-09

53 downloads per month
Used in 2 crates


452 lines

UART RusPiRo crate

This crate provides access to the Uart0(Pl011) and Uart1 (miniUART) peripheral of the Raspberry Pi. This 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 and blinking LEDs are not sufficient.

Travis-CI Status Latest Version Documentation License


To use the crate just add the following dependency to your Cargo.toml file:

ruspiro-uart = "0.3"

Once done the access to the UART abstraction is available in your rust files like so:

use ruspiro_uart::Uart1;

fn demo() {
    let mut uart = Uart1::new();
    if uart.initialize(250_000_000, 115_200).is_ok() {
        uart.send_string("This is some string");

In this example the Uart1 will be no longer be available once it goes out of scope. Whichs makes it a bit cumbersome to use it in a real world example. Therefore the proposed usage of the UART is to use it as a generic console output channel. 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 only 1 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 for details.). This mailbox crate is not linked into the Uart crate to ensure usability of this crate with as less dependencies as possible.

use ruspiro_singleton::Singleton; // don't forget the dependency to be setup
use ruspiro_uart::Uart1;

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

fn demo() {
    let _ = UART.take_for(|uart| uart.initialize(250_000_000, 115_200)).expect("unable to init uart1");

    print_something("Hello Uart...");

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


Licensed under Apache License, Version 2.0, (LICENSE or http://www.apache.org/licenses/LICENSE-2.0)


~42K SLoC