File tree Expand file tree Collapse file tree 4 files changed +545
-11
lines changed Expand file tree Collapse file tree 4 files changed +545
-11
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ nb = "0.1.1"
17
17
stm32g4 = " 0.13.0"
18
18
paste = " 1.0"
19
19
20
+ [dependencies .cast ]
21
+ version = " 0.2.7"
22
+ default-features = false
23
+
20
24
[dependencies .bare-metal ]
21
25
features = [" const-fn" ]
22
26
version = " 0.2.5"
Original file line number Diff line number Diff line change 3
3
#![ no_main]
4
4
#![ no_std]
5
5
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
-
6
+ use hal:: delay:: DelayFromCountDownTimer ;
11
7
use hal:: prelude:: * ;
12
8
use hal:: rcc:: Config ;
13
9
use hal:: stm32;
14
- use rt:: entry;
10
+ use hal:: timer:: Timer ;
11
+ use stm32g4xx_hal as hal;
12
+
13
+ use cortex_m_rt:: entry;
14
+ use log:: info;
15
+
16
+ #[ macro_use]
17
+ mod utils;
15
18
16
19
#[ entry]
17
20
fn main ( ) -> ! {
21
+ utils:: logger:: init ( ) ;
22
+
23
+ info ! ( "start" ) ;
18
24
let dp = stm32:: Peripherals :: take ( ) . expect ( "cannot take peripherals" ) ;
19
25
let cp = cortex_m:: Peripherals :: take ( ) . expect ( "cannot take core peripherals" ) ;
20
26
let mut rcc = dp. RCC . freeze ( Config :: hsi ( ) ) ;
21
27
22
- let gpiob = dp. GPIOB . split ( & mut rcc) ;
23
- let mut led = gpiob. pb8 . into_push_pull_output ( ) ;
28
+ info ! ( "Init Led" ) ;
29
+ let gpioa = dp. GPIOA . split ( & mut rcc) ;
30
+ let mut led = gpioa. pa5 . into_push_pull_output ( ) ;
31
+
32
+ info ! ( "Init SYST delay" ) ;
33
+ let mut delay_syst = cp. SYST . delay ( & rcc. clocks ) ;
24
34
25
- let mut delay = cp. SYST . delay ( & rcc. clocks ) ;
35
+ info ! ( "Init Timer2 delay" ) ;
36
+ let timer2 = Timer :: new ( dp. TIM2 , & rcc. clocks ) ;
37
+ let mut delay_tim2 = DelayFromCountDownTimer :: new ( timer2. start_count_down ( 100 . ms ( ) ) ) ;
26
38
27
39
loop {
40
+ info ! ( "Toggle" ) ;
41
+ led. toggle ( ) . unwrap ( ) ;
42
+ info ! ( "SYST delay" ) ;
43
+ delay_syst. delay ( 1000 . ms ( ) ) ;
44
+ info ! ( "Toggle" ) ;
28
45
led. toggle ( ) . unwrap ( ) ;
29
- delay. delay ( 500 . ms ( ) ) ;
46
+ info ! ( "TIM2 delay" ) ;
47
+ delay_tim2. delay_ms ( 1000_u16 ) ;
30
48
}
31
49
}
Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ pub extern crate stm32g4;
31
31
32
32
pub use nb:: block;
33
33
34
+ mod sealed {
35
+ pub trait Sealed { }
36
+ }
37
+ pub ( crate ) use sealed:: Sealed ;
38
+
34
39
#[ cfg( feature = "stm32g431" ) ]
35
40
pub use stm32g4:: stm32g431 as stm32;
36
41
@@ -76,5 +81,5 @@ pub mod signature;
76
81
// pub mod stopwatch;
77
82
pub mod syscfg;
78
83
pub mod time;
79
- // pub mod timer;
84
+ pub mod timer;
80
85
// pub mod watchdog;
You can’t perform that action at this time.
0 commit comments