diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-01-22 20:44:57 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-01-22 20:44:57 +0000 |
| commit | c1ba008be457cdc8fe083fe36e380aa60dd784e2 (patch) | |
| tree | caabf0c20ce7d2d07e292690b1afb9baa606610f | |
| parent | 20fd03a14f1261e7b2264dcbca8e164393e66b94 (diff) | |
| parent | ee0ebe3121e5d51240e671d8c5cc19ad878b9db9 (diff) | |
Merge pull request #2471 from embassy-rs/remove-gpio-generics
gpio: remove generics.
60 files changed, 351 insertions, 439 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; | |||
| 7 | 7 | ||
| 8 | use cyw43::SpiBusCyw43; | 8 | use cyw43::SpiBusCyw43; |
| 9 | use embassy_rp::dma::Channel; | 9 | use embassy_rp::dma::Channel; |
| 10 | use embassy_rp::gpio::{Drive, Level, Output, Pin, Pull, SlewRate}; | 10 | use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate}; |
| 11 | use embassy_rp::pio::{instr, Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; | 11 | use embassy_rp::pio::{instr, Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; |
| 12 | use embassy_rp::{Peripheral, PeripheralRef}; | 12 | use embassy_rp::{Peripheral, PeripheralRef}; |
| 13 | use fixed::FixedU32; | 13 | use fixed::FixedU32; |
| 14 | use pio_proc::pio_asm; | 14 | use pio_proc::pio_asm; |
| 15 | 15 | ||
| 16 | /// SPI comms driven by PIO. | 16 | /// SPI comms driven by PIO. |
| 17 | pub struct PioSpi<'d, CS: Pin, PIO: Instance, const SM: usize, DMA> { | 17 | pub struct PioSpi<'d, PIO: Instance, const SM: usize, DMA> { |
| 18 | cs: Output<'d, CS>, | 18 | cs: Output<'d>, |
| 19 | sm: StateMachine<'d, PIO, SM>, | 19 | sm: StateMachine<'d, PIO, SM>, |
| 20 | irq: Irq<'d, PIO, 0>, | 20 | irq: Irq<'d, PIO, 0>, |
| 21 | dma: PeripheralRef<'d, DMA>, | 21 | dma: PeripheralRef<'d, DMA>, |
| 22 | wrap_target: u8, | 22 | wrap_target: u8, |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | impl<'d, CS, PIO, const SM: usize, DMA> PioSpi<'d, CS, PIO, SM, DMA> | 25 | impl<'d, PIO, const SM: usize, DMA> PioSpi<'d, PIO, SM, DMA> |
| 26 | where | 26 | where |
| 27 | DMA: Channel, | 27 | DMA: Channel, |
| 28 | CS: Pin, | ||
| 29 | PIO: Instance, | 28 | PIO: Instance, |
| 30 | { | 29 | { |
| 31 | /// Create a new instance of PioSpi. | 30 | /// Create a new instance of PioSpi. |
| @@ -33,7 +32,7 @@ where | |||
| 33 | common: &mut Common<'d, PIO>, | 32 | common: &mut Common<'d, PIO>, |
| 34 | mut sm: StateMachine<'d, PIO, SM>, | 33 | mut sm: StateMachine<'d, PIO, SM>, |
| 35 | irq: Irq<'d, PIO, 0>, | 34 | irq: Irq<'d, PIO, 0>, |
| 36 | cs: Output<'d, CS>, | 35 | cs: Output<'d>, |
| 37 | dio: DIO, | 36 | dio: DIO, |
| 38 | clk: CLK, | 37 | clk: CLK, |
| 39 | dma: impl Peripheral<P = DMA> + 'd, | 38 | dma: impl Peripheral<P = DMA> + 'd, |
| @@ -206,9 +205,8 @@ where | |||
| 206 | } | 205 | } |
| 207 | } | 206 | } |
| 208 | 207 | ||
| 209 | impl<'d, CS, PIO, const SM: usize, DMA> SpiBusCyw43 for PioSpi<'d, CS, PIO, SM, DMA> | 208 | impl<'d, PIO, const SM: usize, DMA> SpiBusCyw43 for PioSpi<'d, PIO, SM, DMA> |
| 210 | where | 209 | where |
| 211 | CS: Pin, | ||
| 212 | PIO: Instance, | 210 | PIO: Instance, |
| 213 | DMA: Channel, | 211 | DMA: Channel, |
| 214 | { | 212 | { |
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | 6 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; |
| 7 | use embassy_nrf::peripherals::P0_13; | ||
| 8 | use embassy_time::{Duration, Timer}; | 7 | use embassy_time::{Duration, Timer}; |
| 9 | use {defmt_rtt as _, panic_probe as _}; // global logger | 8 | use {defmt_rtt as _, panic_probe as _}; // global logger |
| 10 | 9 | ||
| 11 | #[embassy_executor::task] | 10 | #[embassy_executor::task] |
| 12 | async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) { | 11 | async fn blinker(mut led: Output<'static>, interval: Duration) { |
| 13 | loop { | 12 | loop { |
| 14 | led.set_high(); | 13 | led.set_high(); |
| 15 | Timer::after(interval).await; | 14 | Timer::after(interval).await; |
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 @@ | |||
| 3 | 3 | ||
| 4 | use embassy_executor::Spawner; | 4 | use embassy_executor::Spawner; |
| 5 | use embassy_stm32::exti::ExtiInput; | 5 | use embassy_stm32::exti::ExtiInput; |
| 6 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 6 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 7 | use {defmt_rtt as _, panic_probe as _}; | 7 | use {defmt_rtt as _, panic_probe as _}; |
| 8 | 8 | ||
| 9 | #[embassy_executor::main] | 9 | #[embassy_executor::main] |
| 10 | async fn main(_spawner: Spawner) { | 10 | async fn main(_spawner: Spawner) { |
| 11 | let p = embassy_stm32::init(Default::default()); | 11 | let p = embassy_stm32::init(Default::default()); |
| 12 | let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh); | 12 | let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh); |
| 13 | let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13); | 13 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); |
| 14 | 14 | ||
| 15 | loop { | 15 | loop { |
| 16 | button.wait_for_any_edge().await; | 16 | 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; | |||
| 6 | use cortex_m::interrupt::Mutex; | 6 | use cortex_m::interrupt::Mutex; |
| 7 | use cortex_m::peripheral::NVIC; | 7 | use cortex_m::peripheral::NVIC; |
| 8 | use cortex_m_rt::entry; | 8 | use cortex_m_rt::entry; |
| 9 | use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed}; | 9 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; |
| 10 | use embassy_stm32::peripherals::{PB14, PC13}; | ||
| 11 | use embassy_stm32::{interrupt, pac}; | 10 | use embassy_stm32::{interrupt, pac}; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 12 | ||
| 14 | static BUTTON: Mutex<RefCell<Option<Input<'static, PC13>>>> = Mutex::new(RefCell::new(None)); | 13 | static BUTTON: Mutex<RefCell<Option<Input<'static>>>> = Mutex::new(RefCell::new(None)); |
| 15 | static LED: Mutex<RefCell<Option<Output<'static, PB14>>>> = Mutex::new(RefCell::new(None)); | 14 | static LED: Mutex<RefCell<Option<Output<'static>>>> = Mutex::new(RefCell::new(None)); |
| 16 | 15 | ||
| 17 | #[entry] | 16 | #[entry] |
| 18 | fn main() -> ! { | 17 | fn main() -> ! { |
| @@ -62,14 +61,14 @@ fn EXTI15_10() { | |||
| 62 | 61 | ||
| 63 | const PORT: u8 = 2; | 62 | const PORT: u8 = 2; |
| 64 | const PIN: usize = 13; | 63 | const PIN: usize = 13; |
| 65 | fn check_interrupt<P: Pin>(_pin: &mut Input<'static, P>) -> bool { | 64 | fn check_interrupt(_pin: &mut Input<'static>) -> bool { |
| 66 | let exti = pac::EXTI; | 65 | let exti = pac::EXTI; |
| 67 | let pin = PIN; | 66 | let pin = PIN; |
| 68 | let lines = exti.pr(0).read(); | 67 | let lines = exti.pr(0).read(); |
| 69 | lines.line(pin) | 68 | lines.line(pin) |
| 70 | } | 69 | } |
| 71 | 70 | ||
| 72 | fn clear_interrupt<P: Pin>(_pin: &mut Input<'static, P>) { | 71 | fn clear_interrupt(_pin: &mut Input<'static>) { |
| 73 | let exti = pac::EXTI; | 72 | let exti = pac::EXTI; |
| 74 | let pin = PIN; | 73 | let pin = PIN; |
| 75 | let mut lines = exti.pr(0).read(); | 74 | let mut lines = exti.pr(0).read(); |
| @@ -77,7 +76,7 @@ fn clear_interrupt<P: Pin>(_pin: &mut Input<'static, P>) { | |||
| 77 | exti.pr(0).write_value(lines); | 76 | exti.pr(0).write_value(lines); |
| 78 | } | 77 | } |
| 79 | 78 | ||
| 80 | fn enable_interrupt<P: Pin>(_pin: &mut Input<'static, P>) { | 79 | fn enable_interrupt(_pin: &mut Input<'static>) { |
| 81 | cortex_m::interrupt::free(|_| { | 80 | cortex_m::interrupt::free(|_| { |
| 82 | let rcc = pac::RCC; | 81 | let rcc = pac::RCC; |
| 83 | rcc.apb2enr().modify(|w| w.set_syscfgen(true)); | 82 | rcc.apb2enr().modify(|w| w.set_syscfgen(true)); |
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 { | |||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | /// GPIO input driver. | 38 | /// GPIO input driver. |
| 39 | pub struct Input<'d, T: Pin> { | 39 | pub struct Input<'d> { |
| 40 | pub(crate) pin: Flex<'d, T>, | 40 | pub(crate) pin: Flex<'d>, |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | impl<'d, T: Pin> Input<'d, T> { | 43 | impl<'d> Input<'d> { |
| 44 | /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration. | 44 | /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration. |
| 45 | #[inline] | 45 | #[inline] |
| 46 | pub fn new(pin: impl Peripheral<P = T> + 'd, pull: Pull) -> Self { | 46 | pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, pull: Pull) -> Self { |
| 47 | let mut pin = Flex::new(pin); | 47 | let mut pin = Flex::new(pin); |
| 48 | pin.set_as_input(pull); | 48 | pin.set_as_input(pull); |
| 49 | 49 | ||
| @@ -122,14 +122,14 @@ pub enum OutputDrive { | |||
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | /// GPIO output driver. | 124 | /// GPIO output driver. |
| 125 | pub struct Output<'d, T: Pin> { | 125 | pub struct Output<'d> { |
| 126 | pub(crate) pin: Flex<'d, T>, | 126 | pub(crate) pin: Flex<'d>, |
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | impl<'d, T: Pin> Output<'d, T> { | 129 | impl<'d> Output<'d> { |
| 130 | /// Create GPIO output driver for a [Pin] with the provided [Level] and [OutputDriver] configuration. | 130 | /// Create GPIO output driver for a [Pin] with the provided [Level] and [OutputDriver] configuration. |
| 131 | #[inline] | 131 | #[inline] |
| 132 | pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level, drive: OutputDrive) -> Self { | 132 | pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level, drive: OutputDrive) -> Self { |
| 133 | let mut pin = Flex::new(pin); | 133 | let mut pin = Flex::new(pin); |
| 134 | match initial_output { | 134 | match initial_output { |
| 135 | Level::High => pin.set_high(), | 135 | Level::High => pin.set_high(), |
| @@ -209,20 +209,20 @@ fn convert_pull(pull: Pull) -> PULL_A { | |||
| 209 | /// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain | 209 | /// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain |
| 210 | /// set while not in output mode, so the pin's level will be 'remembered' when it is not in output | 210 | /// set while not in output mode, so the pin's level will be 'remembered' when it is not in output |
| 211 | /// mode. | 211 | /// mode. |
| 212 | pub struct Flex<'d, T: Pin> { | 212 | pub struct Flex<'d> { |
| 213 | pub(crate) pin: PeripheralRef<'d, T>, | 213 | pub(crate) pin: PeripheralRef<'d, AnyPin>, |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | impl<'d, T: Pin> Flex<'d, T> { | 216 | impl<'d> Flex<'d> { |
| 217 | /// Wrap the pin in a `Flex`. | 217 | /// Wrap the pin in a `Flex`. |
| 218 | /// | 218 | /// |
| 219 | /// The pin remains disconnected. The initial output level is unspecified, but can be changed | 219 | /// The pin remains disconnected. The initial output level is unspecified, but can be changed |
| 220 | /// before the pin is put into output mode. | 220 | /// before the pin is put into output mode. |
| 221 | #[inline] | 221 | #[inline] |
| 222 | pub fn new(pin: impl Peripheral<P = T> + 'd) -> Self { | 222 | pub fn new(pin: impl Peripheral<P = impl Pin> + 'd) -> Self { |
| 223 | into_ref!(pin); | 223 | into_ref!(pin); |
| 224 | // Pin will be in disconnected state. | 224 | // Pin will be in disconnected state. |
| 225 | Self { pin } | 225 | Self { pin: pin.map_into() } |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | /// Put the pin into input mode. | 228 | /// Put the pin into input mode. |
| @@ -349,7 +349,7 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 349 | } | 349 | } |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | impl<'d, T: Pin> Drop for Flex<'d, T> { | 352 | impl<'d> Drop for Flex<'d> { |
| 353 | fn drop(&mut self) { | 353 | fn drop(&mut self) { |
| 354 | self.pin.conf().reset(); | 354 | self.pin.conf().reset(); |
| 355 | } | 355 | } |
| @@ -510,7 +510,7 @@ macro_rules! impl_pin { | |||
| 510 | mod eh02 { | 510 | mod eh02 { |
| 511 | use super::*; | 511 | use super::*; |
| 512 | 512 | ||
| 513 | impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { | 513 | impl<'d> embedded_hal_02::digital::v2::InputPin for Input<'d> { |
| 514 | type Error = Infallible; | 514 | type Error = Infallible; |
| 515 | 515 | ||
| 516 | fn is_high(&self) -> Result<bool, Self::Error> { | 516 | fn is_high(&self) -> Result<bool, Self::Error> { |
| @@ -522,7 +522,7 @@ mod eh02 { | |||
| 522 | } | 522 | } |
| 523 | } | 523 | } |
| 524 | 524 | ||
| 525 | impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { | 525 | impl<'d> embedded_hal_02::digital::v2::OutputPin for Output<'d> { |
| 526 | type Error = Infallible; | 526 | type Error = Infallible; |
| 527 | 527 | ||
| 528 | fn set_high(&mut self) -> Result<(), Self::Error> { | 528 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| @@ -534,7 +534,7 @@ mod eh02 { | |||
| 534 | } | 534 | } |
| 535 | } | 535 | } |
| 536 | 536 | ||
| 537 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { | 537 | impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d> { |
| 538 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 538 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 539 | Ok(self.is_set_high()) | 539 | Ok(self.is_set_high()) |
| 540 | } | 540 | } |
| @@ -544,7 +544,7 @@ mod eh02 { | |||
| 544 | } | 544 | } |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> { | 547 | impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d> { |
| 548 | type Error = Infallible; | 548 | type Error = Infallible; |
| 549 | #[inline] | 549 | #[inline] |
| 550 | fn toggle(&mut self) -> Result<(), Self::Error> { | 550 | fn toggle(&mut self) -> Result<(), Self::Error> { |
| @@ -556,7 +556,7 @@ mod eh02 { | |||
| 556 | /// Implement [`embedded_hal_02::digital::v2::InputPin`] for [`Flex`]; | 556 | /// Implement [`embedded_hal_02::digital::v2::InputPin`] for [`Flex`]; |
| 557 | /// | 557 | /// |
| 558 | /// If the pin is not in input mode the result is unspecified. | 558 | /// If the pin is not in input mode the result is unspecified. |
| 559 | impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { | 559 | impl<'d> embedded_hal_02::digital::v2::InputPin for Flex<'d> { |
| 560 | type Error = Infallible; | 560 | type Error = Infallible; |
| 561 | 561 | ||
| 562 | fn is_high(&self) -> Result<bool, Self::Error> { | 562 | fn is_high(&self) -> Result<bool, Self::Error> { |
| @@ -568,7 +568,7 @@ mod eh02 { | |||
| 568 | } | 568 | } |
| 569 | } | 569 | } |
| 570 | 570 | ||
| 571 | impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { | 571 | impl<'d> embedded_hal_02::digital::v2::OutputPin for Flex<'d> { |
| 572 | type Error = Infallible; | 572 | type Error = Infallible; |
| 573 | 573 | ||
| 574 | fn set_high(&mut self) -> Result<(), Self::Error> { | 574 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| @@ -580,7 +580,7 @@ mod eh02 { | |||
| 580 | } | 580 | } |
| 581 | } | 581 | } |
| 582 | 582 | ||
| 583 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { | 583 | impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d> { |
| 584 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 584 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 585 | Ok(self.is_set_high()) | 585 | Ok(self.is_set_high()) |
| 586 | } | 586 | } |
| @@ -590,7 +590,7 @@ mod eh02 { | |||
| 590 | } | 590 | } |
| 591 | } | 591 | } |
| 592 | 592 | ||
| 593 | impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> { | 593 | impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d> { |
| 594 | type Error = Infallible; | 594 | type Error = Infallible; |
| 595 | #[inline] | 595 | #[inline] |
| 596 | fn toggle(&mut self) -> Result<(), Self::Error> { | 596 | fn toggle(&mut self) -> Result<(), Self::Error> { |
| @@ -600,11 +600,11 @@ mod eh02 { | |||
| 600 | } | 600 | } |
| 601 | } | 601 | } |
| 602 | 602 | ||
| 603 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { | 603 | impl<'d> embedded_hal_1::digital::ErrorType for Input<'d> { |
| 604 | type Error = Infallible; | 604 | type Error = Infallible; |
| 605 | } | 605 | } |
| 606 | 606 | ||
| 607 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { | 607 | impl<'d> embedded_hal_1::digital::InputPin for Input<'d> { |
| 608 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 608 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 609 | Ok((*self).is_high()) | 609 | Ok((*self).is_high()) |
| 610 | } | 610 | } |
| @@ -614,11 +614,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { | |||
| 614 | } | 614 | } |
| 615 | } | 615 | } |
| 616 | 616 | ||
| 617 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { | 617 | impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> { |
| 618 | type Error = Infallible; | 618 | type Error = Infallible; |
| 619 | } | 619 | } |
| 620 | 620 | ||
| 621 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | 621 | impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> { |
| 622 | fn set_high(&mut self) -> Result<(), Self::Error> { | 622 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| 623 | Ok(self.set_high()) | 623 | Ok(self.set_high()) |
| 624 | } | 624 | } |
| @@ -628,7 +628,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | |||
| 628 | } | 628 | } |
| 629 | } | 629 | } |
| 630 | 630 | ||
| 631 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { | 631 | impl<'d> embedded_hal_1::digital::StatefulOutputPin for Output<'d> { |
| 632 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 632 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 633 | Ok((*self).is_set_high()) | 633 | Ok((*self).is_set_high()) |
| 634 | } | 634 | } |
| @@ -638,14 +638,14 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { | |||
| 638 | } | 638 | } |
| 639 | } | 639 | } |
| 640 | 640 | ||
| 641 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { | 641 | impl<'d> embedded_hal_1::digital::ErrorType for Flex<'d> { |
| 642 | type Error = Infallible; | 642 | type Error = Infallible; |
| 643 | } | 643 | } |
| 644 | 644 | ||
| 645 | /// Implement [`InputPin`] for [`Flex`]; | 645 | /// Implement [`InputPin`] for [`Flex`]; |
| 646 | /// | 646 | /// |
| 647 | /// If the pin is not in input mode the result is unspecified. | 647 | /// If the pin is not in input mode the result is unspecified. |
| 648 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | 648 | impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> { |
| 649 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 649 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 650 | Ok((*self).is_high()) | 650 | Ok((*self).is_high()) |
| 651 | } | 651 | } |
| @@ -655,7 +655,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | |||
| 655 | } | 655 | } |
| 656 | } | 656 | } |
| 657 | 657 | ||
| 658 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { | 658 | impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> { |
| 659 | fn set_high(&mut self) -> Result<(), Self::Error> { | 659 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| 660 | Ok(self.set_high()) | 660 | Ok(self.set_high()) |
| 661 | } | 661 | } |
| @@ -665,7 +665,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { | |||
| 665 | } | 665 | } |
| 666 | } | 666 | } |
| 667 | 667 | ||
| 668 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { | 668 | impl<'d> embedded_hal_1::digital::StatefulOutputPin for Flex<'d> { |
| 669 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 669 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 670 | Ok((*self).is_set_high()) | 670 | Ok((*self).is_set_high()) |
| 671 | } | 671 | } |
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 { | |||
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | /// GPIOTE channel driver in input mode | 158 | /// GPIOTE channel driver in input mode |
| 159 | pub struct InputChannel<'d, C: Channel, T: GpioPin> { | 159 | pub struct InputChannel<'d> { |
| 160 | ch: PeripheralRef<'d, C>, | 160 | ch: PeripheralRef<'d, AnyChannel>, |
| 161 | pin: Input<'d, T>, | 161 | pin: Input<'d>, |
| 162 | } | 162 | } |
| 163 | 163 | ||
| 164 | impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> { | 164 | impl<'d> Drop for InputChannel<'d> { |
| 165 | fn drop(&mut self) { | 165 | fn drop(&mut self) { |
| 166 | let g = regs(); | 166 | let g = regs(); |
| 167 | let num = self.ch.number(); | 167 | let num = self.ch.number(); |
| @@ -170,9 +170,9 @@ impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> { | |||
| 170 | } | 170 | } |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { | 173 | impl<'d> InputChannel<'d> { |
| 174 | /// Create a new GPIOTE input channel driver. | 174 | /// Create a new GPIOTE input channel driver. |
| 175 | pub fn new(ch: impl Peripheral<P = C> + 'd, pin: Input<'d, T>, polarity: InputChannelPolarity) -> Self { | 175 | pub fn new(ch: impl Peripheral<P = impl Channel> + 'd, pin: Input<'d>, polarity: InputChannelPolarity) -> Self { |
| 176 | into_ref!(ch); | 176 | into_ref!(ch); |
| 177 | 177 | ||
| 178 | let g = regs(); | 178 | let g = regs(); |
| @@ -195,7 +195,7 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { | |||
| 195 | 195 | ||
| 196 | g.events_in[num].reset(); | 196 | g.events_in[num].reset(); |
| 197 | 197 | ||
| 198 | InputChannel { ch, pin } | 198 | InputChannel { ch: ch.map_into(), pin } |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | /// Asynchronously wait for an event in this channel. | 201 | /// Asynchronously wait for an event in this channel. |
| @@ -227,12 +227,12 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { | |||
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | /// GPIOTE channel driver in output mode | 229 | /// GPIOTE channel driver in output mode |
| 230 | pub struct OutputChannel<'d, C: Channel, T: GpioPin> { | 230 | pub struct OutputChannel<'d> { |
| 231 | ch: PeripheralRef<'d, C>, | 231 | ch: PeripheralRef<'d, AnyChannel>, |
| 232 | _pin: Output<'d, T>, | 232 | _pin: Output<'d>, |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> { | 235 | impl<'d> Drop for OutputChannel<'d> { |
| 236 | fn drop(&mut self) { | 236 | fn drop(&mut self) { |
| 237 | let g = regs(); | 237 | let g = regs(); |
| 238 | let num = self.ch.number(); | 238 | let num = self.ch.number(); |
| @@ -241,9 +241,9 @@ impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> { | |||
| 241 | } | 241 | } |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { | 244 | impl<'d> OutputChannel<'d> { |
| 245 | /// Create a new GPIOTE output channel driver. | 245 | /// Create a new GPIOTE output channel driver. |
| 246 | pub fn new(ch: impl Peripheral<P = C> + 'd, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self { | 246 | pub fn new(ch: impl Peripheral<P = impl Channel> + 'd, pin: Output<'d>, polarity: OutputChannelPolarity) -> Self { |
| 247 | into_ref!(ch); | 247 | into_ref!(ch); |
| 248 | let g = regs(); | 248 | let g = regs(); |
| 249 | let num = ch.number(); | 249 | let num = ch.number(); |
| @@ -267,7 +267,10 @@ impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { | |||
| 267 | unsafe { w.psel().bits(pin.pin.pin.pin()) } | 267 | unsafe { w.psel().bits(pin.pin.pin.pin()) } |
| 268 | }); | 268 | }); |
| 269 | 269 | ||
| 270 | OutputChannel { ch, _pin: pin } | 270 | OutputChannel { |
| 271 | ch: ch.map_into(), | ||
| 272 | _pin: pin, | ||
| 273 | } | ||
| 271 | } | 274 | } |
| 272 | 275 | ||
| 273 | /// Triggers the OUT task (does the action as configured with task_out_polarity, defaults to Toggle). | 276 | /// 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> { | |||
| 348 | } | 351 | } |
| 349 | } | 352 | } |
| 350 | 353 | ||
| 351 | impl<'d, T: GpioPin> Input<'d, T> { | 354 | impl<'d> Input<'d> { |
| 352 | /// Wait until the pin is high. If it is already high, return immediately. | 355 | /// Wait until the pin is high. If it is already high, return immediately. |
| 353 | pub async fn wait_for_high(&mut self) { | 356 | pub async fn wait_for_high(&mut self) { |
| 354 | self.pin.wait_for_high().await | 357 | self.pin.wait_for_high().await |
| @@ -375,7 +378,7 @@ impl<'d, T: GpioPin> Input<'d, T> { | |||
| 375 | } | 378 | } |
| 376 | } | 379 | } |
| 377 | 380 | ||
| 378 | impl<'d, T: GpioPin> Flex<'d, T> { | 381 | impl<'d> Flex<'d> { |
| 379 | /// Wait until the pin is high. If it is already high, return immediately. | 382 | /// Wait until the pin is high. If it is already high, return immediately. |
| 380 | pub async fn wait_for_high(&mut self) { | 383 | pub async fn wait_for_high(&mut self) { |
| 381 | self.pin.conf().modify(|_, w| w.sense().high()); | 384 | self.pin.conf().modify(|_, w| w.sense().high()); |
| @@ -420,7 +423,7 @@ mod sealed { | |||
| 420 | /// GPIOTE channel trait. | 423 | /// GPIOTE channel trait. |
| 421 | /// | 424 | /// |
| 422 | /// Implemented by all GPIOTE channels. | 425 | /// Implemented by all GPIOTE channels. |
| 423 | pub trait Channel: sealed::Channel + Sized { | 426 | pub trait Channel: sealed::Channel + Into<AnyChannel> + Sized + 'static { |
| 424 | /// Get the channel number. | 427 | /// Get the channel number. |
| 425 | fn number(&self) -> usize; | 428 | fn number(&self) -> usize; |
| 426 | 429 | ||
| @@ -460,6 +463,12 @@ macro_rules! impl_channel { | |||
| 460 | $number as usize | 463 | $number as usize |
| 461 | } | 464 | } |
| 462 | } | 465 | } |
| 466 | |||
| 467 | impl From<peripherals::$type> for AnyChannel { | ||
| 468 | fn from(val: peripherals::$type) -> Self { | ||
| 469 | Channel::degrade(val) | ||
| 470 | } | ||
| 471 | } | ||
| 463 | }; | 472 | }; |
| 464 | } | 473 | } |
| 465 | 474 | ||
| @@ -477,7 +486,7 @@ impl_channel!(GPIOTE_CH7, 7); | |||
| 477 | mod eh02 { | 486 | mod eh02 { |
| 478 | use super::*; | 487 | use super::*; |
| 479 | 488 | ||
| 480 | impl<'d, C: Channel, T: GpioPin> embedded_hal_02::digital::v2::InputPin for InputChannel<'d, C, T> { | 489 | impl<'d> embedded_hal_02::digital::v2::InputPin for InputChannel<'d> { |
| 481 | type Error = Infallible; | 490 | type Error = Infallible; |
| 482 | 491 | ||
| 483 | fn is_high(&self) -> Result<bool, Self::Error> { | 492 | fn is_high(&self) -> Result<bool, Self::Error> { |
| @@ -490,11 +499,11 @@ mod eh02 { | |||
| 490 | } | 499 | } |
| 491 | } | 500 | } |
| 492 | 501 | ||
| 493 | impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> { | 502 | impl<'d> embedded_hal_1::digital::ErrorType for InputChannel<'d> { |
| 494 | type Error = Infallible; | 503 | type Error = Infallible; |
| 495 | } | 504 | } |
| 496 | 505 | ||
| 497 | impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> { | 506 | impl<'d> embedded_hal_1::digital::InputPin for InputChannel<'d> { |
| 498 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 507 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 499 | Ok(self.pin.is_high()) | 508 | Ok(self.pin.is_high()) |
| 500 | } | 509 | } |
| @@ -504,7 +513,7 @@ impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChan | |||
| 504 | } | 513 | } |
| 505 | } | 514 | } |
| 506 | 515 | ||
| 507 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { | 516 | impl<'d> embedded_hal_async::digital::Wait for Input<'d> { |
| 508 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { | 517 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { |
| 509 | Ok(self.wait_for_high().await) | 518 | Ok(self.wait_for_high().await) |
| 510 | } | 519 | } |
| @@ -526,7 +535,7 @@ impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> { | |||
| 526 | } | 535 | } |
| 527 | } | 536 | } |
| 528 | 537 | ||
| 529 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> { | 538 | impl<'d> embedded_hal_async::digital::Wait for Flex<'d> { |
| 530 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { | 539 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { |
| 531 | Ok(self.wait_for_high().await) | 540 | Ok(self.wait_for_high().await) |
| 532 | } | 541 | } |
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}; | |||
| 8 | use embassy_hal_internal::{impl_peripheral, into_ref, PeripheralRef}; | 8 | use embassy_hal_internal::{impl_peripheral, into_ref, PeripheralRef}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use self::sealed::Pin as _; | ||
| 11 | use crate::interrupt::InterruptExt; | 12 | use crate::interrupt::InterruptExt; |
| 12 | use crate::pac::common::{Reg, RW}; | 13 | use crate::pac::common::{Reg, RW}; |
| 13 | use crate::pac::SIO; | 14 | use crate::pac::SIO; |
| @@ -105,14 +106,14 @@ pub struct DormantWakeConfig { | |||
| 105 | } | 106 | } |
| 106 | 107 | ||
| 107 | /// GPIO input driver. | 108 | /// GPIO input driver. |
| 108 | pub struct Input<'d, T: Pin> { | 109 | pub struct Input<'d> { |
| 109 | pin: Flex<'d, T>, | 110 | pin: Flex<'d>, |
| 110 | } | 111 | } |
| 111 | 112 | ||
| 112 | impl<'d, T: Pin> Input<'d, T> { | 113 | impl<'d> Input<'d> { |
| 113 | /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration. | 114 | /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration. |
| 114 | #[inline] | 115 | #[inline] |
| 115 | pub fn new(pin: impl Peripheral<P = T> + 'd, pull: Pull) -> Self { | 116 | pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, pull: Pull) -> Self { |
| 116 | let mut pin = Flex::new(pin); | 117 | let mut pin = Flex::new(pin); |
| 117 | pin.set_as_input(); | 118 | pin.set_as_input(); |
| 118 | pin.set_pull(pull); | 119 | pin.set_pull(pull); |
| @@ -175,7 +176,7 @@ impl<'d, T: Pin> Input<'d, T> { | |||
| 175 | 176 | ||
| 176 | /// Configure dormant wake. | 177 | /// Configure dormant wake. |
| 177 | #[inline] | 178 | #[inline] |
| 178 | pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake<T> { | 179 | pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake<'_> { |
| 179 | self.pin.dormant_wake(cfg) | 180 | self.pin.dormant_wake(cfg) |
| 180 | } | 181 | } |
| 181 | } | 182 | } |
| @@ -255,14 +256,12 @@ fn IO_IRQ_QSPI() { | |||
| 255 | } | 256 | } |
| 256 | 257 | ||
| 257 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 258 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 258 | struct InputFuture<'a, T: Pin> { | 259 | struct InputFuture<'d> { |
| 259 | pin: PeripheralRef<'a, T>, | 260 | pin: PeripheralRef<'d, AnyPin>, |
| 260 | } | 261 | } |
| 261 | 262 | ||
| 262 | impl<'d, T: Pin> InputFuture<'d, T> { | 263 | impl<'d> InputFuture<'d> { |
| 263 | /// Create a new future wiating for input trigger. | 264 | fn new(pin: PeripheralRef<'d, AnyPin>, level: InterruptTrigger) -> Self { |
| 264 | pub fn new(pin: impl Peripheral<P = T> + 'd, level: InterruptTrigger) -> Self { | ||
| 265 | into_ref!(pin); | ||
| 266 | let pin_group = (pin.pin() % 8) as usize; | 265 | let pin_group = (pin.pin() % 8) as usize; |
| 267 | // first, clear the INTR register bits. without this INTR will still | 266 | // first, clear the INTR register bits. without this INTR will still |
| 268 | // contain reports of previous edges, causing the IRQ to fire early | 267 | // contain reports of previous edges, causing the IRQ to fire early |
| @@ -305,7 +304,7 @@ impl<'d, T: Pin> InputFuture<'d, T> { | |||
| 305 | } | 304 | } |
| 306 | } | 305 | } |
| 307 | 306 | ||
| 308 | impl<'d, T: Pin> Future for InputFuture<'d, T> { | 307 | impl<'d> Future for InputFuture<'d> { |
| 309 | type Output = (); | 308 | type Output = (); |
| 310 | 309 | ||
| 311 | fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { | 310 | fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { |
| @@ -344,14 +343,14 @@ impl<'d, T: Pin> Future for InputFuture<'d, T> { | |||
| 344 | } | 343 | } |
| 345 | 344 | ||
| 346 | /// GPIO output driver. | 345 | /// GPIO output driver. |
| 347 | pub struct Output<'d, T: Pin> { | 346 | pub struct Output<'d> { |
| 348 | pin: Flex<'d, T>, | 347 | pin: Flex<'d>, |
| 349 | } | 348 | } |
| 350 | 349 | ||
| 351 | impl<'d, T: Pin> Output<'d, T> { | 350 | impl<'d> Output<'d> { |
| 352 | /// Create GPIO output driver for a [Pin] with the provided [Level]. | 351 | /// Create GPIO output driver for a [Pin] with the provided [Level]. |
| 353 | #[inline] | 352 | #[inline] |
| 354 | pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level) -> Self { | 353 | pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level) -> Self { |
| 355 | let mut pin = Flex::new(pin); | 354 | let mut pin = Flex::new(pin); |
| 356 | match initial_output { | 355 | match initial_output { |
| 357 | Level::High => pin.set_high(), | 356 | Level::High => pin.set_high(), |
| @@ -418,14 +417,14 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 418 | } | 417 | } |
| 419 | 418 | ||
| 420 | /// GPIO output open-drain. | 419 | /// GPIO output open-drain. |
| 421 | pub struct OutputOpenDrain<'d, T: Pin> { | 420 | pub struct OutputOpenDrain<'d> { |
| 422 | pin: Flex<'d, T>, | 421 | pin: Flex<'d>, |
| 423 | } | 422 | } |
| 424 | 423 | ||
| 425 | impl<'d, T: Pin> OutputOpenDrain<'d, T> { | 424 | impl<'d> OutputOpenDrain<'d> { |
| 426 | /// Create GPIO output driver for a [Pin] in open drain mode with the provided [Level]. | 425 | /// Create GPIO output driver for a [Pin] in open drain mode with the provided [Level]. |
| 427 | #[inline] | 426 | #[inline] |
| 428 | pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level) -> Self { | 427 | pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level) -> Self { |
| 429 | let mut pin = Flex::new(pin); | 428 | let mut pin = Flex::new(pin); |
| 430 | pin.set_low(); | 429 | pin.set_low(); |
| 431 | match initial_output { | 430 | match initial_output { |
| @@ -548,17 +547,17 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||
| 548 | /// This pin can be either an input or output pin. The output level register bit will remain | 547 | /// This pin can be either an input or output pin. The output level register bit will remain |
| 549 | /// set while not in output mode, so the pin's level will be 'remembered' when it is not in output | 548 | /// set while not in output mode, so the pin's level will be 'remembered' when it is not in output |
| 550 | /// mode. | 549 | /// mode. |
| 551 | pub struct Flex<'d, T: Pin> { | 550 | pub struct Flex<'d> { |
| 552 | pin: PeripheralRef<'d, T>, | 551 | pin: PeripheralRef<'d, AnyPin>, |
| 553 | } | 552 | } |
| 554 | 553 | ||
| 555 | impl<'d, T: Pin> Flex<'d, T> { | 554 | impl<'d> Flex<'d> { |
| 556 | /// Wrap the pin in a `Flex`. | 555 | /// Wrap the pin in a `Flex`. |
| 557 | /// | 556 | /// |
| 558 | /// The pin remains disconnected. The initial output level is unspecified, but can be changed | 557 | /// The pin remains disconnected. The initial output level is unspecified, but can be changed |
| 559 | /// before the pin is put into output mode. | 558 | /// before the pin is put into output mode. |
| 560 | #[inline] | 559 | #[inline] |
| 561 | pub fn new(pin: impl Peripheral<P = T> + 'd) -> Self { | 560 | pub fn new(pin: impl Peripheral<P = impl Pin> + 'd) -> Self { |
| 562 | into_ref!(pin); | 561 | into_ref!(pin); |
| 563 | 562 | ||
| 564 | pin.pad_ctrl().write(|w| { | 563 | pin.pad_ctrl().write(|w| { |
| @@ -569,7 +568,7 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 569 | w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::SIO_0 as _); | 568 | w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::SIO_0 as _); |
| 570 | }); | 569 | }); |
| 571 | 570 | ||
| 572 | Self { pin } | 571 | Self { pin: pin.map_into() } |
| 573 | } | 572 | } |
| 574 | 573 | ||
| 575 | #[inline] | 574 | #[inline] |
| @@ -716,36 +715,36 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 716 | /// Wait until the pin is high. If it is already high, return immediately. | 715 | /// Wait until the pin is high. If it is already high, return immediately. |
| 717 | #[inline] | 716 | #[inline] |
| 718 | pub async fn wait_for_high(&mut self) { | 717 | pub async fn wait_for_high(&mut self) { |
| 719 | InputFuture::new(&mut self.pin, InterruptTrigger::LevelHigh).await; | 718 | InputFuture::new(self.pin.reborrow(), InterruptTrigger::LevelHigh).await; |
| 720 | } | 719 | } |
| 721 | 720 | ||
| 722 | /// Wait until the pin is low. If it is already low, return immediately. | 721 | /// Wait until the pin is low. If it is already low, return immediately. |
| 723 | #[inline] | 722 | #[inline] |
| 724 | pub async fn wait_for_low(&mut self) { | 723 | pub async fn wait_for_low(&mut self) { |
| 725 | InputFuture::new(&mut self.pin, InterruptTrigger::LevelLow).await; | 724 | InputFuture::new(self.pin.reborrow(), InterruptTrigger::LevelLow).await; |
| 726 | } | 725 | } |
| 727 | 726 | ||
| 728 | /// Wait for the pin to undergo a transition from low to high. | 727 | /// Wait for the pin to undergo a transition from low to high. |
| 729 | #[inline] | 728 | #[inline] |
| 730 | pub async fn wait_for_rising_edge(&mut self) { | 729 | pub async fn wait_for_rising_edge(&mut self) { |
| 731 | InputFuture::new(&mut self.pin, InterruptTrigger::EdgeHigh).await; | 730 | InputFuture::new(self.pin.reborrow(), InterruptTrigger::EdgeHigh).await; |
| 732 | } | 731 | } |
| 733 | 732 | ||
| 734 | /// Wait for the pin to undergo a transition from high to low. | 733 | /// Wait for the pin to undergo a transition from high to low. |
| 735 | #[inline] | 734 | #[inline] |
| 736 | pub async fn wait_for_falling_edge(&mut self) { | 735 | pub async fn wait_for_falling_edge(&mut self) { |
| 737 | InputFuture::new(&mut self.pin, InterruptTrigger::EdgeLow).await; | 736 | InputFuture::new(self.pin.reborrow(), InterruptTrigger::EdgeLow).await; |
| 738 | } | 737 | } |
| 739 | 738 | ||
| 740 | /// Wait for the pin to undergo any transition, i.e low to high OR high to low. | 739 | /// Wait for the pin to undergo any transition, i.e low to high OR high to low. |
| 741 | #[inline] | 740 | #[inline] |
| 742 | pub async fn wait_for_any_edge(&mut self) { | 741 | pub async fn wait_for_any_edge(&mut self) { |
| 743 | InputFuture::new(&mut self.pin, InterruptTrigger::AnyEdge).await; | 742 | InputFuture::new(self.pin.reborrow(), InterruptTrigger::AnyEdge).await; |
| 744 | } | 743 | } |
| 745 | 744 | ||
| 746 | /// Configure dormant wake. | 745 | /// Configure dormant wake. |
| 747 | #[inline] | 746 | #[inline] |
| 748 | pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake<T> { | 747 | pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake<'_> { |
| 749 | let idx = self.pin._pin() as usize; | 748 | let idx = self.pin._pin() as usize; |
| 750 | self.pin.io().intr(idx / 8).write(|w| { | 749 | self.pin.io().intr(idx / 8).write(|w| { |
| 751 | w.set_edge_high(idx % 8, cfg.edge_high); | 750 | w.set_edge_high(idx % 8, cfg.edge_high); |
| @@ -764,7 +763,7 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 764 | } | 763 | } |
| 765 | } | 764 | } |
| 766 | 765 | ||
| 767 | impl<'d, T: Pin> Drop for Flex<'d, T> { | 766 | impl<'d> Drop for Flex<'d> { |
| 768 | #[inline] | 767 | #[inline] |
| 769 | fn drop(&mut self) { | 768 | fn drop(&mut self) { |
| 770 | let idx = self.pin._pin() as usize; | 769 | let idx = self.pin._pin() as usize; |
| @@ -782,12 +781,12 @@ impl<'d, T: Pin> Drop for Flex<'d, T> { | |||
| 782 | } | 781 | } |
| 783 | 782 | ||
| 784 | /// Dormant wake driver. | 783 | /// Dormant wake driver. |
| 785 | pub struct DormantWake<'w, T: Pin> { | 784 | pub struct DormantWake<'w> { |
| 786 | pin: PeripheralRef<'w, T>, | 785 | pin: PeripheralRef<'w, AnyPin>, |
| 787 | cfg: DormantWakeConfig, | 786 | cfg: DormantWakeConfig, |
| 788 | } | 787 | } |
| 789 | 788 | ||
| 790 | impl<'w, T: Pin> Drop for DormantWake<'w, T> { | 789 | impl<'w> Drop for DormantWake<'w> { |
| 791 | fn drop(&mut self) { | 790 | fn drop(&mut self) { |
| 792 | let idx = self.pin._pin() as usize; | 791 | let idx = self.pin._pin() as usize; |
| 793 | self.pin.io().intr(idx / 8).write(|w| { | 792 | self.pin.io().intr(idx / 8).write(|w| { |
| @@ -970,7 +969,7 @@ mod eh02 { | |||
| 970 | 969 | ||
| 971 | use super::*; | 970 | use super::*; |
| 972 | 971 | ||
| 973 | impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { | 972 | impl<'d> embedded_hal_02::digital::v2::InputPin for Input<'d> { |
| 974 | type Error = Infallible; | 973 | type Error = Infallible; |
| 975 | 974 | ||
| 976 | fn is_high(&self) -> Result<bool, Self::Error> { | 975 | fn is_high(&self) -> Result<bool, Self::Error> { |
| @@ -982,7 +981,7 @@ mod eh02 { | |||
| 982 | } | 981 | } |
| 983 | } | 982 | } |
| 984 | 983 | ||
| 985 | impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { | 984 | impl<'d> embedded_hal_02::digital::v2::OutputPin for Output<'d> { |
| 986 | type Error = Infallible; | 985 | type Error = Infallible; |
| 987 | 986 | ||
| 988 | fn set_high(&mut self) -> Result<(), Self::Error> { | 987 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| @@ -994,7 +993,7 @@ mod eh02 { | |||
| 994 | } | 993 | } |
| 995 | } | 994 | } |
| 996 | 995 | ||
| 997 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { | 996 | impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d> { |
| 998 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 997 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 999 | Ok(self.is_set_high()) | 998 | Ok(self.is_set_high()) |
| 1000 | } | 999 | } |
| @@ -1004,7 +1003,7 @@ mod eh02 { | |||
| 1004 | } | 1003 | } |
| 1005 | } | 1004 | } |
| 1006 | 1005 | ||
| 1007 | impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> { | 1006 | impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d> { |
| 1008 | type Error = Infallible; | 1007 | type Error = Infallible; |
| 1009 | #[inline] | 1008 | #[inline] |
| 1010 | fn toggle(&mut self) -> Result<(), Self::Error> { | 1009 | fn toggle(&mut self) -> Result<(), Self::Error> { |
| @@ -1012,7 +1011,7 @@ mod eh02 { | |||
| 1012 | } | 1011 | } |
| 1013 | } | 1012 | } |
| 1014 | 1013 | ||
| 1015 | impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for OutputOpenDrain<'d, T> { | 1014 | impl<'d> embedded_hal_02::digital::v2::InputPin for OutputOpenDrain<'d> { |
| 1016 | type Error = Infallible; | 1015 | type Error = Infallible; |
| 1017 | 1016 | ||
| 1018 | fn is_high(&self) -> Result<bool, Self::Error> { | 1017 | fn is_high(&self) -> Result<bool, Self::Error> { |
| @@ -1024,7 +1023,7 @@ mod eh02 { | |||
| 1024 | } | 1023 | } |
| 1025 | } | 1024 | } |
| 1026 | 1025 | ||
| 1027 | impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, T> { | 1026 | impl<'d> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d> { |
| 1028 | type Error = Infallible; | 1027 | type Error = Infallible; |
| 1029 | 1028 | ||
| 1030 | #[inline] | 1029 | #[inline] |
| @@ -1038,7 +1037,7 @@ mod eh02 { | |||
| 1038 | } | 1037 | } |
| 1039 | } | 1038 | } |
| 1040 | 1039 | ||
| 1041 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { | 1040 | impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d> { |
| 1042 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 1041 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 1043 | Ok(self.is_set_high()) | 1042 | Ok(self.is_set_high()) |
| 1044 | } | 1043 | } |
| @@ -1048,7 +1047,7 @@ mod eh02 { | |||
| 1048 | } | 1047 | } |
| 1049 | } | 1048 | } |
| 1050 | 1049 | ||
| 1051 | impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d, T> { | 1050 | impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d> { |
| 1052 | type Error = Infallible; | 1051 | type Error = Infallible; |
| 1053 | #[inline] | 1052 | #[inline] |
| 1054 | fn toggle(&mut self) -> Result<(), Self::Error> { | 1053 | fn toggle(&mut self) -> Result<(), Self::Error> { |
| @@ -1056,7 +1055,7 @@ mod eh02 { | |||
| 1056 | } | 1055 | } |
| 1057 | } | 1056 | } |
| 1058 | 1057 | ||
| 1059 | impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { | 1058 | impl<'d> embedded_hal_02::digital::v2::InputPin for Flex<'d> { |
| 1060 | type Error = Infallible; | 1059 | type Error = Infallible; |
| 1061 | 1060 | ||
| 1062 | fn is_high(&self) -> Result<bool, Self::Error> { | 1061 | fn is_high(&self) -> Result<bool, Self::Error> { |
| @@ -1068,7 +1067,7 @@ mod eh02 { | |||
| 1068 | } | 1067 | } |
| 1069 | } | 1068 | } |
| 1070 | 1069 | ||
| 1071 | impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { | 1070 | impl<'d> embedded_hal_02::digital::v2::OutputPin for Flex<'d> { |
| 1072 | type Error = Infallible; | 1071 | type Error = Infallible; |
| 1073 | 1072 | ||
| 1074 | fn set_high(&mut self) -> Result<(), Self::Error> { | 1073 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| @@ -1080,7 +1079,7 @@ mod eh02 { | |||
| 1080 | } | 1079 | } |
| 1081 | } | 1080 | } |
| 1082 | 1081 | ||
| 1083 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { | 1082 | impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d> { |
| 1084 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 1083 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 1085 | Ok(self.is_set_high()) | 1084 | Ok(self.is_set_high()) |
| 1086 | } | 1085 | } |
| @@ -1090,7 +1089,7 @@ mod eh02 { | |||
| 1090 | } | 1089 | } |
| 1091 | } | 1090 | } |
| 1092 | 1091 | ||
| 1093 | impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> { | 1092 | impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d> { |
| 1094 | type Error = Infallible; | 1093 | type Error = Infallible; |
| 1095 | #[inline] | 1094 | #[inline] |
| 1096 | fn toggle(&mut self) -> Result<(), Self::Error> { | 1095 | fn toggle(&mut self) -> Result<(), Self::Error> { |
| @@ -1099,11 +1098,11 @@ mod eh02 { | |||
| 1099 | } | 1098 | } |
| 1100 | } | 1099 | } |
| 1101 | 1100 | ||
| 1102 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { | 1101 | impl<'d> embedded_hal_1::digital::ErrorType for Input<'d> { |
| 1103 | type Error = Infallible; | 1102 | type Error = Infallible; |
| 1104 | } | 1103 | } |
| 1105 | 1104 | ||
| 1106 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { | 1105 | impl<'d> embedded_hal_1::digital::InputPin for Input<'d> { |
| 1107 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 1106 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 1108 | Ok((*self).is_high()) | 1107 | Ok((*self).is_high()) |
| 1109 | } | 1108 | } |
| @@ -1113,11 +1112,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { | |||
| 1113 | } | 1112 | } |
| 1114 | } | 1113 | } |
| 1115 | 1114 | ||
| 1116 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { | 1115 | impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> { |
| 1117 | type Error = Infallible; | 1116 | type Error = Infallible; |
| 1118 | } | 1117 | } |
| 1119 | 1118 | ||
| 1120 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | 1119 | impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> { |
| 1121 | fn set_high(&mut self) -> Result<(), Self::Error> { | 1120 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| 1122 | Ok(self.set_high()) | 1121 | Ok(self.set_high()) |
| 1123 | } | 1122 | } |
| @@ -1127,7 +1126,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | |||
| 1127 | } | 1126 | } |
| 1128 | } | 1127 | } |
| 1129 | 1128 | ||
| 1130 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { | 1129 | impl<'d> embedded_hal_1::digital::StatefulOutputPin for Output<'d> { |
| 1131 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 1130 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1132 | Ok((*self).is_set_high()) | 1131 | Ok((*self).is_set_high()) |
| 1133 | } | 1132 | } |
| @@ -1137,11 +1136,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { | |||
| 1137 | } | 1136 | } |
| 1138 | } | 1137 | } |
| 1139 | 1138 | ||
| 1140 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> { | 1139 | impl<'d> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d> { |
| 1141 | type Error = Infallible; | 1140 | type Error = Infallible; |
| 1142 | } | 1141 | } |
| 1143 | 1142 | ||
| 1144 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { | 1143 | impl<'d> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d> { |
| 1145 | fn set_high(&mut self) -> Result<(), Self::Error> { | 1144 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| 1146 | Ok(self.set_high()) | 1145 | Ok(self.set_high()) |
| 1147 | } | 1146 | } |
| @@ -1151,7 +1150,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { | |||
| 1151 | } | 1150 | } |
| 1152 | } | 1151 | } |
| 1153 | 1152 | ||
| 1154 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { | 1153 | impl<'d> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d> { |
| 1155 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 1154 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1156 | Ok((*self).is_set_high()) | 1155 | Ok((*self).is_set_high()) |
| 1157 | } | 1156 | } |
| @@ -1161,7 +1160,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain< | |||
| 1161 | } | 1160 | } |
| 1162 | } | 1161 | } |
| 1163 | 1162 | ||
| 1164 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { | 1163 | impl<'d> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d> { |
| 1165 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 1164 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 1166 | Ok((*self).is_high()) | 1165 | Ok((*self).is_high()) |
| 1167 | } | 1166 | } |
| @@ -1171,11 +1170,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { | |||
| 1171 | } | 1170 | } |
| 1172 | } | 1171 | } |
| 1173 | 1172 | ||
| 1174 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { | 1173 | impl<'d> embedded_hal_1::digital::ErrorType for Flex<'d> { |
| 1175 | type Error = Infallible; | 1174 | type Error = Infallible; |
| 1176 | } | 1175 | } |
| 1177 | 1176 | ||
| 1178 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | 1177 | impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> { |
| 1179 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 1178 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 1180 | Ok((*self).is_high()) | 1179 | Ok((*self).is_high()) |
| 1181 | } | 1180 | } |
| @@ -1185,7 +1184,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | |||
| 1185 | } | 1184 | } |
| 1186 | } | 1185 | } |
| 1187 | 1186 | ||
| 1188 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { | 1187 | impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> { |
| 1189 | fn set_high(&mut self) -> Result<(), Self::Error> { | 1188 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| 1190 | Ok(self.set_high()) | 1189 | Ok(self.set_high()) |
| 1191 | } | 1190 | } |
| @@ -1195,7 +1194,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { | |||
| 1195 | } | 1194 | } |
| 1196 | } | 1195 | } |
| 1197 | 1196 | ||
| 1198 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { | 1197 | impl<'d> embedded_hal_1::digital::StatefulOutputPin for Flex<'d> { |
| 1199 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 1198 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1200 | Ok((*self).is_set_high()) | 1199 | Ok((*self).is_set_high()) |
| 1201 | } | 1200 | } |
| @@ -1205,7 +1204,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { | |||
| 1205 | } | 1204 | } |
| 1206 | } | 1205 | } |
| 1207 | 1206 | ||
| 1208 | impl<'d, T: Pin> embedded_hal_async::digital::Wait for Flex<'d, T> { | 1207 | impl<'d> embedded_hal_async::digital::Wait for Flex<'d> { |
| 1209 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { | 1208 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { |
| 1210 | self.wait_for_high().await; | 1209 | self.wait_for_high().await; |
| 1211 | Ok(()) | 1210 | Ok(()) |
| @@ -1232,7 +1231,7 @@ impl<'d, T: Pin> embedded_hal_async::digital::Wait for Flex<'d, T> { | |||
| 1232 | } | 1231 | } |
| 1233 | } | 1232 | } |
| 1234 | 1233 | ||
| 1235 | impl<'d, T: Pin> embedded_hal_async::digital::Wait for Input<'d, T> { | 1234 | impl<'d> embedded_hal_async::digital::Wait for Input<'d> { |
| 1236 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { | 1235 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { |
| 1237 | self.wait_for_high().await; | 1236 | self.wait_for_high().await; |
| 1238 | Ok(()) | 1237 | Ok(()) |
| @@ -1259,7 +1258,7 @@ impl<'d, T: Pin> embedded_hal_async::digital::Wait for Input<'d, T> { | |||
| 1259 | } | 1258 | } |
| 1260 | } | 1259 | } |
| 1261 | 1260 | ||
| 1262 | impl<'d, T: Pin> embedded_hal_async::digital::Wait for OutputOpenDrain<'d, T> { | 1261 | impl<'d> embedded_hal_async::digital::Wait for OutputOpenDrain<'d> { |
| 1263 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { | 1262 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { |
| 1264 | self.wait_for_high().await; | 1263 | self.wait_for_high().await; |
| 1265 | Ok(()) | 1264 | Ok(()) |
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; | |||
| 5 | use core::pin::Pin; | 5 | use core::pin::Pin; |
| 6 | use core::task::{Context, Poll}; | 6 | use core::task::{Context, Poll}; |
| 7 | 7 | ||
| 8 | use embassy_hal_internal::impl_peripheral; | 8 | use embassy_hal_internal::{impl_peripheral, into_ref}; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin}; | 11 | use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin, Pull}; |
| 12 | use crate::pac::exti::regs::Lines; | 12 | use crate::pac::exti::regs::Lines; |
| 13 | use crate::pac::EXTI; | 13 | use crate::pac::EXTI; |
| 14 | use crate::{interrupt, pac, peripherals, Peripheral}; | 14 | use crate::{interrupt, pac, peripherals, Peripheral}; |
| @@ -93,16 +93,27 @@ impl Iterator for BitIter { | |||
| 93 | /// EXTI channel, which is a limited resource. | 93 | /// EXTI channel, which is a limited resource. |
| 94 | /// | 94 | /// |
| 95 | /// Pins PA5, PB5, PC5... all use EXTI channel 5, so you can't use EXTI on, say, PA5 and PC5 at the same time. | 95 | /// Pins PA5, PB5, PC5... all use EXTI channel 5, so you can't use EXTI on, say, PA5 and PC5 at the same time. |
| 96 | pub struct ExtiInput<'d, T: GpioPin> { | 96 | pub struct ExtiInput<'d> { |
| 97 | pin: Input<'d, T>, | 97 | pin: Input<'d>, |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | impl<'d, T: GpioPin> Unpin for ExtiInput<'d, T> {} | 100 | impl<'d> Unpin for ExtiInput<'d> {} |
| 101 | 101 | ||
| 102 | impl<'d, T: GpioPin> ExtiInput<'d, T> { | 102 | impl<'d> ExtiInput<'d> { |
| 103 | /// Create an EXTI input. | 103 | /// Create an EXTI input. |
| 104 | pub fn new(pin: Input<'d, T>, _ch: impl Peripheral<P = T::ExtiChannel> + 'd) -> Self { | 104 | pub fn new<T: GpioPin>( |
| 105 | Self { pin } | 105 | pin: impl Peripheral<P = T> + 'd, |
| 106 | ch: impl Peripheral<P = T::ExtiChannel> + 'd, | ||
| 107 | pull: Pull, | ||
| 108 | ) -> Self { | ||
| 109 | into_ref!(pin, ch); | ||
| 110 | |||
| 111 | // Needed if using AnyPin+AnyChannel. | ||
| 112 | assert_eq!(pin.pin(), ch.number()); | ||
| 113 | |||
| 114 | Self { | ||
| 115 | pin: Input::new(pin, pull), | ||
| 116 | } | ||
| 106 | } | 117 | } |
| 107 | 118 | ||
| 108 | /// Get whether the pin is high. | 119 | /// Get whether the pin is high. |
| @@ -162,7 +173,7 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> { | |||
| 162 | } | 173 | } |
| 163 | } | 174 | } |
| 164 | 175 | ||
| 165 | impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> { | 176 | impl<'d> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d> { |
| 166 | type Error = Infallible; | 177 | type Error = Infallible; |
| 167 | 178 | ||
| 168 | fn is_high(&self) -> Result<bool, Self::Error> { | 179 | fn is_high(&self) -> Result<bool, Self::Error> { |
| @@ -174,11 +185,11 @@ impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> | |||
| 174 | } | 185 | } |
| 175 | } | 186 | } |
| 176 | 187 | ||
| 177 | impl<'d, T: GpioPin> embedded_hal_1::digital::ErrorType for ExtiInput<'d, T> { | 188 | impl<'d> embedded_hal_1::digital::ErrorType for ExtiInput<'d> { |
| 178 | type Error = Infallible; | 189 | type Error = Infallible; |
| 179 | } | 190 | } |
| 180 | 191 | ||
| 181 | impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> { | 192 | impl<'d> embedded_hal_1::digital::InputPin for ExtiInput<'d> { |
| 182 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 193 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 183 | Ok((*self).is_high()) | 194 | Ok((*self).is_high()) |
| 184 | } | 195 | } |
| @@ -188,7 +199,7 @@ impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> { | |||
| 188 | } | 199 | } |
| 189 | } | 200 | } |
| 190 | 201 | ||
| 191 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for ExtiInput<'d, T> { | 202 | impl<'d> embedded_hal_async::digital::Wait for ExtiInput<'d> { |
| 192 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { | 203 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { |
| 193 | self.wait_for_high().await; | 204 | self.wait_for_high().await; |
| 194 | Ok(()) | 205 | Ok(()) |
| @@ -326,7 +337,7 @@ pub(crate) mod sealed { | |||
| 326 | /// EXTI channel trait. | 337 | /// EXTI channel trait. |
| 327 | pub trait Channel: sealed::Channel + Sized { | 338 | pub trait Channel: sealed::Channel + Sized { |
| 328 | /// Get the EXTI channel number. | 339 | /// Get the EXTI channel number. |
| 329 | fn number(&self) -> usize; | 340 | fn number(&self) -> u8; |
| 330 | 341 | ||
| 331 | /// Type-erase (degrade) this channel into an `AnyChannel`. | 342 | /// Type-erase (degrade) this channel into an `AnyChannel`. |
| 332 | /// | 343 | /// |
| @@ -350,8 +361,8 @@ pub struct AnyChannel { | |||
| 350 | impl_peripheral!(AnyChannel); | 361 | impl_peripheral!(AnyChannel); |
| 351 | impl sealed::Channel for AnyChannel {} | 362 | impl sealed::Channel for AnyChannel {} |
| 352 | impl Channel for AnyChannel { | 363 | impl Channel for AnyChannel { |
| 353 | fn number(&self) -> usize { | 364 | fn number(&self) -> u8 { |
| 354 | self.number as usize | 365 | self.number |
| 355 | } | 366 | } |
| 356 | } | 367 | } |
| 357 | 368 | ||
| @@ -359,8 +370,8 @@ macro_rules! impl_exti { | |||
| 359 | ($type:ident, $number:expr) => { | 370 | ($type:ident, $number:expr) => { |
| 360 | impl sealed::Channel for peripherals::$type {} | 371 | impl sealed::Channel for peripherals::$type {} |
| 361 | impl Channel for peripherals::$type { | 372 | impl Channel for peripherals::$type { |
| 362 | fn number(&self) -> usize { | 373 | fn number(&self) -> u8 { |
| 363 | $number as usize | 374 | $number |
| 364 | } | 375 | } |
| 365 | } | 376 | } |
| 366 | }; | 377 | }; |
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; | |||
| 6 | use critical_section::CriticalSection; | 6 | use critical_section::CriticalSection; |
| 7 | use embassy_hal_internal::{impl_peripheral, into_ref, PeripheralRef}; | 7 | use embassy_hal_internal::{impl_peripheral, into_ref, PeripheralRef}; |
| 8 | 8 | ||
| 9 | use self::sealed::Pin as _; | ||
| 9 | use crate::pac::gpio::{self, vals}; | 10 | use crate::pac::gpio::{self, vals}; |
| 10 | use crate::{pac, peripherals, Peripheral}; | 11 | use crate::{pac, peripherals, Peripheral}; |
| 11 | 12 | ||
| @@ -14,41 +15,21 @@ use crate::{pac, peripherals, Peripheral}; | |||
| 14 | /// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain | 15 | /// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain |
| 15 | /// set while not in output mode, so the pin's level will be 'remembered' when it is not in output | 16 | /// set while not in output mode, so the pin's level will be 'remembered' when it is not in output |
| 16 | /// mode. | 17 | /// mode. |
| 17 | pub struct Flex<'d, T: Pin> { | 18 | pub struct Flex<'d> { |
| 18 | pub(crate) pin: PeripheralRef<'d, T>, | 19 | pub(crate) pin: PeripheralRef<'d, AnyPin>, |
| 19 | } | 20 | } |
| 20 | 21 | ||
| 21 | impl<'d, T: Pin> Flex<'d, T> { | 22 | impl<'d> Flex<'d> { |
| 22 | /// Wrap the pin in a `Flex`. | 23 | /// Wrap the pin in a `Flex`. |
| 23 | /// | 24 | /// |
| 24 | /// The pin remains disconnected. The initial output level is unspecified, but can be changed | 25 | /// The pin remains disconnected. The initial output level is unspecified, but can be changed |
| 25 | /// before the pin is put into output mode. | 26 | /// before the pin is put into output mode. |
| 26 | /// | 27 | /// |
| 27 | #[inline] | 28 | #[inline] |
| 28 | pub fn new(pin: impl Peripheral<P = T> + 'd) -> Self { | 29 | pub fn new(pin: impl Peripheral<P = impl Pin> + 'd) -> Self { |
| 29 | into_ref!(pin); | 30 | into_ref!(pin); |
| 30 | // Pin will be in disconnected state. | 31 | // Pin will be in disconnected state. |
| 31 | Self { pin } | 32 | Self { pin: pin.map_into() } |
| 32 | } | ||
| 33 | |||
| 34 | /// Type-erase (degrade) this pin into an `AnyPin`. | ||
| 35 | /// | ||
| 36 | /// This converts pin singletons (`PA5`, `PB6`, ...), which | ||
| 37 | /// are all different types, into the same type. It is useful for | ||
| 38 | /// creating arrays of pins, or avoiding generics. | ||
| 39 | #[inline] | ||
| 40 | pub fn degrade(self) -> Flex<'d, AnyPin> { | ||
| 41 | // Safety: We are about to drop the other copy of this pin, so | ||
| 42 | // this clone is safe. | ||
| 43 | let pin = unsafe { self.pin.clone_unchecked() }; | ||
| 44 | |||
| 45 | // We don't want to run the destructor here, because that would | ||
| 46 | // deconfigure the pin. | ||
| 47 | core::mem::forget(self); | ||
| 48 | |||
| 49 | Flex { | ||
| 50 | pin: pin.map_into::<AnyPin>(), | ||
| 51 | } | ||
| 52 | } | 33 | } |
| 53 | 34 | ||
| 54 | /// Put the pin into input mode. | 35 | /// Put the pin into input mode. |
| @@ -218,7 +199,7 @@ impl<'d, T: Pin> Flex<'d, T> { | |||
| 218 | } | 199 | } |
| 219 | } | 200 | } |
| 220 | 201 | ||
| 221 | impl<'d, T: Pin> Drop for Flex<'d, T> { | 202 | impl<'d> Drop for Flex<'d> { |
| 222 | #[inline] | 203 | #[inline] |
| 223 | fn drop(&mut self) { | 204 | fn drop(&mut self) { |
| 224 | critical_section::with(|_| { | 205 | critical_section::with(|_| { |
| @@ -309,31 +290,19 @@ impl From<Speed> for vals::Ospeedr { | |||
| 309 | } | 290 | } |
| 310 | 291 | ||
| 311 | /// GPIO input driver. | 292 | /// GPIO input driver. |
| 312 | pub struct Input<'d, T: Pin> { | 293 | pub struct Input<'d> { |
| 313 | pub(crate) pin: Flex<'d, T>, | 294 | pub(crate) pin: Flex<'d>, |
| 314 | } | 295 | } |
| 315 | 296 | ||
| 316 | impl<'d, T: Pin> Input<'d, T> { | 297 | impl<'d> Input<'d> { |
| 317 | /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration. | 298 | /// Create GPIO input driver for a [Pin] with the provided [Pull] configuration. |
| 318 | #[inline] | 299 | #[inline] |
| 319 | pub fn new(pin: impl Peripheral<P = T> + 'd, pull: Pull) -> Self { | 300 | pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, pull: Pull) -> Self { |
| 320 | let mut pin = Flex::new(pin); | 301 | let mut pin = Flex::new(pin); |
| 321 | pin.set_as_input(pull); | 302 | pin.set_as_input(pull); |
| 322 | Self { pin } | 303 | Self { pin } |
| 323 | } | 304 | } |
| 324 | 305 | ||
| 325 | /// Type-erase (degrade) this pin into an `AnyPin`. | ||
| 326 | /// | ||
| 327 | /// This converts pin singletons (`PA5`, `PB6`, ...), which | ||
| 328 | /// are all different types, into the same type. It is useful for | ||
| 329 | /// creating arrays of pins, or avoiding generics. | ||
| 330 | #[inline] | ||
| 331 | pub fn degrade(self) -> Input<'d, AnyPin> { | ||
| 332 | Input { | ||
| 333 | pin: self.pin.degrade(), | ||
| 334 | } | ||
| 335 | } | ||
| 336 | |||
| 337 | /// Get whether the pin input level is high. | 306 | /// Get whether the pin input level is high. |
| 338 | #[inline] | 307 | #[inline] |
| 339 | pub fn is_high(&self) -> bool { | 308 | pub fn is_high(&self) -> bool { |
| @@ -386,14 +355,14 @@ impl From<Level> for bool { | |||
| 386 | /// Note that pins will **return to their floating state** when `Output` is dropped. | 355 | /// Note that pins will **return to their floating state** when `Output` is dropped. |
| 387 | /// If pins should retain their state indefinitely, either keep ownership of the | 356 | /// If pins should retain their state indefinitely, either keep ownership of the |
| 388 | /// `Output`, or pass it to [`core::mem::forget`]. | 357 | /// `Output`, or pass it to [`core::mem::forget`]. |
| 389 | pub struct Output<'d, T: Pin> { | 358 | pub struct Output<'d> { |
| 390 | pub(crate) pin: Flex<'d, T>, | 359 | pub(crate) pin: Flex<'d>, |
| 391 | } | 360 | } |
| 392 | 361 | ||
| 393 | impl<'d, T: Pin> Output<'d, T> { | 362 | impl<'d> Output<'d> { |
| 394 | /// Create GPIO output driver for a [Pin] with the provided [Level] and [Speed] configuration. | 363 | /// Create GPIO output driver for a [Pin] with the provided [Level] and [Speed] configuration. |
| 395 | #[inline] | 364 | #[inline] |
| 396 | pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level, speed: Speed) -> Self { | 365 | pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level, speed: Speed) -> Self { |
| 397 | let mut pin = Flex::new(pin); | 366 | let mut pin = Flex::new(pin); |
| 398 | match initial_output { | 367 | match initial_output { |
| 399 | Level::High => pin.set_high(), | 368 | Level::High => pin.set_high(), |
| @@ -403,18 +372,6 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 403 | Self { pin } | 372 | Self { pin } |
| 404 | } | 373 | } |
| 405 | 374 | ||
| 406 | /// Type-erase (degrade) this pin into an `AnyPin`. | ||
| 407 | /// | ||
| 408 | /// This converts pin singletons (`PA5`, `PB6`, ...), which | ||
| 409 | /// are all different types, into the same type. It is useful for | ||
| 410 | /// creating arrays of pins, or avoiding generics. | ||
| 411 | #[inline] | ||
| 412 | pub fn degrade(self) -> Output<'d, AnyPin> { | ||
| 413 | Output { | ||
| 414 | pin: self.pin.degrade(), | ||
| 415 | } | ||
| 416 | } | ||
| 417 | |||
| 418 | /// Set the output as high. | 375 | /// Set the output as high. |
| 419 | #[inline] | 376 | #[inline] |
| 420 | pub fn set_high(&mut self) { | 377 | pub fn set_high(&mut self) { |
| @@ -463,14 +420,14 @@ impl<'d, T: Pin> Output<'d, T> { | |||
| 463 | /// Note that pins will **return to their floating state** when `OutputOpenDrain` is dropped. | 420 | /// Note that pins will **return to their floating state** when `OutputOpenDrain` is dropped. |
| 464 | /// If pins should retain their state indefinitely, either keep ownership of the | 421 | /// If pins should retain their state indefinitely, either keep ownership of the |
| 465 | /// `OutputOpenDrain`, or pass it to [`core::mem::forget`]. | 422 | /// `OutputOpenDrain`, or pass it to [`core::mem::forget`]. |
| 466 | pub struct OutputOpenDrain<'d, T: Pin> { | 423 | pub struct OutputOpenDrain<'d> { |
| 467 | pub(crate) pin: Flex<'d, T>, | 424 | pub(crate) pin: Flex<'d>, |
| 468 | } | 425 | } |
| 469 | 426 | ||
| 470 | impl<'d, T: Pin> OutputOpenDrain<'d, T> { | 427 | impl<'d> OutputOpenDrain<'d> { |
| 471 | /// Create a new GPIO open drain output driver for a [Pin] with the provided [Level] and [Speed], [Pull] configuration. | 428 | /// Create a new GPIO open drain output driver for a [Pin] with the provided [Level] and [Speed], [Pull] configuration. |
| 472 | #[inline] | 429 | #[inline] |
| 473 | pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level, speed: Speed, pull: Pull) -> Self { | 430 | pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level, speed: Speed, pull: Pull) -> Self { |
| 474 | let mut pin = Flex::new(pin); | 431 | let mut pin = Flex::new(pin); |
| 475 | 432 | ||
| 476 | match initial_output { | 433 | match initial_output { |
| @@ -482,18 +439,6 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||
| 482 | Self { pin } | 439 | Self { pin } |
| 483 | } | 440 | } |
| 484 | 441 | ||
| 485 | /// Type-erase (degrade) this pin into an `AnyPin`. | ||
| 486 | /// | ||
| 487 | /// This converts pin singletons (`PA5`, `PB6`, ...), which | ||
| 488 | /// are all different types, into the same type. It is useful for | ||
| 489 | /// creating arrays of pins, or avoiding generics. | ||
| 490 | #[inline] | ||
| 491 | pub fn degrade(self) -> Output<'d, AnyPin> { | ||
| 492 | Output { | ||
| 493 | pin: self.pin.degrade(), | ||
| 494 | } | ||
| 495 | } | ||
| 496 | |||
| 497 | /// Get whether the pin input level is high. | 442 | /// Get whether the pin input level is high. |
| 498 | #[inline] | 443 | #[inline] |
| 499 | pub fn is_high(&self) -> bool { | 444 | pub fn is_high(&self) -> bool { |
| @@ -836,7 +781,7 @@ pub(crate) unsafe fn init(_cs: CriticalSection) { | |||
| 836 | }); | 781 | }); |
| 837 | } | 782 | } |
| 838 | 783 | ||
| 839 | impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { | 784 | impl<'d> embedded_hal_02::digital::v2::InputPin for Input<'d> { |
| 840 | type Error = Infallible; | 785 | type Error = Infallible; |
| 841 | 786 | ||
| 842 | #[inline] | 787 | #[inline] |
| @@ -850,7 +795,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> { | |||
| 850 | } | 795 | } |
| 851 | } | 796 | } |
| 852 | 797 | ||
| 853 | impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { | 798 | impl<'d> embedded_hal_02::digital::v2::OutputPin for Output<'d> { |
| 854 | type Error = Infallible; | 799 | type Error = Infallible; |
| 855 | 800 | ||
| 856 | #[inline] | 801 | #[inline] |
| @@ -866,7 +811,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> { | |||
| 866 | } | 811 | } |
| 867 | } | 812 | } |
| 868 | 813 | ||
| 869 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> { | 814 | impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d> { |
| 870 | #[inline] | 815 | #[inline] |
| 871 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 816 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 872 | Ok(self.is_set_high()) | 817 | Ok(self.is_set_high()) |
| @@ -879,7 +824,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, | |||
| 879 | } | 824 | } |
| 880 | } | 825 | } |
| 881 | 826 | ||
| 882 | impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> { | 827 | impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d> { |
| 883 | type Error = Infallible; | 828 | type Error = Infallible; |
| 884 | #[inline] | 829 | #[inline] |
| 885 | fn toggle(&mut self) -> Result<(), Self::Error> { | 830 | fn toggle(&mut self) -> Result<(), Self::Error> { |
| @@ -888,7 +833,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d | |||
| 888 | } | 833 | } |
| 889 | } | 834 | } |
| 890 | 835 | ||
| 891 | impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, T> { | 836 | impl<'d> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d> { |
| 892 | type Error = Infallible; | 837 | type Error = Infallible; |
| 893 | 838 | ||
| 894 | #[inline] | 839 | #[inline] |
| @@ -904,7 +849,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, | |||
| 904 | } | 849 | } |
| 905 | } | 850 | } |
| 906 | 851 | ||
| 907 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> { | 852 | impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d> { |
| 908 | #[inline] | 853 | #[inline] |
| 909 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 854 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 910 | Ok(self.is_set_high()) | 855 | Ok(self.is_set_high()) |
| @@ -917,7 +862,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenD | |||
| 917 | } | 862 | } |
| 918 | } | 863 | } |
| 919 | 864 | ||
| 920 | impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d, T> { | 865 | impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d> { |
| 921 | type Error = Infallible; | 866 | type Error = Infallible; |
| 922 | #[inline] | 867 | #[inline] |
| 923 | fn toggle(&mut self) -> Result<(), Self::Error> { | 868 | fn toggle(&mut self) -> Result<(), Self::Error> { |
| @@ -926,7 +871,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpe | |||
| 926 | } | 871 | } |
| 927 | } | 872 | } |
| 928 | 873 | ||
| 929 | impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { | 874 | impl<'d> embedded_hal_02::digital::v2::InputPin for Flex<'d> { |
| 930 | type Error = Infallible; | 875 | type Error = Infallible; |
| 931 | 876 | ||
| 932 | #[inline] | 877 | #[inline] |
| @@ -940,7 +885,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> { | |||
| 940 | } | 885 | } |
| 941 | } | 886 | } |
| 942 | 887 | ||
| 943 | impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { | 888 | impl<'d> embedded_hal_02::digital::v2::OutputPin for Flex<'d> { |
| 944 | type Error = Infallible; | 889 | type Error = Infallible; |
| 945 | 890 | ||
| 946 | #[inline] | 891 | #[inline] |
| @@ -956,7 +901,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> { | |||
| 956 | } | 901 | } |
| 957 | } | 902 | } |
| 958 | 903 | ||
| 959 | impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> { | 904 | impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d> { |
| 960 | #[inline] | 905 | #[inline] |
| 961 | fn is_set_high(&self) -> Result<bool, Self::Error> { | 906 | fn is_set_high(&self) -> Result<bool, Self::Error> { |
| 962 | Ok(self.is_set_high()) | 907 | Ok(self.is_set_high()) |
| @@ -969,7 +914,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> | |||
| 969 | } | 914 | } |
| 970 | } | 915 | } |
| 971 | 916 | ||
| 972 | impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> { | 917 | impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d> { |
| 973 | type Error = Infallible; | 918 | type Error = Infallible; |
| 974 | #[inline] | 919 | #[inline] |
| 975 | fn toggle(&mut self) -> Result<(), Self::Error> { | 920 | fn toggle(&mut self) -> Result<(), Self::Error> { |
| @@ -978,11 +923,11 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, | |||
| 978 | } | 923 | } |
| 979 | } | 924 | } |
| 980 | 925 | ||
| 981 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> { | 926 | impl<'d> embedded_hal_1::digital::ErrorType for Input<'d> { |
| 982 | type Error = Infallible; | 927 | type Error = Infallible; |
| 983 | } | 928 | } |
| 984 | 929 | ||
| 985 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { | 930 | impl<'d> embedded_hal_1::digital::InputPin for Input<'d> { |
| 986 | #[inline] | 931 | #[inline] |
| 987 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 932 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 988 | Ok((*self).is_high()) | 933 | Ok((*self).is_high()) |
| @@ -994,11 +939,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> { | |||
| 994 | } | 939 | } |
| 995 | } | 940 | } |
| 996 | 941 | ||
| 997 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> { | 942 | impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> { |
| 998 | type Error = Infallible; | 943 | type Error = Infallible; |
| 999 | } | 944 | } |
| 1000 | 945 | ||
| 1001 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | 946 | impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> { |
| 1002 | #[inline] | 947 | #[inline] |
| 1003 | fn set_high(&mut self) -> Result<(), Self::Error> { | 948 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| 1004 | Ok(self.set_high()) | 949 | Ok(self.set_high()) |
| @@ -1010,7 +955,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> { | |||
| 1010 | } | 955 | } |
| 1011 | } | 956 | } |
| 1012 | 957 | ||
| 1013 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { | 958 | impl<'d> embedded_hal_1::digital::StatefulOutputPin for Output<'d> { |
| 1014 | #[inline] | 959 | #[inline] |
| 1015 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 960 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1016 | Ok((*self).is_set_high()) | 961 | Ok((*self).is_set_high()) |
| @@ -1023,11 +968,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> { | |||
| 1023 | } | 968 | } |
| 1024 | } | 969 | } |
| 1025 | 970 | ||
| 1026 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> { | 971 | impl<'d> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d> { |
| 1027 | type Error = Infallible; | 972 | type Error = Infallible; |
| 1028 | } | 973 | } |
| 1029 | 974 | ||
| 1030 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { | 975 | impl<'d> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d> { |
| 1031 | #[inline] | 976 | #[inline] |
| 1032 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 977 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 1033 | Ok((*self).is_high()) | 978 | Ok((*self).is_high()) |
| @@ -1039,7 +984,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> { | |||
| 1039 | } | 984 | } |
| 1040 | } | 985 | } |
| 1041 | 986 | ||
| 1042 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { | 987 | impl<'d> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d> { |
| 1043 | #[inline] | 988 | #[inline] |
| 1044 | fn set_high(&mut self) -> Result<(), Self::Error> { | 989 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| 1045 | Ok(self.set_high()) | 990 | Ok(self.set_high()) |
| @@ -1051,7 +996,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> { | |||
| 1051 | } | 996 | } |
| 1052 | } | 997 | } |
| 1053 | 998 | ||
| 1054 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> { | 999 | impl<'d> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d> { |
| 1055 | #[inline] | 1000 | #[inline] |
| 1056 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 1001 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1057 | Ok((*self).is_set_high()) | 1002 | Ok((*self).is_set_high()) |
| @@ -1064,7 +1009,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain< | |||
| 1064 | } | 1009 | } |
| 1065 | } | 1010 | } |
| 1066 | 1011 | ||
| 1067 | impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | 1012 | impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> { |
| 1068 | #[inline] | 1013 | #[inline] |
| 1069 | fn is_high(&mut self) -> Result<bool, Self::Error> { | 1014 | fn is_high(&mut self) -> Result<bool, Self::Error> { |
| 1070 | Ok((*self).is_high()) | 1015 | Ok((*self).is_high()) |
| @@ -1076,7 +1021,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> { | |||
| 1076 | } | 1021 | } |
| 1077 | } | 1022 | } |
| 1078 | 1023 | ||
| 1079 | impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { | 1024 | impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> { |
| 1080 | #[inline] | 1025 | #[inline] |
| 1081 | fn set_high(&mut self) -> Result<(), Self::Error> { | 1026 | fn set_high(&mut self) -> Result<(), Self::Error> { |
| 1082 | Ok(self.set_high()) | 1027 | Ok(self.set_high()) |
| @@ -1088,11 +1033,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> { | |||
| 1088 | } | 1033 | } |
| 1089 | } | 1034 | } |
| 1090 | 1035 | ||
| 1091 | impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { | 1036 | impl<'d> embedded_hal_1::digital::ErrorType for Flex<'d> { |
| 1092 | type Error = Infallible; | 1037 | type Error = Infallible; |
| 1093 | } | 1038 | } |
| 1094 | 1039 | ||
| 1095 | impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> { | 1040 | impl<'d> embedded_hal_1::digital::StatefulOutputPin for Flex<'d> { |
| 1096 | #[inline] | 1041 | #[inline] |
| 1097 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { | 1042 | fn is_set_high(&mut self) -> Result<bool, Self::Error> { |
| 1098 | Ok((*self).is_set_high()) | 1043 | Ok((*self).is_set_high()) |
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 @@ | |||
| 1 | [unstable] | 1 | [unstable] |
| 2 | build-std = ["core"] | 2 | #build-std = ["core"] |
| 3 | build-std-features = ["panic_immediate_abort"] | 3 | #build-std-features = ["panic_immediate_abort"] |
| 4 | 4 | ||
| 5 | [build] | 5 | [build] |
| 6 | target = "thumbv7em-none-eabi" | 6 | 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 @@ | |||
| 1 | [unstable] | 1 | [unstable] |
| 2 | build-std = ["core"] | 2 | #build-std = ["core"] |
| 3 | build-std-features = ["panic_immediate_abort"] | 3 | #build-std-features = ["panic_immediate_abort"] |
| 4 | 4 | ||
| 5 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | 5 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] |
| 6 | runner = "probe-rs run --chip RP2040" | 6 | runner = "probe-rs run --chip RP2040" |
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; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::exti::ExtiInput; | 9 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 11 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 12 | use embassy_sync::mutex::Mutex; | 12 | use embassy_sync::mutex::Mutex; |
| 13 | use panic_reset as _; | 13 | use panic_reset as _; |
| 14 | 14 | ||
| @@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) { | |||
| 23 | let flash = Flash::new_blocking(p.FLASH); | 23 | let flash = Flash::new_blocking(p.FLASH); |
| 24 | let flash = Mutex::new(BlockingAsync::new(flash)); | 24 | let flash = Mutex::new(BlockingAsync::new(flash)); |
| 25 | 25 | ||
| 26 | let button = Input::new(p.PC13, Pull::Up); | 26 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); |
| 27 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 28 | 27 | ||
| 29 | let mut led = Output::new(p.PA5, Level::Low, Speed::Low); | 28 | let mut led = Output::new(p.PA5, Level::Low, Speed::Low); |
| 30 | led.set_high(); | 29 | 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 | |||
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| 11 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 11 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 13 | use embassy_sync::blocking_mutex::Mutex; | 13 | use embassy_sync::blocking_mutex::Mutex; |
| 14 | use embedded_storage::nor_flash::NorFlash; | 14 | use embedded_storage::nor_flash::NorFlash; |
| 15 | use panic_reset as _; | 15 | use panic_reset as _; |
| @@ -25,8 +25,7 @@ async fn main(_spawner: Spawner) { | |||
| 25 | let flash = Flash::new_blocking(p.FLASH); | 25 | let flash = Flash::new_blocking(p.FLASH); |
| 26 | let flash = Mutex::new(RefCell::new(flash)); | 26 | let flash = Mutex::new(RefCell::new(flash)); |
| 27 | 27 | ||
| 28 | let button = Input::new(p.PC13, Pull::Down); | 28 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); |
| 29 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 30 | 29 | ||
| 31 | let mut led = Output::new(p.PB7, Level::Low, Speed::Low); | 30 | let mut led = Output::new(p.PB7, Level::Low, Speed::Low); |
| 32 | led.set_high(); | 31 | 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 | |||
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| 11 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 11 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 12 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 12 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 13 | use embassy_sync::blocking_mutex::Mutex; | 13 | use embassy_sync::blocking_mutex::Mutex; |
| 14 | use embedded_storage::nor_flash::NorFlash; | 14 | use embedded_storage::nor_flash::NorFlash; |
| 15 | use panic_reset as _; | 15 | use panic_reset as _; |
| @@ -25,8 +25,7 @@ async fn main(_spawner: Spawner) { | |||
| 25 | let flash = Flash::new_blocking(p.FLASH); | 25 | let flash = Flash::new_blocking(p.FLASH); |
| 26 | let flash = Mutex::new(RefCell::new(flash)); | 26 | let flash = Mutex::new(RefCell::new(flash)); |
| 27 | 27 | ||
| 28 | let button = Input::new(p.PC13, Pull::Down); | 28 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); |
| 29 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 30 | 29 | ||
| 31 | let mut led = Output::new(p.PB14, Level::Low, Speed::Low); | 30 | let mut led = Output::new(p.PB14, Level::Low, Speed::Low); |
| 32 | led.set_high(); | 31 | 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; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::exti::ExtiInput; | 9 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 11 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 12 | use embassy_sync::mutex::Mutex; | 12 | use embassy_sync::mutex::Mutex; |
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use panic_reset as _; | 14 | use panic_reset as _; |
| @@ -24,8 +24,7 @@ async fn main(_spawner: Spawner) { | |||
| 24 | let flash = Flash::new_blocking(p.FLASH); | 24 | let flash = Flash::new_blocking(p.FLASH); |
| 25 | let flash = Mutex::new(BlockingAsync::new(flash)); | 25 | let flash = Mutex::new(BlockingAsync::new(flash)); |
| 26 | 26 | ||
| 27 | let button = Input::new(p.PB2, Pull::Up); | 27 | let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up); |
| 28 | let mut button = ExtiInput::new(button, p.EXTI2); | ||
| 29 | 28 | ||
| 30 | let mut led = Output::new(p.PB5, Level::Low, Speed::Low); | 29 | let mut led = Output::new(p.PB5, Level::Low, Speed::Low); |
| 31 | 30 | ||
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; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::exti::ExtiInput; | 9 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 11 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 12 | use embassy_sync::mutex::Mutex; | 12 | use embassy_sync::mutex::Mutex; |
| 13 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 14 | use panic_reset as _; | 14 | use panic_reset as _; |
| @@ -24,8 +24,7 @@ async fn main(_spawner: Spawner) { | |||
| 24 | let flash = Flash::new_blocking(p.FLASH); | 24 | let flash = Flash::new_blocking(p.FLASH); |
| 25 | let flash = Mutex::new(BlockingAsync::new(flash)); | 25 | let flash = Mutex::new(BlockingAsync::new(flash)); |
| 26 | 26 | ||
| 27 | let button = Input::new(p.PB2, Pull::Up); | 27 | let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up); |
| 28 | let mut button = ExtiInput::new(button, p.EXTI2); | ||
| 29 | 28 | ||
| 30 | let mut led = Output::new(p.PB5, Level::Low, Speed::Low); | 29 | let mut led = Output::new(p.PB5, Level::Low, Speed::Low); |
| 31 | 30 | ||
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; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::exti::ExtiInput; | 9 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 11 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 12 | use embassy_sync::mutex::Mutex; | 12 | use embassy_sync::mutex::Mutex; |
| 13 | use panic_reset as _; | 13 | use panic_reset as _; |
| 14 | 14 | ||
| @@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) { | |||
| 23 | let flash = Flash::new_blocking(p.FLASH); | 23 | let flash = Flash::new_blocking(p.FLASH); |
| 24 | let flash = Mutex::new(BlockingAsync::new(flash)); | 24 | let flash = Mutex::new(BlockingAsync::new(flash)); |
| 25 | 25 | ||
| 26 | let button = Input::new(p.PC13, Pull::Up); | 26 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); |
| 27 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 28 | 27 | ||
| 29 | let mut led = Output::new(p.PB14, Level::Low, Speed::Low); | 28 | let mut led = Output::new(p.PB14, Level::Low, Speed::Low); |
| 30 | led.set_high(); | 29 | 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; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::exti::ExtiInput; | 9 | use embassy_stm32::exti::ExtiInput; |
| 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; | 10 | use embassy_stm32::flash::{Flash, WRITE_SIZE}; |
| 11 | use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; | 11 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 12 | use embassy_sync::mutex::Mutex; | 12 | use embassy_sync::mutex::Mutex; |
| 13 | use panic_reset as _; | 13 | use panic_reset as _; |
| 14 | 14 | ||
| @@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) { | |||
| 23 | let flash = Flash::new_blocking(p.FLASH); | 23 | let flash = Flash::new_blocking(p.FLASH); |
| 24 | let flash = Mutex::new(BlockingAsync::new(flash)); | 24 | let flash = Mutex::new(BlockingAsync::new(flash)); |
| 25 | 25 | ||
| 26 | let button = Input::new(p.PA0, Pull::Up); | 26 | let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up); |
| 27 | let mut button = ExtiInput::new(button, p.EXTI0); | ||
| 28 | 27 | ||
| 29 | let mut led = Output::new(p.PB9, Level::Low, Speed::Low); | 28 | let mut led = Output::new(p.PB9, Level::Low, Speed::Low); |
| 30 | led.set_high(); | 29 | led.set_high(); |
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 @@ | |||
| 1 | [unstable] | 1 | [unstable] |
| 2 | build-std = ["core"] | 2 | #build-std = ["core"] |
| 3 | build-std-features = ["panic_immediate_abort"] | 3 | #build-std-features = ["panic_immediate_abort"] |
| 4 | 4 | ||
| 5 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | 5 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] |
| 6 | #runner = "./fruitrunner" | 6 | #runner = "./fruitrunner" |
| @@ -8,7 +8,7 @@ runner = "probe-rs run --chip nrf52840_xxAA" | |||
| 8 | 8 | ||
| 9 | rustflags = [ | 9 | rustflags = [ |
| 10 | # Code-size optimizations. | 10 | # Code-size optimizations. |
| 11 | "-Z", "trap-unreachable=no", | 11 | #"-Z", "trap-unreachable=no", |
| 12 | #"-C", "no-vectorize-loops", | 12 | #"-C", "no-vectorize-loops", |
| 13 | "-C", "force-frame-pointers=yes", | 13 | "-C", "force-frame-pointers=yes", |
| 14 | ] | 14 | ] |
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 { | |||
| 24 | #[embassy_executor::task] | 24 | #[embassy_executor::task] |
| 25 | async fn net_task( | 25 | async fn net_task( |
| 26 | stack: &'static Stack< | 26 | stack: &'static Stack< |
| 27 | Enc28j60< | 27 | Enc28j60<ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, Output<'static>>, |
| 28 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>, | ||
| 29 | Output<'static, peripherals::P0_13>, | ||
| 30 | >, | ||
| 31 | >, | 28 | >, |
| 32 | ) -> ! { | 29 | ) -> ! { |
| 33 | stack.run().await | 30 | stack.run().await |
| @@ -71,12 +68,7 @@ async fn main(spawner: Spawner) { | |||
| 71 | // Init network stack | 68 | // Init network stack |
| 72 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); | 69 | static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new(); |
| 73 | static STACK: StaticCell< | 70 | static STACK: StaticCell< |
| 74 | Stack< | 71 | Stack<Enc28j60<ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, Output<'static>>>, |
| 75 | Enc28j60< | ||
| 76 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>, | ||
| 77 | Output<'static, peripherals::P0_13>, | ||
| 78 | >, | ||
| 79 | >, | ||
| 80 | > = StaticCell::new(); | 72 | > = StaticCell::new(); |
| 81 | let stack = STACK.init(Stack::new( | 73 | let stack = STACK.init(Stack::new( |
| 82 | device, | 74 | 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 @@ | |||
| 3 | 3 | ||
| 4 | use defmt::{info, unwrap}; | 4 | use defmt::{info, unwrap}; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull}; | 6 | use embassy_nrf::gpio::{Input, Pull}; |
| 7 | use {defmt_rtt as _, panic_probe as _}; | 7 | use {defmt_rtt as _, panic_probe as _}; |
| 8 | 8 | ||
| 9 | #[embassy_executor::task(pool_size = 4)] | 9 | #[embassy_executor::task(pool_size = 4)] |
| 10 | async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) { | 10 | async fn button_task(n: usize, mut pin: Input<'static>) { |
| 11 | loop { | 11 | loop { |
| 12 | pin.wait_for_low().await; | 12 | pin.wait_for_low().await; |
| 13 | info!("Button {:?} pressed!", n); | 13 | info!("Button {:?} pressed!", n); |
| @@ -21,10 +21,10 @@ async fn main(spawner: Spawner) { | |||
| 21 | let p = embassy_nrf::init(Default::default()); | 21 | let p = embassy_nrf::init(Default::default()); |
| 22 | info!("Starting!"); | 22 | info!("Starting!"); |
| 23 | 23 | ||
| 24 | let btn1 = Input::new(p.P0_11.degrade(), Pull::Up); | 24 | let btn1 = Input::new(p.P0_11, Pull::Up); |
| 25 | let btn2 = Input::new(p.P0_12.degrade(), Pull::Up); | 25 | let btn2 = Input::new(p.P0_12, Pull::Up); |
| 26 | let btn3 = Input::new(p.P0_24.degrade(), Pull::Up); | 26 | let btn3 = Input::new(p.P0_24, Pull::Up); |
| 27 | let btn4 = Input::new(p.P0_25.degrade(), Pull::Up); | 27 | let btn4 = Input::new(p.P0_25, Pull::Up); |
| 28 | 28 | ||
| 29 | unwrap!(spawner.spawn(button_task(1, btn1))); | 29 | unwrap!(spawner.spawn(button_task(1, btn1))); |
| 30 | unwrap!(spawner.spawn(button_task(2, btn2))); | 30 | 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::*; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_futures::join::join; | 9 | use embassy_futures::join::join; |
| 10 | use embassy_futures::select::{select, Either}; | 10 | use embassy_futures::select::{select, Either}; |
| 11 | use embassy_nrf::gpio::{Input, Pin, Pull}; | 11 | use embassy_nrf::gpio::{Input, Pull}; |
| 12 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; | 12 | use embassy_nrf::usb::vbus_detect::HardwareVbusDetect; |
| 13 | use embassy_nrf::usb::Driver; | 13 | use embassy_nrf::usb::Driver; |
| 14 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; | 14 | use embassy_nrf::{bind_interrupts, pac, peripherals, usb}; |
| @@ -97,7 +97,7 @@ async fn main(_spawner: Spawner) { | |||
| 97 | } | 97 | } |
| 98 | }; | 98 | }; |
| 99 | 99 | ||
| 100 | let mut button = Input::new(p.P0_11.degrade(), Pull::Up); | 100 | let mut button = Input::new(p.P0_11, Pull::Up); |
| 101 | 101 | ||
| 102 | let (reader, mut writer) = hid.split(); | 102 | let (reader, mut writer) = hid.split(); |
| 103 | 103 | ||
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}; | |||
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_net::tcp::TcpSocket; | 6 | use embassy_net::tcp::TcpSocket; |
| 7 | use embassy_net::{Stack, StackResources}; | 7 | use embassy_net::{Stack, StackResources}; |
| 8 | use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; | 8 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; |
| 9 | use embassy_nrf::rng::Rng; | 9 | use embassy_nrf::rng::Rng; |
| 10 | use embassy_nrf::spim::{self, Spim}; | 10 | use embassy_nrf::spim::{self, Spim}; |
| 11 | use embassy_nrf::{bind_interrupts, peripherals}; | 11 | use embassy_nrf::{bind_interrupts, peripherals}; |
| @@ -27,9 +27,9 @@ bind_interrupts!(struct Irqs { | |||
| 27 | async fn wifi_task( | 27 | async fn wifi_task( |
| 28 | runner: hosted::Runner< | 28 | runner: hosted::Runner< |
| 29 | 'static, | 29 | 'static, |
| 30 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_31>, Delay>, | 30 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, |
| 31 | Input<'static, AnyPin>, | 31 | Input<'static>, |
| 32 | Output<'static, peripherals::P1_05>, | 32 | Output<'static>, |
| 33 | >, | 33 | >, |
| 34 | ) -> ! { | 34 | ) -> ! { |
| 35 | runner.run().await | 35 | runner.run().await |
| @@ -50,8 +50,8 @@ async fn main(spawner: Spawner) { | |||
| 50 | let sck = p.P0_29; | 50 | let sck = p.P0_29; |
| 51 | let mosi = p.P0_30; | 51 | let mosi = p.P0_30; |
| 52 | let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive); | 52 | let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive); |
| 53 | let handshake = Input::new(p.P1_01.degrade(), Pull::Up); | 53 | let handshake = Input::new(p.P1_01, Pull::Up); |
| 54 | let ready = Input::new(p.P1_04.degrade(), Pull::None); | 54 | let ready = Input::new(p.P1_04, Pull::None); |
| 55 | let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); | 55 | let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); |
| 56 | 56 | ||
| 57 | let mut config = spim::Config::default(); | 57 | let mut config = spim::Config::default(); |
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}; | |||
| 14 | use gpio::{AnyPin, Level, Output}; | 14 | use gpio::{AnyPin, Level, Output}; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 16 | ||
| 17 | type LedType = Mutex<ThreadModeRawMutex, Option<Output<'static, AnyPin>>>; | 17 | type LedType = Mutex<ThreadModeRawMutex, Option<Output<'static>>>; |
| 18 | static LED: LedType = Mutex::new(None); | 18 | static LED: LedType = Mutex::new(None); |
| 19 | 19 | ||
| 20 | #[embassy_executor::main] | 20 | #[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; | |||
| 13 | use embassy_net_wiznet::*; | 13 | use embassy_net_wiznet::*; |
| 14 | use embassy_rp::clocks::RoscRng; | 14 | use embassy_rp::clocks::RoscRng; |
| 15 | use embassy_rp::gpio::{Input, Level, Output, Pull}; | 15 | use embassy_rp::gpio::{Input, Level, Output, Pull}; |
| 16 | use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; | 16 | use embassy_rp::peripherals::SPI0; |
| 17 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | 17 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; |
| 18 | use embassy_time::{Delay, Duration}; | 18 | use embassy_time::{Delay, Duration}; |
| 19 | use embedded_hal_bus::spi::ExclusiveDevice; | 19 | use embedded_hal_bus::spi::ExclusiveDevice; |
| @@ -27,9 +27,9 @@ async fn ethernet_task( | |||
| 27 | runner: Runner< | 27 | runner: Runner< |
| 28 | 'static, | 28 | 'static, |
| 29 | W5500, | 29 | W5500, |
| 30 | ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static, PIN_17>, Delay>, | 30 | ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static>, Delay>, |
| 31 | Input<'static, PIN_21>, | 31 | Input<'static>, |
| 32 | Output<'static, PIN_20>, | 32 | Output<'static>, |
| 33 | >, | 33 | >, |
| 34 | ) -> ! { | 34 | ) -> ! { |
| 35 | runner.run().await | 35 | 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; | |||
| 15 | use embassy_net_wiznet::*; | 15 | use embassy_net_wiznet::*; |
| 16 | use embassy_rp::clocks::RoscRng; | 16 | use embassy_rp::clocks::RoscRng; |
| 17 | use embassy_rp::gpio::{Input, Level, Output, Pull}; | 17 | use embassy_rp::gpio::{Input, Level, Output, Pull}; |
| 18 | use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; | 18 | use embassy_rp::peripherals::SPI0; |
| 19 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | 19 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; |
| 20 | use embassy_time::{Delay, Duration, Timer}; | 20 | use embassy_time::{Delay, Duration, Timer}; |
| 21 | use embedded_hal_bus::spi::ExclusiveDevice; | 21 | use embedded_hal_bus::spi::ExclusiveDevice; |
| @@ -29,9 +29,9 @@ async fn ethernet_task( | |||
| 29 | runner: Runner< | 29 | runner: Runner< |
| 30 | 'static, | 30 | 'static, |
| 31 | W5500, | 31 | W5500, |
| 32 | ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static, PIN_17>, Delay>, | 32 | ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static>, Delay>, |
| 33 | Input<'static, PIN_21>, | 33 | Input<'static>, |
| 34 | Output<'static, PIN_20>, | 34 | Output<'static>, |
| 35 | >, | 35 | >, |
| 36 | ) -> ! { | 36 | ) -> ! { |
| 37 | runner.run().await | 37 | 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; | |||
| 14 | use embassy_net_wiznet::*; | 14 | use embassy_net_wiznet::*; |
| 15 | use embassy_rp::clocks::RoscRng; | 15 | use embassy_rp::clocks::RoscRng; |
| 16 | use embassy_rp::gpio::{Input, Level, Output, Pull}; | 16 | use embassy_rp::gpio::{Input, Level, Output, Pull}; |
| 17 | use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; | 17 | use embassy_rp::peripherals::SPI0; |
| 18 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | 18 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; |
| 19 | use embassy_time::{Delay, Duration}; | 19 | use embassy_time::{Delay, Duration}; |
| 20 | use embedded_hal_bus::spi::ExclusiveDevice; | 20 | use embedded_hal_bus::spi::ExclusiveDevice; |
| @@ -28,9 +28,9 @@ async fn ethernet_task( | |||
| 28 | runner: Runner< | 28 | runner: Runner< |
| 29 | 'static, | 29 | 'static, |
| 30 | W5500, | 30 | W5500, |
| 31 | ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static, PIN_17>, Delay>, | 31 | ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static>, Delay>, |
| 32 | Input<'static, PIN_21>, | 32 | Input<'static>, |
| 33 | Output<'static, PIN_20>, | 33 | Output<'static>, |
| 34 | >, | 34 | >, |
| 35 | ) -> ! { | 35 | ) -> ! { |
| 36 | runner.run().await | 36 | 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; | |||
| 14 | use embassy_net_wiznet::*; | 14 | use embassy_net_wiznet::*; |
| 15 | use embassy_rp::clocks::RoscRng; | 15 | use embassy_rp::clocks::RoscRng; |
| 16 | use embassy_rp::gpio::{Input, Level, Output, Pull}; | 16 | use embassy_rp::gpio::{Input, Level, Output, Pull}; |
| 17 | use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; | 17 | use embassy_rp::peripherals::SPI0; |
| 18 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | 18 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; |
| 19 | use embassy_time::Delay; | 19 | use embassy_time::Delay; |
| 20 | use embedded_hal_bus::spi::ExclusiveDevice; | 20 | use embedded_hal_bus::spi::ExclusiveDevice; |
| @@ -27,9 +27,9 @@ async fn ethernet_task( | |||
| 27 | runner: Runner< | 27 | runner: Runner< |
| 28 | 'static, | 28 | 'static, |
| 29 | W5500, | 29 | W5500, |
| 30 | ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static, PIN_17>, Delay>, | 30 | ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static>, Delay>, |
| 31 | Input<'static, PIN_21>, | 31 | Input<'static>, |
| 32 | Output<'static, PIN_20>, | 32 | Output<'static>, |
| 33 | >, | 33 | >, |
| 34 | ) -> ! { | 34 | ) -> ! { |
| 35 | runner.run().await | 35 | 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::*; | |||
| 9 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| 10 | use embassy_rp::gpio::{Level, Output}; | 10 | use embassy_rp::gpio::{Level, Output}; |
| 11 | use embassy_rp::multicore::{spawn_core1, Stack}; | 11 | use embassy_rp::multicore::{spawn_core1, Stack}; |
| 12 | use embassy_rp::peripherals::PIN_25; | ||
| 13 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 12 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 14 | use embassy_sync::channel::Channel; | 13 | use embassy_sync::channel::Channel; |
| 15 | use embassy_time::Timer; | 14 | use embassy_time::Timer; |
| @@ -52,7 +51,7 @@ async fn core0_task() { | |||
| 52 | } | 51 | } |
| 53 | 52 | ||
| 54 | #[embassy_executor::task] | 53 | #[embassy_executor::task] |
| 55 | async fn core1_task(mut led: Output<'static, PIN_25>) { | 54 | async fn core1_task(mut led: Output<'static>) { |
| 56 | info!("Hello from core 1"); | 55 | info!("Hello from core 1"); |
| 57 | loop { | 56 | loop { |
| 58 | match CHANNEL.receive().await { | 57 | 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; | |||
| 14 | use embassy_net::{Config, Stack, StackResources}; | 14 | use embassy_net::{Config, Stack, StackResources}; |
| 15 | use embassy_rp::bind_interrupts; | 15 | use embassy_rp::bind_interrupts; |
| 16 | use embassy_rp::gpio::{Level, Output}; | 16 | use embassy_rp::gpio::{Level, Output}; |
| 17 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 17 | use embassy_rp::peripherals::{DMA_CH0, PIO0}; |
| 18 | use embassy_rp::pio::{InterruptHandler, Pio}; | 18 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 19 | use embassy_time::Duration; | 19 | use embassy_time::Duration; |
| 20 | use embedded_io_async::Write; | 20 | use embedded_io_async::Write; |
| @@ -26,9 +26,7 @@ bind_interrupts!(struct Irqs { | |||
| 26 | }); | 26 | }); |
| 27 | 27 | ||
| 28 | #[embassy_executor::task] | 28 | #[embassy_executor::task] |
| 29 | async fn wifi_task( | 29 | async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! { |
| 30 | runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, | ||
| 31 | ) -> ! { | ||
| 32 | runner.run().await | 30 | runner.run().await |
| 33 | } | 31 | } |
| 34 | 32 | ||
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::*; | |||
| 10 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
| 11 | use embassy_rp::bind_interrupts; | 11 | use embassy_rp::bind_interrupts; |
| 12 | use embassy_rp::gpio::{Level, Output}; | 12 | use embassy_rp::gpio::{Level, Output}; |
| 13 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 13 | use embassy_rp::peripherals::{DMA_CH0, PIO0}; |
| 14 | use embassy_rp::pio::{InterruptHandler, Pio}; | 14 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 15 | use embassy_time::{Duration, Timer}; | 15 | use embassy_time::{Duration, Timer}; |
| 16 | use static_cell::StaticCell; | 16 | use static_cell::StaticCell; |
| @@ -21,9 +21,7 @@ bind_interrupts!(struct Irqs { | |||
| 21 | }); | 21 | }); |
| 22 | 22 | ||
| 23 | #[embassy_executor::task] | 23 | #[embassy_executor::task] |
| 24 | async fn wifi_task( | 24 | async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! { |
| 25 | runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, | ||
| 26 | ) -> ! { | ||
| 27 | runner.run().await | 25 | runner.run().await |
| 28 | } | 26 | } |
| 29 | 27 | ||
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; | |||
| 13 | use embassy_net::Stack; | 13 | use embassy_net::Stack; |
| 14 | use embassy_rp::bind_interrupts; | 14 | use embassy_rp::bind_interrupts; |
| 15 | use embassy_rp::gpio::{Level, Output}; | 15 | use embassy_rp::gpio::{Level, Output}; |
| 16 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 16 | use embassy_rp::peripherals::{DMA_CH0, PIO0}; |
| 17 | use embassy_rp::pio::{InterruptHandler, Pio}; | 17 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 18 | use static_cell::StaticCell; | 18 | use static_cell::StaticCell; |
| 19 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -23,9 +23,7 @@ bind_interrupts!(struct Irqs { | |||
| 23 | }); | 23 | }); |
| 24 | 24 | ||
| 25 | #[embassy_executor::task] | 25 | #[embassy_executor::task] |
| 26 | async fn wifi_task( | 26 | async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! { |
| 27 | runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, | ||
| 28 | ) -> ! { | ||
| 29 | runner.run().await | 27 | runner.run().await |
| 30 | } | 28 | } |
| 31 | 29 | ||
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; | |||
| 14 | use embassy_net::{Config, Stack, StackResources}; | 14 | use embassy_net::{Config, Stack, StackResources}; |
| 15 | use embassy_rp::bind_interrupts; | 15 | use embassy_rp::bind_interrupts; |
| 16 | use embassy_rp::gpio::{Level, Output}; | 16 | use embassy_rp::gpio::{Level, Output}; |
| 17 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 17 | use embassy_rp::peripherals::{DMA_CH0, PIO0}; |
| 18 | use embassy_rp::pio::{InterruptHandler, Pio}; | 18 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 19 | use embassy_time::{Duration, Timer}; | 19 | use embassy_time::{Duration, Timer}; |
| 20 | use embedded_io_async::Write; | 20 | use embedded_io_async::Write; |
| @@ -29,9 +29,7 @@ const WIFI_NETWORK: &str = "EmbassyTest"; | |||
| 29 | const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; | 29 | const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; |
| 30 | 30 | ||
| 31 | #[embassy_executor::task] | 31 | #[embassy_executor::task] |
| 32 | async fn wifi_task( | 32 | async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! { |
| 33 | runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, | ||
| 34 | ) -> ! { | ||
| 35 | runner.run().await | 33 | runner.run().await |
| 36 | } | 34 | } |
| 37 | 35 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PC13, Pull::Up); | 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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}; | |||
| 8 | use defmt::info; | 8 | use defmt::info; |
| 9 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_stm32::exti::ExtiInput; | 10 | use embassy_stm32::exti::ExtiInput; |
| 11 | use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; | 11 | use embassy_stm32::gpio::{AnyPin, Level, Output, Pin, Pull, Speed}; |
| 12 | use embassy_time::Timer; | 12 | use embassy_time::Timer; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 14 | ||
| @@ -36,8 +36,7 @@ async fn main(spawner: Spawner) { | |||
| 36 | 36 | ||
| 37 | // Configure the button pin and obtain handler. | 37 | // Configure the button pin and obtain handler. |
| 38 | // On the Nucleo F091RC there is a button connected to pin PC13. | 38 | // On the Nucleo F091RC there is a button connected to pin PC13. |
| 39 | let button = Input::new(p.PC13, Pull::None); | 39 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::None); |
| 40 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 41 | 40 | ||
| 42 | // Create and initialize a delay variable to manage delay loop | 41 | // Create and initialize a delay variable to manage delay loop |
| 43 | let mut del_var = 2000; | 42 | 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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -13,8 +13,7 @@ async fn main(_spawner: Spawner) { | |||
| 13 | let p = embassy_stm32::init(Default::default()); | 13 | let p = embassy_stm32::init(Default::default()); |
| 14 | // Configure the button pin and obtain handler. | 14 | // Configure the button pin and obtain handler. |
| 15 | // On the Nucleo F091RC there is a button connected to pin PC13. | 15 | // On the Nucleo F091RC there is a button connected to pin PC13. |
| 16 | let button = Input::new(p.PC13, Pull::Down); | 16 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); |
| 17 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 18 | 17 | ||
| 19 | info!("Press the USER button..."); | 18 | info!("Press the USER button..."); |
| 20 | loop { | 19 | 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 @@ | |||
| 12 | use defmt::*; | 12 | use defmt::*; |
| 13 | use embassy_executor::Spawner; | 13 | use embassy_executor::Spawner; |
| 14 | use embassy_stm32::exti::ExtiInput; | 14 | use embassy_stm32::exti::ExtiInput; |
| 15 | use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed}; | 15 | use embassy_stm32::gpio::{Level, Output, Pull, Speed}; |
| 16 | use embassy_stm32::peripherals::PA0; | ||
| 17 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; | 16 | use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex; |
| 18 | use embassy_sync::channel::Channel; | 17 | use embassy_sync::channel::Channel; |
| 19 | use embassy_time::{with_timeout, Duration, Timer}; | 18 | use embassy_time::{with_timeout, Duration, Timer}; |
| 20 | use {defmt_rtt as _, panic_probe as _}; | 19 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 20 | ||
| 22 | struct Leds<'a> { | 21 | struct Leds<'a> { |
| 23 | leds: [Output<'a, AnyPin>; 8], | 22 | leds: [Output<'a>; 8], |
| 24 | direction: i8, | 23 | direction: i8, |
| 25 | current_led: usize, | 24 | current_led: usize, |
| 26 | } | 25 | } |
| 27 | 26 | ||
| 28 | impl<'a> Leds<'a> { | 27 | impl<'a> Leds<'a> { |
| 29 | fn new(pins: [Output<'a, AnyPin>; 8]) -> Self { | 28 | fn new(pins: [Output<'a>; 8]) -> Self { |
| 30 | Self { | 29 | Self { |
| 31 | leds: pins, | 30 | leds: pins, |
| 32 | direction: 1, | 31 | direction: 1, |
| @@ -100,18 +99,17 @@ static CHANNEL: Channel<ThreadModeRawMutex, ButtonEvent, 4> = Channel::new(); | |||
| 100 | #[embassy_executor::main] | 99 | #[embassy_executor::main] |
| 101 | async fn main(spawner: Spawner) { | 100 | async fn main(spawner: Spawner) { |
| 102 | let p = embassy_stm32::init(Default::default()); | 101 | let p = embassy_stm32::init(Default::default()); |
| 103 | let button = Input::new(p.PA0, Pull::Down); | 102 | let button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Down); |
| 104 | let button = ExtiInput::new(button, p.EXTI0); | ||
| 105 | info!("Press the USER button..."); | 103 | info!("Press the USER button..."); |
| 106 | let leds = [ | 104 | let leds = [ |
| 107 | Output::new(p.PE9.degrade(), Level::Low, Speed::Low), | 105 | Output::new(p.PE9, Level::Low, Speed::Low), |
| 108 | Output::new(p.PE10.degrade(), Level::Low, Speed::Low), | 106 | Output::new(p.PE10, Level::Low, Speed::Low), |
| 109 | Output::new(p.PE11.degrade(), Level::Low, Speed::Low), | 107 | Output::new(p.PE11, Level::Low, Speed::Low), |
| 110 | Output::new(p.PE12.degrade(), Level::Low, Speed::Low), | 108 | Output::new(p.PE12, Level::Low, Speed::Low), |
| 111 | Output::new(p.PE13.degrade(), Level::Low, Speed::Low), | 109 | Output::new(p.PE13, Level::Low, Speed::Low), |
| 112 | Output::new(p.PE14.degrade(), Level::Low, Speed::Low), | 110 | Output::new(p.PE14, Level::Low, Speed::Low), |
| 113 | Output::new(p.PE15.degrade(), Level::Low, Speed::Low), | 111 | Output::new(p.PE15, Level::Low, Speed::Low), |
| 114 | Output::new(p.PE8.degrade(), Level::Low, Speed::Low), | 112 | Output::new(p.PE8, Level::Low, Speed::Low), |
| 115 | ]; | 113 | ]; |
| 116 | let leds = Leds::new(leds); | 114 | let leds = Leds::new(leds); |
| 117 | 115 | ||
| @@ -127,7 +125,7 @@ async fn led_blinker(mut leds: Leds<'static>) { | |||
| 127 | } | 125 | } |
| 128 | 126 | ||
| 129 | #[embassy_executor::task] | 127 | #[embassy_executor::task] |
| 130 | async fn button_waiter(mut button: ExtiInput<'static, PA0>) { | 128 | async fn button_waiter(mut button: ExtiInput<'static>) { |
| 131 | const DOUBLE_CLICK_DELAY: u64 = 250; | 129 | const DOUBLE_CLICK_DELAY: u64 = 250; |
| 132 | const HOLD_DELAY: u64 = 1000; | 130 | const HOLD_DELAY: u64 = 1000; |
| 133 | 131 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PA0, Pull::Down); | 15 | let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Down); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI0); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PC13, Pull::Down); | 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PC13, Pull::Down); | 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PC13, Pull::Up); | 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PC13, Pull::Down); | 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PC13, Pull::Down); | 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PC13, Pull::Down); | 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 10 | 10 | ||
| @@ -13,8 +13,7 @@ async fn main(_spawner: Spawner) { | |||
| 13 | let config = Config::default(); | 13 | let config = Config::default(); |
| 14 | let p = embassy_stm32::init(config); | 14 | let p = embassy_stm32::init(config); |
| 15 | 15 | ||
| 16 | let button = Input::new(p.PB2, Pull::Up); | 16 | let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up); |
| 17 | let mut button = ExtiInput::new(button, p.EXTI2); | ||
| 18 | 17 | ||
| 19 | info!("Press the USER button..."); | 18 | info!("Press the USER button..."); |
| 20 | 19 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PC13, Pull::Up); | 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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); | |||
| 58 | const HTTP_LISTEN_PORT: u16 = 80; | 58 | const HTTP_LISTEN_PORT: u16 = 80; |
| 59 | 59 | ||
| 60 | pub type SpeSpi = Spi<'static, peripherals::SPI2, peripherals::DMA1_CH1, peripherals::DMA1_CH2>; | 60 | pub type SpeSpi = Spi<'static, peripherals::SPI2, peripherals::DMA1_CH1, peripherals::DMA1_CH2>; |
| 61 | pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static, peripherals::PB12>, Delay>; | 61 | pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static>, Delay>; |
| 62 | pub type SpeInt = exti::ExtiInput<'static, peripherals::PB11>; | 62 | pub type SpeInt = exti::ExtiInput<'static>; |
| 63 | pub type SpeRst = Output<'static, peripherals::PC7>; | 63 | pub type SpeRst = Output<'static>; |
| 64 | pub type Adin1110T = ADIN1110<SpeSpiCs>; | 64 | pub type Adin1110T = ADIN1110<SpeSpiCs>; |
| 65 | pub type TempSensI2c = I2c<'static, peripherals::I2C3, peripherals::DMA1_CH6, peripherals::DMA1_CH7>; | 65 | pub type TempSensI2c = I2c<'static, peripherals::I2C3, peripherals::DMA1_CH6, peripherals::DMA1_CH7>; |
| 66 | 66 | ||
| @@ -134,8 +134,7 @@ async fn main(spawner: Spawner) { | |||
| 134 | let spe_cfg1 = Input::new(dp.PC9, Pull::None); | 134 | let spe_cfg1 = Input::new(dp.PC9, Pull::None); |
| 135 | let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low); | 135 | let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low); |
| 136 | 136 | ||
| 137 | let spe_int = Input::new(dp.PB11, Pull::None); | 137 | let spe_int = exti::ExtiInput::new(dp.PB11, dp.EXTI11, Pull::None); |
| 138 | let spe_int = exti::ExtiInput::new(spe_int, dp.EXTI11); | ||
| 139 | 138 | ||
| 140 | let spe_spi_cs_n = Output::new(dp.PB12, Level::High, Speed::High); | 139 | let spe_spi_cs_n = Output::new(dp.PB12, Level::High, Speed::High); |
| 141 | let spe_spi_sclk = dp.PB13; | 140 | let spe_spi_sclk = dp.PB13; |
| @@ -298,7 +297,7 @@ async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net: | |||
| 298 | } | 297 | } |
| 299 | 298 | ||
| 300 | #[embassy_executor::task] | 299 | #[embassy_executor::task] |
| 301 | async fn heartbeat_led(mut led: Output<'static, peripherals::PE6>) { | 300 | async fn heartbeat_led(mut led: Output<'static>) { |
| 302 | let mut tmr = Ticker::every(Duration::from_hz(3)); | 301 | let mut tmr = Ticker::every(Duration::from_hz(3)); |
| 303 | loop { | 302 | loop { |
| 304 | led.toggle(); | 303 | led.toggle(); |
| @@ -308,7 +307,7 @@ async fn heartbeat_led(mut led: Output<'static, peripherals::PE6>) { | |||
| 308 | 307 | ||
| 309 | // ADT7422 | 308 | // ADT7422 |
| 310 | #[embassy_executor::task] | 309 | #[embassy_executor::task] |
| 311 | async fn temp_task(temp_dev_i2c: TempSensI2c, mut led: Output<'static, peripherals::PG15>) -> ! { | 310 | async fn temp_task(temp_dev_i2c: TempSensI2c, mut led: Output<'static>) -> ! { |
| 312 | let mut tmr = Ticker::every(Duration::from_hz(1)); | 311 | let mut tmr = Ticker::every(Duration::from_hz(1)); |
| 313 | let mut temp_sens = ADT7422::new(temp_dev_i2c, 0x48).unwrap(); | 312 | let mut temp_sens = ADT7422::new(temp_dev_i2c, 0x48).unwrap(); |
| 314 | 313 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PC13, Pull::Down); | 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PC4, Pull::Up); | 15 | let mut button = ExtiInput::new(p.PC4, p.EXTI4, Pull::Up); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI4); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PC13, Pull::Up); | 15 | let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::exti::ExtiInput; | 6 | use embassy_stm32::exti::ExtiInput; |
| 7 | use embassy_stm32::gpio::{Input, Pull}; | 7 | use embassy_stm32::gpio::Pull; |
| 8 | use {defmt_rtt as _, panic_probe as _}; | 8 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 9 | ||
| 10 | #[embassy_executor::main] | 10 | #[embassy_executor::main] |
| @@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) { | |||
| 12 | let p = embassy_stm32::init(Default::default()); | 12 | let p = embassy_stm32::init(Default::default()); |
| 13 | info!("Hello World!"); | 13 | info!("Hello World!"); |
| 14 | 14 | ||
| 15 | let button = Input::new(p.PA0, Pull::Up); | 15 | let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up); |
| 16 | let mut button = ExtiInput::new(button, p.EXTI0); | ||
| 17 | 16 | ||
| 18 | info!("Press the USER button..."); | 17 | info!("Press the USER button..."); |
| 19 | 18 | ||
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 { | |||
| 21 | RNG => embassy_nrf::rng::InterruptHandler<peripherals::RNG>; | 21 | RNG => embassy_nrf::rng::InterruptHandler<peripherals::RNG>; |
| 22 | }); | 22 | }); |
| 23 | 23 | ||
| 24 | type MyDriver = Enc28j60< | 24 | type MyDriver = Enc28j60<ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, Output<'static>>; |
| 25 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>, | ||
| 26 | Output<'static, peripherals::P0_13>, | ||
| 27 | >; | ||
| 28 | 25 | ||
| 29 | #[embassy_executor::task] | 26 | #[embassy_executor::task] |
| 30 | async fn net_task(stack: &'static Stack<MyDriver>) -> ! { | 27 | async fn net_task(stack: &'static Stack<MyDriver>) -> ! { |
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); | |||
| 6 | use defmt::{info, unwrap}; | 6 | use defmt::{info, unwrap}; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_net::{Config, Stack, StackResources}; | 8 | use embassy_net::{Config, Stack, StackResources}; |
| 9 | use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull}; | 9 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; |
| 10 | use embassy_nrf::rng::Rng; | 10 | use embassy_nrf::rng::Rng; |
| 11 | use embassy_nrf::spim::{self, Spim}; | 11 | use embassy_nrf::spim::{self, Spim}; |
| 12 | use embassy_nrf::{bind_interrupts, peripherals}; | 12 | use embassy_nrf::{bind_interrupts, peripherals}; |
| @@ -28,9 +28,9 @@ const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; | |||
| 28 | async fn wifi_task( | 28 | async fn wifi_task( |
| 29 | runner: hosted::Runner< | 29 | runner: hosted::Runner< |
| 30 | 'static, | 30 | 'static, |
| 31 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_31>, Delay>, | 31 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, |
| 32 | Input<'static, AnyPin>, | 32 | Input<'static>, |
| 33 | Output<'static, peripherals::P1_05>, | 33 | Output<'static>, |
| 34 | >, | 34 | >, |
| 35 | ) -> ! { | 35 | ) -> ! { |
| 36 | runner.run().await | 36 | runner.run().await |
| @@ -53,8 +53,8 @@ async fn main(spawner: Spawner) { | |||
| 53 | let sck = p.P0_29; | 53 | let sck = p.P0_29; |
| 54 | let mosi = p.P0_30; | 54 | let mosi = p.P0_30; |
| 55 | let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive); | 55 | let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive); |
| 56 | let handshake = Input::new(p.P1_01.degrade(), Pull::Up); | 56 | let handshake = Input::new(p.P1_01, Pull::Up); |
| 57 | let ready = Input::new(p.P1_04.degrade(), Pull::None); | 57 | let ready = Input::new(p.P1_04, Pull::None); |
| 58 | let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); | 58 | let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard); |
| 59 | 59 | ||
| 60 | let mut config = spim::Config::default(); | 60 | let mut config = spim::Config::default(); |
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" | |||
| 10 | 10 | ||
| 11 | rustflags = [ | 11 | rustflags = [ |
| 12 | # Code-size optimizations. | 12 | # Code-size optimizations. |
| 13 | "-Z", "trap-unreachable=no", | 13 | #"-Z", "trap-unreachable=no", |
| 14 | "-C", "inline-threshold=5", | 14 | "-C", "inline-threshold=5", |
| 15 | "-C", "no-vectorize-loops", | 15 | "-C", "no-vectorize-loops", |
| 16 | ] | 16 | ] |
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, *}; | |||
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_net::{Config, Stack, StackResources}; | 8 | use embassy_net::{Config, Stack, StackResources}; |
| 9 | use embassy_rp::gpio::{Level, Output}; | 9 | use embassy_rp::gpio::{Level, Output}; |
| 10 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 10 | use embassy_rp::peripherals::{DMA_CH0, PIO0}; |
| 11 | use embassy_rp::pio::{InterruptHandler, Pio}; | 11 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 12 | use embassy_rp::{bind_interrupts, rom_data}; | 12 | use embassy_rp::{bind_interrupts, rom_data}; |
| 13 | use static_cell::StaticCell; | 13 | use static_cell::StaticCell; |
| @@ -24,9 +24,7 @@ const WIFI_NETWORK: &str = "EmbassyTest"; | |||
| 24 | const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; | 24 | const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; |
| 25 | 25 | ||
| 26 | #[embassy_executor::task] | 26 | #[embassy_executor::task] |
| 27 | async fn wifi_task( | 27 | async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! { |
| 28 | runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, | ||
| 29 | ) -> ! { | ||
| 30 | runner.run().await | 28 | runner.run().await |
| 31 | } | 29 | } |
| 32 | 30 | ||
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; | |||
| 10 | use embassy_net_wiznet::*; | 10 | use embassy_net_wiznet::*; |
| 11 | use embassy_rp::clocks::RoscRng; | 11 | use embassy_rp::clocks::RoscRng; |
| 12 | use embassy_rp::gpio::{Input, Level, Output, Pull}; | 12 | use embassy_rp::gpio::{Input, Level, Output, Pull}; |
| 13 | use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; | 13 | use embassy_rp::peripherals::SPI0; |
| 14 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | 14 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; |
| 15 | use embassy_time::Delay; | 15 | use embassy_time::Delay; |
| 16 | use embedded_hal_bus::spi::ExclusiveDevice; | 16 | use embedded_hal_bus::spi::ExclusiveDevice; |
| @@ -23,9 +23,9 @@ async fn ethernet_task( | |||
| 23 | runner: Runner< | 23 | runner: Runner< |
| 24 | 'static, | 24 | 'static, |
| 25 | W5100S, | 25 | W5100S, |
| 26 | ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static, PIN_17>, Delay>, | 26 | ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static>, Delay>, |
| 27 | Input<'static, PIN_21>, | 27 | Input<'static>, |
| 28 | Output<'static, PIN_20>, | 28 | Output<'static>, |
| 29 | >, | 29 | >, |
| 30 | ) -> ! { | 30 | ) -> ! { |
| 31 | runner.run().await | 31 | 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<const N: usize>(uart: &mut UartRx<'_, impl Instance, Blocking>) -> Resu | |||
| 21 | Ok(buf) | 21 | Ok(buf) |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { | 24 | async fn send(pin: &mut Output<'_>, v: u8, parity: Option<bool>) { |
| 25 | pin.set_low(); | 25 | pin.set_low(); |
| 26 | Timer::after_millis(1).await; | 26 | Timer::after_millis(1).await; |
| 27 | for i in 0..8 { | 27 | for i in 0..8 { |
| @@ -116,7 +116,7 @@ async fn main(_spawner: Spawner) { | |||
| 116 | config.parity = Parity::ParityEven; | 116 | config.parity = Parity::ParityEven; |
| 117 | let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config); | 117 | let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config); |
| 118 | 118 | ||
| 119 | async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: u8) { | 119 | async fn chr(pin: &mut Output<'_>, v: u8, parity: u8) { |
| 120 | send(pin, v, Some(parity != 0)).await; | 120 | send(pin, v, Some(parity != 0)).await; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| @@ -142,7 +142,7 @@ async fn main(_spawner: Spawner) { | |||
| 142 | config.baudrate = 1000; | 142 | config.baudrate = 1000; |
| 143 | let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config); | 143 | let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config); |
| 144 | 144 | ||
| 145 | async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, good: bool) { | 145 | async fn chr(pin: &mut Output<'_>, v: u8, good: bool) { |
| 146 | if good { | 146 | if good { |
| 147 | send(pin, v, None).await; | 147 | send(pin, v, None).await; |
| 148 | } else { | 148 | } 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<const N: usize>(uart: &mut BufferedUartRx<'_, impl Instance>) -> | |||
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { | 39 | async fn send(pin: &mut Output<'_>, v: u8, parity: Option<bool>) { |
| 40 | pin.set_low(); | 40 | pin.set_low(); |
| 41 | Timer::after_millis(1).await; | 41 | Timer::after_millis(1).await; |
| 42 | for i in 0..8 { | 42 | for i in 0..8 { |
| @@ -161,7 +161,7 @@ async fn main(_spawner: Spawner) { | |||
| 161 | let rx_buf = &mut [0u8; 16]; | 161 | let rx_buf = &mut [0u8; 16]; |
| 162 | let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config); | 162 | let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config); |
| 163 | 163 | ||
| 164 | async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: u32) { | 164 | async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) { |
| 165 | send(pin, v, Some(parity != 0)).await; | 165 | send(pin, v, Some(parity != 0)).await; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| @@ -208,7 +208,7 @@ async fn main(_spawner: Spawner) { | |||
| 208 | let rx_buf = &mut [0u8; 16]; | 208 | let rx_buf = &mut [0u8; 16]; |
| 209 | let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config); | 209 | let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config); |
| 210 | 210 | ||
| 211 | async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, good: bool) { | 211 | async fn chr(pin: &mut Output<'_>, v: u8, good: bool) { |
| 212 | if good { | 212 | if good { |
| 213 | send(pin, v, None).await; | 213 | send(pin, v, None).await; |
| 214 | } else { | 214 | } 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<const N: usize>(uart: &mut UartRx<'_, impl Instance, Async>) -> R | |||
| 27 | Ok(buf) | 27 | Ok(buf) |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { | 30 | async fn send(pin: &mut Output<'_>, v: u8, parity: Option<bool>) { |
| 31 | pin.set_low(); | 31 | pin.set_low(); |
| 32 | Timer::after_millis(1).await; | 32 | Timer::after_millis(1).await; |
| 33 | for i in 0..8 { | 33 | for i in 0..8 { |
| @@ -160,7 +160,7 @@ async fn main(_spawner: Spawner) { | |||
| 160 | config.parity = Parity::ParityEven; | 160 | config.parity = Parity::ParityEven; |
| 161 | let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config); | 161 | let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config); |
| 162 | 162 | ||
| 163 | async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: u32) { | 163 | async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) { |
| 164 | send(pin, v, Some(parity != 0)).await; | 164 | send(pin, v, Some(parity != 0)).await; |
| 165 | } | 165 | } |
| 166 | 166 | ||
| @@ -205,7 +205,7 @@ async fn main(_spawner: Spawner) { | |||
| 205 | config.baudrate = 1000; | 205 | config.baudrate = 1000; |
| 206 | let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config); | 206 | let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config); |
| 207 | 207 | ||
| 208 | async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, good: bool) { | 208 | async fn chr(pin: &mut Output<'_>, v: u8, good: bool) { |
| 209 | if good { | 209 | if good { |
| 210 | send(pin, v, None).await; | 210 | send(pin, v, None).await; |
| 211 | } else { | 211 | } else { |
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 @@ | |||
| 1 | [unstable] | 1 | [unstable] |
| 2 | build-std = ["core"] | 2 | #build-std = ["core"] |
| 3 | build-std-features = ["panic_immediate_abort"] | 3 | #build-std-features = ["panic_immediate_abort"] |
| 4 | 4 | ||
| 5 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | 5 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] |
| 6 | runner = "teleprobe client run" | 6 | runner = "teleprobe client run" |
| @@ -8,7 +8,7 @@ runner = "teleprobe client run" | |||
| 8 | 8 | ||
| 9 | rustflags = [ | 9 | rustflags = [ |
| 10 | # Code-size optimizations. | 10 | # Code-size optimizations. |
| 11 | "-Z", "trap-unreachable=no", | 11 | #"-Z", "trap-unreachable=no", |
| 12 | "-C", "inline-threshold=5", | 12 | "-C", "inline-threshold=5", |
| 13 | "-C", "no-vectorize-loops", | 13 | "-C", "no-vectorize-loops", |
| 14 | ] | 14 | ] |
| @@ -20,4 +20,4 @@ target = "thumbv6m-none-eabi" | |||
| 20 | #target = "thumbv8m.main-none-eabihf" | 20 | #target = "thumbv8m.main-none-eabihf" |
| 21 | 21 | ||
| 22 | [env] | 22 | [env] |
| 23 | DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info" \ No newline at end of file | 23 | DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info" |
