rp/gpio: remove generics.

This commit is contained in:
Dario Nieuwenhuis 2024-01-22 21:30:29 +01:00
parent 2bc5e9523d
commit ee0ebe3121
17 changed files with 109 additions and 123 deletions

View File

@ -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,
{

View File

@ -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(())

View File

@ -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]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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

View File

@ -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 {

View File

@ -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 {

View File

@ -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 {