Giter Club home page Giter Club logo

uart_16550's Introduction

uart_16550

Build Status Docs.rs Badge

Minimal support for serial communication through UART devices, which are compatible to the 16550 UART. This crate supports port-mapped and memory mapped UARTS.

Usage

Depending on the system architecture, the UART can be either accessed through port-mapped I/O or memory-mapped I/O.

With port-mappd 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();

With memory mapped serial port

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();

Crate Feature Flags

  • nightly: This is the default.
  • stable: Use this to build with non-nightly rust. Needs default-features = false.

Building with stable rust

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.

License

Licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT).

uart_16550's People

Contributors

dbeckwith avatar edigaryev avatar haraldh avatar imtsuki avatar josephlr avatar lachlansneff avatar olivercalder avatar phil-opp avatar remimimimimi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.