@@ -38,15 +38,17 @@ a look at it and then we can go through it step by step:
38
38
39
39
use cortex_m_rt :: entry;
40
40
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
+ };
43
45
44
46
#[entry]
45
47
fn main () -> ! {
46
- let mut board = Board :: take (). unwrap ();
48
+ let board = Board :: take (). unwrap ();
47
49
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 );
50
52
51
53
loop {}
52
54
}
@@ -57,7 +59,7 @@ However, the main function looks pretty different to what we have seen up to now
57
59
58
60
The first line is related to how most HALs written in Rust work internally.
59
61
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
61
63
these peripherals from the PAC and binds them to a variable. In this specific case we are
62
64
not only working with a HAL but with an entire BSP, so this also takes ownership
63
65
of the Rust representation of the other chips on the board.
@@ -82,8 +84,8 @@ to the GDB stub:
82
84
$ # Your GDB debug command from the last section
83
85
(gdb) target remote :1337
84
86
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)
87
89
(gdb)
88
90
```
89
91
0 commit comments