Skip to content

Commit 67df935

Browse files
committed
Impl sample and channel for all pins, atm this means you can use a sample pin as a channel pin - not sure how to stop atm
1 parent 773902a commit 67df935

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/tsc.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2033
pub 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+
}
2339
impl 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

4157
impl<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

Comments
 (0)