Skip to content

Commit 5c14174

Browse files
committed
Generalize adc feature gates
This does also lift some restrictions
1 parent 24706bc commit 5c14174

File tree

1 file changed

+11
-41
lines changed

1 file changed

+11
-41
lines changed

src/adc.rs

Lines changed: 11 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ macro_rules! adc_pins {
191191
// # ADC1 Pin/Channel mapping
192192
// ## f303
193193

194-
#[cfg(feature = "stm32f303")]
194+
#[cfg(feature = "svd-f303")]
195195
adc_pins!(ADC1,
196196
gpio::PA0<Analog> => 1,
197197
gpio::PA1<Analog> => 2,
@@ -203,19 +203,14 @@ adc_pins!(ADC1,
203203
gpio::PC3<Analog> => 9,
204204
);
205205

206-
#[cfg(any(feature = "stm32f303x6", feature = "stm32f303x8"))]
206+
#[cfg(feature = "gpio-f333")]
207207
adc_pins!(ADC1,
208208
gpio::PB0<Analog> => 11,
209209
gpio::PB1<Analog> => 12,
210210
gpio::PB13<Analog> => 13,
211211
);
212212

213-
#[cfg(any(
214-
feature = "stm32f303xb",
215-
feature = "stm32f303xc",
216-
feature = "stm32f303xd",
217-
feature = "stm32f303xe",
218-
))]
213+
#[cfg(any(feature = "gpio-f303", feature = "gpio-f303e"))]
219214
adc_pins!(ADC1,
220215
gpio::PF4<Analog> => 5,
221216
gpio::PF2<Analog> => 10,
@@ -224,7 +219,7 @@ adc_pins!(ADC1,
224219
// # ADC2 Pin/Channel mapping
225220
// ## f303
226221

227-
#[cfg(feature = "stm32f303")]
222+
#[cfg(feature = "svd-f303")]
228223
adc_pins!(ADC2,
229224
gpio::PA4<Analog> => 1,
230225
gpio::PA5<Analog> => 2,
@@ -239,32 +234,22 @@ adc_pins!(ADC2,
239234
gpio::PB2<Analog> => 12,
240235
);
241236

242-
#[cfg(any(feature = "stm32f303x6", feature = "stm32f303x8"))]
237+
#[cfg(feature = "gpio-f333")]
243238
adc_pins!(ADC2,
244239
gpio::PB12<Analog> => 13,
245240
gpio::PB14<Analog> => 14,
246241
gpio::PB15<Analog> => 15,
247242
);
248243

249-
#[cfg(any(
250-
feature = "stm32f303xb",
251-
feature = "stm32f303xc",
252-
feature = "stm32f303xd",
253-
feature = "stm32f303xe",
254-
))]
244+
#[cfg(any(feature = "gpio-f303", feature = "gpio-f303e",))]
255245
adc_pins!(ADC2,
256246
gpio::PF2<Analog> => 10,
257247
);
258248

259249
// # ADC3 Pin/Channel mapping
260250
// ## f303
261251

262-
#[cfg(any(
263-
feature = "stm32f303xb",
264-
feature = "stm32f303xc",
265-
feature = "stm32f303xd",
266-
feature = "stm32f303xe",
267-
))]
252+
#[cfg(any(feature = "gpio-f303", feature = "gpio-f303e",))]
268253
adc_pins!(ADC3,
269254
gpio::PB1<Analog> => 1,
270255
gpio::PE9<Analog> => 2,
@@ -287,12 +272,7 @@ adc_pins!(ADC3,
287272
// # ADC4 Pin/Channel mapping
288273
// ## f303
289274

290-
#[cfg(any(
291-
feature = "stm32f303xb",
292-
feature = "stm32f303xc",
293-
feature = "stm32f303xd",
294-
feature = "stm32f303xe",
295-
))]
275+
#[cfg(any(feature = "gpio-f303", feature = "gpio-f303e",))]
296276
adc_pins!(ADC4,
297277
gpio::PE14<Analog> => 1,
298278
gpio::PE15<Analog> => 2,
@@ -577,12 +557,7 @@ macro_rules! adc12_hal {
577557

578558
// Macro to implement ADC functionallity for ADC3 and ADC4
579559
// TODO: Extend/differentiate beyond f303.
580-
#[cfg(any(
581-
feature = "stm32f303xb",
582-
feature = "stm32f303xc",
583-
feature = "stm32f303xd",
584-
feature = "stm32f303xe",
585-
))]
560+
#[cfg(any(feature = "gpio-f303", feature = "gpio-f303e",))]
586561
macro_rules! adc34_hal {
587562
($(
588563
$ADC:ident: ($adcx:ident),
@@ -610,17 +585,12 @@ macro_rules! adc34_hal {
610585
}
611586
}
612587

613-
#[cfg(feature = "stm32f303")]
588+
#[cfg(feature = "svd-f303")]
614589
adc12_hal! {
615590
ADC1: (adc1),
616591
ADC2: (adc2),
617592
}
618-
#[cfg(any(
619-
feature = "stm32f303xb",
620-
feature = "stm32f303xc",
621-
feature = "stm32f303xd",
622-
feature = "stm32f303xe",
623-
))]
593+
#[cfg(any(feature = "gpio-f303", feature = "gpio-f303e",))]
624594
adc34_hal! {
625595
ADC3: (adc3),
626596
ADC4: (adc4),

0 commit comments

Comments
 (0)