@@ -9,7 +9,7 @@ use embedded_hal_02 as hal;
9
9
pub use hal:: Direction ;
10
10
11
11
use crate :: rcc:: Clocks ;
12
- use crate :: timer:: { InputPins , Timer } ;
12
+ use crate :: timer:: { InPins , InputPins , Timer } ;
13
13
14
14
/// SMS (Slave Mode Selection) register
15
15
#[ derive( Copy , Clone , Debug ) ]
@@ -58,13 +58,13 @@ impl Default for QeiOptions {
58
58
59
59
pub struct Qei < TIM : InputPins > {
60
60
tim : TIM ,
61
- pins : TIM :: Channels12 ,
61
+ pins : ( TIM :: InCh1 , TIM :: InCh2 ) ,
62
62
}
63
63
64
64
pub trait QeiExt : Sized + InputPins {
65
65
fn qei (
66
66
self ,
67
- pins : impl Into < <Self as InputPins > :: Channels12 > ,
67
+ pins : impl Into < InPins < Self :: InCh1 , Self :: InCh2 > > ,
68
68
options : QeiOptions ,
69
69
clocks : & Clocks ,
70
70
) -> Qei < Self > ;
@@ -74,7 +74,7 @@ pub trait QeiExt: Sized + InputPins {
74
74
impl QeiExt for pac:: TIM1 {
75
75
fn qei (
76
76
self ,
77
- pins : impl Into < <Self as InputPins > :: Channels12 > ,
77
+ pins : impl Into < InPins < Self :: InCh1 , Self :: InCh2 > > ,
78
78
options : QeiOptions ,
79
79
clocks : & Clocks ,
80
80
) -> Qei < Self > {
@@ -86,7 +86,7 @@ impl QeiExt for pac::TIM1 {
86
86
impl Timer < pac:: TIM1 > {
87
87
pub fn qei (
88
88
self ,
89
- pins : impl Into < < pac:: TIM1 as InputPins >:: Channels12 > ,
89
+ pins : impl Into < InPins < < pac:: TIM1 as InputPins >:: InCh1 , <pac :: TIM1 as InputPins > :: InCh2 > > ,
90
90
options : QeiOptions ,
91
91
) -> Qei < pac:: TIM1 > {
92
92
let Self { tim, clk : _ } = self ;
@@ -97,7 +97,7 @@ impl Timer<pac::TIM1> {
97
97
impl QeiExt for pac:: TIM2 {
98
98
fn qei (
99
99
self ,
100
- pins : impl Into < <Self as InputPins > :: Channels12 > ,
100
+ pins : impl Into < InPins < Self :: InCh1 , Self :: InCh2 > > ,
101
101
options : QeiOptions ,
102
102
clocks : & Clocks ,
103
103
) -> Qei < Self > {
@@ -108,7 +108,7 @@ impl QeiExt for pac::TIM2 {
108
108
impl Timer < pac:: TIM2 > {
109
109
pub fn qei (
110
110
self ,
111
- pins : impl Into < < pac:: TIM2 as InputPins >:: Channels12 > ,
111
+ pins : impl Into < InPins < < pac:: TIM2 as InputPins >:: InCh1 , <pac :: TIM2 as InputPins > :: InCh2 > > ,
112
112
options : QeiOptions ,
113
113
) -> Qei < pac:: TIM2 > {
114
114
let Self { tim, clk : _ } = self ;
@@ -119,7 +119,7 @@ impl Timer<pac::TIM2> {
119
119
impl QeiExt for pac:: TIM3 {
120
120
fn qei (
121
121
self ,
122
- pins : impl Into < <Self as InputPins > :: Channels12 > ,
122
+ pins : impl Into < InPins < Self :: InCh1 , Self :: InCh2 > > ,
123
123
options : QeiOptions ,
124
124
clocks : & Clocks ,
125
125
) -> Qei < Self > {
@@ -130,7 +130,7 @@ impl QeiExt for pac::TIM3 {
130
130
impl Timer < pac:: TIM3 > {
131
131
pub fn qei (
132
132
self ,
133
- pins : impl Into < < pac:: TIM3 as InputPins >:: Channels12 > ,
133
+ pins : impl Into < InPins < < pac:: TIM3 as InputPins >:: InCh1 , <pac :: TIM3 as InputPins > :: InCh2 > > ,
134
134
options : QeiOptions ,
135
135
) -> Qei < pac:: TIM3 > {
136
136
let Self { tim, clk : _ } = self ;
@@ -142,7 +142,7 @@ impl Timer<pac::TIM3> {
142
142
impl QeiExt for pac:: TIM4 {
143
143
fn qei (
144
144
self ,
145
- pins : impl Into < <Self as InputPins > :: Channels12 > ,
145
+ pins : impl Into < InPins < Self :: InCh1 , Self :: InCh2 > > ,
146
146
options : QeiOptions ,
147
147
clocks : & Clocks ,
148
148
) -> Qei < Self > {
@@ -154,7 +154,7 @@ impl QeiExt for pac::TIM4 {
154
154
impl Timer < pac:: TIM4 > {
155
155
pub fn qei (
156
156
self ,
157
- pins : impl Into < < pac:: TIM4 as InputPins >:: Channels12 > ,
157
+ pins : impl Into < InPins < < pac:: TIM4 as InputPins >:: InCh1 , <pac :: TIM4 as InputPins > :: InCh2 > > ,
158
158
options : QeiOptions ,
159
159
) -> Qei < pac:: TIM4 > {
160
160
let Self { tim, clk : _ } = self ;
@@ -167,7 +167,7 @@ macro_rules! hal {
167
167
impl Qei <$TIMX> {
168
168
fn $timX(
169
169
tim: $TIMX,
170
- pins: impl Into << $TIMX as InputPins >:: Channels12 >,
170
+ pins: impl Into <InPins << $TIMX as InputPins >:: InCh1 , <$TIMX as InputPins > :: InCh2 > >,
171
171
options: QeiOptions ,
172
172
) -> Self {
173
173
let pins = pins. into( ) ;
@@ -189,10 +189,18 @@ macro_rules! hal {
189
189
tim. arr( ) . write( |w| w. arr( ) . set( options. auto_reload_value) ) ;
190
190
tim. cr1( ) . write( |w| w. cen( ) . set_bit( ) ) ;
191
191
192
- Qei { tim, pins }
192
+ Qei {
193
+ tim,
194
+ pins: ( pins. c1, pins. c2) ,
195
+ }
193
196
}
194
197
195
- pub fn release( self ) -> ( $TIMX, <$TIMX as InputPins >:: Channels12 ) {
198
+ pub fn release(
199
+ self ,
200
+ ) -> (
201
+ $TIMX,
202
+ ( <$TIMX as InputPins >:: InCh1 , <$TIMX as InputPins >:: InCh2 ) ,
203
+ ) {
196
204
( self . tim, self . pins)
197
205
}
198
206
}
0 commit comments