Skip to content

Commit 040e5ae

Browse files
Luctiusluctius
authored andcommitted
examples/blinky: Fix led pin and update to use logging framework
1 parent 68a6ab0 commit 040e5ae

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

examples/blinky.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,35 @@
33
#![no_main]
44
#![no_std]
55

6-
extern crate cortex_m;
7-
extern crate cortex_m_rt as rt;
8-
extern crate panic_halt;
9-
extern crate stm32g4xx_hal as hal;
10-
116
use hal::prelude::*;
127
use hal::stm32;
13-
use rt::entry;
8+
use stm32g4xx_hal as hal;
9+
10+
use cortex_m_rt::entry;
11+
use log::info;
12+
13+
#[macro_use]
14+
mod utils;
1415

1516
#[entry]
1617
fn main() -> ! {
18+
utils::logger::init();
19+
20+
info!("start");
1721
let dp = stm32::Peripherals::take().expect("cannot take peripherals");
1822
let mut rcc = dp.RCC.constrain();
19-
let gpiob = dp.GPIOB.split(&mut rcc);
20-
let mut led = gpiob.pb8.into_push_pull_output();
23+
24+
info!("Init Led");
25+
let gpioa = dp.GPIOA.split(&mut rcc);
26+
let mut led = gpioa.pa5.into_push_pull_output();
2127

2228
loop {
23-
for _ in 0..1_000_000 {
29+
info!("Set Led low");
30+
for _ in 0..100_000 {
2431
led.set_low().unwrap();
2532
}
26-
for _ in 0..1_000_000 {
33+
info!("Set Led High");
34+
for _ in 0..100_000 {
2735
led.set_high().unwrap();
2836
}
2937
}

0 commit comments

Comments
 (0)