Skip to content

Commit 81d61d9

Browse files
committed
Fix documentation
1 parent f579774 commit 81d61d9

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Minimal support for uart_16550 serial and memory mapped I/O.
66

77
## Usage
88

9-
### With `port_{stable, nightly}` feature
9+
### With usual serial port
1010

1111
```rust
1212
use uart_16550::SerialPort;
@@ -23,7 +23,7 @@ serial_port.send(42);
2323
let data = serial_port.receive();
2424
```
2525

26-
### With `mmio_{stable, nightly}` feature
26+
### With memory mapped serial port
2727

2828
```rust
2929
use uart_16550::MmioSerialPort;
@@ -46,10 +46,8 @@ Licensed under the MIT license ([LICENSE](LICENSE) or <http://opensource.org/lic
4646

4747
## Crate Feature Flags
4848

49-
* `port_nightly`: This is the default.
50-
* `port_stable`: Use this to build with non-nightly rust. Needs `default-features = false`.
51-
* `mmio_nightly`: Use this to initialize serial port through memory mapped I/O.
52-
* `mmio_stable`: Use this to build with non-nightly rust. Needs `default-features = false`.
49+
* `nightly`: This is the default.
50+
* `stable`: Use this to build with non-nightly rust. Needs `default-features = false`.
5351

5452
## Building with stable rust
5553

src/lib.rs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,36 @@
11
//! Minimal support for uart_16550 serial I/O.
22
//!
33
//! # 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
2227
//!
2328
//! ```rust
2429
//! use uart_16550::MmioSerialPort;
2530
//!
26-
//! const SERIAL_IO_PORT: usize = 0x1000_0000;
31+
//! const SERIAL_PORT_BASE_ADDRESS: usize = 0x1000_0000;
2732
//!
28-
//! let mut serial_port = unsafe { SerialPort::new(SERIAL_IO_PORT) };
33+
//! let mut serial_port = unsafe { MmioSerialPort::new(SERIAL_PORT_BASE_ADDRESS) };
2934
//! serial_port.init();
3035
//!
3136
//! // Now the serial port is ready to be used. To send a byte:
@@ -34,7 +39,6 @@
3439
//! // To receive a byte:
3540
//! let data = serial_port.receive();
3641
//! ```
37-
3842
#![no_std]
3943
#![warn(missing_docs)]
4044
#![cfg_attr(feature = "nightly", feature(const_ptr_offset))]

0 commit comments

Comments
 (0)