Skip to content

Commit 258bd1f

Browse files
authored
Merge pull request #580 from stm32-rs/clean
missing sai feature
2 parents 5a107e1 + 7edfa80 commit 258bd1f

File tree

2 files changed

+26
-126
lines changed

2 files changed

+26
-126
lines changed

Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ stm32f413 = ["stm32f4/stm32f413", "device-selected", "gpio-f413",
162162
"i2c3",
163163
"otg-fs",
164164
"rng",
165+
"sai",
165166
"sdio",
166167
"spi3", "spi4", "spi5",
167168
"tim2", "tim8",
@@ -203,6 +204,7 @@ stm32f423 = ["stm32f4/stm32f413", "device-selected", "gpio-f413",
203204
"i2c3",
204205
"otg-fs",
205206
"rng",
207+
"sai",
206208
"sdio",
207209
"spi3", "spi4", "spi5",
208210
"tim2", "tim8",
@@ -217,6 +219,7 @@ stm32f427 = ["stm32f4/stm32f427", "device-selected", "gpio-f427",
217219
"otg-fs",
218220
"otg-hs",
219221
"rng",
222+
"sai",
220223
"sdio",
221224
"spi3", "spi4", "spi5", "spi6",
222225
"tim2", "tim8",
@@ -231,6 +234,7 @@ stm32f429 = ["stm32f4/stm32f429", "device-selected", "gpio-f427",
231234
"otg-fs",
232235
"otg-hs",
233236
"rng",
237+
"sai",
234238
"sdio",
235239
"spi3", "spi4", "spi5", "spi6",
236240
"tim2", "tim8",
@@ -245,6 +249,7 @@ stm32f437 = ["stm32f4/stm32f427", "device-selected", "gpio-f427",
245249
"otg-fs",
246250
"otg-hs",
247251
"rng",
252+
"sai",
248253
"sdio",
249254
"spi3", "spi4", "spi5", "spi6",
250255
"tim2", "tim8",
@@ -259,6 +264,7 @@ stm32f439 = ["stm32f4/stm32f429", "device-selected", "gpio-f427",
259264
"otg-fs",
260265
"otg-hs",
261266
"rng",
267+
"sai",
262268
"sdio",
263269
"spi3", "spi4", "spi5", "spi6",
264270
"tim2", "tim8",
@@ -272,6 +278,7 @@ stm32f446 = ["stm32f4/stm32f446", "device-selected", "gpio-f446",
272278
"i2c3",
273279
"otg-fs",
274280
"otg-hs",
281+
"sai",
275282
"spi3", "spi4",
276283
"tim2", "tim8",
277284
"usart3", "uart4", "uart5",
@@ -285,6 +292,7 @@ stm32f469 = ["stm32f4/stm32f469", "device-selected", "gpio-f469",
285292
"otg-fs",
286293
"otg-hs",
287294
"rng",
295+
"sai",
288296
"sdio",
289297
"spi3", "spi4", "spi5", "spi6",
290298
"tim2", "tim8",
@@ -299,6 +307,7 @@ stm32f479 = ["stm32f4/stm32f469", "device-selected", "gpio-f469",
299307
"otg-fs",
300308
"otg-hs",
301309
"rng",
310+
"sai",
302311
"sdio",
303312
"spi3", "spi4", "spi5", "spi6",
304313
"tim2", "tim8",
@@ -346,6 +355,7 @@ i2c3 = []
346355
otg-fs = []
347356
otg-hs = []
348357
rng = []
358+
sai = []
349359
sdio = []
350360
spi3 = []
351361
spi4 = []

src/rcc/mod.rs

Lines changed: 16 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -319,29 +319,9 @@ impl RccExt for RCC {
319319
feature = "stm32f446",
320320
))]
321321
i2s_apb2_clk: None,
322-
#[cfg(any(
323-
feature = "stm32f413",
324-
feature = "stm32f423",
325-
feature = "stm32f427",
326-
feature = "stm32f429",
327-
feature = "stm32f437",
328-
feature = "stm32f439",
329-
feature = "stm32f446",
330-
feature = "stm32f469",
331-
feature = "stm32f479",
332-
))]
322+
#[cfg(feature = "sai")]
333323
sai1_clk: None,
334-
#[cfg(any(
335-
feature = "stm32f413",
336-
feature = "stm32f423",
337-
feature = "stm32f427",
338-
feature = "stm32f429",
339-
feature = "stm32f437",
340-
feature = "stm32f439",
341-
feature = "stm32f446",
342-
feature = "stm32f469",
343-
feature = "stm32f479",
344-
))]
324+
#[cfg(feature = "sai")]
345325
sai2_clk: None,
346326
},
347327
}
@@ -377,7 +357,7 @@ pub const HSI: u32 = 16_000_000; // Hz
377357
/// Minimum system clock frequency
378358
pub const SYSCLK_MIN: u32 = 24_000_000;
379359

