aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/tsc
diff options
context:
space:
mode:
authorKarun <[email protected]>2024-04-17 12:58:45 -0400
committerKarun <[email protected]>2024-05-02 17:17:38 -0400
commitbef76ee05744077cf9a14df23947eb6de4a8346d (patch)
tree0d80e92c9f82823ceb1f204b0be4cf5584c742b0 /embassy-stm32/src/tsc
parent0febc24de73f8cf2bd0e3a7e7409f19aeaf00b1c (diff)
initial set of io changes
Diffstat (limited to 'embassy-stm32/src/tsc')
-rw-r--r--embassy-stm32/src/tsc/mod.rs73
1 files changed, 71 insertions, 2 deletions
diff --git a/embassy-stm32/src/tsc/mod.rs b/embassy-stm32/src/tsc/mod.rs
index 6bff642fa..1a8aabbc6 100644
--- a/embassy-stm32/src/tsc/mod.rs
+++ b/embassy-stm32/src/tsc/mod.rs
@@ -81,14 +81,81 @@ pub struct Config {
81 pub sampling_ios: u32, 81 pub sampling_ios: u32,
82} 82}
83 83
84pub struct TscPin<'d, T> {
85 pin: PeripheralRef<'d, AnyPin>,
86 role: PinType,
87}
88
89pub struct PinGroup<'d, A, B, C, D> {
90 d1: Option<TscPin<'d, A>>,
91 d2: Option<TscPin<'d, B>>,
92 d3: Option<TscPin<'d, C>>,
93 d4: Option<TscPin<'d, D>>,
94}
95
84pub struct TSC<'d, T: Instance> { 96pub struct TSC<'d, T: Instance> {
85 _peri: PeripheralRef<'d, T>, 97 _peri: PeripheralRef<'d, T>,
98 g1: Option<PinGroup<'d, AnyPin, AnyPin, AnyPin, AnyPin>>,
99 g2: Option<PinGroup<'d, AnyPin, AnyPin, AnyPin, AnyPin>>,
100 g3: Option<PinGroup<'d, AnyPin, AnyPin, AnyPin, AnyPin>>,
101 g4: Option<PinGroup<'d, AnyPin, AnyPin, AnyPin, AnyPin>>,
102 g5: Option<PinGroup<'d, AnyPin, AnyPin, AnyPin, AnyPin>>,
103 g6: Option<PinGroup<'d, AnyPin, AnyPin, AnyPin, AnyPin>>,
104 g7: Option<PinGroup<'d, AnyPin, AnyPin, AnyPin, AnyPin>>,
105 g8: Option<PinGroup<'d, AnyPin, AnyPin, AnyPin, AnyPin>>,
86 state: State, 106 state: State,
87 config: Config, 107 config: Config,
88} 108}
89 109
90impl<'d, T: Instance> TSC<'d, T> { 110impl<'d, T: Instance> TSC<'d, T> {
91 pub fn new(peri: impl Peripheral<P = T> + 'd, config: Config) -> Self { 111 pub fn new(
112 peri: impl Peripheral<P = T> + 'd,
113 g1: Option<
114 PinGroup<
115 'd,
116 impl Peripheral<P = impl G1IO1Pin<T>> + 'd,
117 impl Peripheral<P = impl G1IO2Pin<T>> + 'd,
118 impl Peripheral<P = impl G1IO3Pin<T>> + 'd,
119 impl Peripheral<P = impl G1IO4Pin<T>> + 'd,
120 >,
121 >,
122
123 g2_d1: Option<impl Peripheral<P = impl G2IO1Pin<T>> + 'd>,
124 g2_d2: Option<impl Peripheral<P = impl G2IO2Pin<T>> + 'd>,
125 g2_d3: Option<impl Peripheral<P = impl G2IO3Pin<T>> + 'd>,
126 g2_d4: Option<impl Peripheral<P = impl G2IO4Pin<T>> + 'd>,
127
128 g3_d1: Option<impl Peripheral<P = impl G3IO1Pin<T>> + 'd>,
129 g3_d2: Option<impl Peripheral<P = impl G3IO2Pin<T>> + 'd>,
130 g3_d3: Option<impl Peripheral<P = impl G3IO3Pin<T>> + 'd>,
131 g3_d4: Option<impl Peripheral<P = impl G3IO4Pin<T>> + 'd>,
132
133 g4_d1: Option<impl Peripheral<P = impl G4IO1Pin<T>> + 'd>,
134 g4_d2: Option<impl Peripheral<P = impl G4IO2Pin<T>> + 'd>,
135 g4_d3: Option<impl Peripheral<P = impl G4IO3Pin<T>> + 'd>,
136 g4_d4: Option<impl Peripheral<P = impl G4IO4Pin<T>> + 'd>,
137
138 g5_d1: Option<impl Peripheral<P = impl G5IO1Pin<T>> + 'd>,
139 g5_d2: Option<impl Peripheral<P = impl G5IO2Pin<T>> + 'd>,
140 g5_d3: Option<impl Peripheral<P = impl G5IO3Pin<T>> + 'd>,
141 g5_d4: Option<impl Peripheral<P = impl G5IO4Pin<T>> + 'd>,
142
143 g6_d1: Option<impl Peripheral<P = impl G6IO1Pin<T>> + 'd>,
144 g6_d2: Option<impl Peripheral<P = impl G6IO2Pin<T>> + 'd>,
145 g6_d3: Option<impl Peripheral<P = impl G6IO3Pin<T>> + 'd>,
146 g6_d4: Option<impl Peripheral<P = impl G6IO4Pin<T>> + 'd>,
147
148 g7_d1: Option<impl Peripheral<P = impl G7IO1Pin<T>> + 'd>,
149 g7_d2: Option<impl Peripheral<P = impl G7IO2Pin<T>> + 'd>,
150 g7_d3: Option<impl Peripheral<P = impl G7IO3Pin<T>> + 'd>,
151 g7_d4: Option<impl Peripheral<P = impl G7IO4Pin<T>> + 'd>,
152
153 g8_d1: Option<impl Peripheral<P = impl G8IO1Pin<T>> + 'd>,
154 g8_d2: Option<impl Peripheral<P = impl G8IO2Pin<T>> + 'd>,
155 g8_d3: Option<impl Peripheral<P = impl G8IO3Pin<T>> + 'd>,
156 g8_d4: Option<impl Peripheral<P = impl G8IO4Pin<T>> + 'd>,
157 config: Config,
158 ) -> Self {
92 into_ref!(peri); 159 into_ref!(peri);
93 160
94 // Need to check valid pin configuration input 161 // Need to check valid pin configuration input
@@ -96,6 +163,8 @@ impl<'d, T: Instance> TSC<'d, T> {
96 Self::new_inner(peri, config) 163 Self::new_inner(peri, config)
97 } 164 }
98 165
166 fn filter_group() -> Result<PinGroup<'d>, ()> {}
167
99 fn new_inner(peri: impl Peripheral<P = T> + 'd, config: Config) -> Self { 168 fn new_inner(peri: impl Peripheral<P = T> + 'd, config: Config) -> Self {
100 into_ref!(peri); 169 into_ref!(peri);
101 170
@@ -111,7 +180,7 @@ impl<'d, T: Instance> TSC<'d, T> {
111 w.set_pgpsc(config.pulse_generator_prescaler.into()); 180 w.set_pgpsc(config.pulse_generator_prescaler.into());
112 w.set_mcv(config.max_count_value); 181 w.set_mcv(config.max_count_value);
113 w.set_syncpol(config.synchro_pin_polarity); 182 w.set_syncpol(config.synchro_pin_polarity);
114 w.set_am(config.acquisition_mode) 183 w.set_am(config.acquisition_mode);
115 }); 184 });
116 185
117 // Set IO configuration 186 // Set IO configuration