1
1
#![ deny( warnings) ] // This code runs on stm32h747i-disco and does not use example! macro.
2
- #![ allow( unused_macros) ]
2
+ #![ allow( unused_macros) ]
3
3
#![ no_main]
4
4
#![ no_std]
5
5
@@ -16,45 +16,45 @@ fn main() -> ! {
16
16
utilities:: logger:: init ( ) ;
17
17
let cp = cortex_m:: Peripherals :: take ( ) . unwrap ( ) ;
18
18
let dp = pac:: Peripherals :: take ( ) . unwrap ( ) ;
19
-
19
+
20
20
// Constrain and Freeze power
21
21
info ! ( "Setup PWR... " ) ;
22
22
let pwr = dp. PWR . constrain ( ) ;
23
23
// let pwrcfg = example_power!(pwr).freeze();
24
24
let pwrcfg = pwr. smps ( ) . freeze ( ) ; // This code works normally on stm32h747i-disco.
25
-
25
+
26
26
// Constrain and Freeze clock
27
27
// RCC (Reset and Clock Control)
28
28
info ! ( "Setup RCC... " ) ;
29
29
let rcc = dp. RCC . constrain ( ) ;
30
-
30
+
31
31
// CCDR (Core Clock Distribution and Reset)
32
32
// link: https://docs.rs/stm32h7xx-hal/latest/stm32h7xx_hal/rcc/struct.Ccdr.html
33
33
let ccdr = rcc. sys_ck ( 100 . MHz ( ) ) . freeze ( pwrcfg, & dp. SYSCFG ) ;
34
-
34
+
35
35
info ! ( "" ) ;
36
36
info ! ( "stm32h7xx-hal example - Blinky" ) ;
37
37
info ! ( "" ) ;
38
-
38
+
39
39
let gpioi = dp. GPIOI . split ( ccdr. peripheral . GPIOI ) ; // <= GPIO settings for LEDs
40
-
40
+
41
41
// Configure gpio pins as output.
42
42
let mut led1 = gpioi. pi12 . into_push_pull_output ( ) ; // PI12 for LED1
43
43
let mut led2 = gpioi. pi13 . into_push_pull_output ( ) ; // PI13 for LED2
44
44
let mut led3 = gpioi. pi14 . into_push_pull_output ( ) ; // PI14 for LED3
45
45
let mut led4 = gpioi. pi15 . into_push_pull_output ( ) ; // PI15 for LED4
46
-
46
+
47
47
// Get the delay provider.
48
48
let mut delay = cp. SYST . delay ( ccdr. clocks ) ;
49
-
49
+
50
50
loop {
51
51
loop {
52
52
led1. set_high ( ) ;
53
53
led2. set_low ( ) ;
54
54
led3. set_high ( ) ;
55
55
led4. set_low ( ) ;
56
56
delay. delay_ms ( 500_u16 ) ;
57
-
57
+
58
58
led1. set_low ( ) ;
59
59
led2. set_high ( ) ;
60
60
led3. set_low ( ) ;
0 commit comments