Merge pull request #2471 from embassy-rs/remove-gpio-generics
gpio: remove generics.
This commit is contained in:
commit
c1ba008be4
60 changed files with 351 additions and 439 deletions
cyw43-pio/src
docs/modules/ROOT/examples
embassy-nrf/src
embassy-rp/src
embassy-stm32/src
examples
boot
.cargo
application
rp/.cargo
stm32f3/src/bin
stm32f7/src/bin
stm32h7/src/bin
stm32l0/src/bin
stm32l1/src/bin
stm32l4/src/bin
stm32wl/src/bin
bootloader/nrf/.cargo
nrf52840/src/bin
rp/src/bin
blinky_two_tasks.rsethernet_w5500_multisocket.rsethernet_w5500_tcp_client.rsethernet_w5500_tcp_server.rsethernet_w5500_udp.rsmulticore.rswifi_ap_tcp_server.rswifi_blinky.rswifi_scan.rswifi_tcp_server.rs
stm32c0/src/bin
stm32f0/src/bin
stm32f3/src/bin
stm32f4/src/bin
stm32f7/src/bin
stm32g0/src/bin
stm32g4/src/bin
stm32h5/src/bin
stm32h7/src/bin
stm32l0/src/bin
stm32l4/src/bin
stm32l5/src/bin
stm32wb/src/bin
stm32wba/src/bin
stm32wl/src/bin
tests
nrf/src/bin
rp
stm32/.cargo
|
@ -7,25 +7,24 @@ use core::slice;
|
|||
|
||||
use cyw43::SpiBusCyw43;
|
||||
use embassy_rp::dma::Channel;
|
||||
use embassy_rp::gpio::{Drive, Level, Output, Pin, Pull, SlewRate};
|
||||
use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate};
|
||||
use embassy_rp::pio::{instr, Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine};
|
||||
use embassy_rp::{Peripheral, PeripheralRef};
|
||||
use fixed::FixedU32;
|
||||
use pio_proc::pio_asm;
|
||||
|
||||
/// SPI comms driven by PIO.
|
||||
pub struct PioSpi<'d, CS: Pin, PIO: Instance, const SM: usize, DMA> {
|
||||
cs: Output<'d, CS>,
|
||||
pub struct PioSpi<'d, PIO: Instance, const SM: usize, DMA> {
|
||||
cs: Output<'d>,
|
||||
sm: StateMachine<'d, PIO, SM>,
|
||||
irq: Irq<'d, PIO, 0>,
|
||||
dma: PeripheralRef<'d, DMA>,
|
||||
wrap_target: u8,
|
||||
}
|
||||
|
||||
impl<'d, CS, PIO, const SM: usize, DMA> PioSpi<'d, CS, PIO, SM, DMA>
|
||||
impl<'d, PIO, const SM: usize, DMA> PioSpi<'d, PIO, SM, DMA>
|
||||
where
|
||||
DMA: Channel,
|
||||
CS: Pin,
|
||||
PIO: Instance,
|
||||
{
|
||||
/// Create a new instance of PioSpi.
|
||||
|
@ -33,7 +32,7 @@ where
|
|||
common: &mut Common<'d, PIO>,
|
||||
mut sm: StateMachine<'d, PIO, SM>,
|
||||
irq: Irq<'d, PIO, 0>,
|
||||
cs: Output<'d, CS>,
|
||||
cs: Output<'d>,
|
||||
dio: DIO,
|
||||
clk: CLK,
|
||||
dma: impl Peripheral<P = DMA> + 'd,
|
||||
|
@ -206,9 +205,8 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, CS, PIO, const SM: usize, DMA> SpiBusCyw43 for PioSpi<'d, CS, PIO, SM, DMA>
|
||||
impl<'d, PIO, const SM: usize, DMA> SpiBusCyw43 for PioSpi<'d, PIO, SM, DMA>
|
||||
where
|
||||
CS: Pin,
|
||||
PIO: Instance,
|
||||
DMA: Channel,
|
||||
{
|
||||
|
|
|
@ -4,12 +4,11 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_nrf::gpio::{Level, Output, OutputDrive};
|
||||
use embassy_nrf::peripherals::P0_13;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use {defmt_rtt as _, panic_probe as _}; // global logger
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) {
|
||||
async fn blinker(mut led: Output<'static>, interval: Duration) {
|
||||
loop {
|
||||
led.set_high();
|
||||
Timer::after(interval).await;
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh);
|
||||
let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||
|
||||
loop {
|
||||
button.wait_for_any_edge().await;
|
||||
|
|
|
@ -6,13 +6,12 @@ use core::cell::RefCell;
|
|||
use cortex_m::interrupt::Mutex;
|
||||
use cortex_m::peripheral::NVIC;
|
||||
use cortex_m_rt::entry;
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pin, Pull, Speed};
|
||||
use embassy_stm32::peripherals::{PB14, PC13};
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::{interrupt, pac};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
static BUTTON: Mutex<RefCell<Option<Input<'static, PC13>>>> = Mutex::new(RefCell::new(None));
|
||||
static LED: Mutex<RefCell<Option<Output<'static, PB14>>>> = Mutex::new(RefCell::new(None));
|
||||
static BUTTON: Mutex<RefCell<Option<Input<'static>>>> = Mutex::new(RefCell::new(None));
|
||||
static LED: Mutex<RefCell<Option<Output<'static>>>> = Mutex::new(RefCell::new(None));
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
|
@ -62,14 +61,14 @@ fn EXTI15_10() {
|
|||
|
||||
const PORT: u8 = 2;
|
||||
const PIN: usize = 13;
|
||||
fn check_interrupt<P: Pin>(_pin: &mut Input<'static, P>) -> bool {
|
||||
fn check_interrupt(_pin: &mut Input<'static>) -> bool {
|
||||
let exti = pac::EXTI;
|
||||
let pin = PIN;
|
||||
let lines = exti.pr(0).read();
|
||||
lines.line(pin)
|
||||
}
|
||||
|
||||
fn clear_interrupt<P: Pin>(_pin: &mut Input<'static, P>) {
|
||||
fn clear_interrupt(_pin: &mut Input<'static>) {
|
||||
let exti = pac::EXTI;
|
||||
let pin = PIN;
|
||||
let mut lines = exti.pr(0).read();
|
||||
|
@ -77,7 +76,7 @@ fn clear_interrupt<P: Pin>(_pin: &mut Input<'static, P>) {
|
|||
exti.pr(0).write_value(lines);
|
||||
}
|
||||
|
||||
fn enable_interrupt<P: Pin>(_pin: &mut Input<'static, P>) {
|
||||
fn enable_interrupt(_pin: &mut Input<'static>) {
|
||||
cortex_m::interrupt::free(|_| {
|
||||
let rcc = pac::RCC;
|
||||
rcc.apb2enr().modify(|w| w.set_syscfgen(true));
|
||||
|
|
|
@ -36,14 +36,14 @@ pub enum Pull {
|
|||
}
|
||||
|
||||
/// GPIO input driver.
|
||||
pub struct Input<'d, T: Pin> {
|
||||
pub(crate) pin: Flex<'d, T>,
|
||||
pub struct Input<'d> {
|
||||
pub(crate) pin: Flex<'d>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Input<'d, T> {
|
||||
impl<'d> Input<'d> {
|
||||
/// Create GPIO input driver for a [Pin] with the provided [Pull] configuration.
|
||||
#[inline]
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd, pull: Pull) -> Self {
|
||||
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, pull: Pull) -> Self {
|
||||
let mut pin = Flex::new(pin);
|
||||
pin.set_as_input(pull);
|
||||
|
||||
|
@ -122,14 +122,14 @@ pub enum OutputDrive {
|
|||
}
|
||||
|
||||
/// GPIO output driver.
|
||||
pub struct Output<'d, T: Pin> {
|
||||
pub(crate) pin: Flex<'d, T>,
|
||||
pub struct Output<'d> {
|
||||
pub(crate) pin: Flex<'d>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Output<'d, T> {
|
||||
impl<'d> Output<'d> {
|
||||
/// Create GPIO output driver for a [Pin] with the provided [Level] and [OutputDriver] configuration.
|
||||
#[inline]
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level, drive: OutputDrive) -> Self {
|
||||
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level, drive: OutputDrive) -> Self {
|
||||
let mut pin = Flex::new(pin);
|
||||
match initial_output {
|
||||
Level::High => pin.set_high(),
|
||||
|
@ -209,20 +209,20 @@ fn convert_pull(pull: Pull) -> PULL_A {
|
|||
/// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain
|
||||
/// set while not in output mode, so the pin's level will be 'remembered' when it is not in output
|
||||
/// mode.
|
||||
pub struct Flex<'d, T: Pin> {
|
||||
pub(crate) pin: PeripheralRef<'d, T>,
|
||||
pub struct Flex<'d> {
|
||||
pub(crate) pin: PeripheralRef<'d, AnyPin>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Flex<'d, T> {
|
||||
impl<'d> Flex<'d> {
|
||||
/// Wrap the pin in a `Flex`.
|
||||
///
|
||||
/// The pin remains disconnected. The initial output level is unspecified, but can be changed
|
||||
/// before the pin is put into output mode.
|
||||
#[inline]
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd) -> Self {
|
||||
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd) -> Self {
|
||||
into_ref!(pin);
|
||||
// Pin will be in disconnected state.
|
||||
Self { pin }
|
||||
Self { pin: pin.map_into() }
|
||||
}
|
||||
|
||||
/// Put the pin into input mode.
|
||||
|
@ -349,7 +349,7 @@ impl<'d, T: Pin> Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Drop for Flex<'d, T> {
|
||||
impl<'d> Drop for Flex<'d> {
|
||||
fn drop(&mut self) {
|
||||
self.pin.conf().reset();
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ macro_rules! impl_pin {
|
|||
mod eh02 {
|
||||
use super::*;
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::InputPin for Input<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||
|
@ -522,7 +522,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::OutputPin for Output<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -534,7 +534,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d> {
|
||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||
Ok(self.is_set_high())
|
||||
}
|
||||
|
@ -544,7 +544,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d> {
|
||||
type Error = Infallible;
|
||||
#[inline]
|
||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -556,7 +556,7 @@ mod eh02 {
|
|||
/// Implement [`embedded_hal_02::digital::v2::InputPin`] for [`Flex`];
|
||||
///
|
||||
/// If the pin is not in input mode the result is unspecified.
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::InputPin for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||
|
@ -568,7 +568,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::OutputPin for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -580,7 +580,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d> {
|
||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||
Ok(self.is_set_high())
|
||||
}
|
||||
|
@ -590,7 +590,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
#[inline]
|
||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -600,11 +600,11 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for Input<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::InputPin for Input<'d> {
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_high())
|
||||
}
|
||||
|
@ -614,11 +614,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> {
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(self.set_high())
|
||||
}
|
||||
|
@ -628,7 +628,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::StatefulOutputPin for Output<'d> {
|
||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_set_high())
|
||||
}
|
||||
|
@ -638,14 +638,14 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
/// Implement [`InputPin`] for [`Flex`];
|
||||
///
|
||||
/// If the pin is not in input mode the result is unspecified.
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> {
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_high())
|
||||
}
|
||||
|
@ -655,7 +655,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> {
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(self.set_high())
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::StatefulOutputPin for Flex<'d> {
|
||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_set_high())
|
||||
}
|
||||
|
|
|
@ -156,12 +156,12 @@ impl Iterator for BitIter {
|
|||
}
|
||||
|
||||
/// GPIOTE channel driver in input mode
|
||||
pub struct InputChannel<'d, C: Channel, T: GpioPin> {
|
||||
ch: PeripheralRef<'d, C>,
|
||||
pin: Input<'d, T>,
|
||||
pub struct InputChannel<'d> {
|
||||
ch: PeripheralRef<'d, AnyChannel>,
|
||||
pin: Input<'d>,
|
||||
}
|
||||
|
||||
impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> {
|
||||
impl<'d> Drop for InputChannel<'d> {
|
||||
fn drop(&mut self) {
|
||||
let g = regs();
|
||||
let num = self.ch.number();
|
||||
|
@ -170,9 +170,9 @@ impl<'d, C: Channel, T: GpioPin> Drop for InputChannel<'d, C, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> {
|
||||
impl<'d> InputChannel<'d> {
|
||||
/// Create a new GPIOTE input channel driver.
|
||||
pub fn new(ch: impl Peripheral<P = C> + 'd, pin: Input<'d, T>, polarity: InputChannelPolarity) -> Self {
|
||||
pub fn new(ch: impl Peripheral<P = impl Channel> + 'd, pin: Input<'d>, polarity: InputChannelPolarity) -> Self {
|
||||
into_ref!(ch);
|
||||
|
||||
let g = regs();
|
||||
|
@ -195,7 +195,7 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> {
|
|||
|
||||
g.events_in[num].reset();
|
||||
|
||||
InputChannel { ch, pin }
|
||||
InputChannel { ch: ch.map_into(), pin }
|
||||
}
|
||||
|
||||
/// Asynchronously wait for an event in this channel.
|
||||
|
@ -227,12 +227,12 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> {
|
|||
}
|
||||
|
||||
/// GPIOTE channel driver in output mode
|
||||
pub struct OutputChannel<'d, C: Channel, T: GpioPin> {
|
||||
ch: PeripheralRef<'d, C>,
|
||||
_pin: Output<'d, T>,
|
||||
pub struct OutputChannel<'d> {
|
||||
ch: PeripheralRef<'d, AnyChannel>,
|
||||
_pin: Output<'d>,
|
||||
}
|
||||
|
||||
impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> {
|
||||
impl<'d> Drop for OutputChannel<'d> {
|
||||
fn drop(&mut self) {
|
||||
let g = regs();
|
||||
let num = self.ch.number();
|
||||
|
@ -241,9 +241,9 @@ impl<'d, C: Channel, T: GpioPin> Drop for OutputChannel<'d, C, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> {
|
||||
impl<'d> OutputChannel<'d> {
|
||||
/// Create a new GPIOTE output channel driver.
|
||||
pub fn new(ch: impl Peripheral<P = C> + 'd, pin: Output<'d, T>, polarity: OutputChannelPolarity) -> Self {
|
||||
pub fn new(ch: impl Peripheral<P = impl Channel> + 'd, pin: Output<'d>, polarity: OutputChannelPolarity) -> Self {
|
||||
into_ref!(ch);
|
||||
let g = regs();
|
||||
let num = ch.number();
|
||||
|
@ -267,7 +267,10 @@ impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> {
|
|||
unsafe { w.psel().bits(pin.pin.pin.pin()) }
|
||||
});
|
||||
|
||||
OutputChannel { ch, _pin: pin }
|
||||
OutputChannel {
|
||||
ch: ch.map_into(),
|
||||
_pin: pin,
|
||||
}
|
||||
}
|
||||
|
||||
/// Triggers the OUT task (does the action as configured with task_out_polarity, defaults to Toggle).
|
||||
|
@ -348,7 +351,7 @@ impl<'a> Future for PortInputFuture<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: GpioPin> Input<'d, T> {
|
||||
impl<'d> Input<'d> {
|
||||
/// Wait until the pin is high. If it is already high, return immediately.
|
||||
pub async fn wait_for_high(&mut self) {
|
||||
self.pin.wait_for_high().await
|
||||
|
@ -375,7 +378,7 @@ impl<'d, T: GpioPin> Input<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: GpioPin> Flex<'d, T> {
|
||||
impl<'d> Flex<'d> {
|
||||
/// Wait until the pin is high. If it is already high, return immediately.
|
||||
pub async fn wait_for_high(&mut self) {
|
||||
self.pin.conf().modify(|_, w| w.sense().high());
|
||||
|
@ -420,7 +423,7 @@ mod sealed {
|
|||
/// GPIOTE channel trait.
|
||||
///
|
||||
/// Implemented by all GPIOTE channels.
|
||||
pub trait Channel: sealed::Channel + Sized {
|
||||
pub trait Channel: sealed::Channel + Into<AnyChannel> + Sized + 'static {
|
||||
/// Get the channel number.
|
||||
fn number(&self) -> usize;
|
||||
|
||||
|
@ -460,6 +463,12 @@ macro_rules! impl_channel {
|
|||
$number as usize
|
||||
}
|
||||
}
|
||||
|
||||
impl From<peripherals::$type> for AnyChannel {
|
||||
fn from(val: peripherals::$type) -> Self {
|
||||
Channel::degrade(val)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -477,7 +486,7 @@ impl_channel!(GPIOTE_CH7, 7);
|
|||
mod eh02 {
|
||||
use super::*;
|
||||
|
||||
impl<'d, C: Channel, T: GpioPin> embedded_hal_02::digital::v2::InputPin for InputChannel<'d, C, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::InputPin for InputChannel<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||
|
@ -490,11 +499,11 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::ErrorType for InputChannel<'d, C, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for InputChannel<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> {
|
||||
impl<'d> embedded_hal_1::digital::InputPin for InputChannel<'d> {
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok(self.pin.is_high())
|
||||
}
|
||||
|
@ -504,7 +513,7 @@ impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChan
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> {
|
||||
impl<'d> embedded_hal_async::digital::Wait for Input<'d> {
|
||||
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(self.wait_for_high().await)
|
||||
}
|
||||
|
@ -526,7 +535,7 @@ impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_async::digital::Wait for Flex<'d> {
|
||||
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(self.wait_for_high().await)
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use core::task::{Context, Poll};
|
|||
use embassy_hal_internal::{impl_peripheral, into_ref, PeripheralRef};
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
|
||||
use self::sealed::Pin as _;
|
||||
use crate::interrupt::InterruptExt;
|
||||
use crate::pac::common::{Reg, RW};
|
||||
use crate::pac::SIO;
|
||||
|
@ -105,14 +106,14 @@ pub struct DormantWakeConfig {
|
|||
}
|
||||
|
||||
/// GPIO input driver.
|
||||
pub struct Input<'d, T: Pin> {
|
||||
pin: Flex<'d, T>,
|
||||
pub struct Input<'d> {
|
||||
pin: Flex<'d>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Input<'d, T> {
|
||||
impl<'d> Input<'d> {
|
||||
/// Create GPIO input driver for a [Pin] with the provided [Pull] configuration.
|
||||
#[inline]
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd, pull: Pull) -> Self {
|
||||
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, pull: Pull) -> Self {
|
||||
let mut pin = Flex::new(pin);
|
||||
pin.set_as_input();
|
||||
pin.set_pull(pull);
|
||||
|
@ -175,7 +176,7 @@ impl<'d, T: Pin> Input<'d, T> {
|
|||
|
||||
/// Configure dormant wake.
|
||||
#[inline]
|
||||
pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake<T> {
|
||||
pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake<'_> {
|
||||
self.pin.dormant_wake(cfg)
|
||||
}
|
||||
}
|
||||
|
@ -255,14 +256,12 @@ fn IO_IRQ_QSPI() {
|
|||
}
|
||||
|
||||
#[must_use = "futures do nothing unless you `.await` or poll them"]
|
||||
struct InputFuture<'a, T: Pin> {
|
||||
pin: PeripheralRef<'a, T>,
|
||||
struct InputFuture<'d> {
|
||||
pin: PeripheralRef<'d, AnyPin>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> InputFuture<'d, T> {
|
||||
/// Create a new future wiating for input trigger.
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd, level: InterruptTrigger) -> Self {
|
||||
into_ref!(pin);
|
||||
impl<'d> InputFuture<'d> {
|
||||
fn new(pin: PeripheralRef<'d, AnyPin>, level: InterruptTrigger) -> Self {
|
||||
let pin_group = (pin.pin() % 8) as usize;
|
||||
// first, clear the INTR register bits. without this INTR will still
|
||||
// contain reports of previous edges, causing the IRQ to fire early
|
||||
|
@ -305,7 +304,7 @@ impl<'d, T: Pin> InputFuture<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Future for InputFuture<'d, T> {
|
||||
impl<'d> Future for InputFuture<'d> {
|
||||
type Output = ();
|
||||
|
||||
fn poll(self: FuturePin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||
|
@ -344,14 +343,14 @@ impl<'d, T: Pin> Future for InputFuture<'d, T> {
|
|||
}
|
||||
|
||||
/// GPIO output driver.
|
||||
pub struct Output<'d, T: Pin> {
|
||||
pin: Flex<'d, T>,
|
||||
pub struct Output<'d> {
|
||||
pin: Flex<'d>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Output<'d, T> {
|
||||
impl<'d> Output<'d> {
|
||||
/// Create GPIO output driver for a [Pin] with the provided [Level].
|
||||
#[inline]
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level) -> Self {
|
||||
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level) -> Self {
|
||||
let mut pin = Flex::new(pin);
|
||||
match initial_output {
|
||||
Level::High => pin.set_high(),
|
||||
|
@ -418,14 +417,14 @@ impl<'d, T: Pin> Output<'d, T> {
|
|||
}
|
||||
|
||||
/// GPIO output open-drain.
|
||||
pub struct OutputOpenDrain<'d, T: Pin> {
|
||||
pin: Flex<'d, T>,
|
||||
pub struct OutputOpenDrain<'d> {
|
||||
pin: Flex<'d>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> OutputOpenDrain<'d, T> {
|
||||
impl<'d> OutputOpenDrain<'d> {
|
||||
/// Create GPIO output driver for a [Pin] in open drain mode with the provided [Level].
|
||||
#[inline]
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level) -> Self {
|
||||
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level) -> Self {
|
||||
let mut pin = Flex::new(pin);
|
||||
pin.set_low();
|
||||
match initial_output {
|
||||
|
@ -548,17 +547,17 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
|
|||
/// This pin can be either an input or output pin. The output level register bit will remain
|
||||
/// set while not in output mode, so the pin's level will be 'remembered' when it is not in output
|
||||
/// mode.
|
||||
pub struct Flex<'d, T: Pin> {
|
||||
pin: PeripheralRef<'d, T>,
|
||||
pub struct Flex<'d> {
|
||||
pin: PeripheralRef<'d, AnyPin>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Flex<'d, T> {
|
||||
impl<'d> Flex<'d> {
|
||||
/// Wrap the pin in a `Flex`.
|
||||
///
|
||||
/// The pin remains disconnected. The initial output level is unspecified, but can be changed
|
||||
/// before the pin is put into output mode.
|
||||
#[inline]
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd) -> Self {
|
||||
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd) -> Self {
|
||||
into_ref!(pin);
|
||||
|
||||
pin.pad_ctrl().write(|w| {
|
||||
|
@ -569,7 +568,7 @@ impl<'d, T: Pin> Flex<'d, T> {
|
|||
w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::SIO_0 as _);
|
||||
});
|
||||
|
||||
Self { pin }
|
||||
Self { pin: pin.map_into() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -716,36 +715,36 @@ impl<'d, T: Pin> Flex<'d, T> {
|
|||
/// Wait until the pin is high. If it is already high, return immediately.
|
||||
#[inline]
|
||||
pub async fn wait_for_high(&mut self) {
|
||||
InputFuture::new(&mut self.pin, InterruptTrigger::LevelHigh).await;
|
||||
InputFuture::new(self.pin.reborrow(), InterruptTrigger::LevelHigh).await;
|
||||
}
|
||||
|
||||
/// Wait until the pin is low. If it is already low, return immediately.
|
||||
#[inline]
|
||||
pub async fn wait_for_low(&mut self) {
|
||||
InputFuture::new(&mut self.pin, InterruptTrigger::LevelLow).await;
|
||||
InputFuture::new(self.pin.reborrow(), InterruptTrigger::LevelLow).await;
|
||||
}
|
||||
|
||||
/// Wait for the pin to undergo a transition from low to high.
|
||||
#[inline]
|
||||
pub async fn wait_for_rising_edge(&mut self) {
|
||||
InputFuture::new(&mut self.pin, InterruptTrigger::EdgeHigh).await;
|
||||
InputFuture::new(self.pin.reborrow(), InterruptTrigger::EdgeHigh).await;
|
||||
}
|
||||
|
||||
/// Wait for the pin to undergo a transition from high to low.
|
||||
#[inline]
|
||||
pub async fn wait_for_falling_edge(&mut self) {
|
||||
InputFuture::new(&mut self.pin, InterruptTrigger::EdgeLow).await;
|
||||
InputFuture::new(self.pin.reborrow(), InterruptTrigger::EdgeLow).await;
|
||||
}
|
||||
|
||||
/// Wait for the pin to undergo any transition, i.e low to high OR high to low.
|
||||
#[inline]
|
||||
pub async fn wait_for_any_edge(&mut self) {
|
||||
InputFuture::new(&mut self.pin, InterruptTrigger::AnyEdge).await;
|
||||
InputFuture::new(self.pin.reborrow(), InterruptTrigger::AnyEdge).await;
|
||||
}
|
||||
|
||||
/// Configure dormant wake.
|
||||
#[inline]
|
||||
pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake<T> {
|
||||
pub fn dormant_wake(&mut self, cfg: DormantWakeConfig) -> DormantWake<'_> {
|
||||
let idx = self.pin._pin() as usize;
|
||||
self.pin.io().intr(idx / 8).write(|w| {
|
||||
w.set_edge_high(idx % 8, cfg.edge_high);
|
||||
|
@ -764,7 +763,7 @@ impl<'d, T: Pin> Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Drop for Flex<'d, T> {
|
||||
impl<'d> Drop for Flex<'d> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
let idx = self.pin._pin() as usize;
|
||||
|
@ -782,12 +781,12 @@ impl<'d, T: Pin> Drop for Flex<'d, T> {
|
|||
}
|
||||
|
||||
/// Dormant wake driver.
|
||||
pub struct DormantWake<'w, T: Pin> {
|
||||
pin: PeripheralRef<'w, T>,
|
||||
pub struct DormantWake<'w> {
|
||||
pin: PeripheralRef<'w, AnyPin>,
|
||||
cfg: DormantWakeConfig,
|
||||
}
|
||||
|
||||
impl<'w, T: Pin> Drop for DormantWake<'w, T> {
|
||||
impl<'w> Drop for DormantWake<'w> {
|
||||
fn drop(&mut self) {
|
||||
let idx = self.pin._pin() as usize;
|
||||
self.pin.io().intr(idx / 8).write(|w| {
|
||||
|
@ -970,7 +969,7 @@ mod eh02 {
|
|||
|
||||
use super::*;
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::InputPin for Input<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||
|
@ -982,7 +981,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::OutputPin for Output<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -994,7 +993,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d> {
|
||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||
Ok(self.is_set_high())
|
||||
}
|
||||
|
@ -1004,7 +1003,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d> {
|
||||
type Error = Infallible;
|
||||
#[inline]
|
||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -1012,7 +1011,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::InputPin for OutputOpenDrain<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||
|
@ -1024,7 +1023,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
#[inline]
|
||||
|
@ -1038,7 +1037,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d> {
|
||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||
Ok(self.is_set_high())
|
||||
}
|
||||
|
@ -1048,7 +1047,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d> {
|
||||
type Error = Infallible;
|
||||
#[inline]
|
||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -1056,7 +1055,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::InputPin for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||
|
@ -1068,7 +1067,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::OutputPin for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -1080,7 +1079,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d> {
|
||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||
Ok(self.is_set_high())
|
||||
}
|
||||
|
@ -1090,7 +1089,7 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
#[inline]
|
||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -1099,11 +1098,11 @@ mod eh02 {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for Input<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::InputPin for Input<'d> {
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_high())
|
||||
}
|
||||
|
@ -1113,11 +1112,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> {
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(self.set_high())
|
||||
}
|
||||
|
@ -1127,7 +1126,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::StatefulOutputPin for Output<'d> {
|
||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_set_high())
|
||||
}
|
||||
|
@ -1137,11 +1136,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d> {
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(self.set_high())
|
||||
}
|
||||
|
@ -1151,7 +1150,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d> {
|
||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_set_high())
|
||||
}
|
||||
|
@ -1161,7 +1160,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d> {
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_high())
|
||||
}
|
||||
|
@ -1171,11 +1170,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> {
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_high())
|
||||
}
|
||||
|
@ -1185,7 +1184,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> {
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(self.set_high())
|
||||
}
|
||||
|
@ -1195,7 +1194,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::StatefulOutputPin for Flex<'d> {
|
||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_set_high())
|
||||
}
|
||||
|
@ -1205,7 +1204,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_async::digital::Wait for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_async::digital::Wait for Flex<'d> {
|
||||
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
|
||||
self.wait_for_high().await;
|
||||
Ok(())
|
||||
|
@ -1232,7 +1231,7 @@ impl<'d, T: Pin> embedded_hal_async::digital::Wait for Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_async::digital::Wait for Input<'d, T> {
|
||||
impl<'d> embedded_hal_async::digital::Wait for Input<'d> {
|
||||
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
|
||||
self.wait_for_high().await;
|
||||
Ok(())
|
||||
|
@ -1259,7 +1258,7 @@ impl<'d, T: Pin> embedded_hal_async::digital::Wait for Input<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_async::digital::Wait for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_async::digital::Wait for OutputOpenDrain<'d> {
|
||||
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
|
||||
self.wait_for_high().await;
|
||||
Ok(())
|
||||
|
|
|
@ -5,10 +5,10 @@ use core::marker::PhantomData;
|
|||
use core::pin::Pin;
|
||||
use core::task::{Context, Poll};
|
||||
|
||||
use embassy_hal_internal::impl_peripheral;
|
||||
use embassy_hal_internal::{impl_peripheral, into_ref};
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
|
||||
use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin};
|
||||
use crate::gpio::{AnyPin, Input, Level, Pin as GpioPin, Pull};
|
||||
use crate::pac::exti::regs::Lines;
|
||||
use crate::pac::EXTI;
|
||||
use crate::{interrupt, pac, peripherals, Peripheral};
|
||||
|
@ -93,16 +93,27 @@ impl Iterator for BitIter {
|
|||
/// EXTI channel, which is a limited resource.
|
||||
///
|
||||
/// Pins PA5, PB5, PC5... all use EXTI channel 5, so you can't use EXTI on, say, PA5 and PC5 at the same time.
|
||||
pub struct ExtiInput<'d, T: GpioPin> {
|
||||
pin: Input<'d, T>,
|
||||
pub struct ExtiInput<'d> {
|
||||
pin: Input<'d>,
|
||||
}
|
||||
|
||||
impl<'d, T: GpioPin> Unpin for ExtiInput<'d, T> {}
|
||||
impl<'d> Unpin for ExtiInput<'d> {}
|
||||
|
||||
impl<'d, T: GpioPin> ExtiInput<'d, T> {
|
||||
impl<'d> ExtiInput<'d> {
|
||||
/// Create an EXTI input.
|
||||
pub fn new(pin: Input<'d, T>, _ch: impl Peripheral<P = T::ExtiChannel> + 'd) -> Self {
|
||||
Self { pin }
|
||||
pub fn new<T: GpioPin>(
|
||||
pin: impl Peripheral<P = T> + 'd,
|
||||
ch: impl Peripheral<P = T::ExtiChannel> + 'd,
|
||||
pull: Pull,
|
||||
) -> Self {
|
||||
into_ref!(pin, ch);
|
||||
|
||||
// Needed if using AnyPin+AnyChannel.
|
||||
assert_eq!(pin.pin(), ch.number());
|
||||
|
||||
Self {
|
||||
pin: Input::new(pin, pull),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get whether the pin is high.
|
||||
|
@ -162,7 +173,7 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||
|
@ -174,11 +185,11 @@ impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T>
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: GpioPin> embedded_hal_1::digital::ErrorType for ExtiInput<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for ExtiInput<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::InputPin for ExtiInput<'d> {
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_high())
|
||||
}
|
||||
|
@ -188,7 +199,7 @@ impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for ExtiInput<'d, T> {
|
||||
impl<'d> embedded_hal_async::digital::Wait for ExtiInput<'d> {
|
||||
async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
|
||||
self.wait_for_high().await;
|
||||
Ok(())
|
||||
|
@ -326,7 +337,7 @@ pub(crate) mod sealed {
|
|||
/// EXTI channel trait.
|
||||
pub trait Channel: sealed::Channel + Sized {
|
||||
/// Get the EXTI channel number.
|
||||
fn number(&self) -> usize;
|
||||
fn number(&self) -> u8;
|
||||
|
||||
/// Type-erase (degrade) this channel into an `AnyChannel`.
|
||||
///
|
||||
|
@ -350,8 +361,8 @@ pub struct AnyChannel {
|
|||
impl_peripheral!(AnyChannel);
|
||||
impl sealed::Channel for AnyChannel {}
|
||||
impl Channel for AnyChannel {
|
||||
fn number(&self) -> usize {
|
||||
self.number as usize
|
||||
fn number(&self) -> u8 {
|
||||
self.number
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,8 +370,8 @@ macro_rules! impl_exti {
|
|||
($type:ident, $number:expr) => {
|
||||
impl sealed::Channel for peripherals::$type {}
|
||||
impl Channel for peripherals::$type {
|
||||
fn number(&self) -> usize {
|
||||
$number as usize
|
||||
fn number(&self) -> u8 {
|
||||
$number
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -6,6 +6,7 @@ use core::convert::Infallible;
|
|||
use critical_section::CriticalSection;
|
||||
use embassy_hal_internal::{impl_peripheral, into_ref, PeripheralRef};
|
||||
|
||||
use self::sealed::Pin as _;
|
||||
use crate::pac::gpio::{self, vals};
|
||||
use crate::{pac, peripherals, Peripheral};
|
||||
|
||||
|
@ -14,41 +15,21 @@ use crate::{pac, peripherals, Peripheral};
|
|||
/// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain
|
||||
/// set while not in output mode, so the pin's level will be 'remembered' when it is not in output
|
||||
/// mode.
|
||||
pub struct Flex<'d, T: Pin> {
|
||||
pub(crate) pin: PeripheralRef<'d, T>,
|
||||
pub struct Flex<'d> {
|
||||
pub(crate) pin: PeripheralRef<'d, AnyPin>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Flex<'d, T> {
|
||||
impl<'d> Flex<'d> {
|
||||
/// Wrap the pin in a `Flex`.
|
||||
///
|
||||
/// The pin remains disconnected. The initial output level is unspecified, but can be changed
|
||||
/// before the pin is put into output mode.
|
||||
///
|
||||
#[inline]
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd) -> Self {
|
||||
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd) -> Self {
|
||||
into_ref!(pin);
|
||||
// Pin will be in disconnected state.
|
||||
Self { pin }
|
||||
}
|
||||
|
||||
/// Type-erase (degrade) this pin into an `AnyPin`.
|
||||
///
|
||||
/// This converts pin singletons (`PA5`, `PB6`, ...), which
|
||||
/// are all different types, into the same type. It is useful for
|
||||
/// creating arrays of pins, or avoiding generics.
|
||||
#[inline]
|
||||
pub fn degrade(self) -> Flex<'d, AnyPin> {
|
||||
// Safety: We are about to drop the other copy of this pin, so
|
||||
// this clone is safe.
|
||||
let pin = unsafe { self.pin.clone_unchecked() };
|
||||
|
||||
// We don't want to run the destructor here, because that would
|
||||
// deconfigure the pin.
|
||||
core::mem::forget(self);
|
||||
|
||||
Flex {
|
||||
pin: pin.map_into::<AnyPin>(),
|
||||
}
|
||||
Self { pin: pin.map_into() }
|
||||
}
|
||||
|
||||
/// Put the pin into input mode.
|
||||
|
@ -218,7 +199,7 @@ impl<'d, T: Pin> Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Drop for Flex<'d, T> {
|
||||
impl<'d> Drop for Flex<'d> {
|
||||
#[inline]
|
||||
fn drop(&mut self) {
|
||||
critical_section::with(|_| {
|
||||
|
@ -309,31 +290,19 @@ impl From<Speed> for vals::Ospeedr {
|
|||
}
|
||||
|
||||
/// GPIO input driver.
|
||||
pub struct Input<'d, T: Pin> {
|
||||
pub(crate) pin: Flex<'d, T>,
|
||||
pub struct Input<'d> {
|
||||
pub(crate) pin: Flex<'d>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Input<'d, T> {
|
||||
impl<'d> Input<'d> {
|
||||
/// Create GPIO input driver for a [Pin] with the provided [Pull] configuration.
|
||||
#[inline]
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd, pull: Pull) -> Self {
|
||||
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, pull: Pull) -> Self {
|
||||
let mut pin = Flex::new(pin);
|
||||
pin.set_as_input(pull);
|
||||
Self { pin }
|
||||
}
|
||||
|
||||
/// Type-erase (degrade) this pin into an `AnyPin`.
|
||||
///
|
||||
/// This converts pin singletons (`PA5`, `PB6`, ...), which
|
||||
/// are all different types, into the same type. It is useful for
|
||||
/// creating arrays of pins, or avoiding generics.
|
||||
#[inline]
|
||||
pub fn degrade(self) -> Input<'d, AnyPin> {
|
||||
Input {
|
||||
pin: self.pin.degrade(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get whether the pin input level is high.
|
||||
#[inline]
|
||||
pub fn is_high(&self) -> bool {
|
||||
|
@ -386,14 +355,14 @@ impl From<Level> for bool {
|
|||
/// Note that pins will **return to their floating state** when `Output` is dropped.
|
||||
/// If pins should retain their state indefinitely, either keep ownership of the
|
||||
/// `Output`, or pass it to [`core::mem::forget`].
|
||||
pub struct Output<'d, T: Pin> {
|
||||
pub(crate) pin: Flex<'d, T>,
|
||||
pub struct Output<'d> {
|
||||
pub(crate) pin: Flex<'d>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> Output<'d, T> {
|
||||
impl<'d> Output<'d> {
|
||||
/// Create GPIO output driver for a [Pin] with the provided [Level] and [Speed] configuration.
|
||||
#[inline]
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level, speed: Speed) -> Self {
|
||||
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level, speed: Speed) -> Self {
|
||||
let mut pin = Flex::new(pin);
|
||||
match initial_output {
|
||||
Level::High => pin.set_high(),
|
||||
|
@ -403,18 +372,6 @@ impl<'d, T: Pin> Output<'d, T> {
|
|||
Self { pin }
|
||||
}
|
||||
|
||||
/// Type-erase (degrade) this pin into an `AnyPin`.
|
||||
///
|
||||
/// This converts pin singletons (`PA5`, `PB6`, ...), which
|
||||
/// are all different types, into the same type. It is useful for
|
||||
/// creating arrays of pins, or avoiding generics.
|
||||
#[inline]
|
||||
pub fn degrade(self) -> Output<'d, AnyPin> {
|
||||
Output {
|
||||
pin: self.pin.degrade(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Set the output as high.
|
||||
#[inline]
|
||||
pub fn set_high(&mut self) {
|
||||
|
@ -463,14 +420,14 @@ impl<'d, T: Pin> Output<'d, T> {
|
|||
/// Note that pins will **return to their floating state** when `OutputOpenDrain` is dropped.
|
||||
/// If pins should retain their state indefinitely, either keep ownership of the
|
||||
/// `OutputOpenDrain`, or pass it to [`core::mem::forget`].
|
||||
pub struct OutputOpenDrain<'d, T: Pin> {
|
||||
pub(crate) pin: Flex<'d, T>,
|
||||
pub struct OutputOpenDrain<'d> {
|
||||
pub(crate) pin: Flex<'d>,
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> OutputOpenDrain<'d, T> {
|
||||
impl<'d> OutputOpenDrain<'d> {
|
||||
/// Create a new GPIO open drain output driver for a [Pin] with the provided [Level] and [Speed], [Pull] configuration.
|
||||
#[inline]
|
||||
pub fn new(pin: impl Peripheral<P = T> + 'd, initial_output: Level, speed: Speed, pull: Pull) -> Self {
|
||||
pub fn new(pin: impl Peripheral<P = impl Pin> + 'd, initial_output: Level, speed: Speed, pull: Pull) -> Self {
|
||||
let mut pin = Flex::new(pin);
|
||||
|
||||
match initial_output {
|
||||
|
@ -482,18 +439,6 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
|
|||
Self { pin }
|
||||
}
|
||||
|
||||
/// Type-erase (degrade) this pin into an `AnyPin`.
|
||||
///
|
||||
/// This converts pin singletons (`PA5`, `PB6`, ...), which
|
||||
/// are all different types, into the same type. It is useful for
|
||||
/// creating arrays of pins, or avoiding generics.
|
||||
#[inline]
|
||||
pub fn degrade(self) -> Output<'d, AnyPin> {
|
||||
Output {
|
||||
pin: self.pin.degrade(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get whether the pin input level is high.
|
||||
#[inline]
|
||||
pub fn is_high(&self) -> bool {
|
||||
|
@ -836,7 +781,7 @@ pub(crate) unsafe fn init(_cs: CriticalSection) {
|
|||
});
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::InputPin for Input<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
#[inline]
|
||||
|
@ -850,7 +795,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Input<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::OutputPin for Output<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
#[inline]
|
||||
|
@ -866,7 +811,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Output<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d> {
|
||||
#[inline]
|
||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||
Ok(self.is_set_high())
|
||||
|
@ -879,7 +824,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Output<'d,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d> {
|
||||
type Error = Infallible;
|
||||
#[inline]
|
||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -888,7 +833,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Output<'d
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
#[inline]
|
||||
|
@ -904,7 +849,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d> {
|
||||
#[inline]
|
||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||
Ok(self.is_set_high())
|
||||
|
@ -917,7 +862,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenD
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d> {
|
||||
type Error = Infallible;
|
||||
#[inline]
|
||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -926,7 +871,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpe
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::InputPin for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
#[inline]
|
||||
|
@ -940,7 +885,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::OutputPin for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
|
||||
#[inline]
|
||||
|
@ -956,7 +901,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d> {
|
||||
#[inline]
|
||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||
Ok(self.is_set_high())
|
||||
|
@ -969,7 +914,7 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for Flex<'d, T>
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
#[inline]
|
||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||
|
@ -978,11 +923,11 @@ impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for Flex<'d,
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Input<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for Input<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::InputPin for Input<'d> {
|
||||
#[inline]
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_high())
|
||||
|
@ -994,11 +939,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Output<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for Output<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::OutputPin for Output<'d> {
|
||||
#[inline]
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(self.set_high())
|
||||
|
@ -1010,7 +955,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::StatefulOutputPin for Output<'d> {
|
||||
#[inline]
|
||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_set_high())
|
||||
|
@ -1023,11 +968,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for OutputOpenDrain<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d> {
|
||||
#[inline]
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_high())
|
||||
|
@ -1039,7 +984,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d> {
|
||||
#[inline]
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(self.set_high())
|
||||
|
@ -1051,7 +996,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d> {
|
||||
#[inline]
|
||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_set_high())
|
||||
|
@ -1064,7 +1009,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::InputPin for Flex<'d> {
|
||||
#[inline]
|
||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_high())
|
||||
|
@ -1076,7 +1021,7 @@ impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::OutputPin for Flex<'d> {
|
||||
#[inline]
|
||||
fn set_high(&mut self) -> Result<(), Self::Error> {
|
||||
Ok(self.set_high())
|
||||
|
@ -1088,11 +1033,11 @@ impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::ErrorType for Flex<'d> {
|
||||
type Error = Infallible;
|
||||
}
|
||||
|
||||
impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
|
||||
impl<'d> embedded_hal_1::digital::StatefulOutputPin for Flex<'d> {
|
||||
#[inline]
|
||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||
Ok((*self).is_set_high())
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[unstable]
|
||||
build-std = ["core"]
|
||||
build-std-features = ["panic_immediate_abort"]
|
||||
#build-std = ["core"]
|
||||
#build-std-features = ["panic_immediate_abort"]
|
||||
|
||||
[build]
|
||||
target = "thumbv7em-none-eabi"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[unstable]
|
||||
build-std = ["core"]
|
||||
build-std-features = ["panic_immediate_abort"]
|
||||
#build-std = ["core"]
|
||||
#build-std-features = ["panic_immediate_abort"]
|
||||
|
||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
runner = "probe-rs run --chip RP2040"
|
||||
|
|
|
@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync;
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||
use embassy_sync::mutex::Mutex;
|
||||
use panic_reset as _;
|
||||
|
||||
|
@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) {
|
|||
let flash = Flash::new_blocking(p.FLASH);
|
||||
let flash = Mutex::new(BlockingAsync::new(flash));
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||
|
||||
let mut led = Output::new(p.PA5, Level::Low, Speed::Low);
|
||||
led.set_high();
|
||||
|
|
|
@ -9,7 +9,7 @@ use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdater
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||
use embassy_sync::blocking_mutex::Mutex;
|
||||
use embedded_storage::nor_flash::NorFlash;
|
||||
use panic_reset as _;
|
||||
|
@ -25,8 +25,7 @@ async fn main(_spawner: Spawner) {
|
|||
let flash = Flash::new_blocking(p.FLASH);
|
||||
let flash = Mutex::new(RefCell::new(flash));
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Down);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||
|
||||
let mut led = Output::new(p.PB7, Level::Low, Speed::Low);
|
||||
led.set_high();
|
||||
|
|
|
@ -9,7 +9,7 @@ use embassy_boot_stm32::{AlignedBuffer, BlockingFirmwareUpdater, FirmwareUpdater
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||
use embassy_sync::blocking_mutex::Mutex;
|
||||
use embedded_storage::nor_flash::NorFlash;
|
||||
use panic_reset as _;
|
||||
|
@ -25,8 +25,7 @@ async fn main(_spawner: Spawner) {
|
|||
let flash = Flash::new_blocking(p.FLASH);
|
||||
let flash = Mutex::new(RefCell::new(flash));
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Down);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||
|
||||
let mut led = Output::new(p.PB14, Level::Low, Speed::Low);
|
||||
led.set_high();
|
||||
|
|
|
@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync;
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||
use embassy_sync::mutex::Mutex;
|
||||
use embassy_time::Timer;
|
||||
use panic_reset as _;
|
||||
|
@ -24,8 +24,7 @@ async fn main(_spawner: Spawner) {
|
|||
let flash = Flash::new_blocking(p.FLASH);
|
||||
let flash = Mutex::new(BlockingAsync::new(flash));
|
||||
|
||||
let button = Input::new(p.PB2, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI2);
|
||||
let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up);
|
||||
|
||||
let mut led = Output::new(p.PB5, Level::Low, Speed::Low);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync;
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||
use embassy_sync::mutex::Mutex;
|
||||
use embassy_time::Timer;
|
||||
use panic_reset as _;
|
||||
|
@ -24,8 +24,7 @@ async fn main(_spawner: Spawner) {
|
|||
let flash = Flash::new_blocking(p.FLASH);
|
||||
let flash = Mutex::new(BlockingAsync::new(flash));
|
||||
|
||||
let button = Input::new(p.PB2, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI2);
|
||||
let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up);
|
||||
|
||||
let mut led = Output::new(p.PB5, Level::Low, Speed::Low);
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync;
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||
use embassy_sync::mutex::Mutex;
|
||||
use panic_reset as _;
|
||||
|
||||
|
@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) {
|
|||
let flash = Flash::new_blocking(p.FLASH);
|
||||
let flash = Mutex::new(BlockingAsync::new(flash));
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||
|
||||
let mut led = Output::new(p.PB14, Level::Low, Speed::Low);
|
||||
led.set_high();
|
||||
|
|
|
@ -8,7 +8,7 @@ use embassy_embedded_hal::adapter::BlockingAsync;
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::flash::{Flash, WRITE_SIZE};
|
||||
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||
use embassy_sync::mutex::Mutex;
|
||||
use panic_reset as _;
|
||||
|
||||
|
@ -23,8 +23,7 @@ async fn main(_spawner: Spawner) {
|
|||
let flash = Flash::new_blocking(p.FLASH);
|
||||
let flash = Mutex::new(BlockingAsync::new(flash));
|
||||
|
||||
let button = Input::new(p.PA0, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI0);
|
||||
let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up);
|
||||
|
||||
let mut led = Output::new(p.PB9, Level::Low, Speed::Low);
|
||||
led.set_high();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[unstable]
|
||||
build-std = ["core"]
|
||||
build-std-features = ["panic_immediate_abort"]
|
||||
#build-std = ["core"]
|
||||
#build-std-features = ["panic_immediate_abort"]
|
||||
|
||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
#runner = "./fruitrunner"
|
||||
|
@ -8,7 +8,7 @@ runner = "probe-rs run --chip nrf52840_xxAA"
|
|||
|
||||
rustflags = [
|
||||
# Code-size optimizations.
|
||||
"-Z", "trap-unreachable=no",
|
||||
#"-Z", "trap-unreachable=no",
|
||||
#"-C", "no-vectorize-loops",
|
||||
"-C", "force-frame-pointers=yes",
|
||||
]
|
||||
|
|
|
@ -24,10 +24,7 @@ bind_interrupts!(struct Irqs {
|
|||
#[embassy_executor::task]
|
||||
async fn net_task(
|
||||
stack: &'static Stack<
|
||||
Enc28j60<
|
||||
ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>,
|
||||
Output<'static, peripherals::P0_13>,
|
||||
>,
|
||||
Enc28j60<ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, Output<'static>>,
|
||||
>,
|
||||
) -> ! {
|
||||
stack.run().await
|
||||
|
@ -71,12 +68,7 @@ async fn main(spawner: Spawner) {
|
|||
// Init network stack
|
||||
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
|
||||
static STACK: StaticCell<
|
||||
Stack<
|
||||
Enc28j60<
|
||||
ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>,
|
||||
Output<'static, peripherals::P0_13>,
|
||||
>,
|
||||
>,
|
||||
Stack<Enc28j60<ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, Output<'static>>>,
|
||||
> = StaticCell::new();
|
||||
let stack = STACK.init(Stack::new(
|
||||
device,
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
use defmt::{info, unwrap};
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_nrf::gpio::{AnyPin, Input, Pin as _, Pull};
|
||||
use embassy_nrf::gpio::{Input, Pull};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::task(pool_size = 4)]
|
||||
async fn button_task(n: usize, mut pin: Input<'static, AnyPin>) {
|
||||
async fn button_task(n: usize, mut pin: Input<'static>) {
|
||||
loop {
|
||||
pin.wait_for_low().await;
|
||||
info!("Button {:?} pressed!", n);
|
||||
|
@ -21,10 +21,10 @@ async fn main(spawner: Spawner) {
|
|||
let p = embassy_nrf::init(Default::default());
|
||||
info!("Starting!");
|
||||
|
||||
let btn1 = Input::new(p.P0_11.degrade(), Pull::Up);
|
||||
let btn2 = Input::new(p.P0_12.degrade(), Pull::Up);
|
||||
let btn3 = Input::new(p.P0_24.degrade(), Pull::Up);
|
||||
let btn4 = Input::new(p.P0_25.degrade(), Pull::Up);
|
||||
let btn1 = Input::new(p.P0_11, Pull::Up);
|
||||
let btn2 = Input::new(p.P0_12, Pull::Up);
|
||||
let btn3 = Input::new(p.P0_24, Pull::Up);
|
||||
let btn4 = Input::new(p.P0_25, Pull::Up);
|
||||
|
||||
unwrap!(spawner.spawn(button_task(1, btn1)));
|
||||
unwrap!(spawner.spawn(button_task(2, btn2)));
|
||||
|
|
|
@ -8,7 +8,7 @@ use defmt::*;
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_futures::join::join;
|
||||
use embassy_futures::select::{select, Either};
|
||||
use embassy_nrf::gpio::{Input, Pin, Pull};
|
||||
use embassy_nrf::gpio::{Input, Pull};
|
||||
use embassy_nrf::usb::vbus_detect::HardwareVbusDetect;
|
||||
use embassy_nrf::usb::Driver;
|
||||
use embassy_nrf::{bind_interrupts, pac, peripherals, usb};
|
||||
|
@ -97,7 +97,7 @@ async fn main(_spawner: Spawner) {
|
|||
}
|
||||
};
|
||||
|
||||
let mut button = Input::new(p.P0_11.degrade(), Pull::Up);
|
||||
let mut button = Input::new(p.P0_11, Pull::Up);
|
||||
|
||||
let (reader, mut writer) = hid.split();
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use defmt::{info, unwrap, warn};
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_net::tcp::TcpSocket;
|
||||
use embassy_net::{Stack, StackResources};
|
||||
use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull};
|
||||
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
||||
use embassy_nrf::rng::Rng;
|
||||
use embassy_nrf::spim::{self, Spim};
|
||||
use embassy_nrf::{bind_interrupts, peripherals};
|
||||
|
@ -27,9 +27,9 @@ bind_interrupts!(struct Irqs {
|
|||
async fn wifi_task(
|
||||
runner: hosted::Runner<
|
||||
'static,
|
||||
ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_31>, Delay>,
|
||||
Input<'static, AnyPin>,
|
||||
Output<'static, peripherals::P1_05>,
|
||||
ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>,
|
||||
Input<'static>,
|
||||
Output<'static>,
|
||||
>,
|
||||
) -> ! {
|
||||
runner.run().await
|
||||
|
@ -50,8 +50,8 @@ async fn main(spawner: Spawner) {
|
|||
let sck = p.P0_29;
|
||||
let mosi = p.P0_30;
|
||||
let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive);
|
||||
let handshake = Input::new(p.P1_01.degrade(), Pull::Up);
|
||||
let ready = Input::new(p.P1_04.degrade(), Pull::None);
|
||||
let handshake = Input::new(p.P1_01, Pull::Up);
|
||||
let ready = Input::new(p.P1_04, Pull::None);
|
||||
let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard);
|
||||
|
||||
let mut config = spim::Config::default();
|
||||
|
|
|
@ -14,7 +14,7 @@ use embassy_time::{Duration, Ticker};
|
|||
use gpio::{AnyPin, Level, Output};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
type LedType = Mutex<ThreadModeRawMutex, Option<Output<'static, AnyPin>>>;
|
||||
type LedType = Mutex<ThreadModeRawMutex, Option<Output<'static>>>;
|
||||
static LED: LedType = Mutex::new(None);
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
|
|
@ -13,7 +13,7 @@ use embassy_net_wiznet::chip::W5500;
|
|||
use embassy_net_wiznet::*;
|
||||
use embassy_rp::clocks::RoscRng;
|
||||
use embassy_rp::gpio::{Input, Level, Output, Pull};
|
||||
use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0};
|
||||
use embassy_rp::peripherals::SPI0;
|
||||
use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
|
||||
use embassy_time::{Delay, Duration};
|
||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||
|
@ -27,9 +27,9 @@ async fn ethernet_task(
|
|||
runner: Runner<
|
||||
'static,
|
||||
W5500,
|
||||
ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static, PIN_17>, Delay>,
|
||||
Input<'static, PIN_21>,
|
||||
Output<'static, PIN_20>,
|
||||
ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static>, Delay>,
|
||||
Input<'static>,
|
||||
Output<'static>,
|
||||
>,
|
||||
) -> ! {
|
||||
runner.run().await
|
||||
|
|
|
@ -15,7 +15,7 @@ use embassy_net_wiznet::chip::W5500;
|
|||
use embassy_net_wiznet::*;
|
||||
use embassy_rp::clocks::RoscRng;
|
||||
use embassy_rp::gpio::{Input, Level, Output, Pull};
|
||||
use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0};
|
||||
use embassy_rp::peripherals::SPI0;
|
||||
use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
|
||||
use embassy_time::{Delay, Duration, Timer};
|
||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||
|
@ -29,9 +29,9 @@ async fn ethernet_task(
|
|||
runner: Runner<
|
||||
'static,
|
||||
W5500,
|
||||
ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static, PIN_17>, Delay>,
|
||||
Input<'static, PIN_21>,
|
||||
Output<'static, PIN_20>,
|
||||
ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static>, Delay>,
|
||||
Input<'static>,
|
||||
Output<'static>,
|
||||
>,
|
||||
) -> ! {
|
||||
runner.run().await
|
||||
|
|
|
@ -14,7 +14,7 @@ use embassy_net_wiznet::chip::W5500;
|
|||
use embassy_net_wiznet::*;
|
||||
use embassy_rp::clocks::RoscRng;
|
||||
use embassy_rp::gpio::{Input, Level, Output, Pull};
|
||||
use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0};
|
||||
use embassy_rp::peripherals::SPI0;
|
||||
use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
|
||||
use embassy_time::{Delay, Duration};
|
||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||
|
@ -28,9 +28,9 @@ async fn ethernet_task(
|
|||
runner: Runner<
|
||||
'static,
|
||||
W5500,
|
||||
ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static, PIN_17>, Delay>,
|
||||
Input<'static, PIN_21>,
|
||||
Output<'static, PIN_20>,
|
||||
ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static>, Delay>,
|
||||
Input<'static>,
|
||||
Output<'static>,
|
||||
>,
|
||||
) -> ! {
|
||||
runner.run().await
|
||||
|
|
|
@ -14,7 +14,7 @@ use embassy_net_wiznet::chip::W5500;
|
|||
use embassy_net_wiznet::*;
|
||||
use embassy_rp::clocks::RoscRng;
|
||||
use embassy_rp::gpio::{Input, Level, Output, Pull};
|
||||
use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0};
|
||||
use embassy_rp::peripherals::SPI0;
|
||||
use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
|
||||
use embassy_time::Delay;
|
||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||
|
@ -27,9 +27,9 @@ async fn ethernet_task(
|
|||
runner: Runner<
|
||||
'static,
|
||||
W5500,
|
||||
ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static, PIN_17>, Delay>,
|
||||
Input<'static, PIN_21>,
|
||||
Output<'static, PIN_20>,
|
||||
ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static>, Delay>,
|
||||
Input<'static>,
|
||||
Output<'static>,
|
||||
>,
|
||||
) -> ! {
|
||||
runner.run().await
|
||||
|
|
|
@ -9,7 +9,6 @@ use defmt::*;
|
|||
use embassy_executor::Executor;
|
||||
use embassy_rp::gpio::{Level, Output};
|
||||
use embassy_rp::multicore::{spawn_core1, Stack};
|
||||
use embassy_rp::peripherals::PIN_25;
|
||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
||||
use embassy_sync::channel::Channel;
|
||||
use embassy_time::Timer;
|
||||
|
@ -52,7 +51,7 @@ async fn core0_task() {
|
|||
}
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn core1_task(mut led: Output<'static, PIN_25>) {
|
||||
async fn core1_task(mut led: Output<'static>) {
|
||||
info!("Hello from core 1");
|
||||
loop {
|
||||
match CHANNEL.receive().await {
|
||||
|
|
|
@ -14,7 +14,7 @@ use embassy_net::tcp::TcpSocket;
|
|||
use embassy_net::{Config, Stack, StackResources};
|
||||
use embassy_rp::bind_interrupts;
|
||||
use embassy_rp::gpio::{Level, Output};
|
||||
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
||||
use embassy_rp::peripherals::{DMA_CH0, PIO0};
|
||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||
use embassy_time::Duration;
|
||||
use embedded_io_async::Write;
|
||||
|
@ -26,9 +26,7 @@ bind_interrupts!(struct Irqs {
|
|||
});
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn wifi_task(
|
||||
runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>,
|
||||
) -> ! {
|
||||
async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! {
|
||||
runner.run().await
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use defmt::*;
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_rp::bind_interrupts;
|
||||
use embassy_rp::gpio::{Level, Output};
|
||||
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
||||
use embassy_rp::peripherals::{DMA_CH0, PIO0};
|
||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||
use embassy_time::{Duration, Timer};
|
||||
use static_cell::StaticCell;
|
||||
|
@ -21,9 +21,7 @@ bind_interrupts!(struct Irqs {
|
|||
});
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn wifi_task(
|
||||
runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>,
|
||||
) -> ! {
|
||||
async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! {
|
||||
runner.run().await
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ use embassy_executor::Spawner;
|
|||
use embassy_net::Stack;
|
||||
use embassy_rp::bind_interrupts;
|
||||
use embassy_rp::gpio::{Level, Output};
|
||||
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
||||
use embassy_rp::peripherals::{DMA_CH0, PIO0};
|
||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||
use static_cell::StaticCell;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
@ -23,9 +23,7 @@ bind_interrupts!(struct Irqs {
|
|||
});
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn wifi_task(
|
||||
runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>,
|
||||
) -> ! {
|
||||
async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! {
|
||||
runner.run().await
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ use embassy_net::tcp::TcpSocket;
|
|||
use embassy_net::{Config, Stack, StackResources};
|
||||
use embassy_rp::bind_interrupts;
|
||||
use embassy_rp::gpio::{Level, Output};
|
||||
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
||||
use embassy_rp::peripherals::{DMA_CH0, PIO0};
|
||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||
use embassy_time::{Duration, Timer};
|
||||
use embedded_io_async::Write;
|
||||
|
@ -29,9 +29,7 @@ const WIFI_NETWORK: &str = "EmbassyTest";
|
|||
const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud";
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn wifi_task(
|
||||
runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>,
|
||||
) -> ! {
|
||||
async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! {
|
||||
runner.run().await
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ use core::sync::atomic::{AtomicU32, Ordering};
|
|||
use defmt::info;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed};
|
||||
use embassy_stm32::gpio::{AnyPin, Level, Output, Pin, Pull, Speed};
|
||||
use embassy_time::Timer;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
|
@ -36,8 +36,7 @@ async fn main(spawner: Spawner) {
|
|||
|
||||
// Configure the button pin and obtain handler.
|
||||
// On the Nucleo F091RC there is a button connected to pin PC13.
|
||||
let button = Input::new(p.PC13, Pull::None);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::None);
|
||||
|
||||
// Create and initialize a delay variable to manage delay loop
|
||||
let mut del_var = 2000;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -13,8 +13,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
// Configure the button pin and obtain handler.
|
||||
// On the Nucleo F091RC there is a button connected to pin PC13.
|
||||
let button = Input::new(p.PC13, Pull::Down);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||
|
||||
info!("Press the USER button...");
|
||||
loop {
|
||||
|
|
|
@ -12,21 +12,20 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{AnyPin, Input, Level, Output, Pin, Pull, Speed};
|
||||
use embassy_stm32::peripherals::PA0;
|
||||
use embassy_stm32::gpio::{Level, Output, Pull, Speed};
|
||||
use embassy_sync::blocking_mutex::raw::ThreadModeRawMutex;
|
||||
use embassy_sync::channel::Channel;
|
||||
use embassy_time::{with_timeout, Duration, Timer};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
struct Leds<'a> {
|
||||
leds: [Output<'a, AnyPin>; 8],
|
||||
leds: [Output<'a>; 8],
|
||||
direction: i8,
|
||||
current_led: usize,
|
||||
}
|
||||
|
||||
impl<'a> Leds<'a> {
|
||||
fn new(pins: [Output<'a, AnyPin>; 8]) -> Self {
|
||||
fn new(pins: [Output<'a>; 8]) -> Self {
|
||||
Self {
|
||||
leds: pins,
|
||||
direction: 1,
|
||||
|
@ -100,18 +99,17 @@ static CHANNEL: Channel<ThreadModeRawMutex, ButtonEvent, 4> = Channel::new();
|
|||
#[embassy_executor::main]
|
||||
async fn main(spawner: Spawner) {
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
let button = Input::new(p.PA0, Pull::Down);
|
||||
let button = ExtiInput::new(button, p.EXTI0);
|
||||
let button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Down);
|
||||
info!("Press the USER button...");
|
||||
let leds = [
|
||||
Output::new(p.PE9.degrade(), Level::Low, Speed::Low),
|
||||
Output::new(p.PE10.degrade(), Level::Low, Speed::Low),
|
||||
Output::new(p.PE11.degrade(), Level::Low, Speed::Low),
|
||||
Output::new(p.PE12.degrade(), Level::Low, Speed::Low),
|
||||
Output::new(p.PE13.degrade(), Level::Low, Speed::Low),
|
||||
Output::new(p.PE14.degrade(), Level::Low, Speed::Low),
|
||||
Output::new(p.PE15.degrade(), Level::Low, Speed::Low),
|
||||
Output::new(p.PE8.degrade(), Level::Low, Speed::Low),
|
||||
Output::new(p.PE9, Level::Low, Speed::Low),
|
||||
Output::new(p.PE10, Level::Low, Speed::Low),
|
||||
Output::new(p.PE11, Level::Low, Speed::Low),
|
||||
Output::new(p.PE12, Level::Low, Speed::Low),
|
||||
Output::new(p.PE13, Level::Low, Speed::Low),
|
||||
Output::new(p.PE14, Level::Low, Speed::Low),
|
||||
Output::new(p.PE15, Level::Low, Speed::Low),
|
||||
Output::new(p.PE8, Level::Low, Speed::Low),
|
||||
];
|
||||
let leds = Leds::new(leds);
|
||||
|
||||
|
@ -127,7 +125,7 @@ async fn led_blinker(mut leds: Leds<'static>) {
|
|||
}
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn button_waiter(mut button: ExtiInput<'static, PA0>) {
|
||||
async fn button_waiter(mut button: ExtiInput<'static>) {
|
||||
const DOUBLE_CLICK_DELAY: u64 = 250;
|
||||
const HOLD_DELAY: u64 = 1000;
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PA0, Pull::Down);
|
||||
let mut button = ExtiInput::new(button, p.EXTI0);
|
||||
let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Down);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Down);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Down);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Down);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Down);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Down);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use embassy_stm32::Config;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
|
@ -13,8 +13,7 @@ async fn main(_spawner: Spawner) {
|
|||
let config = Config::default();
|
||||
let p = embassy_stm32::init(config);
|
||||
|
||||
let button = Input::new(p.PB2, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI2);
|
||||
let mut button = ExtiInput::new(p.PB2, p.EXTI2, Pull::Up);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -58,9 +58,9 @@ const IP_ADDRESS: Ipv4Cidr = Ipv4Cidr::new(Ipv4Address([192, 168, 1, 5]), 24);
|
|||
const HTTP_LISTEN_PORT: u16 = 80;
|
||||
|
||||
pub type SpeSpi = Spi<'static, peripherals::SPI2, peripherals::DMA1_CH1, peripherals::DMA1_CH2>;
|
||||
pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static, peripherals::PB12>, Delay>;
|
||||
pub type SpeInt = exti::ExtiInput<'static, peripherals::PB11>;
|
||||
pub type SpeRst = Output<'static, peripherals::PC7>;
|
||||
pub type SpeSpiCs = ExclusiveDevice<SpeSpi, Output<'static>, Delay>;
|
||||
pub type SpeInt = exti::ExtiInput<'static>;
|
||||
pub type SpeRst = Output<'static>;
|
||||
pub type Adin1110T = ADIN1110<SpeSpiCs>;
|
||||
pub type TempSensI2c = I2c<'static, peripherals::I2C3, peripherals::DMA1_CH6, peripherals::DMA1_CH7>;
|
||||
|
||||
|
@ -134,8 +134,7 @@ async fn main(spawner: Spawner) {
|
|||
let spe_cfg1 = Input::new(dp.PC9, Pull::None);
|
||||
let _spe_ts_capt = Output::new(dp.PC6, Level::Low, Speed::Low);
|
||||
|
||||
let spe_int = Input::new(dp.PB11, Pull::None);
|
||||
let spe_int = exti::ExtiInput::new(spe_int, dp.EXTI11);
|
||||
let spe_int = exti::ExtiInput::new(dp.PB11, dp.EXTI11, Pull::None);
|
||||
|
||||
let spe_spi_cs_n = Output::new(dp.PB12, Level::High, Speed::High);
|
||||
let spe_spi_sclk = dp.PB13;
|
||||
|
@ -298,7 +297,7 @@ async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net:
|
|||
}
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn heartbeat_led(mut led: Output<'static, peripherals::PE6>) {
|
||||
async fn heartbeat_led(mut led: Output<'static>) {
|
||||
let mut tmr = Ticker::every(Duration::from_hz(3));
|
||||
loop {
|
||||
led.toggle();
|
||||
|
@ -308,7 +307,7 @@ async fn heartbeat_led(mut led: Output<'static, peripherals::PE6>) {
|
|||
|
||||
// ADT7422
|
||||
#[embassy_executor::task]
|
||||
async fn temp_task(temp_dev_i2c: TempSensI2c, mut led: Output<'static, peripherals::PG15>) -> ! {
|
||||
async fn temp_task(temp_dev_i2c: TempSensI2c, mut led: Output<'static>) -> ! {
|
||||
let mut tmr = Ticker::every(Duration::from_hz(1));
|
||||
let mut temp_sens = ADT7422::new(temp_dev_i2c, 0x48).unwrap();
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Down);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Down);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PC4, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI4);
|
||||
let mut button = ExtiInput::new(p.PC4, p.EXTI4, Pull::Up);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PC13, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI13);
|
||||
let mut button = ExtiInput::new(p.PC13, p.EXTI13, Pull::Up);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::exti::ExtiInput;
|
||||
use embassy_stm32::gpio::{Input, Pull};
|
||||
use embassy_stm32::gpio::Pull;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
|
@ -12,8 +12,7 @@ async fn main(_spawner: Spawner) {
|
|||
let p = embassy_stm32::init(Default::default());
|
||||
info!("Hello World!");
|
||||
|
||||
let button = Input::new(p.PA0, Pull::Up);
|
||||
let mut button = ExtiInput::new(button, p.EXTI0);
|
||||
let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up);
|
||||
|
||||
info!("Press the USER button...");
|
||||
|
||||
|
|
|
@ -21,10 +21,7 @@ bind_interrupts!(struct Irqs {
|
|||
RNG => embassy_nrf::rng::InterruptHandler<peripherals::RNG>;
|
||||
});
|
||||
|
||||
type MyDriver = Enc28j60<
|
||||
ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>,
|
||||
Output<'static, peripherals::P0_13>,
|
||||
>;
|
||||
type MyDriver = Enc28j60<ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>, Output<'static>>;
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn net_task(stack: &'static Stack<MyDriver>) -> ! {
|
||||
|
|
|
@ -6,7 +6,7 @@ teleprobe_meta::timeout!(120);
|
|||
use defmt::{info, unwrap};
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_net::{Config, Stack, StackResources};
|
||||
use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull};
|
||||
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
||||
use embassy_nrf::rng::Rng;
|
||||
use embassy_nrf::spim::{self, Spim};
|
||||
use embassy_nrf::{bind_interrupts, peripherals};
|
||||
|
@ -28,9 +28,9 @@ const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud";
|
|||
async fn wifi_task(
|
||||
runner: hosted::Runner<
|
||||
'static,
|
||||
ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_31>, Delay>,
|
||||
Input<'static, AnyPin>,
|
||||
Output<'static, peripherals::P1_05>,
|
||||
ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static>, Delay>,
|
||||
Input<'static>,
|
||||
Output<'static>,
|
||||
>,
|
||||
) -> ! {
|
||||
runner.run().await
|
||||
|
@ -53,8 +53,8 @@ async fn main(spawner: Spawner) {
|
|||
let sck = p.P0_29;
|
||||
let mosi = p.P0_30;
|
||||
let cs = Output::new(p.P0_31, Level::High, OutputDrive::HighDrive);
|
||||
let handshake = Input::new(p.P1_01.degrade(), Pull::Up);
|
||||
let ready = Input::new(p.P1_04.degrade(), Pull::None);
|
||||
let handshake = Input::new(p.P1_01, Pull::Up);
|
||||
let ready = Input::new(p.P1_04, Pull::None);
|
||||
let reset = Output::new(p.P1_05, Level::Low, OutputDrive::Standard);
|
||||
|
||||
let mut config = spim::Config::default();
|
||||
|
|
|
@ -10,7 +10,7 @@ runner = "teleprobe client run"
|
|||
|
||||
rustflags = [
|
||||
# Code-size optimizations.
|
||||
"-Z", "trap-unreachable=no",
|
||||
#"-Z", "trap-unreachable=no",
|
||||
"-C", "inline-threshold=5",
|
||||
"-C", "no-vectorize-loops",
|
||||
]
|
||||
|
|
|
@ -7,7 +7,7 @@ use defmt::{panic, *};
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_net::{Config, Stack, StackResources};
|
||||
use embassy_rp::gpio::{Level, Output};
|
||||
use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
|
||||
use embassy_rp::peripherals::{DMA_CH0, PIO0};
|
||||
use embassy_rp::pio::{InterruptHandler, Pio};
|
||||
use embassy_rp::{bind_interrupts, rom_data};
|
||||
use static_cell::StaticCell;
|
||||
|
@ -24,9 +24,7 @@ const WIFI_NETWORK: &str = "EmbassyTest";
|
|||
const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud";
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn wifi_task(
|
||||
runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>,
|
||||
) -> ! {
|
||||
async fn wifi_task(runner: cyw43::Runner<'static, Output<'static>, PioSpi<'static, PIO0, 0, DMA_CH0>>) -> ! {
|
||||
runner.run().await
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ use embassy_net_wiznet::chip::W5100S;
|
|||
use embassy_net_wiznet::*;
|
||||
use embassy_rp::clocks::RoscRng;
|
||||
use embassy_rp::gpio::{Input, Level, Output, Pull};
|
||||
use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0};
|
||||
use embassy_rp::peripherals::SPI0;
|
||||
use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
|
||||
use embassy_time::Delay;
|
||||
use embedded_hal_bus::spi::ExclusiveDevice;
|
||||
|
@ -23,9 +23,9 @@ async fn ethernet_task(
|
|||
runner: Runner<
|
||||
'static,
|
||||
W5100S,
|
||||
ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static, PIN_17>, Delay>,
|
||||
Input<'static, PIN_21>,
|
||||
Output<'static, PIN_20>,
|
||||
ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static>, Delay>,
|
||||
Input<'static>,
|
||||
Output<'static>,
|
||||
>,
|
||||
) -> ! {
|
||||
runner.run().await
|
||||
|
|
|
@ -21,7 +21,7 @@ fn read1<const N: usize>(uart: &mut UartRx<'_, impl Instance, Blocking>) -> Resu
|
|||
Ok(buf)
|
||||
}
|
||||
|
||||
async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) {
|
||||
async fn send(pin: &mut Output<'_>, v: u8, parity: Option<bool>) {
|
||||
pin.set_low();
|
||||
Timer::after_millis(1).await;
|
||||
for i in 0..8 {
|
||||
|
@ -116,7 +116,7 @@ async fn main(_spawner: Spawner) {
|
|||
config.parity = Parity::ParityEven;
|
||||
let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config);
|
||||
|
||||
async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: u8) {
|
||||
async fn chr(pin: &mut Output<'_>, v: u8, parity: u8) {
|
||||
send(pin, v, Some(parity != 0)).await;
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ async fn main(_spawner: Spawner) {
|
|||
config.baudrate = 1000;
|
||||
let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config);
|
||||
|
||||
async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, good: bool) {
|
||||
async fn chr(pin: &mut Output<'_>, v: u8, good: bool) {
|
||||
if good {
|
||||
send(pin, v, None).await;
|
||||
} else {
|
||||
|
|
|
@ -36,7 +36,7 @@ async fn read1<const N: usize>(uart: &mut BufferedUartRx<'_, impl Instance>) ->
|
|||
}
|
||||
}
|
||||
|
||||
async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) {
|
||||
async fn send(pin: &mut Output<'_>, v: u8, parity: Option<bool>) {
|
||||
pin.set_low();
|
||||
Timer::after_millis(1).await;
|
||||
for i in 0..8 {
|
||||
|
@ -161,7 +161,7 @@ async fn main(_spawner: Spawner) {
|
|||
let rx_buf = &mut [0u8; 16];
|
||||
let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config);
|
||||
|
||||
async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: u32) {
|
||||
async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) {
|
||||
send(pin, v, Some(parity != 0)).await;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ async fn main(_spawner: Spawner) {
|
|||
let rx_buf = &mut [0u8; 16];
|
||||
let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config);
|
||||
|
||||
async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, good: bool) {
|
||||
async fn chr(pin: &mut Output<'_>, v: u8, good: bool) {
|
||||
if good {
|
||||
send(pin, v, None).await;
|
||||
} else {
|
||||
|
|
|
@ -27,7 +27,7 @@ async fn read1<const N: usize>(uart: &mut UartRx<'_, impl Instance, Async>) -> R
|
|||
Ok(buf)
|
||||
}
|
||||
|
||||
async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) {
|
||||
async fn send(pin: &mut Output<'_>, v: u8, parity: Option<bool>) {
|
||||
pin.set_low();
|
||||
Timer::after_millis(1).await;
|
||||
for i in 0..8 {
|
||||
|
@ -160,7 +160,7 @@ async fn main(_spawner: Spawner) {
|
|||
config.parity = Parity::ParityEven;
|
||||
let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config);
|
||||
|
||||
async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: u32) {
|
||||
async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) {
|
||||
send(pin, v, Some(parity != 0)).await;
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ async fn main(_spawner: Spawner) {
|
|||
config.baudrate = 1000;
|
||||
let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config);
|
||||
|
||||
async fn chr(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, good: bool) {
|
||||
async fn chr(pin: &mut Output<'_>, v: u8, good: bool) {
|
||||
if good {
|
||||
send(pin, v, None).await;
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[unstable]
|
||||
build-std = ["core"]
|
||||
build-std-features = ["panic_immediate_abort"]
|
||||
#build-std = ["core"]
|
||||
#build-std-features = ["panic_immediate_abort"]
|
||||
|
||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
runner = "teleprobe client run"
|
||||
|
@ -8,7 +8,7 @@ runner = "teleprobe client run"
|
|||
|
||||
rustflags = [
|
||||
# Code-size optimizations.
|
||||
"-Z", "trap-unreachable=no",
|
||||
#"-Z", "trap-unreachable=no",
|
||||
"-C", "inline-threshold=5",
|
||||
"-C", "no-vectorize-loops",
|
||||
]
|
||||
|
@ -20,4 +20,4 @@ target = "thumbv6m-none-eabi"
|
|||
#target = "thumbv8m.main-none-eabihf"
|
||||
|
||||
[env]
|
||||
DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info"
|
||||
DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info"
|
||||
|
|
Loading…
Add table
Reference in a new issue