Skip to content

Commit

Permalink
Merge pull request #3435 from embassy-rs/octospim-fix
Browse files Browse the repository at this point in the history
stm32: Fix build for chips with octospim but not octospi2.
  • Loading branch information
Dirbaio authored Oct 20, 2024
2 parents a561a76 + ecac24a commit 34eeaa0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ cargo batch \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32h562ag,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32wba50ke,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32wba55ug,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32u5f9zj,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32u5g9nj,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb35ce,defmt,exti,time-driver-any,time \
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32u031r8,defmt,exti,time-driver-any,time \
Expand Down
14 changes: 9 additions & 5 deletions embassy-stm32/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn main() {
let mut singletons: Vec<String> = Vec::new();
for p in METADATA.peripherals {
if let Some(r) = &p.registers {
if r.kind == "adccommon" || r.kind == "sai" || r.kind == "ucpd" || r.kind == "otg" {
if r.kind == "adccommon" || r.kind == "sai" || r.kind == "ucpd" || r.kind == "otg" || r.kind == "octospi" {
// TODO: should we emit this for all peripherals? if so, we will need a list of all
// possible peripherals across all chips, so that we can declare the configs
// (replacing the hard-coded list of `peri_*` cfgs below)
Expand Down Expand Up @@ -113,6 +113,7 @@ fn main() {
"peri_ucpd2",
"peri_usb_otg_fs",
"peri_usb_otg_hs",
"peri_octospi2",
]);
cfgs.declare_all(&["mco", "mco1", "mco2"]);

Expand Down Expand Up @@ -1137,11 +1138,14 @@ fn main() {

// OCTOSPIM is special
if p.name == "OCTOSPIM" {
// Some chips have OCTOSPIM but not OCTOSPI2.
if METADATA.peripherals.iter().any(|p| p.name == "OCTOSPI2") {
peri = format_ident!("{}", "OCTOSPI2");
g.extend(quote! {
pin_trait_impl!(#tr, #peri, #pin_name, #af);
});
}
peri = format_ident!("{}", "OCTOSPI1");
g.extend(quote! {
pin_trait_impl!(#tr, #peri, #pin_name, #af);
});
peri = format_ident!("{}", "OCTOSPI2");
}

g.extend(quote! {
Expand Down
2 changes: 1 addition & 1 deletion embassy-stm32/src/ospi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ impl SealedOctospimInstance for peripherals::OCTOSPI1 {
const OCTOSPI_IDX: u8 = 1;
}

#[cfg(octospim_v1)]
#[cfg(all(octospim_v1, peri_octospi2))]
impl SealedOctospimInstance for peripherals::OCTOSPI2 {
const OCTOSPIM_REGS: Octospim = crate::pac::OCTOSPIM;
const OCTOSPI_IDX: u8 = 2;
Expand Down

0 comments on commit 34eeaa0

Please sign in to comment.