From 397722c32877d1521584de004b49e815f29afe91 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 26 Jun 2022 23:52:38 +0200 Subject: [PATCH 1/5] stm32: fix f100 build. --- embassy-stm32/src/rcc/f1.rs | 4 +++- embassy-stm32/src/rcc/mod.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/src/rcc/f1.rs b/embassy-stm32/src/rcc/f1.rs index ca0883b4a..8e2e6684a 100644 --- a/embassy-stm32/src/rcc/f1.rs +++ b/embassy-stm32/src/rcc/f1.rs @@ -2,7 +2,7 @@ use core::convert::TryFrom; use super::{set_freqs, Clocks}; use crate::pac::flash::vals::Latency; -use crate::pac::rcc::vals::{Adcpre, Hpre, Pllmul, Pllsrc, Ppre1, Sw, Usbpre}; +use crate::pac::rcc::vals::*; use crate::pac::{FLASH, RCC}; use crate::time::Hertz; @@ -110,6 +110,7 @@ pub(crate) unsafe fn init(config: Config) { // the USB clock is only valid if an external crystal is used, the PLL is enabled, and the // PLL output frequency is a supported one. // usbpre == false: divide clock by 1.5, otherwise no division + #[cfg(not(rcc_f100))] let (usbpre, _usbclk_valid) = match (config.hse, pllmul_bits, real_sysclk) { (Some(_), Some(_), 72_000_000) => (false, true), (Some(_), Some(_), 48_000_000) => (true, true), @@ -154,6 +155,7 @@ pub(crate) unsafe fn init(config: Config) { w.set_ppre2(Ppre1(ppre2_bits)); w.set_ppre1(Ppre1(ppre1_bits)); w.set_hpre(Hpre(hpre_bits)); + #[cfg(not(rcc_f100))] w.set_usbpre(Usbpre(usbpre as u8)); w.set_sw(Sw(if pllmul_bits.is_some() { // PLL diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index 866b1ffc4..1b1180c03 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs @@ -5,7 +5,7 @@ use core::mem::MaybeUninit; use crate::time::Hertz; #[cfg_attr(rcc_f0, path = "f0.rs")] -#[cfg_attr(any(rcc_f1, rcc_f1cl), path = "f1.rs")] +#[cfg_attr(any(rcc_f1, rcc_f100, rcc_f1cl), path = "f1.rs")] #[cfg_attr(rcc_f2, path = "f2.rs")] #[cfg_attr(rcc_f3, path = "f3.rs")] #[cfg_attr(any(rcc_f4, rcc_f410), path = "f4.rs")] From 065a1d097aedcb639996bb779445b7c694303d11 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 26 Jun 2022 23:53:03 +0200 Subject: [PATCH 2/5] cortex-m: document Interrupt changes depending on Cargo features. --- embassy-cortex-m/src/interrupt.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/embassy-cortex-m/src/interrupt.rs b/embassy-cortex-m/src/interrupt.rs index cd132076f..8a63b18b1 100644 --- a/embassy-cortex-m/src/interrupt.rs +++ b/embassy-cortex-m/src/interrupt.rs @@ -205,6 +205,8 @@ const PRIO_MASK: u8 = 0xfe; const PRIO_MASK: u8 = 0xff; /// The interrupt priority level. +/// +/// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. #[cfg(feature = "prio-bits-0")] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -214,6 +216,8 @@ pub enum Priority { } /// The interrupt priority level. +/// +/// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. #[cfg(feature = "prio-bits-1")] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -224,6 +228,8 @@ pub enum Priority { } /// The interrupt priority level. +/// +/// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. #[cfg(feature = "prio-bits-2")] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -236,6 +242,8 @@ pub enum Priority { } /// The interrupt priority level. +/// +/// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. #[cfg(feature = "prio-bits-3")] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -252,6 +260,8 @@ pub enum Priority { } /// The interrupt priority level. +/// +/// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. #[cfg(feature = "prio-bits-4")] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -276,6 +286,8 @@ pub enum Priority { } /// The interrupt priority level. +/// +/// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. #[cfg(feature = "prio-bits-5")] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -316,6 +328,8 @@ pub enum Priority { } /// The interrupt priority level. +/// +/// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. #[cfg(feature = "prio-bits-6")] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -388,6 +402,8 @@ pub enum Priority { } /// The interrupt priority level. +/// +/// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. #[cfg(feature = "prio-bits-7")] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -524,6 +540,8 @@ pub enum Priority { } /// The interrupt priority level. +/// +/// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. #[cfg(feature = "prio-bits-8")] #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] From 948bb93dc2aed743ac5e7dc229988c67da32ba7c Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 26 Jun 2022 23:55:38 +0200 Subject: [PATCH 3/5] docs: Add $COMMIT to git srclinks. --- embassy-cortex-m/Cargo.toml | 4 ++-- embassy-lora/Cargo.toml | 6 +++--- embassy-net/Cargo.toml | 4 ++-- embassy-nrf/Cargo.toml | 3 +-- embassy-rp/Cargo.toml | 2 +- embassy-stm32/Cargo.toml | 4 ++-- embassy-usb-hid/Cargo.toml | 2 +- embassy-usb-ncm/Cargo.toml | 2 +- embassy-usb-serial/Cargo.toml | 2 +- embassy-usb/Cargo.toml | 2 +- embassy/Cargo.toml | 2 +- 11 files changed, 16 insertions(+), 17 deletions(-) diff --git a/embassy-cortex-m/Cargo.toml b/embassy-cortex-m/Cargo.toml index f1e7beb56..9dbec0462 100644 --- a/embassy-cortex-m/Cargo.toml +++ b/embassy-cortex-m/Cargo.toml @@ -5,8 +5,8 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-cortex-m-v$VERSION/embassy-cortex-m/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/master/embassy-cortex-m/src/" -features = [] +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-cortex-m/src/" +features = ["prio-bits-3"] flavors = [ { name = "thumbv6m-none-eabi", target = "thumbv6m-none-eabi", features = [] }, { name = "thumbv7m-none-eabi", target = "thumbv7m-none-eabi", features = [] }, diff --git a/embassy-lora/Cargo.toml b/embassy-lora/Cargo.toml index 0304c2c35..9b6b2c652 100644 --- a/embassy-lora/Cargo.toml +++ b/embassy-lora/Cargo.toml @@ -5,11 +5,11 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-lora-v$VERSION/embassy-lora/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/master/embassy-lora/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-lora/src/" features = ["time", "defmt"] flavors = [ - { name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any"] }, - { name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any"] }, + { name = "sx127x", target = "thumbv7em-none-eabihf", features = ["sx127x", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy/time-tick-32768hz"] }, + { name = "stm32wl", target = "thumbv7em-none-eabihf", features = ["stm32wl", "embassy-stm32/stm32wl55jc-cm4", "embassy-stm32/time-driver-any", "embassy/time-tick-32768hz"] }, ] [lib] diff --git a/embassy-net/Cargo.toml b/embassy-net/Cargo.toml index 279313240..70acc7e4e 100644 --- a/embassy-net/Cargo.toml +++ b/embassy-net/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-net-v$VERSION/embassy-net/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/master/embassy-net/src/" -features = [ "tcp", "dhcpv4", "medium-ethernet", "medium-ip", "embassy/time", "embassy/time-tick-1mhz"] +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-net/src/" +features = [ "pool-4", "defmt", "tcp", "dns", "dhcpv4", "proto-ipv6", "medium-ethernet", "medium-ip", "embassy/time", "embassy/time-tick-1mhz"] flavors = [ { name = "default", target = "thumbv7em-none-eabihf" }, ] diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index b148d2c56..887ea1bd2 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-nrf-v$VERSION/embassy-nrf/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/master/embassy-nrf/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-nrf/src/" features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "gpiote", "time-driver-rtc1"] flavors = [ @@ -79,7 +79,6 @@ defmt = { version = "0.3", optional = true } log = { version = "0.4.14", optional = true } cortex-m-rt = ">=0.6.15,<0.8" cortex-m = "0.7.3" -embedded-dma = "0.1.2" futures = { version = "0.3.17", default-features = false } critical-section = "0.2.5" rand_core = "0.6.3" diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index 1c572b619..217221b0e 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-rp-v$VERSION/embassy-rp/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/master/embassy-rp/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-rp/src/" features = ["nightly", "defmt", "unstable-pac", "unstable-traits"] flavors = [ { name = "rp2040", target = "thumbv6m-none-eabi" }, diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 88c0f42f7..2c1007b40 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -5,12 +5,12 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-stm32-v$VERSION/embassy-stm32/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/master/embassy-stm32/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-stm32/src/" # TODO: sdmmc # TODO: net # TODO: subghz -features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any"] +features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "exti", "time-driver-any", "embassy/time-tick-32768hz"] flavors = [ { regex_feature = "stm32f0.*", target = "thumbv6m-none-eabi" }, { regex_feature = "stm32f1.*", target = "thumbv7m-none-eabi" }, diff --git a/embassy-usb-hid/Cargo.toml b/embassy-usb-hid/Cargo.toml index c5181325b..b8185fa5a 100644 --- a/embassy-usb-hid/Cargo.toml +++ b/embassy-usb-hid/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-hid-v$VERSION/embassy-usb-hid/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/master/embassy-usb-hid/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb-hid/src/" features = ["defmt", "embassy/time-tick-1mhz"] flavors = [ { name = "default", target = "thumbv7em-none-eabihf" }, diff --git a/embassy-usb-ncm/Cargo.toml b/embassy-usb-ncm/Cargo.toml index aaef01d6d..636a81c2c 100644 --- a/embassy-usb-ncm/Cargo.toml +++ b/embassy-usb-ncm/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-ncm-v$VERSION/embassy-usb-ncm/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/master/embassy-usb-ncm/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb-ncm/src/" features = ["defmt"] flavors = [ { name = "default", target = "thumbv7em-none-eabihf" }, diff --git a/embassy-usb-serial/Cargo.toml b/embassy-usb-serial/Cargo.toml index 553f2a13c..682707afe 100644 --- a/embassy-usb-serial/Cargo.toml +++ b/embassy-usb-serial/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-serial-v$VERSION/embassy-usb-serial/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/master/embassy-usb-serial/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb-serial/src/" features = ["defmt"] flavors = [ { name = "default", target = "thumbv7em-none-eabihf" }, diff --git a/embassy-usb/Cargo.toml b/embassy-usb/Cargo.toml index 48c205064..513dc8c1f 100644 --- a/embassy-usb/Cargo.toml +++ b/embassy-usb/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-usb-v$VERSION/embassy-usb/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/master/embassy-usb/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-usb/src/" features = ["defmt"] flavors = [ { name = "default", target = "thumbv7em-none-eabihf" }, diff --git a/embassy/Cargo.toml b/embassy/Cargo.toml index d2c96e30d..a5d36c10c 100644 --- a/embassy/Cargo.toml +++ b/embassy/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" [package.metadata.embassy_docs] src_base = "https://github.com/embassy-rs/embassy/blob/embassy-v$VERSION/embassy/src/" -src_base_git = "https://github.com/embassy-rs/embassy/blob/master/embassy/src/" +src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy/src/" features = ["nightly", "defmt", "unstable-traits", "time", "time-tick-1mhz"] flavors = [ { name = "std", target = "x86_64-unknown-linux-gnu", features = ["std"] }, From edb9eedb45bcf41aafae63979b58561e940c88c1 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Sun, 26 Jun 2022 23:56:44 +0200 Subject: [PATCH 4/5] stm32: add f100 to CI. --- ci.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci.sh b/ci.sh index ff33c8ad1..2464bd476 100755 --- a/ci.sh +++ b/ci.sh @@ -60,6 +60,7 @@ cargo batch \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5ub,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f100c4,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \ --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4,embassy/time-tick-32768hz \ --- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \ From a855889f7073ac6cfbc459e8ede95f7ad94bdfa5 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 27 Jun 2022 00:43:18 +0200 Subject: [PATCH 5/5] Update stm32-data --- embassy-stm32/src/usb/usb.rs | 2 +- stm32-data | 2 +- stm32-metapac-gen/src/lib.rs | 13 ++++++------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/embassy-stm32/src/usb/usb.rs b/embassy-stm32/src/usb/usb.rs index 10eb94e6c..cadbb423c 100644 --- a/embassy-stm32/src/usb/usb.rs +++ b/embassy-stm32/src/usb/usb.rs @@ -141,7 +141,7 @@ impl<'d, T: Instance> Driver<'d, T> { unsafe { crate::peripherals::PWR::enable(); - pac::PWR.cr2().modify(|w| w.set_usv(pac::pwr::vals::Usv::VALID)); + pac::PWR.cr2().modify(|w| w.set_usv(true)); } unsafe { diff --git a/stm32-data b/stm32-data index fa294eae7..56d5b8b2a 160000 --- a/stm32-data +++ b/stm32-data @@ -1 +1 @@ -Subproject commit fa294eae79c0f33f4cde1e73b4e69db59f7429e3 +Subproject commit 56d5b8b2aee7026b4f9bcffc427bb8f9d48afeb5 diff --git a/stm32-metapac-gen/src/lib.rs b/stm32-metapac-gen/src/lib.rs index 0d761508f..9bd60cb79 100644 --- a/stm32-metapac-gen/src/lib.rs +++ b/stm32-metapac-gen/src/lib.rs @@ -117,13 +117,12 @@ impl Gen { write!(&mut extra, "pub const CORE_INDEX: usize = {};\n", core_index).unwrap(); let flash = chip.memory.iter().find(|r| r.name == "BANK_1").unwrap(); - write!(&mut extra, "pub const FLASH_BASE: usize = {};\n", flash.address,).unwrap(); - write!(&mut extra, "pub const FLASH_SIZE: usize = {};\n", flash.size,).unwrap(); - if let Some(settings) = &flash.settings { - write!(&mut extra, "pub const ERASE_SIZE: usize = {};\n", settings.erase_size,).unwrap(); - write!(&mut extra, "pub const WRITE_SIZE: usize = {};\n", settings.write_size,).unwrap(); - write!(&mut extra, "pub const ERASE_VALUE: u8 = {};\n", settings.erase_value,).unwrap(); - } + let settings = flash.settings.as_ref().unwrap(); + write!(&mut extra, "pub const FLASH_BASE: usize = {};\n", flash.address).unwrap(); + write!(&mut extra, "pub const FLASH_SIZE: usize = {};\n", flash.size).unwrap(); + write!(&mut extra, "pub const ERASE_SIZE: usize = {};\n", settings.erase_size).unwrap(); + write!(&mut extra, "pub const WRITE_SIZE: usize = {};\n", settings.write_size).unwrap(); + write!(&mut extra, "pub const ERASE_VALUE: u8 = {};\n", settings.erase_value).unwrap(); // Cleanups! transform::sort::Sort {}.run(&mut ir).unwrap();