Skip to content

device feature gates #261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
rust:
- stable
mcu:
- stm32l4x1
- stm32l4x2
- stm32l4x3
- stm32l4x5
- stm32l4x6
- generic_pac_stm32l4x1
- generic_pac_stm32l4x2
- generic_pac_stm32l4x3
- generic_pac_stm32l4x5
- generic_pac_stm32l4x6

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
on:
push:
branches: [ master ]
branches: [master]
pull_request:

name: Clippy check
Expand All @@ -19,4 +19,4 @@ jobs:
- uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
args: --examples --target thumbv7em-none-eabihf --features=stm32l4x2,rt,unproven
args: --examples --target thumbv7em-none-eabihf --features=stm32l432,rt,unproven
105 changes: 88 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,89 @@ features = ["cortex-m", "fs"]
optional = true

[package.metadata.docs.rs]
features = ["rt", "stm32l4x2", "stm32-usbd"]
features = ["rt", "stm32l432", "stm32-usbd"]

[features]
rt = ["stm32l4/rt"]
stm32l4x1 = ["stm32l4/stm32l4x1"]
stm32l4x2 = ["stm32l4/stm32l4x2"]
stm32l4x3 = ["stm32l4/stm32l4x3"]
stm32l4x5 = ["stm32l4/stm32l4x5"]
stm32l4x6 = ["stm32l4/stm32l4x6"]
unproven = ["embedded-hal/unproven"]
otg_fs = ["synopsys-usb-otg"]

# private features are for internal use only
private_line_stm32l4x1 = []
private_line_stm32l4x2 = []
private_line_stm32l4x3 = []
private_line_stm32l4x5 = []
private_line_stm32l4x6 = []
private_line_stm32l4x7 = []
private_line_stm32l4x9 = []

# Devices can also be grouped by peripheral set (PAC may need similar features?)
private_product_L41_L42 = []
private_product_L43_L44 = []
private_product_L45_L46 = []
private_product_L47_L48 = []
private_product_L49_L4A = []
# L4+ products
private_product_L4P_L4Q = []
private_product_L4R_L4S = []

# AES is available only for L4(A/8/6/4/2) and L4+(Q/S)
# these devices are otherwise identical the the odd numbered pair
private_aes = []
# SHA-256 is only present on L4(A) and the L4+(Q/S)
private_sha256 = []

# generics are used by dependants that don't want to specify a specific MCU
# Also used by specific MCU features as shorthand for the private and PAC features
generic_pac_stm32l4x1 = ["private_line_stm32l4x1", "stm32l4/stm32l4x1"]
generic_pac_stm32l4x2 = ["private_line_stm32l4x2", "stm32l4/stm32l4x2"]
generic_pac_stm32l4x3 = ["private_line_stm32l4x3", "stm32l4/stm32l4x3"]
generic_pac_stm32l4x5 = ["private_line_stm32l4x5", "stm32l4/stm32l4x5"]
generic_pac_stm32l4x6 = ["private_line_stm32l4x6", "stm32l4/stm32l4x6"]
generic_pac_stm32l4x7 = ["private_line_stm32l4x7", "stm32l4/stm32l4x5"] # NOTE: x5 not x7
generic_pac_stm32l4x9 = ["private_line_stm32l4x9", "stm32l4/stm32l4r9"] # NOTE: r9 no x9

# L4x1
stm32l431 = [ "generic_pac_stm32l4x1", "private_product_L43_L44" ]
stm32l451 = [ "generic_pac_stm32l4x1", "private_product_L45_L46" ]
stm32l471 = [ "generic_pac_stm32l4x1", "private_product_L47_L48" ]

# L4x2
stm32l412 = [ "generic_pac_stm32l4x2", "private_product_L41_L42" ]
stm32l422 = [ "generic_pac_stm32l4x2", "private_product_L41_L42", "private_aes" ]
stm32l432 = [ "generic_pac_stm32l4x2", "private_product_L43_L44" ]
stm32l442 = [ "generic_pac_stm32l4x2", "private_product_L43_L44", "private_aes" ]
stm32l452 = [ "generic_pac_stm32l4x2", "private_product_L45_L46" ]
stm32l462 = [ "generic_pac_stm32l4x2", "private_product_L45_L46", "private_aes" ]

# L4x3
stm32l433 = [ "generic_pac_stm32l4x3", "private_product_L43_L44" ]
stm32l443 = [ "generic_pac_stm32l4x3", "private_product_L43_L44" ]

