Skip to content

Commit 8fc7b9f

Browse files
committed
Update examples to the new crate versions
1 parent 456c302 commit 8fc7b9f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

microbit/src/05-led-roulette/light-it-up.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,17 @@ a look at it and then we can go through it step by step:
3838

3939
use cortex_m_rt::entry;
4040
use panic_halt as _;
41-
use microbit::board::Board;
42-
use microbit::hal::prelude::*;
41+
use microbit::{
42+
board::Board,
43+
hal::gpio::Level,
44+
};
4345

4446
#[entry]
4547
fn main() -> ! {
46-
let mut board = Board::take().unwrap();
48+
let board = Board::take().unwrap();
4749

48-
board.display_pins.col1.set_low().unwrap();
49-
board.display_pins.row1.set_high().unwrap();
50+
board.display_pins.col1.into_push_pull_output(Level::Low);
51+
board.display_pins.row1.into_push_pull_output(Level::High);
5052

5153
loop {}
5254
}
@@ -57,7 +59,7 @@ However, the main function looks pretty different to what we have seen up to now
5759

5860
The first line is related to how most HALs written in Rust work internally.
5961
As discussed before they are built on top of PAC crates which own (in the Rust sense)
60-
all the peripherals of a chip. `let mut board = Board::take().unwrap();` basically takes all
62+
all the peripherals of a chip. `let board = Board::take().unwrap();` basically takes all
6163
these peripherals from the PAC and binds them to a variable. In this specific case we are
6264
not only working with a HAL but with an entire BSP, so this also takes ownership
6365
of the Rust representation of the other chips on the board.
@@ -82,8 +84,8 @@ to the GDB stub:
8284
$ # Your GDB debug command from the last section
8385
(gdb) target remote :1337
8486
Remote debugging using :1337
85-
cortex_m_rt::Reset () at /home/nix/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-rt-0.6.12/src/lib.rs:489
86-
489 pub unsafe extern "C" fn Reset() -> ! {
87+
(...)
88+
0x00000100 in microbit_common::display::nonblocking::control::{impl#0}::initialise_for_display (self=0xaf0a8041)
8789
(gdb)
8890
```
8991

0 commit comments

Comments
 (0)