@@ -9,7 +9,7 @@ use embedded_hal_02 as hal;
99pub use hal:: Direction ;
1010
1111use crate :: rcc:: Clocks ;
12- use crate :: timer:: { InputPins , Timer } ;
12+ use crate :: timer:: { InPins , InputPins , Timer } ;
1313
1414/// SMS (Slave Mode Selection) register
1515#[ derive( Copy , Clone , Debug ) ]
@@ -58,13 +58,13 @@ impl Default for QeiOptions {
5858
5959pub struct Qei < TIM : InputPins > {
6060 tim : TIM ,
61- pins : TIM :: Channels12 ,
61+ pins : ( TIM :: InCh1 , TIM :: InCh2 ) ,
6262}
6363
6464pub trait QeiExt : Sized + InputPins {
6565 fn qei (
6666 self ,
67- pins : impl Into < <Self as InputPins > :: Channels12 > ,
67+ pins : impl Into < InPins < Self :: InCh1 , Self :: InCh2 > > ,
6868 options : QeiOptions ,
6969 clocks : & Clocks ,
7070 ) -> Qei < Self > ;
@@ -74,7 +74,7 @@ pub trait QeiExt: Sized + InputPins {
7474impl QeiExt for pac:: TIM1 {
7575 fn qei (
7676 self ,
77- pins : impl Into < <Self as InputPins > :: Channels12 > ,
77+ pins : impl Into < InPins < Self :: InCh1 , Self :: InCh2 > > ,
7878 options : QeiOptions ,
7979 clocks : & Clocks ,
8080 ) -> Qei < Self > {
@@ -86,7 +86,7 @@ impl QeiExt for pac::TIM1 {
8686impl Timer < pac:: TIM1 > {
8787 pub fn qei (
8888 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 > > ,
9090 options : QeiOptions ,
9191 ) -> Qei < pac:: TIM1 > {
9292 let Self { tim, clk : _ } = self ;
@@ -97,7 +97,7 @@ impl Timer<pac::TIM1> {
9797impl QeiExt for pac:: TIM2 {
9898 fn qei (
9999 self ,
100- pins : impl Into < <Self as InputPins > :: Channels12 > ,
100+ pins : impl Into < InPins < Self :: InCh1 , Self :: InCh2 > > ,
101101 options : QeiOptions ,
102102 clocks : & Clocks ,
103103 ) -> Qei < Self > {
@@ -108,7 +108,7 @@ impl QeiExt for pac::TIM2 {
108108impl Timer < pac:: TIM2 > {
109109 pub fn qei (
110110 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 > > ,
112112 options : QeiOptions ,
113113 ) -> Qei < pac:: TIM2 > {
114114 let Self { tim, clk : _ } = self ;
@@ -119,7 +119,7 @@ impl Timer<pac::TIM2> {
119119impl QeiExt for pac:: TIM3 {
120120 fn qei (
121121 self ,
122- pins : impl Into < <Self as InputPins > :: Channels12 > ,
122+ pins : impl Into < InPins < Self :: InCh1 , Self :: InCh2 > > ,
123123 options : QeiOptions ,
124124 clocks : & Clocks ,
125125 ) -> Qei < Self > {
@@ -130,7 +130,7 @@ impl QeiExt for pac::TIM3 {
130130impl Timer < pac:: TIM3 > {
131131 pub fn qei (
132132 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 > > ,
134134 options : QeiOptions ,
135135 ) -> Qei < pac:: TIM3 > {
136136 let Self { tim, clk : _ } = self ;
@@ -142,7 +142,7 @@ impl Timer<pac::TIM3> {
142142impl QeiExt for pac:: TIM4 {
143143 fn qei (
144144 self ,
145- pins : impl Into < <Self as InputPins > :: Channels12 > ,
145+ pins : impl Into < InPins < Self :: InCh1 , Self :: InCh2 > > ,
146146 options : QeiOptions ,
147147 clocks : & Clocks ,
148148 ) -> Qei < Self > {
@@ -154,7 +154,7 @@ impl QeiExt for pac::TIM4 {
154154impl Timer < pac:: TIM4 > {
155155 pub fn qei (
156156 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 > > ,
158158 options : QeiOptions ,
159159 ) -> Qei < pac:: TIM4 > {
160160 let Self { tim, clk : _ } = self ;
@@ -167,7 +167,7 @@ macro_rules! hal {
167167 impl Qei <$TIMX> {
168168 fn $timX(
169169 tim: $TIMX,
170- pins: impl Into << $TIMX as InputPins >:: Channels12 >,
170+ pins: impl Into <InPins << $TIMX as InputPins >:: InCh1 , <$TIMX as InputPins > :: InCh2 > >,
171171 options: QeiOptions ,
172172 ) -> Self {
173173 let pins = pins. into( ) ;
@@ -189,10 +189,18 @@ macro_rules! hal {
189189 tim. arr( ) . write( |w| w. arr( ) . set( options. auto_reload_value) ) ;
190190 tim. cr1( ) . write( |w| w. cen( ) . set_bit( ) ) ;
191191
192- Qei { tim, pins }
192+ Qei {
193+ tim,
194+ pins: ( pins. c1, pins. c2) ,
195+ }
193196 }
194197
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+ ) {
196204 ( self . tim, self . pins)
197205 }
198206 }
0 commit comments