fix hello-world not building

This commit is contained in:
Michael Droogleever
2018-07-21 23:42:24 +02:00
parent 2150659783
commit 9ec744b942
2 changed files with 21 additions and 2 deletions

View File

@@ -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
```

View File

@@ -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");