Crates.io | uart_16550 |
lib.rs | uart_16550 |
version | |
source | src |
created_at | 2018-05-21 12:29:43.177159 |
updated_at | 2024-11-13 13:58:22.186041 |
description | Minimal support for uart_16550 serial output. |
homepage | |
repository | https://github.com/rust-osdev/uart_16550 |
max_upload_size | |
id | 66440 |
Cargo.toml error: | TOML parse error at line 21, column 1 | 21 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Minimal support for serial communication through UART devices, which are compatible to the 16550 UART. This crate supports I/O port-mapped (x86 only) and memory-mapped UARTS.
Depending on the system architecture, the UART can be either accessed through port-mapped I/O or memory-mapped I/O.
The UART is accessed through port-mapped I/O on architectures such as x86_64
. On these architectures, the SerialPort
type can be used:
use uart_16550::SerialPort;
const SERIAL_IO_PORT: u16 = 0x3F8;
let mut serial_port = unsafe { SerialPort::new(SERIAL_IO_PORT) };
serial_port.init();
// Now the serial port is ready to be used. To send a byte:
serial_port.send(42);
// To receive a byte:
let data = serial_port.receive();
Most other architectures, such as RISC-V, use memory-mapped I/O for accessing the UARTs. On these architectures, the MmioSerialPort
type can be used:
use uart_16550::MmioSerialPort;
const SERIAL_PORT_BASE_ADDRESS: usize = 0x1000_0000;
let mut serial_port = unsafe { MmioSerialPort::new(SERIAL_PORT_BASE_ADDRESS) };
serial_port.init();
// Now the serial port is ready to be used. To send a byte:
serial_port.send(42);
// To receive a byte:
let data = serial_port.receive();
This needs to have the compile-time requirements of the cc
crate installed on your system.
It was currently only tested on Linux and MacOS.
Licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT).