@@ -7,7 +7,7 @@ use heapless::Vec;
77use panic_rtt_target as _;
88use rtic:: app;
99use rtt_target:: { rprintln, rtt_init_print} ;
10- use stm32l4xx_hal:: gpio:: { gpiob:: PB3 , Output , PushPull , State } ;
10+ use stm32l4xx_hal:: gpio:: { gpiob:: PB3 , Output , PushPull } ;
1111use stm32l4xx_hal:: prelude:: * ;
1212use systick_monotonic:: { fugit:: Duration , Systick } ;
1313
@@ -38,15 +38,14 @@ mod app {
3838 rtt_init_print ! ( ) ;
3939 rprintln ! ( "init" ) ;
4040
41- let _clocks = rcc. cfgr . sysclk ( 72 . mhz ( ) ) . freeze ( & mut flash. acr , & mut pwr) ;
41+ let _clocks = rcc. cfgr . sysclk ( 72 . MHz ( ) ) . freeze ( & mut flash. acr , & mut pwr) ;
4242
4343 // Setup LED
4444 let mut gpiob = cx. device . GPIOB . split ( & mut rcc. ahb2 ) ;
45- let led = gpiob. pb3 . into_push_pull_output_with_state (
46- & mut gpiob. moder ,
47- & mut gpiob. otyper ,
48- State :: Low ,
49- ) ;
45+ let mut led = gpiob
46+ . pb3
47+ . into_push_pull_output ( & mut gpiob. moder , & mut gpiob. otyper ) ;
48+ led. set_low ( ) ;
5049
5150 // Simple heart beat LED on/off sequence
5251 let mut intervals: Vec < u32 , 6 > = Vec :: new ( ) ;
@@ -76,16 +75,11 @@ mod app {
7675 let duration = cx. local . intervals [ state] ;
7776 let next_state = ( state + 1 ) % cx. local . intervals . len ( ) ;
7877
79- if state % 2 == 0 {
80- cx. local . led . set_high ( ) . unwrap ( ) ;
81- } else {
82- cx. local . led . set_low ( ) . unwrap ( ) ;
83- }
78+ cx. local . led . toggle ( ) ;
8479
85- blink:: spawn_after (
80+ let _ = blink:: spawn_after (
8681 Duration :: < u64 , 1 , 1000 > :: from_ticks ( duration as u64 ) ,
8782 next_state,
88- )
89- . unwrap ( ) ;
83+ ) ;
9084 }
9185}
0 commit comments