diff --git a/src/hello-world/02.00.UART.md b/src/hello-world/02.00.UART.md index 07e1058..f59112e 100644 --- a/src/hello-world/02.00.UART.md +++ b/src/hello-world/02.00.UART.md @@ -26,6 +26,9 @@ To read and write to the serial bus from your computer, you will need to configu ## Code ``` rust +use microbit::hal::prelude::*; +use microbit::hal::serial; +use microbit::hal::serial::BAUD115200; // -- snip -- if let Some(p) = microbit::Peripherals::take() { let mut gpio = p.GPIO.split(); @@ -33,6 +36,18 @@ if let Some(p) = microbit::Peripherals::take() { let tx = gpio.pin24.into_push_pull_output().downgrade(); let rx = gpio.pin25.into_floating_input().downgrade(); let (mut tx, _) = serial::Serial::uart0(p.UART0, tx, rx, BAUD115200).split(); - let _ = write!(tx, "\n\rStarting!\n\r"); + let _ = write!(tx, "serial test\n\r"); } ``` + +``` +Welcome to minicom 2.7.1 + +OPTIONS: I18n +Compiled on Jun 5 2018, 10:54:41. +Port /dev/ttyACM0, 19:50:57 + +Press CTRL-A Z for help on special keys + +serial test +``` diff --git a/src/hello-world/src/main.rs b/src/hello-world/src/main.rs index 2a987c1..2f18f5c 100644 --- a/src/hello-world/src/main.rs +++ b/src/hello-world/src/main.rs @@ -12,6 +12,10 @@ use core::fmt::Write; use rt::ExceptionFrame; use sh::hio; +use microbit::hal::prelude::*; +use microbit::hal::serial; +use microbit::hal::serial::BAUD115200; + exception!(HardFault, hard_fault); fn hard_fault(ef: &ExceptionFrame) -> ! { @@ -35,7 +39,7 @@ fn main() -> ! { let tx = gpio.pin24.into_push_pull_output().downgrade(); let rx = gpio.pin25.into_floating_input().downgrade(); let (mut tx, _) = serial::Serial::uart0(p.UART0, tx, rx, BAUD115200).split(); - let _ = write!(tx, "\n\rserial test\n\r"); + let _ = write!(tx, "serial test\n\r"); } panic!("test-panic");