380-
#[cfg(any(feature = "stm32f446"))]
360+
#[cfg(feature = "stm32f446")]
381361
/// Minimum system clock frequency
382362
pub const SYSCLK_MIN: u32 = 12_500_000;
383363

@@ -481,29 +461,9 @@ pub struct CFGR {
481461
feature = "stm32f446",
482462
))]
483463
i2s_apb2_clk: Option<u32>,
484-
#[cfg(any(
485-
feature = "stm32f413",
486-
feature = "stm32f423",
487-
feature = "stm32f427",
488-
feature = "stm32f429",
489-
feature = "stm32f437",
490-
feature = "stm32f439",
491-
feature = "stm32f446",
492-
feature = "stm32f469",
493-
feature = "stm32f479",
494-
))]
464+
#[cfg(feature = "sai")]
495465
sai1_clk: Option<u32>,
496-
#[cfg(any(
497-
feature = "stm32f413",
498-
feature = "stm32f423",
499-
feature = "stm32f427",
500-
feature = "stm32f429",
501-
feature = "stm32f437",
502-
feature = "stm32f439",
503-
feature = "stm32f446",
504-
feature = "stm32f469",
505-
feature = "stm32f479",
506-
))]
466+
#[cfg(feature = "sai")]
507467
sai2_clk: Option<u32>,
508468
}
509469

@@ -641,14 +601,14 @@ impl CFGR {
641601
}
642602

643603
/// Selects a SAI1 clock frequency and enables the SAI1 clock.
644-
#[cfg(any(feature = "stm32f446",))]
604+
#[cfg(feature = "stm32f446")]
645605
pub fn sai1_clk(mut self, freq: Hertz) -> Self {
646606
self.sai1_clk = Some(freq.raw());
647607
self
648608
}
649609

650610
/// Selects a SAI2 clock frequency and enables the SAI2 clock.
651-
#[cfg(any(feature = "stm32f446",))]
611+
#[cfg(feature = "stm32f446")]
652612
pub fn sai2_clk(mut self, freq: Hertz) -> Self {
653613
self.sai2_clk = Some(freq.raw());
654614
self
@@ -828,17 +788,7 @@ impl CFGR {
828788
}
829789
}
830790

831-
#[cfg(any(
832-
feature = "stm32f413",
833-
feature = "stm32f423",
834-
feature = "stm32f427",
835-
feature = "stm32f429",
836-
feature = "stm32f437",
837-
feature = "stm32f439",
838-
feature = "stm32f446",
839-
feature = "stm32f469",
840-
feature = "stm32f479",
841-
))]
791+
#[cfg(feature = "sai")]
842792
fn sai_clocks(&self) -> SaiClocks {
843793
let sai1_ext = self.sai1_clk.is_some() && self.sai1_clk == self.i2s_ckin;
844794
#[cfg(not(feature = "stm32f446"))]
@@ -1100,17 +1050,7 @@ impl CFGR {
11001050

11011051
// Select I2S and SAI clocks
11021052
plls.i2s.config_clocksel();
1103-
#[cfg(any(
1104-
feature = "stm32f413",
1105-
feature = "stm32f423",
1106-
feature = "stm32f427",
1107-
feature = "stm32f429",
1108-
feature = "stm32f437",
1109-
feature = "stm32f439",
1110-
feature = "stm32f446",
1111-
feature = "stm32f469",
1112-
feature = "stm32f479",
1113-
))]
1053+
#[cfg(feature = "sai")]
11141054
plls.sai.config_clocksel();
11151055

