From 6416f2fc08578d0851ae603d96907256bd2849e7 Mon Sep 17 00:00:00 2001 From: xoviat Date: Tue, 6 Apr 2021 13:56:22 -0500 Subject: [PATCH 1/6] stm32: use crates version --- embassy-stm32/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 237eaa01..6ab434d1 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -46,6 +46,6 @@ embedded-hal = { version = "0.2.4" } embedded-dma = { version = "0.1.2" } bxcan = "0.5.0" nb = "*" -stm32f4xx-hal = { version = "0.8.3", features = ["rt", "can"], git = "https://github.com/stm32-rs/stm32f4xx-hal.git", optional = true } +stm32f4xx-hal = { version = "0.9.0", features = ["rt", "can"], optional = true } stm32l0xx-hal = { version = "0.7.0", features = ["rt"], optional = true } futures = { version = "0.3.5", default-features = false, features = ["async-await"] } \ No newline at end of file From 47843fcba5c4f1b0f1886cdb0a73cb0a61f5c8ae Mon Sep 17 00:00:00 2001 From: xoviat Date: Tue, 6 Apr 2021 13:58:55 -0500 Subject: [PATCH 2/6] stm32: fix interrupts --- embassy-stm32/src/interrupt.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/src/interrupt.rs b/embassy-stm32/src/interrupt.rs index 262bc3d9..63b80a6c 100644 --- a/embassy-stm32/src/interrupt.rs +++ b/embassy-stm32/src/interrupt.rs @@ -243,8 +243,8 @@ mod irqs { // declare!(SPI5); // declare!(SPI6); // declare!(SAI1); - declare!(LCD_TFT); - declare!(LCD_TFT_1); + // declare!(LCD_TFT); + // declare!(LCD_TFT_1); // declare!(DMA2D); } From 86cc1eee98e9f8232410d1cf2cf1302feb2d426d Mon Sep 17 00:00:00 2001 From: xoviat Date: Tue, 6 Apr 2021 14:05:08 -0500 Subject: [PATCH 3/6] stm32: fix examples --- embassy-stm32-examples/Cargo.toml | 35 ++++++++++++------------ embassy-stm32-examples/src/bin/can.rs | 4 +-- embassy-stm32-examples/src/bin/exti.rs | 4 +-- embassy-stm32-examples/src/bin/hello.rs | 2 +- embassy-stm32-examples/src/bin/serial.rs | 8 +++--- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/embassy-stm32-examples/Cargo.toml b/embassy-stm32-examples/Cargo.toml index 52446db3..f12ed910 100644 --- a/embassy-stm32-examples/Cargo.toml +++ b/embassy-stm32-examples/Cargo.toml @@ -15,23 +15,23 @@ defmt-info = [] defmt-warn = [] defmt-error = [] -stm32f401 = ["stm32f4xx-hal/stm32f401", "embassy-stm32/stm32f401"] -stm32f405 = ["stm32f4xx-hal/stm32f405", "embassy-stm32/stm32f405"] -stm32f407 = ["stm32f4xx-hal/stm32f407", "embassy-stm32/stm32f407"] -stm32f410 = ["stm32f4xx-hal/stm32f410", "embassy-stm32/stm32f410"] -stm32f411 = ["stm32f4xx-hal/stm32f411", "embassy-stm32/stm32f411"] -stm32f412 = ["stm32f4xx-hal/stm32f412", "embassy-stm32/stm32f412"] -stm32f413 = ["stm32f4xx-hal/stm32f413", "embassy-stm32/stm32f413"] -stm32f415 = ["stm32f4xx-hal/stm32f405", "embassy-stm32/stm32f405"] -stm32f417 = ["stm32f4xx-hal/stm32f407", "embassy-stm32/stm32f407"] -stm32f423 = ["stm32f4xx-hal/stm32f413", "embassy-stm32/stm32f413"] -stm32f427 = ["stm32f4xx-hal/stm32f427", "embassy-stm32/stm32f427"] -stm32f429 = ["stm32f4xx-hal/stm32f429", "embassy-stm32/stm32f429"] -stm32f437 = ["stm32f4xx-hal/stm32f427", "embassy-stm32/stm32f427"] -stm32f439 = ["stm32f4xx-hal/stm32f429", "embassy-stm32/stm32f429"] -stm32f446 = ["stm32f4xx-hal/stm32f446", "embassy-stm32/stm32f446"] -stm32f469 = ["stm32f4xx-hal/stm32f469", "embassy-stm32/stm32f469"] -stm32f479 = ["stm32f4xx-hal/stm32f469", "embassy-stm32/stm32f469"] +stm32f401 = ["embassy-stm32/stm32f401"] +stm32f405 = ["embassy-stm32/stm32f405"] +stm32f407 = ["embassy-stm32/stm32f407"] +stm32f410 = ["embassy-stm32/stm32f410"] +stm32f411 = ["embassy-stm32/stm32f411"] +stm32f412 = ["embassy-stm32/stm32f412"] +stm32f413 = ["embassy-stm32/stm32f413"] +stm32f415 = ["embassy-stm32/stm32f405"] +stm32f417 = ["embassy-stm32/stm32f407"] +stm32f423 = ["embassy-stm32/stm32f413"] +stm32f427 = ["embassy-stm32/stm32f427"] +stm32f429 = ["embassy-stm32/stm32f429"] +stm32f437 = ["embassy-stm32/stm32f427"] +stm32f439 = ["embassy-stm32/stm32f429"] +stm32f446 = ["embassy-stm32/stm32f446"] +stm32f469 = ["embassy-stm32/stm32f469"] +stm32f479 = ["embassy-stm32/stm32f469"] [dependencies] @@ -47,7 +47,6 @@ cortex-m = "0.7.1" cortex-m-rt = "0.6.13" embedded-hal = { version = "0.2.4" } panic-probe = "0.1.0" -stm32f4xx-hal = { version = "0.8.3", features = ["rt", "usb_fs"], git = "https://github.com/stm32-rs/stm32f4xx-hal.git"} futures = { version = "0.3.8", default-features = false, features = ["async-await"] } rtt-target = { version = "0.3", features = ["cortex-m"] } bxcan = "0.5.0" diff --git a/embassy-stm32-examples/src/bin/can.rs b/embassy-stm32-examples/src/bin/can.rs index 4923d399..72272212 100644 --- a/embassy-stm32-examples/src/bin/can.rs +++ b/embassy-stm32-examples/src/bin/can.rs @@ -13,9 +13,9 @@ use bxcan::filter::Mask32; use cortex_m_rt::entry; use embassy::executor::Executor; use embassy::util::Forever; +use embassy_stm32::hal::prelude::*; +use embassy_stm32::hal::{can::Can, stm32}; use embassy_stm32::{can, interrupt}; -use stm32f4xx_hal::prelude::*; -use stm32f4xx_hal::{can::Can, stm32}; #[embassy::task] async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) { diff --git a/embassy-stm32-examples/src/bin/exti.rs b/embassy-stm32-examples/src/bin/exti.rs index 6c08e689..27744c4c 100644 --- a/embassy-stm32-examples/src/bin/exti.rs +++ b/embassy-stm32-examples/src/bin/exti.rs @@ -14,10 +14,10 @@ use embassy::executor::Executor; use embassy::traits::gpio::*; use embassy::util::Forever; use embassy_stm32::exti::ExtiPin; +use embassy_stm32::hal::prelude::*; use embassy_stm32::interrupt; +use embassy_stm32::pac as stm32; use futures::pin_mut; -use stm32f4xx_hal::prelude::*; -use stm32f4xx_hal::stm32; #[embassy::task] async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) { diff --git a/embassy-stm32-examples/src/bin/hello.rs b/embassy-stm32-examples/src/bin/hello.rs index 8a665414..d2db4a2a 100644 --- a/embassy-stm32-examples/src/bin/hello.rs +++ b/embassy-stm32-examples/src/bin/hello.rs @@ -10,7 +10,7 @@ mod example_common; use example_common::*; use cortex_m_rt::entry; -use stm32f4xx_hal::prelude::*; +use embassy_stm32::hal::prelude::*; #[entry] fn main() -> ! { diff --git a/embassy-stm32-examples/src/bin/serial.rs b/embassy-stm32-examples/src/bin/serial.rs index 78ad06ab..9aeca537 100644 --- a/embassy-stm32-examples/src/bin/serial.rs +++ b/embassy-stm32-examples/src/bin/serial.rs @@ -14,13 +14,13 @@ use cortex_m_rt::entry; use embassy::executor::{Executor, Spawner}; use embassy::traits::uart::{Read, ReadUntilIdle, Write}; use embassy::util::Forever; +use embassy_stm32::hal::dma::StreamsTuple; +use embassy_stm32::hal::prelude::*; +use embassy_stm32::hal::serial::config::Config; use embassy_stm32::interrupt; +use embassy_stm32::pac as stm32; use embassy_stm32::serial; use futures::pin_mut; -use stm32f4xx_hal::dma::StreamsTuple; -use stm32f4xx_hal::prelude::*; -use stm32f4xx_hal::serial::config::Config; -use stm32f4xx_hal::stm32; #[embassy::main(use_hse = 16, sysclk = 48, pclk1 = 24)] async fn main(spawner: Spawner) { From 12bd3c5ea5571c88283ac3aeea5629f0186e7218 Mon Sep 17 00:00:00 2001 From: xoviat Date: Tue, 6 Apr 2021 14:10:47 -0500 Subject: [PATCH 4/6] stm32: fix peripherals --- embassy-stm32/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 3b8b36fa..5e86e5be 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -206,7 +206,7 @@ embassy_extras::std_peripherals! { PWR, QUADSPI, SPDIFRX, - SDMMC, +// SDMMC, HDMI_CEC, FPU, STK, From dea09876e030f97ed53d1b81a5327d98c7bcb805 Mon Sep 17 00:00:00 2001 From: xoviat Date: Tue, 6 Apr 2021 14:17:29 -0500 Subject: [PATCH 5/6] stm32: fix example --- embassy-stm32-examples/src/bin/hello.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embassy-stm32-examples/src/bin/hello.rs b/embassy-stm32-examples/src/bin/hello.rs index d2db4a2a..b851482d 100644 --- a/embassy-stm32-examples/src/bin/hello.rs +++ b/embassy-stm32-examples/src/bin/hello.rs @@ -16,7 +16,7 @@ use embassy_stm32::hal::prelude::*; fn main() -> ! { info!("Hello World!"); - let p = stm32f4xx_hal::stm32::Peripherals::take().unwrap(); + let p = embassy_stm32::pac::Peripherals::take().unwrap(); p.DBGMCU.cr.modify(|_, w| { w.dbg_sleep().set_bit(); From 7cb46ac720a85cdf67e68730ba11130b1d02fbc6 Mon Sep 17 00:00:00 2001 From: xoviat Date: Tue, 6 Apr 2021 14:23:13 -0500 Subject: [PATCH 6/6] stm32: fix usb --- embassy-stm32-examples/src/bin/usb_serial.rs | 4 ++-- embassy-stm32/Cargo.toml | 2 +- embassy-stm32/src/rtc.rs | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/embassy-stm32-examples/src/bin/usb_serial.rs b/embassy-stm32-examples/src/bin/usb_serial.rs index 7e95f122..6a1d27d5 100644 --- a/embassy-stm32-examples/src/bin/usb_serial.rs +++ b/embassy-stm32-examples/src/bin/usb_serial.rs @@ -17,11 +17,11 @@ use embassy::time::{Duration, Timer}; use embassy::util::Forever; use embassy_extras::usb::usb_serial::UsbSerial; use embassy_extras::usb::Usb; +use embassy_stm32::hal::otg_fs::{UsbBus, USB}; +use embassy_stm32::hal::prelude::*; use embassy_stm32::{interrupt, pac, rtc}; use futures::future::{select, Either}; use futures::pin_mut; -use stm32f4xx_hal::otg_fs::{UsbBus, USB}; -use stm32f4xx_hal::prelude::*; use usb_device::bus::UsbBusAllocator; use usb_device::prelude::*; diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 6ab434d1..52335941 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -46,6 +46,6 @@ embedded-hal = { version = "0.2.4" } embedded-dma = { version = "0.1.2" } bxcan = "0.5.0" nb = "*" -stm32f4xx-hal = { version = "0.9.0", features = ["rt", "can"], optional = true } +stm32f4xx-hal = { version = "0.9.0", features = ["rt", "can", "usb_fs"], optional = true } stm32l0xx-hal = { version = "0.7.0", features = ["rt"], optional = true } futures = { version = "0.3.5", default-features = false, features = ["async-await"] } \ No newline at end of file diff --git a/embassy-stm32/src/rtc.rs b/embassy-stm32/src/rtc.rs index 824a4707..b1abba32 100644 --- a/embassy-stm32/src/rtc.rs +++ b/embassy-stm32/src/rtc.rs @@ -1,8 +1,8 @@ +use crate::hal::bb; +use crate::hal::rcc::Clocks; use core::cell::Cell; use core::convert::TryInto; use core::sync::atomic::{compiler_fence, AtomicU32, Ordering}; -use stm32f4xx_hal::bb; -use stm32f4xx_hal::rcc::Clocks; use embassy::interrupt::InterruptExt; use embassy::time::{Clock, TICKS_PER_SECOND}; @@ -259,7 +259,7 @@ macro_rules! impl_timer { ($module:ident: ($TYPE:ident, $INT:ident, $apbenr:ident, $enrbit:expr, $apbrstr:ident, $rstrbit:expr, $ppre:ident, $pclk: ident), 3) => { mod $module { use super::*; - use stm32f4xx_hal::pac::{$TYPE, RCC}; + use crate::hal::pac::{$TYPE, RCC}; impl sealed::Sealed for $TYPE {} @@ -376,7 +376,7 @@ macro_rules! impl_timer { ($module:ident: ($TYPE:ident, $INT:ident, $apbenr:ident, $enrbit:expr, $apbrstr:ident, $rstrbit:expr, $ppre:ident, $pclk: ident), 1) => { mod $module { use super::*; - use stm32f4xx_hal::pac::{$TYPE, RCC}; + use crate::hal::pac::{$TYPE, RCC}; impl sealed::Sealed for $TYPE {}