# L4x5
stm32l475 = [ "generic_pac_stm32l4x5", "private_product_L47_L48" ]
# L4+ series PAC support??
stm32l4p5 = [ "generic_pac_stm32l4x5", "private_product_L4P_L4Q" ]
stm32l4q5 = [ "generic_pac_stm32l4x5", "private_product_L4P_L4Q", "private_aes", "private_sha256" ]
stm32l4r5 = [ "generic_pac_stm32l4x5", "private_product_L4R_L4S" ]
stm32l4s5 = [ "generic_pac_stm32l4x5", "private_product_L4R_L4S", "private_aes", "private_sha256" ]

# L4x6
stm32l476 = [ "generic_pac_stm32l4x6", "private_product_L47_L48" ]
stm32l486 = [ "generic_pac_stm32l4x6", "private_product_L47_L48" ]
stm32l496 = [ "generic_pac_stm32l4x6", "private_product_L49_L4A" ]
stm32l4A6 = [ "generic_pac_stm32l4x6", "private_product_L49_L4A", "private_aes", "private_sha256" ]

# L4x7
# L4+ series PAC support??
stm32l4r7 = [ "generic_pac_stm32l4x7", "private_product_L4R_L4S" ]
stm32l4s7 = [ "generic_pac_stm32l4x7", "private_product_L4R_L4S", "private_aes", "private_sha256" ]

## L4x9
# L4+ series PAC support??
stm32l4r9 = [ "private_line_stm32l4x9", "stm32l4/stm32l4r9", "private_product_L4R_L4S" ] # PAC has an L4r9 specific variation
stm32l4s9 = [ "generic_pac_stm32l4x9", "private_product_L4R_L4S", "private_aes", "private_sha256" ]

[dev-dependencies]
panic-halt = "0.2.0"
panic-semihosting = "0.5.0"
Expand Down Expand Up @@ -103,19 +174,19 @@ lto = true

[[example]]
name = "adc"
required-features = ["rt", "stm32l4x3"]
required-features = ["rt", "private_line_stm32l4x3"]

[[example]]
name = "can-loopback"
required-features = ["rt", "stm32l4x1"]
required-features = ["rt", "private_line_stm32l4x1"]

[[example]]
name = "irq_button"
required-features = ["rt"]

[[example]]
name = "qspi"
required-features = ["rt", "stm32l4x5"]
required-features = ["rt", "private_line_stm32l4x5"]

[[example]]
name = "rng"
Expand All @@ -127,36 +198,36 @@ required-features = ["rt"]

[[example]]
name = "rtic_frame_serial_dma"
required-features = ["rt", "stm32l4x2"]
required-features = ["rt", "private_line_stm32l4x2"]

[[example]]
name = "spi_dma_rxtx"
required-features = ["rt", "stm32l4x2"]
required-features = ["rt", "private_line_stm32l4x2"]

[[example]]
name = "serial_echo_rtic"
required-features = ["rt", "stm32l4x3"]
required-features = ["rt", "private_line_stm32l4x3"]

[[example]]
name = "timer"
required-features = ["rt"]

[[example]]
name = "usb_serial"
required-features = ["rt", "stm32l4x2", "stm32-usbd"]
required-features = ["rt", "private_line_stm32l4x2", "stm32-usbd"]

[[example]]
name = "otg_fs_serial"
required-features = ["rt", "stm32l4x6", "otg_fs"]
required-features = ["rt", "private_line_stm32l4x6", "otg_fs"]

[[example]]
name = "i2c_write"
required-features = ["stm32l4x1"]
required-features = ["private_line_stm32l4x1"]

[[example]]
name = "lptim_rtic"
required-features = ["rt", "stm32l4x2"]
required-features = ["rt", "private_line_stm32l4x2"]

[[example]]
name = "adc_dma"
required-features = ["rt", "stm32l4x1"]
required-features = ["rt", "private_line_stm32l4x1"]
2 changes: 1 addition & 1 deletion src/can.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ mod common_pins {
}
}

