@@ -5,7 +5,7 @@ In this chapter we are going to make one of the many LEDs on the back of the mic
5
5
basically the "Hello World" of embedded programming. In order to get this task done we will use one of the traits
6
6
provided by ` embedded-hal ` , specifically the [ ` OutputPin ` ] trait which allows us to turn a pin on or off.
7
7
8
- [ `OutputPin` ] : https://docs.rs/embedded-hal/0.2.6 /embedded_hal/digital/v2 /trait.OutputPin.html
8
+ [ `OutputPin` ] : https://docs.rs/embedded-hal/1.0.0 /embedded_hal/digital/trait.OutputPin.html
9
9
10
10
## The micro: bit LEDs
11
11
@@ -37,18 +37,16 @@ a look at it and then we can go through it step by step:
37
37
#![no_std]
38
38
39
39
use cortex_m_rt :: entry;
40
+ use embedded_hal :: digital :: OutputPin ;
40
41
use panic_halt as _;
41
- use microbit :: {
42
- board :: Board ,
43
- hal :: gpio :: Level ,
44
- };
42
+ use microbit :: board :: Board ,
45
43
46
44
#[entry]
47
45
fn main() -> ! {
48
- let board = Board :: take (). unwrap ();
46
+ let mut board = Board :: take(). unwrap();
49
47
50
- board . display_pins. col1. into_push_pull_output ( Level :: Low );
51
- board . display_pins. row1. into_push_pull_output ( Level :: High );
48
+ board . display_pins. col1. set_low () . unwrap ( );
49
+ board . display_pins. row1. set_high () . unwrap ( );
52
50
53
51
loop {}
54
52
}
@@ -59,7 +57,7 @@ However, the main function looks pretty different to what we have seen up to now
59
57
60
58
The first line is related to how most HALs written in Rust work internally.
61
59
As discussed before they are built on top of PAC crates which own (in the Rust sense)
62
- all the peripherals of a chip. ` let board = Board::take().unwrap(); ` basically takes all
60
+ all the peripherals of a chip. ` let mut board = Board::take().unwrap(); ` basically takes all
63
61
these peripherals from the PAC and binds them to a variable. In this specific case we are
64
62
not only working with a HAL but with an entire BSP, so this also takes ownership
65
63
of the Rust representation of the other chips on the board.
0 commit comments