Skip to content

Commit d1eb768

Browse files
authored
Merge pull request #53 from phip1611/restructure
Improve documentation examples and streamline architecture support
2 parents 71d6582 + 8893849 commit d1eb768

File tree

9 files changed

+487
-386
lines changed

9 files changed

+487
-386
lines changed

.github/workflows/rust.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,15 @@ jobs:
9292
- run: rustup component add miri
9393
- run: cargo miri test --tests
9494

95+
# Style + documentation checks
9596
style_checks:
96-
runs-on: ubuntu-latest
97+
runs-on: "${{ matrix.runs-on }}"
9798
strategy:
9899
matrix:
100+
runs-on:
101+
- macos-latest # aarch64
102+
- ubuntu-latest # x86_64
103+
- windows-latest # x86_64
99104
rust:
100105
- stable
101106
steps:
@@ -113,3 +118,7 @@ jobs:
113118
run: cargo clippy --all-targets
114119
- name: Rustdoc
115120
run: cargo doc --no-deps --document-private-items
121+
- name: Rustdoc (doc_cfg + nightly)
122+
env:
123+
RUSTDOCFLAGS: --cfg docsrs
124+
run: cargo +nightly doc --no-deps --document-private-items

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ assert2 = { version = "0.4.0", default-features = false, features = [] }
3131
[features]
3232
default = []
3333
embedded-io = ["dep:embedded-io"]
34+
35+
[package.metadata.docs.rs]
36+
all-features = true
37+
rustdoc-args = ["--cfg", "docsrs"]

README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,24 @@ layer.
4646

4747
# Overview
4848

49-
Use `Uart16550Tty` for a quick start. For more fine-grained low-level
50-
control, please have a look at `Uart16550` instead.
49+
Use `Uart16550Tty` for a quick start to write to a terminal via your serial
50+
connection. For more fine-grained low-level control, please have a look at
51+
`Uart16550` instead.
5152

52-
# Example (Minimalistic)
53+
# Example (Minimal - x86 Port IO)
54+
55+
```rust
56+
use uart_16550::{Config, Uart16550Tty};
57+
use core::fmt::Write;
58+
59+
fn main() {
60+
// SAFETY: The port is valid and we have exclusive access.
61+
let mut uart = unsafe { Uart16550Tty::new_port(0x3f8, Config::default()).expect("should initialize device") };
62+
uart.write_str("hello world\nhow's it going?");
63+
}
64+
```
65+
66+
# Example (Minimal - MMIO)
5367

5468
```rust
5569
use uart_16550::{Config, Uart16550Tty};
@@ -58,7 +72,6 @@ use core::fmt::Write;
5872
fn main() {
5973
// SAFETY: The address is valid and we have exclusive access.
6074
let mut uart = unsafe { Uart16550Tty::new_mmio(0x1000 as *mut _, 4, Config::default()).expect("should initialize device") };
61-
// ^ or `new_port(0x3f8, Config::default())`
6275
uart.write_str("hello world\nhow's it going?");
6376
}
6477
```
@@ -74,6 +87,7 @@ fn main() {
7487
// ^ or `new_port(0x3f8)`
7588
uart.init(Config::default()).expect("should init device successfully");
7689
uart.test_loopback().expect("should have working loopback mode");
90+
// Note: Might fail on real hardware with some null-modem cables
7791
uart.check_connected().expect("should have physically connected receiver");
7892
uart.send_bytes_exact(b"hello world!");
7993
}

0 commit comments

Comments
 (0)