@@ -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\ n how's it going?" );
63+ }
64+ ```
65+
66+ # Example (Minimal - MMIO)
5367
5468``` rust
5569use uart_16550 :: {Config , Uart16550Tty };
@@ -58,7 +72,6 @@ use core::fmt::Write;
5872fn 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\ n how'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