Skip to content

Commit 9f7c451

Browse files
committed
document-features
1 parent 0b6cecc commit 9f7c451

File tree

5 files changed

+41
-21
lines changed

5 files changed

+41
-21
lines changed

Cargo.toml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ systick-monotonic = { version = "1.0", optional = true }
4949
enumflags2 = "0.7.8"
5050
embedded-storage = "0.3"
5151
vcell = "0.1.3"
52+
document-features = "0.2"
5253

5354
[dependencies.time]
5455
version = "0.3.14"
@@ -98,6 +99,11 @@ default-features = false
9899
features = ["macros"]
99100

100101
[features]
102+
#! Use one of the supported STM32-serie related features:
103+
#! `stm32f401`, `stm32f405`, `stm32f407`, `stm32f415`, `stm32f417`, `stm32f410`,
104+
#! `stm32f411`, `stm32f412`, `stm32f413`, `stm32f423`, `stm32f427`, `stm32f429`,
105+
#! `stm32f437`, `stm32f439`, `stm32f446`, `stm32f469`, `stm32f479`.
106+
101107
# Note: stm32f4 has only one feature for some very similar device families,
102108
# so it's intended for e.g. stm32f405/415 to both enable stm32f4/stm32f405.
103109
stm32f401 = ["stm32f4/stm32f401"]
@@ -118,18 +124,28 @@ stm32f446 = ["stm32f4/stm32f446"]
118124
stm32f469 = ["stm32f4/stm32f469"]
119125
stm32f479 = ["stm32f4/stm32f469"]
120126

121-
usb_fs = ["synopsys-usb-otg", "synopsys-usb-otg/fs"]
122-
usb_hs = ["synopsys-usb-otg", "synopsys-usb-otg/hs"]
127+
## Support monotonic timers that can be used by [RTIC framework](https://crates.io/crates/cortex-m-rtic)
128+
rtic = ["dep:rtic-monotonic", "dep:systick-monotonic"]
129+
130+
## Implementation of `defmt::Format` for public enums and structures. See [defmt](https://crates.io/crates/defmt)
131+
defmt = ["dep:defmt", "fugit/defmt", "nb/defmt-0-3"]
123132

124-
can = ["bxcan"]
133+
## bxCAN peripheral support. See [bxcan](https://crates.io/crates/bxcan)
134+
can = ["dep:bxcan"]
125135

126-
i2s = ["stm32_i2s_v12x"]
136+
## I2S peripheral support. See [stm32_i2s_v12x](https://crates.io/crates/stm32_i2s_v12x)
137+
i2s = ["dep:stm32_i2s_v12x"]
127138

128-
fsmc_lcd = ["display-interface"]
139+
## USB OTG-FS peripheral support. See [synopsys-usb-otg](https://crates.io/crates/synopsys-usb-otg)
140+
usb_fs = ["dep:synopsys-usb-otg", "synopsys-usb-otg/fs"]
141+
## USB OTG-HS peripheral support. See [synopsys-usb-otg](https://crates.io/crates/synopsys-usb-otg)
142+
usb_hs = ["dep:synopsys-usb-otg", "synopsys-usb-otg/hs"]
129143

130-
defmt = ["dep:defmt", "fugit/defmt", "nb/defmt-0-3"]
144+
## LCD support via FMC/FSMC peripheral. See [display-interface](https://crates.io/crates/display-interface)
145+
fsmc_lcd = ["dep:display-interface"]
131146

132-
rtic = ["rtic-monotonic", "systick-monotonic"]
147+
## SDIO peripheral support. See [sdio-host](https://crates.io/crates/sdio-host)
148+
sdio-host = ["dep:sdio-host"]
133149

134150
[profile.dev]
135151
debug = true

src/i2s.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use crate::pac;
1212
use crate::rcc::{self, Clocks, Reset};
1313
use fugit::HertzU32 as Hertz;
1414

15-
#[cfg(feature = "stm32_i2s_v12x")]
16-
pub extern crate stm32_i2s_v12x;
15+
#[cfg(feature = "i2s")]
16+
pub use stm32_i2s_v12x;
1717

1818
// I2S pins are mostly the same as the corresponding SPI pins:
1919
// MOSI -> SD
@@ -202,7 +202,7 @@ macro_rules! i2s {
202202
}
203203
}
204204

