From 9f76dbb93b4ab5efc8a0d51b4507ab7eb144fcd9 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 22 Jan 2024 21:29:25 +0100 Subject: Remove nightly-only flags from cargo configs. --- examples/boot/.cargo/config.toml | 4 ++-- examples/boot/application/rp/.cargo/config.toml | 4 ++-- examples/boot/bootloader/nrf/.cargo/config.toml | 6 +++--- tests/rp/.cargo/config.toml | 2 +- tests/stm32/.cargo/config.toml | 8 ++++---- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/boot/.cargo/config.toml b/examples/boot/.cargo/config.toml index de3a814f7..be1b73e45 100644 --- a/examples/boot/.cargo/config.toml +++ b/examples/boot/.cargo/config.toml @@ -1,6 +1,6 @@ [unstable] -build-std = ["core"] -build-std-features = ["panic_immediate_abort"] +#build-std = ["core"] +#build-std-features = ["panic_immediate_abort"] [build] target = "thumbv7em-none-eabi" diff --git a/examples/boot/application/rp/.cargo/config.toml b/examples/boot/application/rp/.cargo/config.toml index cd8d1ef02..22ab3a5c1 100644 --- a/examples/boot/application/rp/.cargo/config.toml +++ b/examples/boot/application/rp/.cargo/config.toml @@ -1,6 +1,6 @@ [unstable] -build-std = ["core"] -build-std-features = ["panic_immediate_abort"] +#build-std = ["core"] +#build-std-features = ["panic_immediate_abort"] [target.'cfg(all(target_arch = "arm", target_os = "none"))'] runner = "probe-rs run --chip RP2040" diff --git a/examples/boot/bootloader/nrf/.cargo/config.toml b/examples/boot/bootloader/nrf/.cargo/config.toml index c292846aa..58acd1a49 100644 --- a/examples/boot/bootloader/nrf/.cargo/config.toml +++ b/examples/boot/bootloader/nrf/.cargo/config.toml @@ -1,6 +1,6 @@ [unstable] -build-std = ["core"] -build-std-features = ["panic_immediate_abort"] +#build-std = ["core"] +#build-std-features = ["panic_immediate_abort"] [target.'cfg(all(target_arch = "arm", target_os = "none"))'] #runner = "./fruitrunner" @@ -8,7 +8,7 @@ runner = "probe-rs run --chip nrf52840_xxAA" rustflags = [ # Code-size optimizations. - "-Z", "trap-unreachable=no", + #"-Z", "trap-unreachable=no", #"-C", "no-vectorize-loops", "-C", "force-frame-pointers=yes", ] diff --git a/tests/rp/.cargo/config.toml b/tests/rp/.cargo/config.toml index 40b5d7000..de7bb0e56 100644 --- a/tests/rp/.cargo/config.toml +++ b/tests/rp/.cargo/config.toml @@ -10,7 +10,7 @@ runner = "teleprobe client run" rustflags = [ # Code-size optimizations. - "-Z", "trap-unreachable=no", + #"-Z", "trap-unreachable=no", "-C", "inline-threshold=5", "-C", "no-vectorize-loops", ] diff --git a/tests/stm32/.cargo/config.toml b/tests/stm32/.cargo/config.toml index 2e3f055d4..8e32b4cee 100644 --- a/tests/stm32/.cargo/config.toml +++ b/tests/stm32/.cargo/config.toml @@ -1,6 +1,6 @@ [unstable] -build-std = ["core"] -build-std-features = ["panic_immediate_abort"] +#build-std = ["core"] +#build-std-features = ["panic_immediate_abort"] [target.'cfg(all(target_arch = "arm", target_os = "none"))'] runner = "teleprobe client run" @@ -8,7 +8,7 @@ runner = "teleprobe client run" rustflags = [ # Code-size optimizations. - "-Z", "trap-unreachable=no", + #"-Z", "trap-unreachable=no", "-C", "inline-threshold=5", "-C", "no-vectorize-loops", ] @@ -20,4 +20,4 @@ target = "thumbv6m-none-eabi" #target = "thumbv8m.main-none-eabihf" [env] -DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info" \ No newline at end of file +DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info" -- cgit From 3387ee7238f1c9c4eeccb732ba543cbe38ab7ccd Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 22 Jan 2024 20:12:36 +0100 Subject: stm32/gpio: remove generics. --- .../layer-by-layer/blinky-async/src/main.rs | 4 +- .../examples/layer-by-layer/blinky-irq/src/main.rs | 13 +- embassy-stm32/src/exti.rs | 45 ++++--- embassy-stm32/src/gpio.rs | 141 +++++++-------------- examples/boot/application/stm32f3/src/bin/a.rs | 5 +- examples/boot/application/stm32f7/src/bin/a.rs | 5 +- examples/boot/application/stm32h7/src/bin/a.rs | 5 +- examples/boot/application/stm32l0/src/bin/a.rs | 5 +- examples/boot/application/stm32l1/src/bin/a.rs | 5 +- examples/boot/application/stm32l4/src/bin/a.rs | 5 +- examples/boot/application/stm32wl/src/bin/a.rs | 5 +- examples/stm32c0/src/bin/button_exti.rs | 5 +- .../stm32f0/src/bin/button_controlled_blink.rs | 5 +- examples/stm32f0/src/bin/button_exti.rs | 5 +- examples/stm32f3/src/bin/button_events.rs | 28 ++-- examples/stm32f3/src/bin/button_exti.rs | 5 +- examples/stm32f4/src/bin/button_exti.rs | 5 +- examples/stm32f7/src/bin/button_exti.rs | 5 +- examples/stm32g0/src/bin/button_exti.rs | 5 +- examples/stm32g4/src/bin/button_exti.rs | 5 +- examples/stm32h5/src/bin/button_exti.rs | 5 +- examples/stm32h7/src/bin/button_exti.rs | 5 +- examples/stm32l0/src/bin/button_exti.rs | 5 +- examples/stm32l4/src/bin/button_exti.rs | 5 +- .../stm32l4/src/bin/spe_adin1110_http_server.rs | 13 +- examples/stm32l5/src/bin/button_exti.rs | 5 +- examples/stm32wb/src/bin/button_exti.rs | 5 +- examples/stm32wba/src/bin/button_exti.rs | 5 +- examples/stm32wl/src/bin/button_exti.rs | 5 +- 29 files changed, 144 insertions(+), 215 deletions(-) diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs index e6753be28..004602816 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs @@ -3,14 +3,14 @@ use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::gpio::{Level, Output, Pull, Speed}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh); - let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); loop { button.wait_for_any_edge().await; diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs index aecba0755..743c9d99b 100644 --- a/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs +++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-irq/src/main.rs @@ -6,13 +6,12 @@ use core::cell::RefCell; use cortex_m::interrupt::Mutex; use cortex_m::peripheral::NVIC; use cortex_m_rt::entry; -use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; -use embassy_stm32::peripherals::{PB14, PC13}; +use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; use embassy_stm32::{interrupt, pac}; use {defmt_rtt as _, panic_probe as _}; -static BUTTON: Mutex>>> = Mutex::new(RefCell::new(None)); -static LED: Mutex>>> = Mutex::new(RefCell::new(None)); +static BUTTON: Mutex>>> = Mutex::new(RefCell::new(None)); +static LED: Mutex>>> = Mutex::new(RefCell::new(None)); #[entry] fn main() -> ! { @@ -62,14 +61,14 @@ fn EXTI15_10() { const PORT: u8 = 2; const PIN: usize = 13; -fn check_interrupt(_pin: &mut Input<'static, P>) -> bool { +fn check_interrupt(_pin: &mut Input<'static>) -> bool { let exti = pac::EXTI; let pin = PIN; let lines = exti.pr(0).read(); lines.line(pin) } -fn clear_interrupt(_pin: &mut Input<'static, P>) { +fn clear_interrupt(_pin: &mut Input<'static>) { let exti = pac::EXTI; let pin = PIN; let mut lines = exti.pr(0).read(); @@ -77,7 +76,7 @@ fn clear_interrupt(_pin: &mut Input<'static, P>) { exti.pr(0).write_value(lines); } -fn enable_interrupt(_pin: &mut Input<'static, P>) { +fn enable_interrupt(_pin: &mut Input<'static>) { cortex_m::interrupt::free(|_| { let rcc = pac::RCC; rcc.apb2enr().modify(|w| w.set_syscfgen(true)); diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 2821435ef..bd10ba158 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -5,10 +5,10 @@ use core::marker::PhantomData; use core::pin::Pin; use core::task::{Context, Poll}; -use embassy_hal_internal::impl_peripheral; +use embassy_hal_internal::{impl_peripheral, into_ref}; use embassy_sync::waitqueue::AtomicWaker; -use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin}; +use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin, Pull}; use crate::pac::exti::regs::Lines; use crate::pac::EXTI; use crate::{interrupt, pac, peripherals, Peripheral}; @@ -93,16 +93,27 @@ impl Iterator for BitIter { /// EXTI channel, which is a limited resource. /// /// Pins PA5, PB5, PC5... all use EXTI channel 5, so you can't use EXTI on, say, PA5 and PC5 at the same time. -pub struct ExtiInput<'d, T: GpioPin> { - pin: Input<'d, T>, +pub struct ExtiInput<'d> { + pin: Input<'d>, } -impl<'d, T: GpioPin> Unpin for ExtiInput<'d, T> {} +impl<'d> Unpin for ExtiInput<'d> {} -impl<'d, T: GpioPin> ExtiInput<'d, T> { +impl<'d> ExtiInput<'d> { /// Create an EXTI input. - pub fn new(pin: Input<'d, T>, _ch: impl Peripheral

+ 'd) -> Self { - Self { pin } + pub fn new( + pin: impl Peripheral

+ 'd, + ch: impl Peripheral