#[cfg(feature = "stm32l4x1")]
#[cfg(feature = "private_line_stm32l4x1")]
mod pb13_pb12_af10 {
use crate::gpio::{
gpiob::{PB12, PB13},
Expand Down
4 changes: 2 additions & 2 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ gpio!(GPIOE, gpioe, gpioc, gpioeen, gpioerst, PEx, 4, [
PE15: (pe15, 15, Input<Floating>, AFRH, exticr4),
]);

#[cfg(any(feature = "stm32l4x5", feature = "stm32l4x6"))]
#[cfg(any(feature = "private_line_stm32l4x5", feature = "private_line_stm32l4x6"))]
gpio!(GPIOF, gpiof, gpioc, gpiofen, gpiofrst, PFx, 5, [
PF0: (pf0, 0, Input<Floating>, AFRL, exticr1),
PF1: (pf1, 1, Input<Floating>, AFRL, exticr1),
Expand All @@ -890,7 +890,7 @@ gpio!(GPIOF, gpiof, gpioc, gpiofen, gpiofrst, PFx, 5, [
PF15: (pf15, 15, Input<Floating>, AFRH, exticr4),
]);

#[cfg(any(feature = "stm32l4x5", feature = "stm32l4x6"))]
#[cfg(any(feature = "private_line_stm32l4x5", feature = "private_line_stm32l4x6"))]
gpio!(GPIOG, gpiog, gpioc, gpiogen, gpiogrst, PGx, 6, [
PG0: (pg0, 0, Input<Floating>, AFRL, exticr1),
PG1: (pg1, 1, Input<Floating>, AFRL, exticr1),
Expand Down
22 changes: 15 additions & 7 deletions src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
//! as of 2021-02-25.

use crate::hal::blocking::i2c::{Read, Write, WriteRead};
#[cfg(any(feature = "stm32l4x1", feature = "stm32l4x2", feature = "stm32l4x6"))]
#[cfg(any(
feature = "private_line_stm32l4x1",
feature = "private_line_stm32l4x2",
feature = "private_line_stm32l4x6"
))]
use crate::pac::I2C4;
use crate::pac::{i2c1, I2C1, I2C2, I2C3};

Expand Down Expand Up @@ -190,7 +194,11 @@ hal!(I2C3, enr, rstr, i2c3, i2c3en, i2c3rst);
// STM32L471XX and STM32L431XX
// STM32L432XX and STM32l442XX
// STM32L486XX and STM32L476XX
#[cfg(any(feature = "stm32l4x1", feature = "stm32l4x2", feature = "stm32l4x6"))]
#[cfg(any(
feature = "private_line_stm32l4x1",
feature = "private_line_stm32l4x2",
feature = "private_line_stm32l4x6"
))]
hal!(I2C4, enr2, rstr2, i2c4, i2c4en, i2c4rst);

impl<SCL, SDA, I2C> I2c<I2C, (SCL, SDA)>
Expand Down Expand Up @@ -443,7 +451,7 @@ where
}
}

#[cfg(feature = "stm32l4x1")]
#[cfg(feature = "private_line_stm32l4x1")]
mod stm32l4x1_pins {
use super::{I2C1, I2C2, I2C3, I2C4};
use crate::gpio::*;
Expand All @@ -468,7 +476,7 @@ mod stm32l4x1_pins {
pins!(I2C4, AF3, SCL: [PB10], SDA: [PB11]);
}

#[cfg(feature = "stm32l4x2")]
#[cfg(feature = "private_line_stm32l4x2")]
mod stm32l4x2_pins {
use super::{I2C1, I2C2, I2C3, I2C4};
use crate::gpio::*;
Expand All @@ -494,7 +502,7 @@ mod stm32l4x2_pins {
pins!(I2C4, AF4, SCL: [PD12], SDA: [PD13]);
}

#[cfg(feature = "stm32l4x3")]
#[cfg(feature = "private_line_stm32l4x3")]
mod stm32l4x3_pins {
use super::{I2C1, I2C2, I2C3};
use crate::gpio::*;
Expand All @@ -509,7 +517,7 @@ mod stm32l4x3_pins {
pins!(I2C3, AF4, SCL: [PA7, PC0], SDA: [PB4, PC1]);
}

#[cfg(feature = "stm32l4x5")]
#[cfg(feature = "private_line_stm32l4x5")]
mod stm32l4x5_pins {
use super::{I2C1, I2C2, I2C3};
use crate::gpio::*;
Expand All @@ -523,7 +531,7 @@ mod stm32l4x5_pins {
pins!(I2C3, AF4, SCL: [PC0], SDA: [PC1]);
}

#[cfg(feature = "stm32l4x6")]
#[cfg(feature = "private_line_stm32l4x6")]
mod stm32l4x6_pins {
use super::{I2C1, I2C2, I2C3, I2C4};
use crate::gpio::*;
Expand Down
Loading