@@ -14,12 +14,28 @@ pub enum Event {
1414}
1515
1616// TODO macro to impl all possible channel/sample pin combinations
17- pub trait SamplePin < TSC > { }
18- impl SamplePin < TSC > for PB4 < Alternate < AF9 , Output < OpenDrain > > > { }
17+ pub trait SamplePin < TSC > {
18+ const OFFSET : u32 ;
19+ }
20+ impl SamplePin < TSC > for PB4 < Alternate < AF9 , Output < OpenDrain > > > {
21+ const OFFSET : u32 = 1 << 0 + ( 1 * 4 ) ;
22+ }
23+ impl SamplePin < TSC > for PB5 < Alternate < AF9 , Output < OpenDrain > > > {
24+ const OFFSET : u32 = 1 << 1 + ( 1 * 4 ) ;
25+ }
26+ impl SamplePin < TSC > for PB6 < Alternate < AF9 , Output < OpenDrain > > > {
27+ const OFFSET : u32 = 1 << 2 + ( 1 * 4 ) ;
28+ }
29+ impl SamplePin < TSC > for PB7 < Alternate < AF9 , Output < OpenDrain > > > {
30+ const OFFSET : u32 = 1 << 3 + ( 1 * 4 ) ;
31+ }
1932
2033pub trait ChannelPin < TSC > {
2134 const OFFSET : u32 ;
2235}
36+ impl ChannelPin < TSC > for PB4 < Alternate < AF9 , Output < PushPull > > > {
37+ const OFFSET : u32 = 1 << 0 + ( 1 * 4 ) ;
38+ }
2339impl ChannelPin < TSC > for PB5 < Alternate < AF9 , Output < PushPull > > > {
2440 const OFFSET : u32 = 1 << 1 + ( 1 * 4 ) ;
2541}
@@ -40,7 +56,7 @@ pub struct Tsc<SPIN> {
4056
4157impl < SPIN > Tsc < SPIN > {
4258 pub fn tsc ( tsc : TSC , sample_pin : SPIN , ahb : & mut AHB1 ) -> Self
43- where SPIN : SamplePin < TSC > // PINS: ChannelPins<TSC>,
59+ where SPIN : SamplePin < TSC >
4460 {
4561 /* Enable the peripheral clock */
4662 ahb. enr ( ) . modify ( |_, w| w. tscen ( ) . set_bit ( ) ) ;
0 commit comments