+ 'd, + pull: Pull, + ) -> Self { + into_ref!(pin, ch); + + // Needed if using AnyPin+AnyChannel. + assert_eq!(pin.pin(), ch.number()); + + Self { + pin: Input::new(pin, pull), + } } /// Get whether the pin is high. @@ -162,7 +173,7 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> { } } -impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> { +impl<'d> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d> { type Error = Infallible; fn is_high(&self) -> Result { @@ -174,11 +185,11 @@ impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> } } -impl<'d, T: GpioPin> embedded_hal_1::digital::ErrorType for ExtiInput<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for ExtiInput<'d> { type Error = Infallible; } -impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> { +impl<'d> embedded_hal_1::digital::InputPin for ExtiInput<'d> { fn is_high(&mut self) -> Result { Ok((*self).is_high()) } @@ -188,7 +199,7 @@ impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> { } } -impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for ExtiInput<'d, T> { +impl<'d> embedded_hal_async::digital::Wait for ExtiInput<'d> { async fn wait_for_high(&mut self) -> Result<(), Self::Error> { self.wait_for_high().await; Ok(()) @@ -326,7 +337,7 @@ pub(crate) mod sealed { /// EXTI channel trait. pub trait Channel: sealed::Channel + Sized { /// Get the EXTI channel number. - fn number(&self) -> usize; + fn number(&self) -> u8; /// Type-erase (degrade) this channel into an `AnyChannel`. /// @@ -350,8 +361,8 @@ pub struct AnyChannel { impl_peripheral!(AnyChannel); impl sealed::Channel for AnyChannel {} impl Channel for AnyChannel { - fn number(&self) -> usize { - self.number as usize + fn number(&self) -> u8 { + self.number } } @@ -359,8 +370,8 @@ macro_rules! impl_exti { ($type:ident, $number:expr) => { impl sealed::Channel for peripherals::$type {} impl Channel for peripherals::$type { - fn number(&self) -> usize { - $number as usize + fn number(&self) -> u8 { + $number } } }; diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 7eb70496f..1051a13c8 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -6,6 +6,7 @@ use core::convert::Infallible; use critical_section::CriticalSection; use embassy_hal_internal::{impl_peripheral, into_ref, PeripheralRef}; +use self::sealed::Pin as _; use crate::pac::gpio::{self, vals}; use crate::{pac, peripherals, Peripheral}; @@ -14,41 +15,21 @@ use crate::{pac, peripherals, Peripheral}; /// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain /// set while not in output mode, so the pin's level will be 'remembered' when it is not in output /// mode. -pub struct Flex<'d, T: Pin> { - pub(crate) pin: PeripheralRef<'d, T>, +pub struct Flex<'d> { + pub(crate) pin: PeripheralRef<'d, AnyPin>, } -impl<'d, T: Pin> Flex<'d, T> { +impl<'d> Flex<'d> { /// Wrap the pin in a `Flex`. /// /// The pin remains disconnected. The initial output level is unspecified, but can be changed /// before the pin is put into output mode. /// #[inline] - pub fn new(pin: impl Peripheral

+ 'd) -> Self { + pub fn new(pin: impl Peripheral

+ 'd) -> Self { into_ref!(pin); // Pin will be in disconnected state. - Self { pin } - } - - /// Type-erase (degrade) this pin into an `AnyPin`. - /// - /// This converts pin singletons (`PA5`, `PB6`, ...), which - /// are all different types, into the same type. It is useful for - /// creating arrays of pins, or avoiding generics. - #[inline] - pub fn degrade(self) -> Flex<'d, AnyPin> { - // Safety: We are about to drop the other copy of this pin, so - // this clone is safe. - let pin = unsafe { self.pin.clone_unchecked() }; - - // We don't want to run the destructor here, because that would - // deconfigure the pin. - core::mem::forget(self); - - Flex { - pin: pin.map_into::(), - } + Self { pin: pin.map_into() } } /// Put the pin into input mode. @@ -218,7 +199,7 @@ impl<'d, T: Pin> Flex<'d, T> { } } -impl<'d, T: Pin> Drop for Flex<'d, T> { +impl<'d> Drop for Flex<'d> { #[inline] fn drop(&mut self) { critical_section::with(|_| { @@ -309,31 +290,19 @@ impl From for vals::Ospeedr { } /// GPIO input driver. -pub struct Input<'d, T: Pin> { - pub(crate) pin: Flex<'d, T>, +pub struct Input<'d> { + pub(crate) pin: Flex<'d>, } -impl<'d, T: Pin> Input<'d, T> { +impl<'d> Input<'d> { /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration. #[inline] - pub fn new(pin: impl Peripheral

+ 'd, pull: Pull) -> Self { + pub fn new(pin: impl Peripheral

+ 'd, pull: Pull) -> Self { let mut pin = Flex::new(pin); pin.set_as_input(pull); Self { pin } } - /// Type-erase (degrade) this pin into an `AnyPin`. - /// - /// This converts pin singletons (`PA5`, `PB6`, ...), which - /// are all different types, into the same type. It is useful for - /// creating arrays of pins, or avoiding generics. - #[inline] - pub fn degrade(self) -> Input<'d, AnyPin> { - Input { - pin: self.pin.degrade(), - } - } - /// Get whether the pin input level is high. #[inline] pub fn is_high(&self) -> bool { @@ -386,14 +355,14 @@ impl From for bool { /// Note that pins will **return to their floating state** when `Output` is dropped. /// If pins should retain their state indefinitely, either keep ownership of the /// `Output`, or pass it to [`core::mem::forget`]. -pub struct Output<'d, T: Pin> { - pub(crate) pin: Flex<'d, T>, +pub struct Output<'d> { + pub(crate) pin: Flex<'d>, } -impl<'d, T: Pin> Output<'d, T> { +impl<'d> Output<'d> { /// Create GPIO output driver for a [Pin] with the provided [Level] and [Speed] configuration. #[inline] - pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level, speed: Speed) -> Self { + pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level, speed: Speed) -> Self { let mut pin = Flex::new(pin); match initial_output { Level::High => pin.set_high(), @@ -403,18 +372,6 @@ impl<'d, T: Pin> Output<'d, T> { Self { pin } } - /// Type-erase (degrade) this pin into an `AnyPin`. - /// - /// This converts pin singletons (`PA5`, `PB6`, ...), which - /// are all different types, into the same type. It is useful for - /// creating arrays of pins, or avoiding generics. - #[inline] - pub fn degrade(self) -> Output<'d, AnyPin> { - Output { - pin: self.pin.degrade(), - } - } - /// Set the output as high. #[inline] pub fn set_high(&mut self) { @@ -463,14 +420,14 @@ impl<'d, T: Pin> Output<'d, T> { /// Note that pins will **return to their floating state** when `OutputOpenDrain` is dropped. /// If pins should retain their state indefinitely, either keep ownership of the /// `OutputOpenDrain`, or pass it to [`core::mem::forget`]. -pub struct OutputOpenDrain<'d, T: Pin> { - pub(crate) pin: Flex<'d, T>, +pub struct OutputOpenDrain<'d> { + pub(crate) pin: Flex<'d>, } -impl<'d, T: Pin> OutputOpenDrain<'d, T> { +impl<'d> OutputOpenDrain<'d> { /// Create a new GPIO open drain output driver for a [Pin] with the provided [Level] and [Speed], [Pull] configuration. #[inline] - pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level, speed: Speed, pull: Pull) -> Self { + pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level, speed: Speed, pull: Pull) -> Self { let mut pin = Flex::new(pin); match initial_output { @@ -482,18 +439,6 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { Self { pin } } - /// Type-erase (degrade) this pin into an `AnyPin`. - /// - /// This converts pin singletons (`PA5`, `PB6`, ...), which - /// are all different types, into the same type. It is useful for - /// creating arrays of pins, or avoiding generics. - #[inline] - pub fn degrade(self) -> Output<'d, AnyPin> { - Output { - pin: self.pin.degrade(), - } - } - /// Get whether the pin input level is high. #[inline] pub fn is_high(&self) -> bool { @@ -836,7 +781,7 @@ pub(crate) unsafe fn init(_cs: CriticalSection) { }); } -impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { +impl<'d> embedded_hal_02::digital::v2::InputPin for Input<'d> { type Error = Infallible; #[inline] @@ -850,7 +795,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { } } -impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { +impl<'d> embedded_hal_02::digital::v2::OutputPin for Output<'d> { type Error = Infallible; #[inline] @@ -866,7 +811,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { } } -impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { +impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d> { #[inline] fn is_set_high(&self) -> Result { Ok(self.is_set_high()) @@ -879,7 +824,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, } } -impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> { +impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d> { type Error = Infallible; #[inline] fn toggle(&mut self) -> Result<(), Self::Error> { @@ -888,7 +833,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d } } -impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d> { type Error = Infallible; #[inline] @@ -904,7 +849,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, } } -impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d> { #[inline] fn is_set_high(&self) -> Result { Ok(self.is_set_high()) @@ -917,7 +862,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenD } } -impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d> { type Error = Infallible; #[inline] fn toggle(&mut self) -> Result<(), Self::Error> { @@ -926,7 +871,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpe } } -impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { +impl<'d> embedded_hal_02::digital::v2::InputPin for Flex<'d> { type Error = Infallible; #[inline] @@ -940,7 +885,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { } } -impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { +impl<'d> embedded_hal_02::digital::v2::OutputPin for Flex<'d> { type Error = Infallible; #[inline] @@ -956,7 +901,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { } } -impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { +impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d> { #[inline] fn is_set_high(&self) -> Result { Ok(self.is_set_high()) @@ -969,7 +914,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> } } -impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> { +impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d> { type Error = Infallible; #[inline] fn toggle(&mut self) -> Result<(), Self::Error> { @@ -978,11 +923,11 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, } } -impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for Input<'d> { type Error = Infallible; } -impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { +impl<'d> embedded_hal_1::digital::InputPin for Input<'d> { #[inline] fn is_high(&mut self) -> Result { Ok((*self).is_high()) @@ -994,11 +939,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> { type Error = Infallible; } -impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { +impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> { #[inline] fn set_high(&mut self) -> Result<(), Self::Error> { Ok(self.set_high()) @@ -1010,7 +955,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { +impl<'d> embedded_hal_1::digital::StatefulOutputPin for Output<'d> { #[inline] fn is_set_high(&mut self) -> Result { Ok((*self).is_set_high()) @@ -1023,11 +968,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d> { type Error = Infallible; } -impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d> { #[inline] fn is_high(&mut self) -> Result { Ok((*self).is_high()) @@ -1039,7 +984,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d> { #[inline] fn set_high(&mut self) -> Result<(), Self::Error> { Ok(self.set_high()) @@ -1051,7 +996,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d> { #[inline] fn is_set_high(&mut self) -> Result { Ok((*self).is_set_high()) @@ -1064,7 +1009,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain< } } -impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> { #[inline] fn is_high(&mut self) -> Result { Ok((*self).is_high()) @@ -1076,7 +1021,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> { #[inline] fn set_high(&mut self) -> Result<(), Self::Error> { Ok(self.set_high()) @@ -1088,11 +1033,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for Flex<'d> { type Error = Infallible; } -impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::StatefulOutputPin for Flex<'d> { #[inline] fn is_set_high(&mut self) -> Result { Ok((*self).is_set_high()) diff --git a/examples/boot/application/stm32f3/src/bin/a.rs b/examples/boot/application/stm32f3/src/bin/a.rs index 96ae5c47b..3f9ebe5c8 100644 --- a/examples/boot/application/stm32f3/src/bin/a.rs +++ b/examples/boot/application/stm32f3/src/bin/a.rs @@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::{Flash, WRITE_SIZE}; -use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::gpio::{Level, Output, Pull, Speed}; use embassy_sync::mutex::Mutex; use panic_reset as _; @@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) { let flash = Flash::new_blocking(p.FLASH); let flash = Mutex::new(BlockingAsync::new(flash)); - let button = Input::new(p.PC13, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); let mut led = Output::new(p.PA5, Level::Low, Speed::Low); led.set_high(); diff --git a/examples/boot/application/stm32f7/src/bin/a.rs b/examples/boot/application/stm32f7/src/bin/a.rs index a6107386a..c57c29263 100644 --- a/examples/boot/application/stm32f7/src/bin/a.rs +++ b/examples/boot/application/stm32f7/src/bin/a.rs @@ -9,7 +9,7 @@ use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdater use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::{Flash, WRITE_SIZE}; -use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::gpio::{Level, Output, Pull, Speed}; use embassy_sync::blocking_mutex::Mutex; use embedded_storage::nor_flash::NorFlash; use panic_reset as _; @@ -25,8 +25,7 @@ async fn main(_spawner: Spawner) { let flash = Flash::new_blocking(p.FLASH); let flash = Mutex::new(RefCell::new(flash)); - let button = Input::new(p.PC13, Pull::Down); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); let mut led = Output::new(p.PB7, Level::Low, Speed::Low); led.set_high(); diff --git a/examples/boot/application/stm32h7/src/bin/a.rs b/examples/boot/application/stm32h7/src/bin/a.rs index b73506cf3..a00d17408 100644 --- a/examples/boot/application/stm32h7/src/bin/a.rs +++ b/examples/boot/application/stm32h7/src/bin/a.rs @@ -9,7 +9,7 @@ use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdater use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::{Flash, WRITE_SIZE}; -use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::gpio::{Level, Output, Pull, Speed}; use embassy_sync::blocking_mutex::Mutex; use embedded_storage::nor_flash::NorFlash; use panic_reset as _; @@ -25,8 +25,7 @@ async fn main(_spawner: Spawner) { let flash = Flash::new_blocking(p.FLASH); let flash = Mutex::new(RefCell::new(flash)); - let button = Input::new(p.PC13, Pull::Down); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); let mut led = Output::new(p.PB14, Level::Low, Speed::Low); led.set_high(); diff --git a/examples/boot/application/stm32l0/src/bin/a.rs b/examples/boot/application/stm32l0/src/bin/a.rs index 02f74bdef..dbec49d44 100644 --- a/examples/boot/application/stm32l0/src/bin/a.rs +++ b/examples/boot/application/stm32l0/src/bin/a.rs @@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::{Flash, WRITE_SIZE}; -use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::gpio::{Level, Output, Pull, Speed}; use embassy_sync::mutex::Mutex; use embassy_time::Timer; use panic_reset as _; @@ -24,8 +24,7 @@ async fn main(_spawner: Spawner) { let flash = Flash::new_blocking(p.FLASH); let flash = Mutex::new(BlockingAsync::new(flash)); - let button = Input::new(p.PB2, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI2); + let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up); let mut led = Output::new(p.PB5, Level::Low, Speed::Low); diff --git a/examples/boot/application/stm32l1/src/bin/a.rs b/examples/boot/application/stm32l1/src/bin/a.rs index 02f74bdef..dbec49d44 100644 --- a/examples/boot/application/stm32l1/src/bin/a.rs +++ b/examples/boot/application/stm32l1/src/bin/a.rs @@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::{Flash, WRITE_SIZE}; -use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::gpio::{Level, Output, Pull, Speed}; use embassy_sync::mutex::Mutex; use embassy_time::Timer; use panic_reset as _; @@ -24,8 +24,7 @@ async fn main(_spawner: Spawner) { let flash = Flash::new_blocking(p.FLASH); let flash = Mutex::new(BlockingAsync::new(flash)); - let button = Input::new(p.PB2, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI2); + let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up); let mut led = Output::new(p.PB5, Level::Low, Speed::Low); diff --git a/examples/boot/application/stm32l4/src/bin/a.rs b/examples/boot/application/stm32l4/src/bin/a.rs index 892446968..e946c3cdf 100644 --- a/examples/boot/application/stm32l4/src/bin/a.rs +++ b/examples/boot/application/stm32l4/src/bin/a.rs @@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::{Flash, WRITE_SIZE}; -use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::gpio::{Level, Output, Pull, Speed}; use embassy_sync::mutex::Mutex; use panic_reset as _; @@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) { let flash = Flash::new_blocking(p.FLASH); let flash = Mutex::new(BlockingAsync::new(flash)); - let button = Input::new(p.PC13, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); let mut led = Output::new(p.PB14, Level::Low, Speed::Low); led.set_high(); diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs index d9665e6ee..b582d8b25 100644 --- a/examples/boot/application/stm32wl/src/bin/a.rs +++ b/examples/boot/application/stm32wl/src/bin/a.rs @@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; use embassy_stm32::flash::{Flash, WRITE_SIZE}; -use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::gpio::{Level, Output, Pull, Speed}; use embassy_sync::mutex::Mutex; use panic_reset as _; @@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) { let flash = Flash::new_blocking(p.FLASH); let flash = Mutex::new(BlockingAsync::new(flash)); - let button = Input::new(p.PA0, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI0); + let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up); let mut led = Output::new(p.PB9, Level::Low, Speed::Low); led.set_high(); diff --git a/examples/stm32c0/src/bin/button_exti.rs b/examples/stm32c0/src/bin/button_exti.rs index 1e970fdd6..34a08bbc6 100644 --- a/examples/stm32c0/src/bin/button_exti.rs +++ b/examples/stm32c0/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PC13, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); info!("Press the USER button..."); diff --git a/examples/stm32f0/src/bin/button_controlled_blink.rs b/examples/stm32f0/src/bin/button_controlled_blink.rs index 360d153c3..4465483d9 100644 --- a/examples/stm32f0/src/bin/button_controlled_blink.rs +++ b/examples/stm32f0/src/bin/button_controlled_blink.rs @@ -8,7 +8,7 @@ use core::sync::atomic::{AtomicU32, Ordering}; use defmt::info; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; +use embassy_stm32::gpio::{AnyPin, Level, Output, Pin, Pull, Speed}; use embassy_time::Timer; use {defmt_rtt as _, panic_probe as _}; @@ -36,8 +36,7 @@ async fn main(spawner: Spawner) { // Configure the button pin and obtain handler. // On the Nucleo F091RC there is a button connected to pin PC13. - let button = Input::new(p.PC13, Pull::None); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::None); // Create and initialize a delay variable to manage delay loop let mut del_var = 2000; diff --git a/examples/stm32f0/src/bin/button_exti.rs b/examples/stm32f0/src/bin/button_exti.rs index ce17c1a48..fd615a215 100644 --- a/examples/stm32f0/src/bin/button_exti.rs +++ b/examples/stm32f0/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -13,8 +13,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); // Configure the button pin and obtain handler. // On the Nucleo F091RC there is a button connected to pin PC13. - let button = Input::new(p.PC13, Pull::Down); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); info!("Press the USER button..."); loop { diff --git a/examples/stm32f3/src/bin/button_events.rs b/examples/stm32f3/src/bin/button_events.rs index 2f7da4ef5..f5ed5d2c9 100644 --- a/examples/stm32f3/src/bin/button_events.rs +++ b/examples/stm32f3/src/bin/button_events.rs @@ -12,21 +12,20 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; -use embassy_stm32::peripherals::PA0; +use embassy_stm32::gpio::{Level, Output, Pull, Speed}; use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; use embassy_sync::channel::Channel; use embassy_time::{with_timeout, Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; struct Leds<'a> { - leds: [Output<'a, AnyPin>; 8], + leds: [Output<'a>; 8], direction: i8, current_led: usize, } impl<'a> Leds<'a> { - fn new(pins: [Output<'a, AnyPin>; 8]) -> Self { + fn new(pins: [Output<'a>; 8]) -> Self { Self { leds: pins, direction: 1, @@ -100,18 +99,17 @@ static CHANNEL: Channel = Channel::new(); #[embassy_executor::main] async fn main(spawner: Spawner) { let p = embassy_stm32::init(Default::default()); - let button = Input::new(p.PA0, Pull::Down); - let button = ExtiInput::new(button, p.EXTI0); + let button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Down); info!("Press the USER button..."); let leds = [ - Output::new(p.PE9.degrade(), Level::Low, Speed::Low), - Output::new(p.PE10.degrade(), Level::Low, Speed::Low), - Output::new(p.PE11.degrade(), Level::Low, Speed::Low), - Output::new(p.PE12.degrade(), Level::Low, Speed::Low), - Output::new(p.PE13.degrade(), Level::Low, Speed::Low), - Output::new(p.PE14.degrade(), Level::Low, Speed::Low), - Output::new(p.PE15.degrade(), Level::Low, Speed::Low), - Output::new(p.PE8.degrade(), Level::Low, Speed::Low), + Output::new(p.PE9, Level::Low, Speed::Low), + Output::new(p.PE10, Level::Low, Speed::Low), + Output::new(p.PE11, Level::Low, Speed::Low), + Output::new(p.PE12, Level::Low, Speed::Low), + Output::new(p.PE13, Level::Low, Speed::Low), + Output::new(p.PE14, Level::Low, Speed::Low), + Output::new(p.PE15, Level::Low, Speed::Low), + Output::new(p.PE8, Level::Low, Speed::Low), ]; let leds = Leds::new(leds); @@ -127,7 +125,7 @@ async fn led_blinker(mut leds: Leds<'static>) { } #[embassy_executor::task] -async fn button_waiter(mut button: ExtiInput<'static, PA0>) { +async fn button_waiter(mut button: ExtiInput<'static>) { const DOUBLE_CLICK_DELAY: u64 = 250; const HOLD_DELAY: u64 = 1000; diff --git a/examples/stm32f3/src/bin/button_exti.rs b/examples/stm32f3/src/bin/button_exti.rs index 86ff68492..a55530e0e 100644 --- a/examples/stm32f3/src/bin/button_exti.rs +++ b/examples/stm32f3/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PA0, Pull::Down); - let mut button = ExtiInput::new(button, p.EXTI0); + let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Down); info!("Press the USER button..."); diff --git a/examples/stm32f4/src/bin/button_exti.rs b/examples/stm32f4/src/bin/button_exti.rs index 67751187d..2a546dac5 100644 --- a/examples/stm32f4/src/bin/button_exti.rs +++ b/examples/stm32f4/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PC13, Pull::Down); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); info!("Press the USER button..."); diff --git a/examples/stm32f7/src/bin/button_exti.rs b/examples/stm32f7/src/bin/button_exti.rs index 67751187d..2a546dac5 100644 --- a/examples/stm32f7/src/bin/button_exti.rs +++ b/examples/stm32f7/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PC13, Pull::Down); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); info!("Press the USER button..."); diff --git a/examples/stm32g0/src/bin/button_exti.rs b/examples/stm32g0/src/bin/button_exti.rs index 1e970fdd6..34a08bbc6 100644 --- a/examples/stm32g0/src/bin/button_exti.rs +++ b/examples/stm32g0/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PC13, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); info!("Press the USER button..."); diff --git a/examples/stm32g4/src/bin/button_exti.rs b/examples/stm32g4/src/bin/button_exti.rs index 67751187d..2a546dac5 100644 --- a/examples/stm32g4/src/bin/button_exti.rs +++ b/examples/stm32g4/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PC13, Pull::Down); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); info!("Press the USER button..."); diff --git a/examples/stm32h5/src/bin/button_exti.rs b/examples/stm32h5/src/bin/button_exti.rs index 67751187d..2a546dac5 100644 --- a/examples/stm32h5/src/bin/button_exti.rs +++ b/examples/stm32h5/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PC13, Pull::Down); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); info!("Press the USER button..."); diff --git a/examples/stm32h7/src/bin/button_exti.rs b/examples/stm32h7/src/bin/button_exti.rs index 67751187d..2a546dac5 100644 --- a/examples/stm32h7/src/bin/button_exti.rs +++ b/examples/stm32h7/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PC13, Pull::Down); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); info!("Press the USER button..."); diff --git a/examples/stm32l0/src/bin/button_exti.rs b/examples/stm32l0/src/bin/button_exti.rs index f517fce04..4945da7ce 100644 --- a/examples/stm32l0/src/bin/button_exti.rs +++ b/examples/stm32l0/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use embassy_stm32::Config; use {defmt_rtt as _, panic_probe as _}; @@ -13,8 +13,7 @@ async fn main(_spawner: Spawner) { let config = Config::default(); let p = embassy_stm32::init(config); - let button = Input::new(p.PB2, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI2); + let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up); info!("Press the USER button..."); diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs index 1e970fdd6..34a08bbc6 100644 --- a/examples/stm32l4/src/bin/button_exti.rs +++ b/examples/stm32l4/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PC13, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); info!("Press the USER button..."); diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs index 5b4cdfe5e..026a3a477 100644 --- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs @@ -58,9 +58,9 @@ const IP_ADDRESS: Ipv4Cidr = Ipv4Cidr::new(Ipv4Address([192, 168, 1, 5]), 24); const HTTP_LISTEN_PORT: u16 = 80; pub type SpeSpi = Spi<'static, peripherals::SPI2, peripherals::DMA1_CH1, peripherals::DMA1_CH2>; -pub type SpeSpiCs = ExclusiveDevice, Delay>; -pub type SpeInt = exti::ExtiInput<'static, peripherals::PB11>; -pub type SpeRst = Output<'static, peripherals::PC7>; +pub type SpeSpiCs = ExclusiveDevice, Delay>; +pub type SpeInt = exti::ExtiInput<'static>; +pub type SpeRst = Output<'static>; pub type Adin1110T = ADIN1110; pub type TempSensI2c = I2c<'static, peripherals::I2C3, peripherals::DMA1_CH6, peripherals::DMA1_CH7>; @@ -134,8 +134,7 @@ async fn main(spawner: Spawner) { let spe_cfg1 = Input::new(dp.PC9, Pull::None); let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low); - let spe_int = Input::new(dp.PB11, Pull::None); - let spe_int = exti::ExtiInput::new(spe_int, dp.EXTI11); + let spe_int = exti::ExtiInput::new(dp.PB11, dp.EXTI11, Pull::None); let spe_spi_cs_n = Output::new(dp.PB12, Level::High, Speed::High); let spe_spi_sclk = dp.PB13; @@ -298,7 +297,7 @@ async fn wait_for_config(stack: &'static Stack>) -> embassy_net: } #[embassy_executor::task] -async fn heartbeat_led(mut led: Output<'static, peripherals::PE6>) { +async fn heartbeat_led(mut led: Output<'static>) { let mut tmr = Ticker::every(Duration::from_hz(3)); loop { led.toggle(); @@ -308,7 +307,7 @@ async fn heartbeat_led(mut led: Output<'static, peripherals::PE6>) { // ADT7422 #[embassy_executor::task] -async fn temp_task(temp_dev_i2c: TempSensI2c, mut led: Output<'static, peripherals::PG15>) -> ! { +async fn temp_task(temp_dev_i2c: TempSensI2c, mut led: Output<'static>) -> ! { let mut tmr = Ticker::every(Duration::from_hz(1)); let mut temp_sens = ADT7422::new(temp_dev_i2c, 0x48).unwrap(); diff --git a/examples/stm32l5/src/bin/button_exti.rs b/examples/stm32l5/src/bin/button_exti.rs index 91d0ccc2e..e6639d22b 100644 --- a/examples/stm32l5/src/bin/button_exti.rs +++ b/examples/stm32l5/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PC13, Pull::Down); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); info!("Press the USER button..."); diff --git a/examples/stm32wb/src/bin/button_exti.rs b/examples/stm32wb/src/bin/button_exti.rs index d34dde3e9..2871fd55f 100644 --- a/examples/stm32wb/src/bin/button_exti.rs +++ b/examples/stm32wb/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PC4, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI4); + let mut button = ExtiInput::new(p.PC4, p.EXTI4, Pull::Up); info!("Press the USER button..."); diff --git a/examples/stm32wba/src/bin/button_exti.rs b/examples/stm32wba/src/bin/button_exti.rs index 1e970fdd6..34a08bbc6 100644 --- a/examples/stm32wba/src/bin/button_exti.rs +++ b/examples/stm32wba/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PC13, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI13); + let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); info!("Press the USER button..."); diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs index e6ad4b80b..27d5330bd 100644 --- a/examples/stm32wl/src/bin/button_exti.rs +++ b/examples/stm32wl/src/bin/button_exti.rs @@ -4,7 +4,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::gpio::Pull; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { let p = embassy_stm32::init(Default::default()); info!("Hello World!"); - let button = Input::new(p.PA0, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI0); + let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up); info!("Press the USER button..."); -- cgit From 2bc5e9523d4373002487614ecfef1e3f0858fd66 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 22 Jan 2024 21:19:18 +0100 Subject: nrf/gpio: remove generics. --- docs/modules/ROOT/examples/basic/src/main.rs | 3 +- embassy-nrf/src/gpio.rs | 62 +++++++++++++------------- embassy-nrf/src/gpiote.rs | 53 +++++++++++++--------- examples/nrf52840/src/bin/ethernet_enc28j60.rs | 12 +---- examples/nrf52840/src/bin/gpiote_port.rs | 12 ++--- examples/nrf52840/src/bin/usb_hid_keyboard.rs | 4 +- examples/nrf52840/src/bin/wifi_esp_hosted.rs | 12 ++--- tests/nrf/src/bin/ethernet_enc28j60_perf.rs | 5 +-- tests/nrf/src/bin/wifi_esp_hosted_perf.rs | 12 ++--- 9 files changed, 86 insertions(+), 89 deletions(-) diff --git a/docs/modules/ROOT/examples/basic/src/main.rs b/docs/modules/ROOT/examples/basic/src/main.rs index 2a4ee5968..4412712c8 100644 --- a/docs/modules/ROOT/examples/basic/src/main.rs +++ b/docs/modules/ROOT/examples/basic/src/main.rs @@ -4,12 +4,11 @@ use defmt::*; use embassy_executor::Spawner; use embassy_nrf::gpio::{Level, Output, OutputDrive}; -use embassy_nrf::peripherals::P0_13; use embassy_time::{Duration, Timer}; use {defmt_rtt as _, panic_probe as _}; // global logger #[embassy_executor::task] -async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { +async fn blinker(mut led: Output<'static>, interval: Duration) { loop { led.set_high(); Timer::after(interval).await; diff --git a/embassy-nrf/src/gpio.rs b/embassy-nrf/src/gpio.rs index eabf409dd..287811e61 100644 --- a/embassy-nrf/src/gpio.rs +++ b/embassy-nrf/src/gpio.rs @@ -36,14 +36,14 @@ pub enum Pull { } /// GPIO input driver. -pub struct Input<'d, T: Pin> { - pub(crate) pin: Flex<'d, T>, +pub struct Input<'d> { + pub(crate) pin: Flex<'d>, } -impl<'d, T: Pin> Input<'d, T> { +impl<'d> Input<'d> { /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration. #[inline] - pub fn new(pin: impl Peripheral

+ 'd, pull: Pull) -> Self { + pub fn new(pin: impl Peripheral

+ 'd, pull: Pull) -> Self { let mut pin = Flex::new(pin); pin.set_as_input(pull); @@ -122,14 +122,14 @@ pub enum OutputDrive { } /// GPIO output driver. -pub struct Output<'d, T: Pin> { - pub(crate) pin: Flex<'d, T>, +pub struct Output<'d> { + pub(crate) pin: Flex<'d>, } -impl<'d, T: Pin> Output<'d, T> { +impl<'d> Output<'d> { /// Create GPIO output driver for a [Pin] with the provided [Level] and [OutputDriver] configuration. #[inline] - pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level, drive: OutputDrive) -> Self { + pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level, drive: OutputDrive) -> Self { let mut pin = Flex::new(pin); match initial_output { Level::High => pin.set_high(), @@ -209,20 +209,20 @@ fn convert_pull(pull: Pull) -> PULL_A { /// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain /// set while not in output mode, so the pin's level will be 'remembered' when it is not in output /// mode. -pub struct Flex<'d, T: Pin> { - pub(crate) pin: PeripheralRef<'d, T>, +pub struct Flex<'d> { + pub(crate) pin: PeripheralRef<'d, AnyPin>, } -impl<'d, T: Pin> Flex<'d, T> { +impl<'d> Flex<'d> { /// Wrap the pin in a `Flex`. /// /// The pin remains disconnected. The initial output level is unspecified, but can be changed /// before the pin is put into output mode. #[inline] - pub fn new(pin: impl Peripheral

+ 'd) -> Self { + pub fn new(pin: impl Peripheral

+ 'd) -> Self { into_ref!(pin); // Pin will be in disconnected state. - Self { pin } + Self { pin: pin.map_into() } } /// Put the pin into input mode. @@ -349,7 +349,7 @@ impl<'d, T: Pin> Flex<'d, T> { } } -impl<'d, T: Pin> Drop for Flex<'d, T> { +impl<'d> Drop for Flex<'d> { fn drop(&mut self) { self.pin.conf().reset(); } @@ -510,7 +510,7 @@ macro_rules! impl_pin { mod eh02 { use super::*; - impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { + impl<'d> embedded_hal_02::digital::v2::InputPin for Input<'d> { type Error = Infallible; fn is_high(&self) -> Result { @@ -522,7 +522,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { + impl<'d> embedded_hal_02::digital::v2::OutputPin for Output<'d> { type Error = Infallible; fn set_high(&mut self) -> Result<(), Self::Error> { @@ -534,7 +534,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { + impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d> { fn is_set_high(&self) -> Result { Ok(self.is_set_high()) } @@ -544,7 +544,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> { + impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d> { type Error = Infallible; #[inline] fn toggle(&mut self) -> Result<(), Self::Error> { @@ -556,7 +556,7 @@ mod eh02 { /// Implement [`embedded_hal_02::digital::v2::InputPin`] for [`Flex`]; /// /// If the pin is not in input mode the result is unspecified. - impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { + impl<'d> embedded_hal_02::digital::v2::InputPin for Flex<'d> { type Error = Infallible; fn is_high(&self) -> Result { @@ -568,7 +568,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { + impl<'d> embedded_hal_02::digital::v2::OutputPin for Flex<'d> { type Error = Infallible; fn set_high(&mut self) -> Result<(), Self::Error> { @@ -580,7 +580,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { + impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d> { fn is_set_high(&self) -> Result { Ok(self.is_set_high()) } @@ -590,7 +590,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> { + impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d> { type Error = Infallible; #[inline] fn toggle(&mut self) -> Result<(), Self::Error> { @@ -600,11 +600,11 @@ mod eh02 { } } -impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for Input<'d> { type Error = Infallible; } -impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { +impl<'d> embedded_hal_1::digital::InputPin for Input<'d> { fn is_high(&mut self) -> Result { Ok((*self).is_high()) } @@ -614,11 +614,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> { type Error = Infallible; } -impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { +impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> { fn set_high(&mut self) -> Result<(), Self::Error> { Ok(self.set_high()) } @@ -628,7 +628,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { +impl<'d> embedded_hal_1::digital::StatefulOutputPin for Output<'d> { fn is_set_high(&mut self) -> Result { Ok((*self).is_set_high()) } @@ -638,14 +638,14 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for Flex<'d> { type Error = Infallible; } /// Implement [`InputPin`] for [`Flex`]; /// /// If the pin is not in input mode the result is unspecified. -impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> { fn is_high(&mut self) -> Result { Ok((*self).is_high()) } @@ -655,7 +655,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> { fn set_high(&mut self) -> Result<(), Self::Error> { Ok(self.set_high()) } @@ -665,7 +665,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::StatefulOutputPin for Flex<'d> { fn is_set_high(&mut self) -> Result { Ok((*self).is_set_high()) } diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 8020b8dc2..a459446a2 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs @@ -156,12 +156,12 @@ impl Iterator for BitIter { } /// GPIOTE channel driver in input mode -pub struct InputChannel<'d, C: Channel, T: GpioPin> { - ch: PeripheralRef<'d, C>, - pin: Input<'d, T>, +pub struct InputChannel<'d> { + ch: PeripheralRef<'d, AnyChannel>, + pin: Input<'d>, } -impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> { +impl<'d> Drop for InputChannel<'d> { fn drop(&mut self) { let g = regs(); let num = self.ch.number(); @@ -170,9 +170,9 @@ impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> { } } -impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { +impl<'d> InputChannel<'d> { /// Create a new GPIOTE input channel driver. - pub fn new(ch: impl Peripheral

+ 'd, pin: Input<'d, T>, polarity: InputChannelPolarity) -> Self { + pub fn new(ch: impl Peripheral

+ 'd, pin: Input<'d>, polarity: InputChannelPolarity) -> Self { into_ref!(ch); let g = regs(); @@ -195,7 +195,7 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { g.events_in[num].reset(); - InputChannel { ch, pin } + InputChannel { ch: ch.map_into(), pin } } /// Asynchronously wait for an event in this channel. @@ -227,12 +227,12 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { } /// GPIOTE channel driver in output mode -pub struct OutputChannel<'d, C: Channel, T: GpioPin> { - ch: PeripheralRef<'d, C>, - _pin: Output<'d, T>, +pub struct OutputChannel<'d> { + ch: PeripheralRef<'d, AnyChannel>, + _pin: Output<'d>, } -impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> { +impl<'d> Drop for OutputChannel<'d> { fn drop(&mut self) { let g = regs(); let num = self.ch.number(); @@ -241,9 +241,9 @@ impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> { } } -impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { +impl<'d> OutputChannel<'d> { /// Create a new GPIOTE output channel driver. - pub fn new(ch: impl Peripheral

+ 'd, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self { + pub fn new(ch: impl Peripheral

+ 'd, pin: Output<'d>, polarity: OutputChannelPolarity) -> Self { into_ref!(ch); let g = regs(); let num = ch.number(); @@ -267,7 +267,10 @@ impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { unsafe { w.psel().bits(pin.pin.pin.pin()) } }); - OutputChannel { ch, _pin: pin } + OutputChannel { + ch: ch.map_into(), + _pin: pin, + } } /// Triggers the OUT task (does the action as configured with task_out_polarity, defaults to Toggle). @@ -348,7 +351,7 @@ impl<'a> Future for PortInputFuture<'a> { } } -impl<'d, T: GpioPin> Input<'d, T> { +impl<'d> Input<'d> { /// Wait until the pin is high. If it is already high, return immediately. pub async fn wait_for_high(&mut self) { self.pin.wait_for_high().await @@ -375,7 +378,7 @@ impl<'d, T: GpioPin> Input<'d, T> { } } -impl<'d, T: GpioPin> Flex<'d, T> { +impl<'d> Flex<'d> { /// Wait until the pin is high. If it is already high, return immediately. pub async fn wait_for_high(&mut self) { self.pin.conf().modify(|_, w| w.sense().high()); @@ -420,7 +423,7 @@ mod sealed { /// GPIOTE channel trait. /// /// Implemented by all GPIOTE channels. -pub trait Channel: sealed::Channel + Sized { +pub trait Channel: sealed::Channel + Into + Sized + 'static { /// Get the channel number. fn number(&self) -> usize; @@ -460,6 +463,12 @@ macro_rules! impl_channel { $number as usize } } + + impl From for AnyChannel { + fn from(val: peripherals::$type) -> Self { + Channel::degrade(val) + } + } }; } @@ -477,7 +486,7 @@ impl_channel!(GPIOTE_CH7, 7); mod eh02 { use super::*; - impl<'d, C: Channel, T: GpioPin> embedded_hal_02::digital::v2::InputPin for InputChannel<'d, C, T> { + impl<'d> embedded_hal_02::digital::v2::InputPin for InputChannel<'d> { type Error = Infallible; fn is_high(&self) -> Result { @@ -490,11 +499,11 @@ mod eh02 { } } -impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> { +impl<'d> embedded_hal_1::digital::ErrorType for InputChannel<'d> { type Error = Infallible; } -impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> { +impl<'d> embedded_hal_1::digital::InputPin for InputChannel<'d> { fn is_high(&mut self) -> Result { Ok(self.pin.is_high()) } @@ -504,7 +513,7 @@ impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChan } } -impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { +impl<'d> embedded_hal_async::digital::Wait for Input<'d> { async fn wait_for_high(&mut self) -> Result<(), Self::Error> { Ok(self.wait_for_high().await) } @@ -526,7 +535,7 @@ impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { } } -impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> { +impl<'d> embedded_hal_async::digital::Wait for Flex<'d> { async fn wait_for_high(&mut self) -> Result<(), Self::Error> { Ok(self.wait_for_high().await) } diff --git a/examples/nrf52840/src/bin/ethernet_enc28j60.rs b/examples/nrf52840/src/bin/ethernet_enc28j60.rs index a8e64b38a..279f32edc 100644 --- a/examples/nrf52840/src/bin/ethernet_enc28j60.rs +++ b/examples/nrf52840/src/bin/ethernet_enc28j60.rs @@ -24,10 +24,7 @@ bind_interrupts!(struct Irqs { #[embassy_executor::task] async fn net_task( stack: &'static Stack< - Enc28j60< - ExclusiveDevice, Output<'static, peripherals::P0_15>, Delay>, - Output<'static, peripherals::P0_13>, - >, + Enc28j60, Output<'static>, Delay>, Output<'static>>, >, ) -> ! { stack.run().await @@ -71,12 +68,7 @@ async fn main(spawner: Spawner) { // Init network stack static RESOURCES: StaticCell> = StaticCell::new(); static STACK: StaticCell< - Stack< - Enc28j60< - ExclusiveDevice, Output<'static, peripherals::P0_15>, Delay>, - Output<'static, peripherals::P0_13>, - >, - >, + Stack, Output<'static>, Delay>, Output<'static>>>, > = StaticCell::new(); let stack = STACK.init(Stack::new( device, diff --git a/examples/nrf52840/src/bin/gpiote_port.rs b/examples/nrf52840/src/bin/gpiote_port.rs index c1afe2f20..0dddb1a97 100644 --- a/examples/nrf52840/src/bin/gpiote_port.rs +++ b/examples/nrf52840/src/bin/gpiote_port.rs @@ -3,11 +3,11 @@ use defmt::{info, unwrap}; use embassy_executor::Spawner; -use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; +use embassy_nrf::gpio::{Input, Pull}; use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::task(pool_size = 4)] -async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { +async fn button_task(n: usize, mut pin: Input<'static>) { loop { pin.wait_for_low().await; info!("Button {:?} pressed!", n); @@ -21,10 +21,10 @@ async fn main(spawner: Spawner) { let p = embassy_nrf::init(Default::default()); info!("Starting!"); - let btn1 = Input::new(p.P0_11.degrade(), Pull::Up); - let btn2 = Input::new(p.P0_12.degrade(), Pull::Up); - let btn3 = Input::new(p.P0_24.degrade(), Pull::Up); - let btn4 = Input::new(p.P0_25.degrade(), Pull::Up); + let btn1 = Input::new(p.P0_11, Pull::Up); + let btn2 = Input::new(p.P0_12, Pull::Up); + let btn3 = Input::new(p.P0_24, Pull::Up); + let btn4 = Input::new(p.P0_25, Pull::Up); unwrap!(spawner.spawn(button_task(1, btn1))); unwrap!(spawner.spawn(button_task(2, btn2))); diff --git a/examples/nrf52840/src/bin/usb_hid_keyboard.rs b/examples/nrf52840/src/bin/usb_hid_keyboard.rs index 45850b4a4..3e86590c4 100644 --- a/examples/nrf52840/src/bin/usb_hid_keyboard.rs +++ b/examples/nrf52840/src/bin/usb_hid_keyboard.rs @@ -8,7 +8,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_futures::join::join; use embassy_futures::select::{select, Either}; -use embassy_nrf::gpio::{Input, Pin, Pull}; +use embassy_nrf::gpio::{Input, Pull}; use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; use embassy_nrf::usb::Driver; use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; @@ -97,7 +97,7 @@ async fn main(_spawner: Spawner) { } }; - let mut button = Input::new(p.P0_11.degrade(), Pull::Up); + let mut button = Input::new(p.P0_11, Pull::Up); let (reader, mut writer) = hid.split(); diff --git a/examples/nrf52840/src/bin/wifi_esp_hosted.rs b/examples/nrf52840/src/bin/wifi_esp_hosted.rs index fc2086f75..00bd50081 100644 --- a/examples/nrf52840/src/bin/wifi_esp_hosted.rs +++ b/examples/nrf52840/src/bin/wifi_esp_hosted.rs @@ -5,7 +5,7 @@ use defmt::{info, unwrap, warn}; use embassy_executor::Spawner; use embassy_net::tcp::TcpSocket; use embassy_net::{Stack, StackResources}; -use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; +use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; use embassy_nrf::rng::Rng; use embassy_nrf::spim::{self, Spim}; use embassy_nrf::{bind_interrupts, peripherals}; @@ -27,9 +27,9 @@ bind_interrupts!(struct Irqs { async fn wifi_task( runner: hosted::Runner< 'static, - ExclusiveDevice, Output<'static, peripherals::P0_31>, Delay>, - Input<'static, AnyPin>, - Output<'static, peripherals::P1_05>, + ExclusiveDevice, Output<'static>, Delay>, + Input<'static>, + Output<'static>, >, ) -> ! { runner.run().await @@ -50,8 +50,8 @@ async fn main(spawner: Spawner) { let sck = p.P0_29; let mosi = p.P0_30; let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive); - let handshake = Input::new(p.P1_01.degrade(), Pull::Up); - let ready = Input::new(p.P1_04.degrade(), Pull::None); + let handshake = Input::new(p.P1_01, Pull::Up); + let ready = Input::new(p.P1_04, Pull::None); let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); let mut config = spim::Config::default(); diff --git a/tests/nrf/src/bin/ethernet_enc28j60_perf.rs b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs index 7dc1941d7..33c2f4235 100644 --- a/tests/nrf/src/bin/ethernet_enc28j60_perf.rs +++ b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs @@ -21,10 +21,7 @@ bind_interrupts!(struct Irqs { RNG => embassy_nrf::rng::InterruptHandler; }); -type MyDriver = Enc28j60< - ExclusiveDevice, Output<'static, peripherals::P0_15>, Delay>, - Output<'static, peripherals::P0_13>, ->; +type MyDriver = Enc28j60, Output<'static>, Delay>, Output<'static>>; #[embassy_executor::task] async fn net_task(stack: &'static Stack) -> ! { diff --git a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs index c96064f84..b83edddc4 100644 --- a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs +++ b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs @@ -6,7 +6,7 @@ teleprobe_meta::timeout!(120); use defmt::{info, unwrap}; use embassy_executor::Spawner; use embassy_net::{Config, Stack, StackResources}; -use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; +use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; use embassy_nrf::rng::Rng; use embassy_nrf::spim::{self, Spim}; use embassy_nrf::{bind_interrupts, peripherals}; @@ -28,9 +28,9 @@ const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; async fn wifi_task( runner: hosted::Runner< 'static, - ExclusiveDevice, Output<'static, peripherals::P0_31>, Delay>, - Input<'static, AnyPin>, - Output<'static, peripherals::P1_05>, + ExclusiveDevice, Output<'static>, Delay>, + Input<'static>, + Output<'static>, >, ) -> ! { runner.run().await @@ -53,8 +53,8 @@ async fn main(spawner: Spawner) { let sck = p.P0_29; let mosi = p.P0_30; let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive); - let handshake = Input::new(p.P1_01.degrade(), Pull::Up); - let ready = Input::new(p.P1_04.degrade(), Pull::None); + let handshake = Input::new(p.P1_01, Pull::Up); + let ready = Input::new(p.P1_04, Pull::None); let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); let mut config = spim::Config::default(); -- cgit From ee0ebe3121e5d51240e671d8c5cc19ad878b9db9 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Mon, 22 Jan 2024 21:30:29 +0100 Subject: rp/gpio: remove generics. --- cyw43-pio/src/lib.rs | 14 ++- embassy-rp/src/gpio.rs | 125 +++++++++++----------- examples/rp/src/bin/blinky_two_tasks.rs | 2 +- examples/rp/src/bin/ethernet_w5500_multisocket.rs | 8 +- examples/rp/src/bin/ethernet_w5500_tcp_client.rs | 8 +- examples/rp/src/bin/ethernet_w5500_tcp_server.rs | 8 +- examples/rp/src/bin/ethernet_w5500_udp.rs | 8 +- examples/rp/src/bin/multicore.rs | 3 +- examples/rp/src/bin/wifi_ap_tcp_server.rs | 6 +- examples/rp/src/bin/wifi_blinky.rs | 6 +- examples/rp/src/bin/wifi_scan.rs | 6 +- examples/rp/src/bin/wifi_tcp_server.rs | 6 +- tests/rp/src/bin/cyw43-perf.rs | 6 +- tests/rp/src/bin/ethernet_w5100s_perf.rs | 8 +- tests/rp/src/bin/uart.rs | 6 +- tests/rp/src/bin/uart_buffered.rs | 6 +- tests/rp/src/bin/uart_dma.rs | 6 +- 17 files changed, 109 insertions(+), 123 deletions(-) diff --git a/cyw43-pio/src/lib.rs b/cyw43-pio/src/lib.rs index 5efab10e4..8c217b995 100644 --- a/cyw43-pio/src/lib.rs +++ b/cyw43-pio/src/lib.rs @@ -7,25 +7,24 @@ use core::slice; use cyw43::SpiBusCyw43; use embassy_rp::dma::Channel; -use embassy_rp::gpio::{Drive, Level, Output, Pin, Pull, SlewRate}; +use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate}; use embassy_rp::pio::{instr, Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; use embassy_rp::{Peripheral, PeripheralRef}; use fixed::FixedU32; use pio_proc::pio_asm; /// SPI comms driven by PIO. -pub struct PioSpi<'d, CS: Pin, PIO: Instance, const SM: usize, DMA> { - cs: Output<'d, CS>, +pub struct PioSpi<'d, PIO: Instance, const SM: usize, DMA> { + cs: Output<'d>, sm: StateMachine<'d, PIO, SM>, irq: Irq<'d, PIO, 0>, dma: PeripheralRef<'d, DMA>, wrap_target: u8, } -impl<'d, CS, PIO, const SM: usize, DMA> PioSpi<'d, CS, PIO, SM, DMA> +impl<'d, PIO, const SM: usize, DMA> PioSpi<'d, PIO, SM, DMA> where DMA: Channel, - CS: Pin, PIO: Instance, { /// Create a new instance of PioSpi. @@ -33,7 +32,7 @@ where common: &mut Common<'d, PIO>, mut sm: StateMachine<'d, PIO, SM>, irq: Irq<'d, PIO, 0>, - cs: Output<'d, CS>, + cs: Output<'d>, dio: DIO, clk: CLK, dma: impl Peripheral

+ 'd, @@ -206,9 +205,8 @@ where } } -impl<'d, CS, PIO, const SM: usize, DMA> SpiBusCyw43 for PioSpi<'d, CS, PIO, SM, DMA> +impl<'d, PIO, const SM: usize, DMA> SpiBusCyw43 for PioSpi<'d, PIO, SM, DMA> where - CS: Pin, PIO: Instance, DMA: Channel, { diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs index 7eb57bbe6..93b29bbf9 100644 --- a/embassy-rp/src/gpio.rs +++ b/embassy-rp/src/gpio.rs @@ -8,6 +8,7 @@ use core::task::{Context, Poll}; use embassy_hal_internal::{impl_peripheral, into_ref, PeripheralRef}; use embassy_sync::waitqueue::AtomicWaker; +use self::sealed::Pin as _; use crate::interrupt::InterruptExt; use crate::pac::common::{Reg, RW}; use crate::pac::SIO; @@ -105,14 +106,14 @@ pub struct DormantWakeConfig { } /// GPIO input driver. -pub struct Input<'d, T: Pin> { - pin: Flex<'d, T>, +pub struct Input<'d> { + pin: Flex<'d>, } -impl<'d, T: Pin> Input<'d, T> { +impl<'d> Input<'d> { /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration. #[inline] - pub fn new(pin: impl Peripheral

+ 'd, pull: Pull) -> Self { + pub fn new(pin: impl Peripheral

+ 'd, pull: Pull) -> Self { let mut pin = Flex::new(pin); pin.set_as_input(); pin.set_pull(pull); @@ -175,7 +176,7 @@ impl<'d, T: Pin> Input<'d, T> { /// Configure dormant wake. #[inline] - pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake { + pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake<'_> { self.pin.dormant_wake(cfg) } } @@ -255,14 +256,12 @@ fn IO_IRQ_QSPI() { } #[must_use = "futures do nothing unless you `.await` or poll them"] -struct InputFuture<'a, T: Pin> { - pin: PeripheralRef<'a, T>, +struct InputFuture<'d> { + pin: PeripheralRef<'d, AnyPin>, } -impl<'d, T: Pin> InputFuture<'d, T> { - /// Create a new future wiating for input trigger. - pub fn new(pin: impl Peripheral

+ 'd, level: InterruptTrigger) -> Self { - into_ref!(pin); +impl<'d> InputFuture<'d> { + fn new(pin: PeripheralRef<'d, AnyPin>, level: InterruptTrigger) -> Self { let pin_group = (pin.pin() % 8) as usize; // first, clear the INTR register bits. without this INTR will still // contain reports of previous edges, causing the IRQ to fire early @@ -305,7 +304,7 @@ impl<'d, T: Pin> InputFuture<'d, T> { } } -impl<'d, T: Pin> Future for InputFuture<'d, T> { +impl<'d> Future for InputFuture<'d> { type Output = (); fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll { @@ -344,14 +343,14 @@ impl<'d, T: Pin> Future for InputFuture<'d, T> { } /// GPIO output driver. -pub struct Output<'d, T: Pin> { - pin: Flex<'d, T>, +pub struct Output<'d> { + pin: Flex<'d>, } -impl<'d, T: Pin> Output<'d, T> { +impl<'d> Output<'d> { /// Create GPIO output driver for a [Pin] with the provided [Level]. #[inline] - pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level) -> Self { + pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level) -> Self { let mut pin = Flex::new(pin); match initial_output { Level::High => pin.set_high(), @@ -418,14 +417,14 @@ impl<'d, T: Pin> Output<'d, T> { } /// GPIO output open-drain. -pub struct OutputOpenDrain<'d, T: Pin> { - pin: Flex<'d, T>, +pub struct OutputOpenDrain<'d> { + pin: Flex<'d>, } -impl<'d, T: Pin> OutputOpenDrain<'d, T> { +impl<'d> OutputOpenDrain<'d> { /// Create GPIO output driver for a [Pin] in open drain mode with the provided [Level]. #[inline] - pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level) -> Self { + pub fn new(pin: impl Peripheral

+ 'd, initial_output: Level) -> Self { let mut pin = Flex::new(pin); pin.set_low(); match initial_output { @@ -548,17 +547,17 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { /// This pin can be either an input or output pin. The output level register bit will remain /// set while not in output mode, so the pin's level will be 'remembered' when it is not in output /// mode. -pub struct Flex<'d, T: Pin> { - pin: PeripheralRef<'d, T>, +pub struct Flex<'d> { + pin: PeripheralRef<'d, AnyPin>, } -impl<'d, T: Pin> Flex<'d, T> { +impl<'d> Flex<'d> { /// Wrap the pin in a `Flex`. /// /// The pin remains disconnected. The initial output level is unspecified, but can be changed /// before the pin is put into output mode. #[inline] - pub fn new(pin: impl Peripheral

+ 'd) -> Self { + pub fn new(pin: impl Peripheral

+ 'd) -> Self { into_ref!(pin); pin.pad_ctrl().write(|w| { @@ -569,7 +568,7 @@ impl<'d, T: Pin> Flex<'d, T> { w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::SIO_0 as _); }); - Self { pin } + Self { pin: pin.map_into() } } #[inline] @@ -716,36 +715,36 @@ impl<'d, T: Pin> Flex<'d, T> { /// Wait until the pin is high. If it is already high, return immediately. #[inline] pub async fn wait_for_high(&mut self) { - InputFuture::new(&mut self.pin, InterruptTrigger::LevelHigh).await; + InputFuture::new(self.pin.reborrow(), InterruptTrigger::LevelHigh).await; } /// Wait until the pin is low. If it is already low, return immediately. #[inline] pub async fn wait_for_low(&mut self) { - InputFuture::new(&mut self.pin, InterruptTrigger::LevelLow).await; + InputFuture::new(self.pin.reborrow(), InterruptTrigger::LevelLow).await; } /// Wait for the pin to undergo a transition from low to high. #[inline] pub async fn wait_for_rising_edge(&mut self) { - InputFuture::new(&mut self.pin, InterruptTrigger::EdgeHigh).await; + InputFuture::new(self.pin.reborrow(), InterruptTrigger::EdgeHigh).await; } /// Wait for the pin to undergo a transition from high to low. #[inline] pub async fn wait_for_falling_edge(&mut self) { - InputFuture::new(&mut self.pin, InterruptTrigger::EdgeLow).await; + InputFuture::new(self.pin.reborrow(), InterruptTrigger::EdgeLow).await; } /// Wait for the pin to undergo any transition, i.e low to high OR high to low. #[inline] pub async fn wait_for_any_edge(&mut self) { - InputFuture::new(&mut self.pin, InterruptTrigger::AnyEdge).await; + InputFuture::new(self.pin.reborrow(), InterruptTrigger::AnyEdge).await; } /// Configure dormant wake. #[inline] - pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake { + pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake<'_> { let idx = self.pin._pin() as usize; self.pin.io().intr(idx / 8).write(|w| { w.set_edge_high(idx % 8, cfg.edge_high); @@ -764,7 +763,7 @@ impl<'d, T: Pin> Flex<'d, T> { } } -impl<'d, T: Pin> Drop for Flex<'d, T> { +impl<'d> Drop for Flex<'d> { #[inline] fn drop(&mut self) { let idx = self.pin._pin() as usize; @@ -782,12 +781,12 @@ impl<'d, T: Pin> Drop for Flex<'d, T> { } /// Dormant wake driver. -pub struct DormantWake<'w, T: Pin> { - pin: PeripheralRef<'w, T>, +pub struct DormantWake<'w> { + pin: PeripheralRef<'w, AnyPin>, cfg: DormantWakeConfig, } -impl<'w, T: Pin> Drop for DormantWake<'w, T> { +impl<'w> Drop for DormantWake<'w> { fn drop(&mut self) { let idx = self.pin._pin() as usize; self.pin.io().intr(idx / 8).write(|w| { @@ -970,7 +969,7 @@ mod eh02 { use super::*; - impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { + impl<'d> embedded_hal_02::digital::v2::InputPin for Input<'d> { type Error = Infallible; fn is_high(&self) -> Result { @@ -982,7 +981,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { + impl<'d> embedded_hal_02::digital::v2::OutputPin for Output<'d> { type Error = Infallible; fn set_high(&mut self) -> Result<(), Self::Error> { @@ -994,7 +993,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { + impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d> { fn is_set_high(&self) -> Result { Ok(self.is_set_high()) } @@ -1004,7 +1003,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> { + impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d> { type Error = Infallible; #[inline] fn toggle(&mut self) -> Result<(), Self::Error> { @@ -1012,7 +1011,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for OutputOpenDrain<'d, T> { + impl<'d> embedded_hal_02::digital::v2::InputPin for OutputOpenDrain<'d> { type Error = Infallible; fn is_high(&self) -> Result { @@ -1024,7 +1023,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, T> { + impl<'d> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d> { type Error = Infallible; #[inline] @@ -1038,7 +1037,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { + impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d> { fn is_set_high(&self) -> Result { Ok(self.is_set_high()) } @@ -1048,7 +1047,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d, T> { + impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d> { type Error = Infallible; #[inline] fn toggle(&mut self) -> Result<(), Self::Error> { @@ -1056,7 +1055,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { + impl<'d> embedded_hal_02::digital::v2::InputPin for Flex<'d> { type Error = Infallible; fn is_high(&self) -> Result { @@ -1068,7 +1067,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { + impl<'d> embedded_hal_02::digital::v2::OutputPin for Flex<'d> { type Error = Infallible; fn set_high(&mut self) -> Result<(), Self::Error> { @@ -1080,7 +1079,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { + impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d> { fn is_set_high(&self) -> Result { Ok(self.is_set_high()) } @@ -1090,7 +1089,7 @@ mod eh02 { } } - impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> { + impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d> { type Error = Infallible; #[inline] fn toggle(&mut self) -> Result<(), Self::Error> { @@ -1099,11 +1098,11 @@ mod eh02 { } } -impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for Input<'d> { type Error = Infallible; } -impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { +impl<'d> embedded_hal_1::digital::InputPin for Input<'d> { fn is_high(&mut self) -> Result { Ok((*self).is_high()) } @@ -1113,11 +1112,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> { type Error = Infallible; } -impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { +impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> { fn set_high(&mut self) -> Result<(), Self::Error> { Ok(self.set_high()) } @@ -1127,7 +1126,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { +impl<'d> embedded_hal_1::digital::StatefulOutputPin for Output<'d> { fn is_set_high(&mut self) -> Result { Ok((*self).is_set_high()) } @@ -1137,11 +1136,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d> { type Error = Infallible; } -impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d> { fn set_high(&mut self) -> Result<(), Self::Error> { Ok(self.set_high()) } @@ -1151,7 +1150,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d> { fn is_set_high(&mut self) -> Result { Ok((*self).is_set_high()) } @@ -1161,7 +1160,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain< } } -impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d> { fn is_high(&mut self) -> Result { Ok((*self).is_high()) } @@ -1171,11 +1170,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::ErrorType for Flex<'d> { type Error = Infallible; } -impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> { fn is_high(&mut self) -> Result { Ok((*self).is_high()) } @@ -1185,7 +1184,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> { fn set_high(&mut self) -> Result<(), Self::Error> { Ok(self.set_high()) } @@ -1195,7 +1194,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { } } -impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { +impl<'d> embedded_hal_1::digital::StatefulOutputPin for Flex<'d> { fn is_set_high(&mut self) -> Result { Ok((*self).is_set_high()) } @@ -1205,7 +1204,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { } } -impl<'d, T: Pin> embedded_hal_async::digital::Wait for Flex<'d, T> { +impl<'d> embedded_hal_async::digital::Wait for Flex<'d> { async fn wait_for_high(&mut self) -> Result<(), Self::Error> { self.wait_for_high().await; Ok(()) @@ -1232,7 +1231,7 @@ impl<'d, T: Pin> embedded_hal_async::digital::Wait for Flex<'d, T> { } } -impl<'d, T: Pin> embedded_hal_async::digital::Wait for Input<'d, T> { +impl<'d> embedded_hal_async::digital::Wait for Input<'d> { async fn wait_for_high(&mut self) -> Result<(), Self::Error> { self.wait_for_high().await; Ok(()) @@ -1259,7 +1258,7 @@ impl<'d, T: Pin> embedded_hal_async::digital::Wait for Input<'d, T> { } } -impl<'d, T: Pin> embedded_hal_async::digital::Wait for OutputOpenDrain<'d, T> { +impl<'d> embedded_hal_async::digital::Wait for OutputOpenDrain<'d> { async fn wait_for_high(&mut self) -> Result<(), Self::Error> { self.wait_for_high().await; Ok(()) diff --git a/examples/rp/src/bin/blinky_two_tasks.rs b/examples/rp/src/bin/blinky_two_tasks.rs index a03f3a592..a57b513d6 100644 --- a/examples/rp/src/bin/blinky_two_tasks.rs +++ b/examples/rp/src/bin/blinky_two_tasks.rs @@ -14,7 +14,7 @@ use embassy_time::{Duration, Ticker}; use gpio::{AnyPin, Level, Output}; use {defmt_rtt as _, panic_probe as _}; -type LedType = Mutex>>; +type LedType = Mutex>>; static LED: LedType = Mutex::new(None); #[embassy_executor::main] diff --git a/examples/rp/src/bin/ethernet_w5500_multisocket.rs b/examples/rp/src/bin/ethernet_w5500_multisocket.rs index a16ea0007..bd52cadca 100644 --- a/examples/rp/src/bin/ethernet_w5500_multisocket.rs +++ b/examples/rp/src/bin/ethernet_w5500_multisocket.rs @@ -13,7 +13,7 @@ use embassy_net_wiznet::chip::W5500; use embassy_net_wiznet::*; use embassy_rp::clocks::RoscRng; use embassy_rp::gpio::{Input, Level, Output, Pull}; -use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; +use embassy_rp::peripherals::SPI0; use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; use embassy_time::{Delay, Duration}; use embedded_hal_bus::spi::ExclusiveDevice; @@ -27,9 +27,9 @@ async fn ethernet_task( runner: Runner< 'static, W5500, - ExclusiveDevice, Output<'static, PIN_17>, Delay>, - Input<'static, PIN_21>, - Output<'static, PIN_20>, + ExclusiveDevice, Output<'static>, Delay>, + Input<'static>, + Output<'static>, >, ) -> ! { runner.run().await diff --git a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs index 975b3d385..3e4fbd2e6 100644 --- a/examples/rp/src/bin/ethernet_w5500_tcp_client.rs +++ b/examples/rp/src/bin/ethernet_w5500_tcp_client.rs @@ -15,7 +15,7 @@ use embassy_net_wiznet::chip::W5500; use embassy_net_wiznet::*; use embassy_rp::clocks::RoscRng; use embassy_rp::gpio::{Input, Level, Output, Pull}; -use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; +use embassy_rp::peripherals::SPI0; use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; use embassy_time::{Delay, Duration, Timer}; use embedded_hal_bus::spi::ExclusiveDevice; @@ -29,9 +29,9 @@ async fn ethernet_task( runner: Runner< 'static, W5500, - ExclusiveDevice, Output<'static, PIN_17>, Delay>, - Input<'static, PIN_21>, - Output<'static, PIN_20>, + ExclusiveDevice, Output<'static>, Delay>, + Input<'static>, + Output<'static>, >, ) -> ! { runner.run().await diff --git a/examples/rp/src/bin/ethernet_w5500_tcp_server.rs b/examples/rp/src/bin/ethernet_w5500_tcp_server.rs index 489af2c76..5532851f3 100644 --- a/examples/rp/src/bin/ethernet_w5500_tcp_server.rs +++ b/examples/rp/src/bin/ethernet_w5500_tcp_server.rs @@ -14,7 +14,7 @@ use embassy_net_wiznet::chip::W5500; use embassy_net_wiznet::*; use embassy_rp::clocks::RoscRng; use embassy_rp::gpio::{Input, Level, Output, Pull}; -use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; +use embassy_rp::peripherals::SPI0; use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; use embassy_time::{Delay, Duration}; use embedded_hal_bus::spi::ExclusiveDevice; @@ -28,9 +28,9 @@ async fn ethernet_task( runner: Runner< 'static, W5500, - ExclusiveDevice, Output<'static, PIN_17>, Delay>, - Input<'static, PIN_21>, - Output<'static, PIN_20>, + ExclusiveDevice, Output<'static>, Delay>, + Input<'static>, + Output<'static>, >, ) -> ! { runner.run().await diff --git a/examples/rp/src/bin/ethernet_w5500_udp.rs b/examples/rp/src/bin/ethernet_w5500_udp.rs index 41bd7d077..adb1d8941 100644 --- a/examples/rp/src/bin/ethernet_w5500_udp.rs +++ b/examples/rp/src/bin/ethernet_w5500_udp.rs @@ -14,7 +14,7 @@ use embassy_net_wiznet::chip::W5500; use embassy_net_wiznet::*; use embassy_rp::clocks::RoscRng; use embassy_rp::gpio::{Input, Level, Output, Pull}; -use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; +use embassy_rp::peripherals::SPI0; use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; use embassy_time::Delay; use embedded_hal_bus::spi::ExclusiveDevice; @@ -27,9 +27,9 @@ async fn ethernet_task( runner: Runner< 'static, W5500, - ExclusiveDevice, Output<'static, PIN_17>, Delay>, - Input<'static, PIN_21>, - Output<'static, PIN_20>, + ExclusiveDevice, Output<'static>, Delay>, + Input<'static>, + Output<'static>, >, ) -> ! { runner.run().await diff --git a/examples/rp/src/bin/multicore.rs b/examples/rp/src/bin/multicore.rs index a1678d99a..c7b087476 100644 --- a/examples/rp/src/bin/multicore.rs +++ b/examples/rp/src/bin/multicore.rs @@ -9,7 +9,6 @@ use defmt::*; use embassy_executor::Executor; use embassy_rp::gpio::{Level, Output}; use embassy_rp::multicore::{spawn_core1, Stack}; -use embassy_rp::peripherals::PIN_25; use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; use embassy_sync::channel::Channel; use embassy_time::Timer; @@ -52,7 +51,7 @@ async fn core0_task() { } #[embassy_executor::task] -async fn core1_task(mut led: Output<'static, PIN_25>) { +async fn core1_task(mut led: Output<'static>) { info!("Hello from core 1"); loop { match CHANNEL.receive().await { diff --git a/examples/rp/src/bin/wifi_ap_tcp_server.rs b/examples/rp/src/bin/wifi_ap_tcp_server.rs index 1bd75607e..b60852359 100644 --- a/examples/rp/src/bin/wifi_ap_tcp_server.rs +++ b/examples/rp/src/bin/wifi_ap_tcp_server.rs @@ -14,7 +14,7 @@ use embassy_net::tcp::TcpSocket; use embassy_net::{Config, Stack, StackResources}; use embassy_rp::bind_interrupts; use embassy_rp::gpio::{Level, Output}; -use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; +use embassy_rp::peripherals::{DMA_CH0, PIO0}; use embassy_rp::pio::{InterruptHandler, Pio}; use embassy_time::Duration; use embedded_io_async::Write; @@ -26,9 +26,7 @@ bind_interrupts!(struct Irqs { }); #[embassy_executor::task] -async fn wifi_task( - runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, -) -> ! { +async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! { runner.run().await } diff --git a/examples/rp/src/bin/wifi_blinky.rs b/examples/rp/src/bin/wifi_blinky.rs index 1ed74993c..18eefe41f 100644 --- a/examples/rp/src/bin/wifi_blinky.rs +++ b/examples/rp/src/bin/wifi_blinky.rs @@ -10,7 +10,7 @@ use defmt::*; use embassy_executor::Spawner; use embassy_rp::bind_interrupts; use embassy_rp::gpio::{Level, Output}; -use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; +use embassy_rp::peripherals::{DMA_CH0, PIO0}; use embassy_rp::pio::{InterruptHandler, Pio}; use embassy_time::{Duration, Timer}; use static_cell::StaticCell; @@ -21,9 +21,7 @@ bind_interrupts!(struct Irqs { }); #[embassy_executor::task] -async fn wifi_task( - runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, -) -> ! { +async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! { runner.run().await } diff --git a/examples/rp/src/bin/wifi_scan.rs b/examples/rp/src/bin/wifi_scan.rs index e678209dd..e0f85a6b0 100644 --- a/examples/rp/src/bin/wifi_scan.rs +++ b/examples/rp/src/bin/wifi_scan.rs @@ -13,7 +13,7 @@ use embassy_executor::Spawner; use embassy_net::Stack; use embassy_rp::bind_interrupts; use embassy_rp::gpio::{Level, Output}; -use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; +use embassy_rp::peripherals::{DMA_CH0, PIO0}; use embassy_rp::pio::{InterruptHandler, Pio}; use static_cell::StaticCell; use {defmt_rtt as _, panic_probe as _}; @@ -23,9 +23,7 @@ bind_interrupts!(struct Irqs { }); #[embassy_executor::task] -async fn wifi_task( - runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, -) -> ! { +async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! { runner.run().await } diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index c346f1ded..f1afc4a00 100644 --- a/examples/rp/src/bin/wifi_tcp_server.rs +++ b/examples/rp/src/bin/wifi_tcp_server.rs @@ -14,7 +14,7 @@ use embassy_net::tcp::TcpSocket; use embassy_net::{Config, Stack, StackResources}; use embassy_rp::bind_interrupts; use embassy_rp::gpio::{Level, Output}; -use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; +use embassy_rp::peripherals::{DMA_CH0, PIO0}; use embassy_rp::pio::{InterruptHandler, Pio}; use embassy_time::{Duration, Timer}; use embedded_io_async::Write; @@ -29,9 +29,7 @@ const WIFI_NETWORK: &str = "EmbassyTest"; const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; #[embassy_executor::task] -async fn wifi_task( - runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, -) -> ! { +async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! { runner.run().await } diff --git a/tests/rp/src/bin/cyw43-perf.rs b/tests/rp/src/bin/cyw43-perf.rs index a1b2946e6..b46ae670a 100644 --- a/tests/rp/src/bin/cyw43-perf.rs +++ b/tests/rp/src/bin/cyw43-perf.rs @@ -7,7 +7,7 @@ use defmt::{panic, *}; use embassy_executor::Spawner; use embassy_net::{Config, Stack, StackResources}; use embassy_rp::gpio::{Level, Output}; -use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; +use embassy_rp::peripherals::{DMA_CH0, PIO0}; use embassy_rp::pio::{InterruptHandler, Pio}; use embassy_rp::{bind_interrupts, rom_data}; use static_cell::StaticCell; @@ -24,9 +24,7 @@ const WIFI_NETWORK: &str = "EmbassyTest"; const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; #[embassy_executor::task] -async fn wifi_task( - runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, -) -> ! { +async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! { runner.run().await } diff --git a/tests/rp/src/bin/ethernet_w5100s_perf.rs b/tests/rp/src/bin/ethernet_w5100s_perf.rs index 8c9089d0e..5d5547773 100644 --- a/tests/rp/src/bin/ethernet_w5100s_perf.rs +++ b/tests/rp/src/bin/ethernet_w5100s_perf.rs @@ -10,7 +10,7 @@ use embassy_net_wiznet::chip::W5100S; use embassy_net_wiznet::*; use embassy_rp::clocks::RoscRng; use embassy_rp::gpio::{Input, Level, Output, Pull}; -use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; +use embassy_rp::peripherals::SPI0; use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; use embassy_time::Delay; use embedded_hal_bus::spi::ExclusiveDevice; @@ -23,9 +23,9 @@ async fn ethernet_task( runner: Runner< 'static, W5100S, - ExclusiveDevice, Output<'static, PIN_17>, Delay>, - Input<'static, PIN_21>, - Output<'static, PIN_20>, + ExclusiveDevice, Output<'static>, Delay>, + Input<'static>, + Output<'static>, >, ) -> ! { runner.run().await diff --git a/tests/rp/src/bin/uart.rs b/tests/rp/src/bin/uart.rs index f4d641175..6e6e5517b 100644 --- a/tests/rp/src/bin/uart.rs +++ b/tests/rp/src/bin/uart.rs @@ -21,7 +21,7 @@ fn read1(uart: &mut UartRx<'_, impl Instance, Blocking>) -> Resu Ok(buf) } -async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option) { +async fn send(pin: &mut Output<'_>, v: u8, parity: Option) { pin.set_low(); Timer::after_millis(1).await; for i in 0..8 { @@ -116,7 +116,7 @@ async fn main(_spawner: Spawner) { config.parity = Parity::ParityEven; let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config); - async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: u8) { + async fn chr(pin: &mut Output<'_>, v: u8, parity: u8) { send(pin, v, Some(parity != 0)).await; } @@ -142,7 +142,7 @@ async fn main(_spawner: Spawner) { config.baudrate = 1000; let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config); - async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, good: bool) { + async fn chr(pin: &mut Output<'_>, v: u8, good: bool) { if good { send(pin, v, None).await; } else { diff --git a/tests/rp/src/bin/uart_buffered.rs b/tests/rp/src/bin/uart_buffered.rs index 14647e44a..d68c23cbd 100644 --- a/tests/rp/src/bin/uart_buffered.rs +++ b/tests/rp/src/bin/uart_buffered.rs @@ -36,7 +36,7 @@ async fn read1(uart: &mut BufferedUartRx<'_, impl Instance>) -> } } -async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option) { +async fn send(pin: &mut Output<'_>, v: u8, parity: Option) { pin.set_low(); Timer::after_millis(1).await; for i in 0..8 { @@ -161,7 +161,7 @@ async fn main(_spawner: Spawner) { let rx_buf = &mut [0u8; 16]; let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config); - async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: u32) { + async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) { send(pin, v, Some(parity != 0)).await; } @@ -208,7 +208,7 @@ async fn main(_spawner: Spawner) { let rx_buf = &mut [0u8; 16]; let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config); - async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, good: bool) { + async fn chr(pin: &mut Output<'_>, v: u8, good: bool) { if good { send(pin, v, None).await; } else { diff --git a/tests/rp/src/bin/uart_dma.rs b/tests/rp/src/bin/uart_dma.rs index 130d8599e..edc87175a 100644 --- a/tests/rp/src/bin/uart_dma.rs +++ b/tests/rp/src/bin/uart_dma.rs @@ -27,7 +27,7 @@ async fn read1(uart: &mut UartRx<'_, impl Instance, Async>) -> R Ok(buf) } -async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option) { +async fn send(pin: &mut Output<'_>, v: u8, parity: Option) { pin.set_low(); Timer::after_millis(1).await; for i in 0..8 { @@ -160,7 +160,7 @@ async fn main(_spawner: Spawner) { config.parity = Parity::ParityEven; let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config); - async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: u32) { + async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) { send(pin, v, Some(parity != 0)).await; } @@ -205,7 +205,7 @@ async fn main(_spawner: Spawner) { config.baudrate = 1000; let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config); - async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, good: bool) { + async fn chr(pin: &mut Output<'_>, v: u8, good: bool) { if good { send(pin, v, None).await; } else { -- cgit