File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ no_main]
2
+ #![ no_std]
3
+
4
+ use panic_halt;
5
+
6
+ use stm32f0xx_hal as hal;
7
+
8
+ use crate :: hal:: prelude:: * ;
9
+ use crate :: hal:: stm32;
10
+ use crate :: hal:: time:: * ;
11
+ use crate :: hal:: timers:: * ;
12
+
13
+ use cortex_m_rt:: entry;
14
+ use nb:: block;
15
+
16
+ #[ entry]
17
+ fn main ( ) -> ! {
18
+ if let Some ( p) = stm32:: Peripherals :: take ( ) {
19
+ let gpioa = p. GPIOA . split ( ) ;
20
+ /* (Re-)configure PA1 as output */
21
+ let mut led = gpioa. pa1 . into_push_pull_output ( ) ;
22
+
23
+ /* Constrain clocking registers */
24
+ let rcc = p. RCC . constrain ( ) ;
25
+
26
+ /* Configure clock to 8 MHz (i.e. the default) and freeze it */
27
+ let clocks = rcc. cfgr . sysclk ( 8 . mhz ( ) ) . freeze ( ) ;
28
+
29
+ let mut timer = Timer :: tim1 ( p. TIM1 , Hertz ( 1 ) , clocks) ;
30
+
31
+ loop {
32
+ led. toggle ( ) ;
33
+ block ! ( timer. wait( ) ) . ok ( ) ;
34
+ }
35
+ }
36
+
37
+ loop {
38
+ continue ;
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments