File tree Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Expand file tree Collapse file tree 2 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -69,3 +69,7 @@ codegen-units = 1 # better optimizations
69
69
debug = true # symbols are nice and they don't increase the size in flash
70
70
lto = true # better optimizations
71
71
opt-level = " s" # optimize for binary size
72
+
73
+ [[example ]]
74
+ name = " blinky"
75
+ required-features = [" stm32h503" ]
Original file line number Diff line number Diff line change
1
+ #![ deny( warnings) ]
1
2
#![ no_main]
2
3
#![ no_std]
3
4
@@ -6,7 +7,7 @@ mod utilities;
6
7
use cortex_m_rt:: entry;
7
8
use embedded_hal:: delay:: DelayNs ;
8
9
use fugit:: SecsDurationU32 ;
9
- use stm32h5xx_hal:: { delay:: Delay , pac, prelude:: * , rcc :: ResetEnable } ;
10
+ use stm32h5xx_hal:: { delay:: Delay , pac, prelude:: * } ;
10
11
11
12
#[ entry]
12
13
fn main ( ) -> ! {
@@ -22,20 +23,18 @@ fn main() -> ! {
22
23
let rcc = dp. RCC . constrain ( ) ;
23
24
let ccdr = rcc. sys_ck ( 250 . MHz ( ) ) . freeze ( pwrcfg, & dp. SBS ) ;
24
25
25
- ccdr. peripheral . GPIOA . enable ( ) ;
26
-
27
- dp. GPIOA . moder ( ) . write ( |w| w. mode5 ( ) . output ( ) ) ; // output
28
- dp. GPIOA . pupdr ( ) . write ( |w| w. pupd5 ( ) . pull_up ( ) ) ; // pull-up
26
+ let gpioa = dp. GPIOA . split ( ccdr. peripheral . GPIOA ) ;
27
+ let mut led = gpioa. pa5 . into_push_pull_output ( ) ;
29
28
30
29
let mut delay = Delay :: new ( cp. SYST , & ccdr. clocks ) ;
31
30
let duration = SecsDurationU32 :: secs ( 1 ) . to_millis ( ) ;
32
31
33
32
loop {
34
- dp. GPIOA . odr ( ) . write ( |w| w. od5 ( ) . low ( ) ) ;
35
- delay. delay_ms ( duration) ;
33
+ led. set_low ( ) ;
36
34
log:: info!( "Off" ) ;
37
- dp. GPIOA . odr ( ) . write ( |w| w. od5 ( ) . high ( ) ) ;
38
35
delay. delay_ms ( duration) ;
36
+ led. set_high ( ) ;
39
37
log:: info!( "On" ) ;
38
+ delay. delay_ms ( duration) ;
40
39
}
41
40
}
You can’t perform that action at this time.
0 commit comments