diff options
| author | pennae <[email protected]> | 2023-07-07 04:30:46 +0200 |
|---|---|---|
| committer | pennae <[email protected]> | 2023-07-07 16:27:10 +0200 |
| commit | 4b63829110b8ef314d22d78c160f54e6ae98634c (patch) | |
| tree | cf45eb607ae5aaee38c1d221bb2bd83ac6d5e7ef /examples | |
| parent | e196387e695da96b44609079a84ede77ef9ba7af (diff) | |
rp/pio: use bind_interrupts for irqs
closes #1338
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rp/src/bin/pio_async.rs | 9 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_dma.rs | 11 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_hd44780.rs | 15 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_ws2812.rs | 13 | ||||
| -rw-r--r-- | examples/rp/src/bin/wifi_ap_tcp_server.rs | 9 | ||||
| -rw-r--r-- | examples/rp/src/bin/wifi_blinky.rs | 9 | ||||
| -rw-r--r-- | examples/rp/src/bin/wifi_scan.rs | 9 | ||||
| -rw-r--r-- | examples/rp/src/bin/wifi_tcp_server.rs | 9 |
8 files changed, 64 insertions, 20 deletions
diff --git a/examples/rp/src/bin/pio_async.rs b/examples/rp/src/bin/pio_async.rs index 79eda1a09..69034c92a 100644 --- a/examples/rp/src/bin/pio_async.rs +++ b/examples/rp/src/bin/pio_async.rs | |||
| @@ -3,13 +3,18 @@ | |||
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | use defmt::info; | 4 | use defmt::info; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_rp::bind_interrupts; | ||
| 6 | use embassy_rp::peripherals::PIO0; | 7 | use embassy_rp::peripherals::PIO0; |
| 7 | use embassy_rp::pio::{Common, Config, Irq, Pio, PioPin, ShiftDirection, StateMachine}; | 8 | use embassy_rp::pio::{Common, Config, InterruptHandler, Irq, Pio, PioPin, ShiftDirection, StateMachine}; |
| 8 | use embassy_rp::relocate::RelocatedProgram; | 9 | use embassy_rp::relocate::RelocatedProgram; |
| 9 | use fixed::traits::ToFixed; | 10 | use fixed::traits::ToFixed; |
| 10 | use fixed_macro::types::U56F8; | 11 | use fixed_macro::types::U56F8; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 13 | ||
| 14 | bind_interrupts!(struct Irqs { | ||
| 15 | PIO0_IRQ_0 => InterruptHandler<PIO0>; | ||
| 16 | }); | ||
| 17 | |||
| 13 | fn setup_pio_task_sm0<'a>(pio: &mut Common<'a, PIO0>, sm: &mut StateMachine<'a, PIO0, 0>, pin: impl PioPin) { | 18 | fn setup_pio_task_sm0<'a>(pio: &mut Common<'a, PIO0>, sm: &mut StateMachine<'a, PIO0, 0>, pin: impl PioPin) { |
| 14 | // Setup sm0 | 19 | // Setup sm0 |
| 15 | 20 | ||
| @@ -110,7 +115,7 @@ async fn main(spawner: Spawner) { | |||
| 110 | mut sm1, | 115 | mut sm1, |
| 111 | mut sm2, | 116 | mut sm2, |
| 112 | .. | 117 | .. |
| 113 | } = Pio::new(pio); | 118 | } = Pio::new(pio, Irqs); |
| 114 | 119 | ||
| 115 | setup_pio_task_sm0(&mut common, &mut sm0, p.PIN_0); | 120 | setup_pio_task_sm0(&mut common, &mut sm0, p.PIN_0); |
| 116 | setup_pio_task_sm1(&mut common, &mut sm1); | 121 | setup_pio_task_sm1(&mut common, &mut sm1); |
diff --git a/examples/rp/src/bin/pio_dma.rs b/examples/rp/src/bin/pio_dma.rs index 05c0ebb16..80c963556 100644 --- a/examples/rp/src/bin/pio_dma.rs +++ b/examples/rp/src/bin/pio_dma.rs | |||
| @@ -4,13 +4,18 @@ | |||
| 4 | use defmt::info; | 4 | use defmt::info; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_futures::join::join; | 6 | use embassy_futures::join::join; |
| 7 | use embassy_rp::pio::{Config, Pio, ShiftConfig, ShiftDirection}; | 7 | use embassy_rp::peripherals::PIO0; |
| 8 | use embassy_rp::pio::{Config, InterruptHandler, Pio, ShiftConfig, ShiftDirection}; | ||
| 8 | use embassy_rp::relocate::RelocatedProgram; | 9 | use embassy_rp::relocate::RelocatedProgram; |
| 9 | use embassy_rp::Peripheral; | 10 | use embassy_rp::{bind_interrupts, Peripheral}; |
| 10 | use fixed::traits::ToFixed; | 11 | use fixed::traits::ToFixed; |
| 11 | use fixed_macro::types::U56F8; | 12 | use fixed_macro::types::U56F8; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 14 | ||
| 15 | bind_interrupts!(struct Irqs { | ||
| 16 | PIO0_IRQ_0 => InterruptHandler<PIO0>; | ||
| 17 | }); | ||
| 18 | |||
| 14 | fn swap_nibbles(v: u32) -> u32 { | 19 | fn swap_nibbles(v: u32) -> u32 { |
| 15 | let v = (v & 0x0f0f_0f0f) << 4 | (v & 0xf0f0_f0f0) >> 4; | 20 | let v = (v & 0x0f0f_0f0f) << 4 | (v & 0xf0f0_f0f0) >> 4; |
| 16 | let v = (v & 0x00ff_00ff) << 8 | (v & 0xff00_ff00) >> 8; | 21 | let v = (v & 0x00ff_00ff) << 8 | (v & 0xff00_ff00) >> 8; |
| @@ -25,7 +30,7 @@ async fn main(_spawner: Spawner) { | |||
| 25 | mut common, | 30 | mut common, |
| 26 | sm0: mut sm, | 31 | sm0: mut sm, |
| 27 | .. | 32 | .. |
| 28 | } = Pio::new(pio); | 33 | } = Pio::new(pio, Irqs); |
| 29 | 34 | ||
| 30 | let prg = pio_proc::pio_asm!( | 35 | let prg = pio_proc::pio_asm!( |
| 31 | ".origin 0", | 36 | ".origin 0", |
diff --git a/examples/rp/src/bin/pio_hd44780.rs b/examples/rp/src/bin/pio_hd44780.rs index bfc6c9908..0a4514a66 100644 --- a/examples/rp/src/bin/pio_hd44780.rs +++ b/examples/rp/src/bin/pio_hd44780.rs | |||
| @@ -7,13 +7,19 @@ use core::fmt::Write; | |||
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_rp::dma::{AnyChannel, Channel}; | 8 | use embassy_rp::dma::{AnyChannel, Channel}; |
| 9 | use embassy_rp::peripherals::PIO0; | 9 | use embassy_rp::peripherals::PIO0; |
| 10 | use embassy_rp::pio::{Config, Direction, FifoJoin, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine}; | 10 | use embassy_rp::pio::{ |
| 11 | Config, Direction, FifoJoin, InterruptHandler, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine, | ||
| 12 | }; | ||
| 11 | use embassy_rp::pwm::{self, Pwm}; | 13 | use embassy_rp::pwm::{self, Pwm}; |
| 12 | use embassy_rp::relocate::RelocatedProgram; | 14 | use embassy_rp::relocate::RelocatedProgram; |
| 13 | use embassy_rp::{into_ref, Peripheral, PeripheralRef}; | 15 | use embassy_rp::{bind_interrupts, into_ref, Peripheral, PeripheralRef}; |
| 14 | use embassy_time::{Duration, Instant, Timer}; | 16 | use embassy_time::{Duration, Instant, Timer}; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 18 | ||
| 19 | bind_interrupts!(pub struct Irqs { | ||
| 20 | PIO0_IRQ_0 => InterruptHandler<PIO0>; | ||
| 21 | }); | ||
| 22 | |||
| 17 | #[embassy_executor::main] | 23 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner) { | 24 | async fn main(_spawner: Spawner) { |
| 19 | // this test assumes a 2x16 HD44780 display attached as follow: | 25 | // this test assumes a 2x16 HD44780 display attached as follow: |
| @@ -37,7 +43,7 @@ async fn main(_spawner: Spawner) { | |||
| 37 | }); | 43 | }); |
| 38 | 44 | ||
| 39 | let mut hd = HD44780::new( | 45 | let mut hd = HD44780::new( |
| 40 | p.PIO0, p.DMA_CH3, p.PIN_0, p.PIN_1, p.PIN_2, p.PIN_3, p.PIN_4, p.PIN_5, p.PIN_6, | 46 | p.PIO0, Irqs, p.DMA_CH3, p.PIN_0, p.PIN_1, p.PIN_2, p.PIN_3, p.PIN_4, p.PIN_5, p.PIN_6, |
| 41 | ) | 47 | ) |
| 42 | .await; | 48 | .await; |
| 43 | 49 | ||
| @@ -72,6 +78,7 @@ pub struct HD44780<'l> { | |||
| 72 | impl<'l> HD44780<'l> { | 78 | impl<'l> HD44780<'l> { |
| 73 | pub async fn new( | 79 | pub async fn new( |
| 74 | pio: impl Peripheral<P = PIO0> + 'l, | 80 | pio: impl Peripheral<P = PIO0> + 'l, |
| 81 | irq: Irqs, | ||
| 75 | dma: impl Peripheral<P = impl Channel> + 'l, | 82 | dma: impl Peripheral<P = impl Channel> + 'l, |
| 76 | rs: impl PioPin, | 83 | rs: impl PioPin, |
| 77 | rw: impl PioPin, | 84 | rw: impl PioPin, |
| @@ -88,7 +95,7 @@ impl<'l> HD44780<'l> { | |||
| 88 | mut irq0, | 95 | mut irq0, |
| 89 | mut sm0, | 96 | mut sm0, |
| 90 | .. | 97 | .. |
| 91 | } = Pio::new(pio); | 98 | } = Pio::new(pio, irq); |
| 92 | 99 | ||
| 93 | // takes command words (<wait:24> <command:4> <0:4>) | 100 | // takes command words (<wait:24> <command:4> <0:4>) |
| 94 | let prg = pio_proc::pio_asm!( | 101 | let prg = pio_proc::pio_asm!( |
diff --git a/examples/rp/src/bin/pio_ws2812.rs b/examples/rp/src/bin/pio_ws2812.rs index 26422421f..4a111e7aa 100644 --- a/examples/rp/src/bin/pio_ws2812.rs +++ b/examples/rp/src/bin/pio_ws2812.rs | |||
| @@ -5,15 +5,22 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::dma::{AnyChannel, Channel}; | 7 | use embassy_rp::dma::{AnyChannel, Channel}; |
| 8 | use embassy_rp::pio::{Common, Config, FifoJoin, Instance, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine}; | 8 | use embassy_rp::peripherals::PIO0; |
| 9 | use embassy_rp::pio::{ | ||
| 10 | Common, Config, FifoJoin, Instance, InterruptHandler, Pio, PioPin, ShiftConfig, ShiftDirection, StateMachine, | ||
| 11 | }; | ||
| 9 | use embassy_rp::relocate::RelocatedProgram; | 12 | use embassy_rp::relocate::RelocatedProgram; |
| 10 | use embassy_rp::{clocks, into_ref, Peripheral, PeripheralRef}; | 13 | use embassy_rp::{bind_interrupts, clocks, into_ref, Peripheral, PeripheralRef}; |
| 11 | use embassy_time::{Duration, Timer}; | 14 | use embassy_time::{Duration, Timer}; |
| 12 | use fixed::types::U24F8; | 15 | use fixed::types::U24F8; |
| 13 | use fixed_macro::fixed; | 16 | use fixed_macro::fixed; |
| 14 | use smart_leds::RGB8; | 17 | use smart_leds::RGB8; |
| 15 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 16 | 19 | ||
| 20 | bind_interrupts!(struct Irqs { | ||
| 21 | PIO0_IRQ_0 => InterruptHandler<PIO0>; | ||
| 22 | }); | ||
| 23 | |||
| 17 | pub struct Ws2812<'d, P: Instance, const S: usize, const N: usize> { | 24 | pub struct Ws2812<'d, P: Instance, const S: usize, const N: usize> { |
| 18 | dma: PeripheralRef<'d, AnyChannel>, | 25 | dma: PeripheralRef<'d, AnyChannel>, |
| 19 | sm: StateMachine<'d, P, S>, | 26 | sm: StateMachine<'d, P, S>, |
| @@ -123,7 +130,7 @@ async fn main(_spawner: Spawner) { | |||
| 123 | info!("Start"); | 130 | info!("Start"); |
| 124 | let p = embassy_rp::init(Default::default()); | 131 | let p = embassy_rp::init(Default::default()); |
| 125 | 132 | ||
| 126 | let Pio { mut common, sm0, .. } = Pio::new(p.PIO0); | 133 | let Pio { mut common, sm0, .. } = Pio::new(p.PIO0, Irqs); |
| 127 | 134 | ||
| 128 | // This is the number of leds in the string. Helpfully, the sparkfun thing plus and adafruit | 135 | // This is the number of leds in the string. Helpfully, the sparkfun thing plus and adafruit |
| 129 | // feather boards for the 2040 both have one built in. | 136 | // feather boards for the 2040 both have one built in. |
diff --git a/examples/rp/src/bin/wifi_ap_tcp_server.rs b/examples/rp/src/bin/wifi_ap_tcp_server.rs index 310e84d92..3e41f83be 100644 --- a/examples/rp/src/bin/wifi_ap_tcp_server.rs +++ b/examples/rp/src/bin/wifi_ap_tcp_server.rs | |||
| @@ -11,14 +11,19 @@ use defmt::*; | |||
| 11 | use embassy_executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_net::tcp::TcpSocket; | 12 | use embassy_net::tcp::TcpSocket; |
| 13 | use embassy_net::{Config, Stack, StackResources}; | 13 | use embassy_net::{Config, Stack, StackResources}; |
| 14 | use embassy_rp::bind_interrupts; | ||
| 14 | use embassy_rp::gpio::{Level, Output}; | 15 | use embassy_rp::gpio::{Level, Output}; |
| 15 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 16 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; |
| 16 | use embassy_rp::pio::Pio; | 17 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 17 | use embassy_time::Duration; | 18 | use embassy_time::Duration; |
| 18 | use embedded_io::asynch::Write; | 19 | use embedded_io::asynch::Write; |
| 19 | use static_cell::make_static; | 20 | use static_cell::make_static; |
| 20 | use {defmt_rtt as _, panic_probe as _}; | 21 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 22 | ||
| 23 | bind_interrupts!(struct Irqs { | ||
| 24 | PIO0_IRQ_0 => InterruptHandler<PIO0>; | ||
| 25 | }); | ||
| 26 | |||
| 22 | #[embassy_executor::task] | 27 | #[embassy_executor::task] |
| 23 | async fn wifi_task( | 28 | async fn wifi_task( |
| 24 | runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, | 29 | runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, |
| @@ -49,7 +54,7 @@ async fn main(spawner: Spawner) { | |||
| 49 | 54 | ||
| 50 | let pwr = Output::new(p.PIN_23, Level::Low); | 55 | let pwr = Output::new(p.PIN_23, Level::Low); |
| 51 | let cs = Output::new(p.PIN_25, Level::High); | 56 | let cs = Output::new(p.PIN_25, Level::High); |
| 52 | let mut pio = Pio::new(p.PIO0); | 57 | let mut pio = Pio::new(p.PIO0, Irqs); |
| 53 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); | 58 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); |
| 54 | 59 | ||
| 55 | let state = make_static!(cyw43::State::new()); | 60 | let state = make_static!(cyw43::State::new()); |
diff --git a/examples/rp/src/bin/wifi_blinky.rs b/examples/rp/src/bin/wifi_blinky.rs index bbcb1b5ec..6eb207af6 100644 --- a/examples/rp/src/bin/wifi_blinky.rs +++ b/examples/rp/src/bin/wifi_blinky.rs | |||
| @@ -5,13 +5,18 @@ | |||
| 5 | use cyw43_pio::PioSpi; | 5 | use cyw43_pio::PioSpi; |
| 6 | use defmt::*; | 6 | use defmt::*; |
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_rp::bind_interrupts; | ||
| 8 | use embassy_rp::gpio::{Level, Output}; | 9 | use embassy_rp::gpio::{Level, Output}; |
| 9 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 10 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; |
| 10 | use embassy_rp::pio::Pio; | 11 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 11 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::{Duration, Timer}; |
| 12 | use static_cell::make_static; | 13 | use static_cell::make_static; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 14 | use {defmt_rtt as _, panic_probe as _}; |
| 14 | 15 | ||
| 16 | bind_interrupts!(struct Irqs { | ||
| 17 | PIO0_IRQ_0 => InterruptHandler<PIO0>; | ||
| 18 | }); | ||
| 19 | |||
| 15 | #[embassy_executor::task] | 20 | #[embassy_executor::task] |
| 16 | async fn wifi_task( | 21 | async fn wifi_task( |
| 17 | runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, | 22 | runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, |
| @@ -34,7 +39,7 @@ async fn main(spawner: Spawner) { | |||
| 34 | 39 | ||
| 35 | let pwr = Output::new(p.PIN_23, Level::Low); | 40 | let pwr = Output::new(p.PIN_23, Level::Low); |
| 36 | let cs = Output::new(p.PIN_25, Level::High); | 41 | let cs = Output::new(p.PIN_25, Level::High); |
| 37 | let mut pio = Pio::new(p.PIO0); | 42 | let mut pio = Pio::new(p.PIO0, Irqs); |
| 38 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); | 43 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); |
| 39 | 44 | ||
| 40 | let state = make_static!(cyw43::State::new()); | 45 | let state = make_static!(cyw43::State::new()); |
diff --git a/examples/rp/src/bin/wifi_scan.rs b/examples/rp/src/bin/wifi_scan.rs index 391e12282..aef18aa24 100644 --- a/examples/rp/src/bin/wifi_scan.rs +++ b/examples/rp/src/bin/wifi_scan.rs | |||
| @@ -10,12 +10,17 @@ use cyw43_pio::PioSpi; | |||
| 10 | use defmt::*; | 10 | use defmt::*; |
| 11 | use embassy_executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_net::Stack; | 12 | use embassy_net::Stack; |
| 13 | use embassy_rp::bind_interrupts; | ||
| 13 | use embassy_rp::gpio::{Level, Output}; | 14 | use embassy_rp::gpio::{Level, Output}; |
| 14 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 15 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; |
| 15 | use embassy_rp::pio::Pio; | 16 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 16 | use static_cell::make_static; | 17 | use static_cell::make_static; |
| 17 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 18 | 19 | ||
| 20 | bind_interrupts!(struct Irqs { | ||
| 21 | PIO0_IRQ_0 => InterruptHandler<PIO0>; | ||
| 22 | }); | ||
| 23 | |||
| 19 | #[embassy_executor::task] | 24 | #[embassy_executor::task] |
| 20 | async fn wifi_task( | 25 | async fn wifi_task( |
| 21 | runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, | 26 | runner: cyw43::Runner<'static, Output<'static, PIN_23>, PioSpi<'static, PIN_25, PIO0, 0, DMA_CH0>>, |
| @@ -46,7 +51,7 @@ async fn main(spawner: Spawner) { | |||
| 46 | 51 | ||
| 47 | let pwr = Output::new(p.PIN_23, Level::Low); | 52 | let pwr = Output::new(p.PIN_23, Level::Low); |
| 48 | let cs = Output::new(p.PIN_25, Level::High); | 53 | let cs = Output::new(p.PIN_25, Level::High); |
| 49 | let mut pio = Pio::new(p.PIO0); | 54 | let mut pio = Pio::new(p.PIO0, Irqs); |
| 50 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); | 55 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); |
| 51 | 56 | ||
| 52 | let state = make_static!(cyw43::State::new()); | 57 | let state = make_static!(cyw43::State::new()); |
diff --git a/examples/rp/src/bin/wifi_tcp_server.rs b/examples/rp/src/bin/wifi_tcp_server.rs index 197535f45..4fce74a66 100644 --- a/examples/rp/src/bin/wifi_tcp_server.rs +++ b/examples/rp/src/bin/wifi_tcp_server.rs | |||
| @@ -11,14 +11,19 @@ use defmt::*; | |||
| 11 | use embassy_executor::Spawner; | 11 | use embassy_executor::Spawner; |
| 12 | use embassy_net::tcp::TcpSocket; | 12 | use embassy_net::tcp::TcpSocket; |
| 13 | use embassy_net::{Config, Stack, StackResources}; | 13 | use embassy_net::{Config, Stack, StackResources}; |
| 14 | use embassy_rp::bind_interrupts; | ||
| 14 | use embassy_rp::gpio::{Level, Output}; | 15 | use embassy_rp::gpio::{Level, Output}; |
| 15 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; | 16 | use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; |
| 16 | use embassy_rp::pio::Pio; | 17 | use embassy_rp::pio::{InterruptHandler, Pio}; |
| 17 | use embassy_time::Duration; | 18 | use embassy_time::Duration; |
| 18 | use embedded_io::asynch::Write; | 19 | use embedded_io::asynch::Write; |
| 19 | use static_cell::make_static; | 20 | use static_cell::make_static; |
| 20 | use {defmt_rtt as _, panic_probe as _}; | 21 | use {defmt_rtt as _, panic_probe as _}; |
| 21 | 22 | ||
| 23 | bind_interrupts!(struct Irqs { | ||
| 24 | PIO0_IRQ_0 => InterruptHandler<PIO0>; | ||
| 25 | }); | ||
| 26 | |||
| 22 | const WIFI_NETWORK: &str = "EmbassyTest"; | 27 | const WIFI_NETWORK: &str = "EmbassyTest"; |
| 23 | const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; | 28 | const WIFI_PASSWORD: &str = "V8YxhKt5CdIAJFud"; |
| 24 | 29 | ||
| @@ -52,7 +57,7 @@ async fn main(spawner: Spawner) { | |||
| 52 | 57 | ||
| 53 | let pwr = Output::new(p.PIN_23, Level::Low); | 58 | let pwr = Output::new(p.PIN_23, Level::Low); |
| 54 | let cs = Output::new(p.PIN_25, Level::High); | 59 | let cs = Output::new(p.PIN_25, Level::High); |
| 55 | let mut pio = Pio::new(p.PIO0); | 60 | let mut pio = Pio::new(p.PIO0, Irqs); |
| 56 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); | 61 | let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); |
| 57 | 62 | ||
| 58 | let state = make_static!(cyw43::State::new()); | 63 | let state = make_static!(cyw43::State::new()); |
