diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-07-11 00:25:35 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-07-11 00:25:35 +0200 |
| commit | 069a57fcf85c725d000e03163716edb4ae3922ca (patch) | |
| tree | e0b672124cdfc0c8d4a58896d887496f5dec7d1d /examples | |
| parent | e560415fde967483573d42f628e52501768584e0 (diff) | |
async ioctls working.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rpi-pico-w/src/main.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/examples/rpi-pico-w/src/main.rs b/examples/rpi-pico-w/src/main.rs index de8c5a2ba..7545dfde8 100644 --- a/examples/rpi-pico-w/src/main.rs +++ b/examples/rpi-pico-w/src/main.rs | |||
| @@ -6,11 +6,12 @@ use core::slice; | |||
| 6 | 6 | ||
| 7 | use defmt::{assert, assert_eq, panic, *}; | 7 | use defmt::{assert, assert_eq, panic, *}; |
| 8 | use embassy::executor::Spawner; | 8 | use embassy::executor::Spawner; |
| 9 | use embassy::util::Forever; | ||
| 9 | use embassy_rp::gpio::{Flex, Level, Output, Pin}; | 10 | use embassy_rp::gpio::{Flex, Level, Output, Pin}; |
| 11 | use embassy_rp::peripherals::{PIN_23, PIN_24, PIN_25, PIN_29}; | ||
| 10 | use embassy_rp::Peripherals; | 12 | use embassy_rp::Peripherals; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 14 | ||
| 13 | |||
| 14 | macro_rules! forever { | 15 | macro_rules! forever { |
| 15 | ($val:expr) => {{ | 16 | ($val:expr) => {{ |
| 16 | type T = impl Sized; | 17 | type T = impl Sized; |
| @@ -19,21 +20,29 @@ macro_rules! forever { | |||
| 19 | }}; | 20 | }}; |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 23 | #[embassy::task] | ||
| 24 | async fn wifi_task(runner: cyw43::Runner<'static, PIN_23, PIN_25, PIN_29, PIN_24>) -> ! { | ||
| 25 | runner.run().await | ||
| 26 | } | ||
| 27 | |||
| 22 | #[embassy::main] | 28 | #[embassy::main] |
| 23 | async fn main(_spawner: Spawner, p: Peripherals) { | 29 | async fn main(spawner: Spawner, p: Peripherals) { |
| 24 | info!("Hello World!"); | 30 | info!("Hello World!"); |
| 25 | 31 | ||
| 26 | let (pwr, cs, clk, dio) = (p.PIN_23, p.PIN_25, p.PIN_29, p.PIN_24); | 32 | let (pwr, cs, clk, dio) = (p.PIN_23, p.PIN_25, p.PIN_29, p.PIN_24); |
| 27 | //let (pwr, cs, clk, dio) = (p.PIN_23, p.PIN_0, p.PIN_1, p.PIN_2); | 33 | //let (pwr, cs, clk, dio) = (p.PIN_23, p.PIN_0, p.PIN_1, p.PIN_2); |
| 28 | 34 | ||
| 29 | let mut driver = cyw43::Driver::new( | 35 | let state = forever!(cyw43::State::new()); |
| 36 | let (mut control, runner) = cyw43::new( | ||
| 37 | state, | ||
| 30 | Output::new(pwr, Level::Low), | 38 | Output::new(pwr, Level::Low), |
| 31 | Output::new(cs, Level::High), | 39 | Output::new(cs, Level::High), |
| 32 | Output::new(clk, Level::Low), | 40 | Output::new(clk, Level::Low), |
| 33 | Flex::new(dio), | 41 | Flex::new(dio), |
| 34 | ); | 42 | ) |
| 43 | .await; | ||
| 35 | 44 | ||
| 36 | driver.init().await; | 45 | spawner.spawn(wifi_task(runner)).unwrap(); |
| 37 | 46 | ||
| 38 | loop {} | 47 | control.init().await; |
| 39 | } | 48 | } |
