diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 5c2b0f6fc..1bc5553a2 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -34,11 +34,11 @@ impl From for vals::Pupdr { #[derive(Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Speed { - LowSpeed, - MediumSpeed, + Low, + Medium, #[cfg(not(syscfg_f0))] - HighSpeed, - VeryHighSpeed, + High, + VeryHigh, } impl From for vals::Ospeedr { @@ -46,11 +46,11 @@ impl From for vals::Ospeedr { use Speed::*; match speed { - LowSpeed => vals::Ospeedr::LOWSPEED, - MediumSpeed => vals::Ospeedr::MEDIUMSPEED, + Low => vals::Ospeedr::LOWSPEED, + Medium => vals::Ospeedr::MEDIUMSPEED, #[cfg(not(syscfg_f0))] - HighSpeed => vals::Ospeedr::HIGHSPEED, - VeryHighSpeed => vals::Ospeedr::VERYHIGHSPEED, + High => vals::Ospeedr::HIGHSPEED, + VeryHigh => vals::Ospeedr::VERYHIGHSPEED, } } } @@ -246,7 +246,7 @@ impl<'d, T: Pin> OutputPin for OutputOpenDrain<'d, T> { } } -impl<'d, T: Pin> InputPin for Input<'d, T> { +impl<'d, T: Pin> InputPin for OutputOpenDrain<'d, T> { type Error = Infallible; fn is_high(&self) -> Result { diff --git a/examples/stm32f4/src/bin/blinky.rs b/examples/stm32f4/src/bin/blinky.rs index 7590764d8..d2b607c2c 100644 --- a/examples/stm32f4/src/bin/blinky.rs +++ b/examples/stm32f4/src/bin/blinky.rs @@ -8,7 +8,7 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::gpio::{Level, Output}; +use embassy_stm32::gpio::{Level, Output, Speed}; use embedded_hal::digital::v2::OutputPin; use example_common::*; @@ -40,7 +40,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let mut led = Output::new(p.PB7, Level::High); + let mut led = Output::new(p.PB7, Level::High, Speed::Low); loop { info!("high"); diff --git a/examples/stm32f4/src/bin/button.rs b/examples/stm32f4/src/bin/button.rs index 1ee99f527..c7160d219 100644 --- a/examples/stm32f4/src/bin/button.rs +++ b/examples/stm32f4/src/bin/button.rs @@ -8,7 +8,7 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::gpio::{Input, Level, Output, Pull}; +use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embedded_hal::digital::v2::{InputPin, OutputPin}; use example_common::*; @@ -41,9 +41,9 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); let button = Input::new(p.PC13, Pull::Down); - let mut led1 = Output::new(p.PB0, Level::High); - let _led2 = Output::new(p.PB7, Level::High); - let mut led3 = Output::new(p.PB14, Level::High); + let mut led1 = Output::new(p.PB0, Level::High, Speed::Low); + let _led2 = Output::new(p.PB7, Level::High, Speed::Low); + let mut led3 = Output::new(p.PB14, Level::High, Speed::Low); loop { if button.is_high().unwrap() { diff --git a/examples/stm32f4/src/bin/spi.rs b/examples/stm32f4/src/bin/spi.rs index 610bb64e9..dda0ee4ed 100644 --- a/examples/stm32f4/src/bin/spi.rs +++ b/examples/stm32f4/src/bin/spi.rs @@ -9,7 +9,7 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::gpio::{Level, Output}; +use embassy_stm32::gpio::{Level, Output, Speed}; use embedded_hal::digital::v2::OutputPin; use example_common::*; @@ -58,7 +58,7 @@ fn main() -> ! { Config::default(), ); - let mut cs = Output::new(p.PE0, Level::High); + let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); loop { let mut buf = [0x0A; 4]; diff --git a/examples/stm32h7/src/bin/blinky.rs b/examples/stm32h7/src/bin/blinky.rs index c425b7f8e..d9f891e49 100644 --- a/examples/stm32h7/src/bin/blinky.rs +++ b/examples/stm32h7/src/bin/blinky.rs @@ -8,15 +8,15 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::gpio::{Level, Output}; +use embassy_stm32::gpio::{Level, Output, Speed}; use embedded_hal::digital::v2::OutputPin; use example_common::*; use cortex_m_rt::entry; use stm32h7::stm32h743 as pac; -use stm32h7xx_hal as hal; use hal::prelude::*; +use stm32h7xx_hal as hal; #[entry] fn main() -> ! { @@ -24,8 +24,7 @@ fn main() -> ! { let pp = pac::Peripherals::take().unwrap(); - let pwrcfg = pp.PWR.constrain() - .freeze(); + let pwrcfg = pp.PWR.constrain().freeze(); let rcc = pp.RCC.constrain(); @@ -60,7 +59,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let mut led = Output::new(p.PB14, Level::High); + let mut led = Output::new(p.PB14, Level::High, Speed::Low); loop { info!("high"); @@ -71,5 +70,4 @@ fn main() -> ! { led.set_low().unwrap(); cortex_m::asm::delay(10_000_000); } - } diff --git a/examples/stm32l0/src/bin/blinky.rs b/examples/stm32l0/src/bin/blinky.rs index ab0a2bdb2..833c14fbf 100644 --- a/examples/stm32l0/src/bin/blinky.rs +++ b/examples/stm32l0/src/bin/blinky.rs @@ -9,7 +9,7 @@ #[path = "../example_common.rs"] mod example_common; use embassy_stm32::{ - gpio::{Level, Output}, + gpio::{Level, Output, Speed}, rcc::*, }; use embedded_hal::digital::v2::OutputPin; @@ -25,7 +25,7 @@ fn main() -> ! { Rcc::new(p.RCC).enable_debug_wfe(&mut p.DBGMCU, true); - let mut led = Output::new(p.PB5, Level::High); + let mut led = Output::new(p.PB5, Level::High, Speed::Low); loop { info!("high"); diff --git a/examples/stm32l0/src/bin/button.rs b/examples/stm32l0/src/bin/button.rs index 04c48112a..5f46ec794 100644 --- a/examples/stm32l0/src/bin/button.rs +++ b/examples/stm32l0/src/bin/button.rs @@ -9,7 +9,7 @@ #[path = "../example_common.rs"] mod example_common; use embassy_stm32::{ - gpio::{Input, Level, Output, Pull}, + gpio::{Input, Level, Output, Pull, Speed}, rcc::*, }; use embedded_hal::digital::v2::{InputPin, OutputPin}; @@ -25,8 +25,8 @@ fn main() -> ! { Rcc::new(p.RCC).enable_debug_wfe(&mut p.DBGMCU, true); let button = Input::new(p.PB2, Pull::Up); - let mut led1 = Output::new(p.PA5, Level::High); - let mut led2 = Output::new(p.PB5, Level::High); + let mut led1 = Output::new(p.PA5, Level::High, Speed::Low); + let mut led2 = Output::new(p.PB5, Level::High, Speed::Low); loop { if button.is_high().unwrap() { diff --git a/examples/stm32l0/src/bin/spi.rs b/examples/stm32l0/src/bin/spi.rs index 0e828c436..9bb9b741e 100644 --- a/examples/stm32l0/src/bin/spi.rs +++ b/examples/stm32l0/src/bin/spi.rs @@ -9,7 +9,7 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::gpio::{Level, Output}; +use embassy_stm32::gpio::{Level, Output, Speed}; use embedded_hal::digital::v2::OutputPin; use example_common::*; @@ -36,7 +36,7 @@ fn main() -> ! { Config::default(), ); - let mut cs = Output::new(p.PA15, Level::High); + let mut cs = Output::new(p.PA15, Level::High, Speed::VeryHigh); loop { let mut buf = [0x0A; 4]; diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs index 42c9333f4..ae4b3d1d1 100644 --- a/examples/stm32l4/src/bin/blinky.rs +++ b/examples/stm32l4/src/bin/blinky.rs @@ -8,7 +8,7 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::gpio::{Level, Output}; +use embassy_stm32::gpio::{Level, Output, Speed}; use embedded_hal::digital::v2::OutputPin; use example_common::*; @@ -39,7 +39,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let mut led = Output::new(p.PB14, Level::High); + let mut led = Output::new(p.PB14, Level::High, Speed::Low); loop { info!("high"); diff --git a/examples/stm32l4/src/bin/button.rs b/examples/stm32l4/src/bin/button.rs index 962d5aa75..3efeee20f 100644 --- a/examples/stm32l4/src/bin/button.rs +++ b/examples/stm32l4/src/bin/button.rs @@ -8,7 +8,7 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::gpio::{Input, Level, Output, Pull}; +use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embedded_hal::digital::v2::{InputPin, OutputPin}; use example_common::*; @@ -40,8 +40,8 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); let button = Input::new(p.PC13, Pull::Up); - let mut led1 = Output::new(p.PA5, Level::High); - let mut led2 = Output::new(p.PB14, Level::High); + let mut led1 = Output::new(p.PA5, Level::High, Speed::Low); + let mut led2 = Output::new(p.PB14, Level::High, Speed::Low); loop { if button.is_high().unwrap() { diff --git a/examples/stm32l4/src/bin/spi.rs b/examples/stm32l4/src/bin/spi.rs index 7c672b70d..28c563c19 100644 --- a/examples/stm32l4/src/bin/spi.rs +++ b/examples/stm32l4/src/bin/spi.rs @@ -9,7 +9,7 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::gpio::{Level, Output}; +use embassy_stm32::gpio::{Level, Output, Speed}; use embedded_hal::digital::v2::OutputPin; use example_common::*; @@ -52,7 +52,7 @@ fn main() -> ! { Config::default(), ); - let mut cs = Output::new(p.PE0, Level::High); + let mut cs = Output::new(p.PE0, Level::High, Speed::VeryHigh); loop { let mut buf = [0x0A; 4]; diff --git a/examples/stm32wb55/src/bin/blinky.rs b/examples/stm32wb55/src/bin/blinky.rs index 8ce78a3c3..d53ad611a 100644 --- a/examples/stm32wb55/src/bin/blinky.rs +++ b/examples/stm32wb55/src/bin/blinky.rs @@ -8,7 +8,7 @@ #[path = "../example_common.rs"] mod example_common; -use embassy_stm32::gpio::{Level, Output}; +use embassy_stm32::gpio::{Level, Output, Speed}; use embedded_hal::digital::v2::OutputPin; use example_common::*; @@ -28,7 +28,7 @@ fn main() -> ! { let p = embassy_stm32::init(Default::default()); - let mut led = Output::new(p.PB0, Level::High); + let mut led = Output::new(p.PB0, Level::High, Speed::Low); loop { info!("high");