11161056
// Set scaling factors
@@ -1227,17 +1167,7 @@ struct PllSetup {
12271167

12281168
i2s: RealI2sClocks,
12291169

1230-
#[cfg(any(
1231-
feature = "stm32f413",
1232-
feature = "stm32f423",
1233-
feature = "stm32f427",
1234-
feature = "stm32f429",
1235-
feature = "stm32f437",
1236-
feature = "stm32f439",
1237-
feature = "stm32f446",
1238-
feature = "stm32f469",
1239-
feature = "stm32f479",
1240-
))]
1170+
#[cfg(feature = "sai")]
12411171
sai: RealSaiClocks,
12421172
}
12431173

@@ -1386,17 +1316,7 @@ impl RealI2sClocks {
13861316
}
13871317
}
13881318

1389-
#[cfg(any(
1390-
feature = "stm32f413",
1391-
feature = "stm32f423",
1392-
feature = "stm32f427",
1393-
feature = "stm32f429",
1394-
feature = "stm32f437",
1395-
feature = "stm32f439",
1396-
feature = "stm32f446",
1397-
feature = "stm32f469",
1398-
feature = "stm32f479",
1399-
))]
1319+
#[cfg(feature = "sai")]
14001320
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
14011321
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
14021322
struct SaiClocks {
@@ -1409,17 +1329,7 @@ struct SaiClocks {
14091329
pll_sai_clk: Option<u32>,
14101330
}
14111331

1412-
#[cfg(any(
1413-
feature = "stm32f413",
1414-
feature = "stm32f423",
1415-
feature = "stm32f427",
1416-
feature = "stm32f429",
1417-
feature = "stm32f437",
1418-
feature = "stm32f439",
1419-
feature = "stm32f446",
1420-
feature = "stm32f469",
1421-
feature = "stm32f479",
1422-
))]
1332+
#[cfg(feature = "sai")]
14231333
impl SaiClocks {
14241334
fn real(&self, pll_sai_clk: Option<u32>, i2s_ckin: Option<u32>) -> RealSaiClocks {
14251335
RealSaiClocks {
@@ -1435,17 +1345,7 @@ impl SaiClocks {
14351345
}
14361346
}
14371347

1438-
#[cfg(any(
1439-
feature = "stm32f413",
1440-
feature = "stm32f423",
1441-
feature = "stm32f427",
1442-
feature = "stm32f429",
1443-
feature = "stm32f437",
1444-
feature = "stm32f439",
1445-
feature = "stm32f446",
1446-
feature = "stm32f469",
1447-
feature = "stm32f479",
1448-
))]
1348+
#[cfg(feature = "sai")]
14491349
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
14501350
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
14511351
struct RealSaiClocks {
@@ -1456,29 +1356,19 @@ struct RealSaiClocks {
14561356
sai2_clk: Option<u32>,
14571357
}
14581358

1459-
#[cfg(any(
1460-
feature = "stm32f413",
1461-
feature = "stm32f423",
1462-
feature = "stm32f427",
1463-
feature = "stm32f429",
1464-
feature = "stm32f437",
1465-
feature = "stm32f439",
1466-
feature = "stm32f446",
1467-
feature = "stm32f469",
1468-
feature = "stm32f479",
1469-
))]
1359+
#[cfg(feature = "sai")]
14701360
impl RealSaiClocks {
14711361
fn config_clocksel(&self) {
14721362
let rcc = unsafe { &*RCC::ptr() };
14731363

14741364
// Configure SAI clocks.
1475-
#[cfg(not(feature = "stm32f446",))]
1365+
#[cfg(not(feature = "stm32f446"))]
14761366
if self.sai1_ext {
14771367
rcc.dckcfgr.modify(|_, w| w.sai1asrc().i2s_ckin());
14781368
} else {
14791369
rcc.dckcfgr.modify(|_, w| w.sai1asrc().pllsai());
14801370
}
1481-
#[cfg(not(feature = "stm32f446",))]
1371+
#[cfg(not(feature = "stm32f446"))]
14821372
if self.sai2_ext {
14831373
rcc.dckcfgr.modify(|_, w| w.sai1bsrc().i2s_ckin());
14841374
} else {

0 commit comments

Comments
 (0)