@@ -7,14 +7,23 @@ use panic_rtt_target as _;
7
7
mod app {
8
8
use dwt_systick_monotonic:: DwtSystick ;
9
9
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
+ } ;
12
15
13
16
#[ monotonic( binds = SysTick , default = true ) ]
14
17
type DwtMono = DwtSystick < 48_000_000 > ;
15
18
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 > > ;
18
27
#[ resources]
19
28
struct Resources {
20
29
serial : SerialType ,
@@ -39,7 +48,9 @@ mod app {
39
48
// Initialize the peripherals
40
49
// DIR
41
50
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 ) ;
43
54
dir. set_low ( ) . unwrap ( ) ;
44
55
45
56
// SERIAL
@@ -53,14 +64,20 @@ mod app {
53
64
. into_af7_push_pull ( & mut gpioa. moder , & mut gpioa. otyper , & mut gpioa. afrh ) ,
54
65
) ;
55
66
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
+ ) ;
57
74
serial. listen ( Event :: Rxne ) ;
58
75
59
76
rprintln ! ( "post init" ) ;
60
77
61
78
task1:: spawn ( ) . unwrap ( ) ;
62
79
63
- ( init:: LateResources { serial , dir} , init:: Monotonics ( mono) )
80
+ ( init:: LateResources { dir, serial } , init:: Monotonics ( mono) )
64
81
}
65
82
66
83
#[ task( binds = USART1_EXTI25 , resources = [ serial, dir] ) ]
@@ -77,7 +94,7 @@ mod app {
77
94
Ok ( byte) => {
78
95
serial. write ( byte) . unwrap ( ) ;
79
96
serial. listen ( Event :: Tc ) ;
80
- } ,
97
+ }
81
98
Err ( _error) => rprintln ! ( "irq error" ) ,
82
99
} ;
83
100
}
@@ -86,11 +103,11 @@ mod app {
86
103
dir. set_low ( ) . unwrap ( ) ;
87
104
serial. unlisten ( Event :: Tc ) ;
88
105
serial. listen ( Event :: Rxne ) ;
89
- }
106
+ }
90
107
} )
91
108
} ) ;
92
109
}
93
-
110
+
94
111
#[ task]
95
112
fn task1 ( _cx : task1:: Context ) {
96
113
rprintln ! ( "task1" ) ;
0 commit comments