|
1 | 1 | //! Minimal support for uart_16550 serial I/O. |
2 | 2 | //! |
3 | 3 | //! # Usage |
4 | | -//! ## With `port_{stable, nightly}` feature |
5 | | -//! |
6 | | -//! ```rust |
7 | | -//! use uart_16550::SerialPort; |
8 | | -//! |
9 | | -//! const SERIAL_IO_PORT: u16 = 0x3F8; |
10 | | -//! |
11 | | -//! let mut serial_port = unsafe { SerialPort::new(SERIAL_IO_PORT) }; |
12 | | -//! serial_port.init(); |
13 | | -//! |
14 | | -//! // Now the serial port is ready to be used. To send a byte: |
15 | | -//! serial_port.send(42); |
16 | | -//! |
17 | | -//! // To receive a byte: |
18 | | -//! let data = serial_port.receive(); |
19 | | -//! ``` |
20 | | -//! |
21 | | -//! ## With `mmio_{stable, nightly}` feature |
| 4 | +
|
| 5 | +#![cfg_attr( |
| 6 | + target_arch = "x86_64", |
| 7 | + doc = " |
| 8 | +## With usual serial port |
| 9 | +```rust |
| 10 | +use uart_16550::SerialPort; |
| 11 | +
|
| 12 | +const SERIAL_IO_PORT: u16 = 0x3F8; |
| 13 | +
|
| 14 | +let mut serial_port = unsafe { SerialPort::new(SERIAL_IO_PORT) }; |
| 15 | +serial_port.init(); |
| 16 | +
|
| 17 | +// Now the serial port is ready to be used. To send a byte: |
| 18 | +serial_port.send(42); |
| 19 | +
|
| 20 | +// To receive a byte: |
| 21 | +let data = serial_port.receive(); |
| 22 | +``` |
| 23 | +" |
| 24 | +)] |
| 25 | + |
| 26 | +//! ## With memory mapped serial port |
22 | 27 | //! |
23 | 28 | //! ```rust |
24 | 29 | //! use uart_16550::MmioSerialPort; |
25 | 30 | //! |
26 | | -//! const SERIAL_IO_PORT: usize = 0x1000_0000; |
| 31 | +//! const SERIAL_PORT_BASE_ADDRESS: usize = 0x1000_0000; |
27 | 32 | //! |
28 | | -//! let mut serial_port = unsafe { SerialPort::new(SERIAL_IO_PORT) }; |
| 33 | +//! let mut serial_port = unsafe { MmioSerialPort::new(SERIAL_PORT_BASE_ADDRESS) }; |
29 | 34 | //! serial_port.init(); |
30 | 35 | //! |
31 | 36 | //! // Now the serial port is ready to be used. To send a byte: |
|
34 | 39 | //! // To receive a byte: |
35 | 40 | //! let data = serial_port.receive(); |
36 | 41 | //! ``` |
37 | | -
|
38 | 42 | #![no_std] |
39 | 43 | #![warn(missing_docs)] |
40 | 44 | #![cfg_attr(feature = "nightly", feature(const_ptr_offset))] |
|
0 commit comments