205-
#[cfg(feature = "stm32_i2s_v12x")]
205+
#[cfg(feature = "i2s")]
206206
impl stm32_i2s_v12x::WsPin for gpio::alt::$i2s::Ws {
207207
fn is_high(&self) -> bool {
208208
use crate::gpio::ReadPin;
@@ -214,7 +214,7 @@ macro_rules! i2s {
214214
}
215215
}
216216

217-
#[cfg(feature = "stm32_i2s_v12x")]
217+
#[cfg(feature = "i2s")]
218218
unsafe impl stm32_i2s_v12x::I2sPeripheral for I2s<$SPI>
219219
where
220220
$SPI: rcc::Reset,
@@ -375,7 +375,7 @@ macro_rules! dual_i2s {
375375
type I2sExtPeripheral = $I2SEXT;
376376
}
377377

378-
#[cfg(feature = "stm32_i2s_v12x")]
378+
#[cfg(feature = "i2s")]
379379
unsafe impl stm32_i2s_v12x::DualI2sPeripheral for DualI2s<$SPI>
380380
where
381381
$SPI: rcc::Reset,
@@ -420,7 +420,7 @@ dual_i2s!(pac::SPI3, pac::I2S3EXT, DualI2s3, i2s3, i2s_clk);
420420
dual_i2s!(pac::SPI3, pac::I2S3EXT, DualI2s3, i2s3, i2s_apb1_clk);
421421

422422
// DMA support: reuse existing mappings for SPI
423-
#[cfg(feature = "stm32_i2s_v12x")]
423+
#[cfg(feature = "i2s")]
424424
mod dma {
425425
use super::*;
426426
use crate::dma::traits::{DMASet, PeriAddress};

src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Multi device hardware abstraction on top of the peripheral access API for the STMicro STM32F4 series microcontrollers.
2+
//!
3+
//! ## Feature flags
4+
#![doc = document_features::document_features!()]
15
#![no_std]
26
#![allow(non_camel_case_types)]
37

@@ -93,7 +97,7 @@ pub mod i2c;
9397
pub mod i2s;
9498
#[cfg(all(feature = "usb_fs", pac_otg_fs))]
9599
pub mod otg_fs;
96-
#[cfg(all(any(feature = "usb_hs", docsrs), pac_otg_hs,))]
100+
#[cfg(all(any(feature = "usb_hs", docsrs), pac_otg_hs))]
97101
pub mod otg_hs;
98102

99103
#[cfg(pac_rng)]

src/rcc/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl RccExt for RCC {
302302
sysclk: None,
303303
pll48clk: false,
304304
i2s_ckin: None,
305-
#[cfg(any(gpio_f401, gpio_f410, gpio_f411, gpio_f417, gpio_f427, gpio_f469,))]
305+
#[cfg(any(gpio_f401, gpio_f410, gpio_f411, gpio_f417, gpio_f427, gpio_f469))]
306306
i2s_clk: None,
307307
#[cfg(any(gpio_f412, gpio_f413, gpio_f446))]
308308
i2s_apb1_clk: None,
@@ -343,15 +343,15 @@ pub const SYSCLK_MAX: u32 = 84_000_000;
343343
/// Maximum system clock frequency
344344
pub const SYSCLK_MAX: u32 = 168_000_000;
345345

346-
#[cfg(any(gpio_f410, gpio_f411, gpio_f412, gpio_f413,))]
346+
#[cfg(any(gpio_f410, gpio_f411, gpio_f412, gpio_f413))]
347347
/// Maximum system clock frequency
348348
pub const SYSCLK_MAX: u32 = 100_000_000;
349349

350350
#[cfg(any(gpio_f427, gpio_f446, gpio_f469))]
351351
/// Maximum system clock frequency
352352
pub const SYSCLK_MAX: u32 = 180_000_000;
353353

354-
#[cfg(any(gpio_f401, gpio_f410, gpio_f411, gpio_f412, gpio_f413,))]
354+
#[cfg(any(gpio_f401, gpio_f410, gpio_f411, gpio_f412, gpio_f413))]
355355
/// Maximum APB2 peripheral clock frequency
356356
pub const PCLK2_MAX: u32 = SYSCLK_MAX;
357357

@@ -372,7 +372,7 @@ pub struct CFGR {
372372
pll48clk: bool,
373373

374374
i2s_ckin: Option<u32>,
375-
#[cfg(any(gpio_f401, gpio_f410, gpio_f411, gpio_f417, gpio_f427, gpio_f469,))]
375+
#[cfg(any(gpio_f401, gpio_f410, gpio_f411, gpio_f417, gpio_f427, gpio_f469))]
376376
i2s_clk: Option<u32>,
377377
#[cfg(any(gpio_f412, gpio_f413, gpio_f446))]
378378
i2s_apb1_clk: Option<u32>,
@@ -441,7 +441,7 @@ impl CFGR {
441441
}
442442

443443
/// Selects an I2S clock frequency and enables the I2S clock.
444-
#[cfg(any(gpio_f401, gpio_f410, gpio_f411, gpio_f417, gpio_f427, gpio_f469,))]
444+
#[cfg(any(gpio_f401, gpio_f410, gpio_f411, gpio_f417, gpio_f427, gpio_f469))]
445445
pub fn i2s_clk(mut self, freq: Hertz) -> Self {
446446
self.i2s_clk = Some(freq.raw());
447447
self
@@ -596,7 +596,7 @@ impl CFGR {
596596
}
597597
}
598598

599-
#[cfg(any(gpio_f401, gpio_f417, gpio_f427, gpio_f469,))]
599+
#[cfg(any(gpio_f401, gpio_f417, gpio_f427, gpio_f469))]
600600
#[inline(always)]
601601
fn pll_setup(&self, pllsrcclk: u32, pllsysclk: Option<u32>) -> PllSetup {
602602
let i2s_clocks = self.i2s_clocks();

src/spi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::ops::{Deref, DerefMut};
44
use crate::dma::traits::{DMASet, PeriAddress};
55
use crate::dma::{MemoryToPeripheral, PeripheralToMemory};
66
use crate::gpio::{self, NoPin};
7-
use crate::{pac, ReadFlags};
7+
use crate::pac;
88

99
/// Clock polarity
1010
#[derive(Clone, Copy, Debug, PartialEq, Eq)]

0 commit comments

Comments
 (0)