@@ -7,14 +7,23 @@ use panic_rtt_target as _;
77mod app {
88 use dwt_systick_monotonic:: DwtSystick ;
99 use rtt_target:: { rprintln, rtt_init_print} ;
10- use stm32f3xx_hal:: { prelude:: * , serial:: { Event , Serial } } ;
11- use stm32f3xx_hal:: gpio:: { self , Output , PushPull , Alternate , U } ;
10+ use stm32f3xx_hal:: {
11+ gpio:: { self , Output , PushPull , AF7 } ,
12+ prelude:: * ,
13+ serial:: { Event , Serial } ,
14+ } ;
1215
1316 #[ monotonic( binds = SysTick , default = true ) ]
1417 type DwtMono = DwtSystick < 48_000_000 > ;
1518
16- type SerialType = Serial < stm32f3xx_hal:: pac:: USART1 , ( gpio:: Pin < gpio:: Gpioa , U < 9_u8 > , Alternate < PushPull , 7_u8 > > , gpio:: Pin < gpio:: Gpioa , U < 10_u8 > , Alternate < PushPull , 7_u8 > > ) > ;
17- type DirType = stm32f3xx_hal:: gpio:: Pin < gpio:: Gpioe , U < 13_u8 > , Output < PushPull > > ;
19+ type SerialType = Serial <
20+ stm32f3xx_hal:: pac:: USART1 ,
21+ (
22+ gpio:: gpioa:: PA9 < AF7 < PushPull > > ,
23+ gpio:: gpioa:: PA10 < AF7 < PushPull > > ,
24+ ) ,
25+ > ;
26+ type DirType = stm32f3xx_hal:: gpio:: gpioe:: PE13 < Output < PushPull > > ;
1827 #[ resources]
1928 struct Resources {
2029 serial : SerialType ,
@@ -39,7 +48,9 @@ mod app {
3948 // Initialize the peripherals
4049 // DIR
4150 let mut gpioe = cx. device . GPIOE . split ( & mut rcc. ahb ) ;
42- let mut dir : DirType = gpioe. pe13 . into_push_pull_output ( & mut gpioe. moder , & mut gpioe. otyper ) ;
51+ let mut dir: DirType = gpioe
52+ . pe13
53+ . into_push_pull_output ( & mut gpioe. moder , & mut gpioe. otyper ) ;
4354 dir. set_low ( ) . unwrap ( ) ;
4455
4556 // SERIAL
@@ -53,14 +64,20 @@ mod app {
5364 . into_af7_push_pull ( & mut gpioa. moder , & mut gpioa. otyper , & mut gpioa. afrh ) ,
5465 ) ;
5566 pins. 1 . internal_pull_up ( & mut gpioa. pupdr , true ) ;
56- let mut serial: SerialType = Serial :: usart1 ( cx. device . USART1 , pins, 19200_u32 . Bd ( ) , clocks, & mut rcc. apb2 ) ;
67+ let mut serial: SerialType = Serial :: usart1 (
68+ cx. device . USART1 ,
69+ pins,
70+ 19200_u32 . Bd ( ) ,
71+ clocks,
72+ & mut rcc. apb2 ,
73+ ) ;
5774 serial. listen ( Event :: Rxne ) ;
5875
5976 rprintln ! ( "post init" ) ;
6077
6178 task1:: spawn ( ) . unwrap ( ) ;
6279
63- ( init:: LateResources { serial , dir} , init:: Monotonics ( mono) )
80+ ( init:: LateResources { dir, serial } , init:: Monotonics ( mono) )
6481 }
6582
6683 #[ task( binds = USART1_EXTI25 , resources = [ serial, dir] ) ]
@@ -77,7 +94,7 @@ mod app {
7794 Ok ( byte) => {
7895 serial. write ( byte) . unwrap ( ) ;
7996 serial. listen ( Event :: Tc ) ;
80- } ,
97+ }
8198 Err ( _error) => rprintln ! ( "irq error" ) ,
8299 } ;
83100 }
@@ -86,11 +103,11 @@ mod app {
86103 dir. set_low ( ) . unwrap ( ) ;
87104 serial. unlisten ( Event :: Tc ) ;
88105 serial. listen ( Event :: Rxne ) ;
89- }
106+ }
90107 } )
91108 } ) ;
92109 }
93-
110+
94111 #[ task]
95112 fn task1 ( _cx : task1:: Context ) {
96113 rprintln ! ( "task1" ) ;
0 commit comments