diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-08-22 17:24:43 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-08-22 17:26:05 +0200 |
| commit | 945449b10fe815dd10875f55482d4777d6d801b7 (patch) | |
| tree | a8abaf8af7fcdc23029b6c4865b6dcbc5af7eaad /examples | |
| parent | 79c7be3fc65315c2822cae139bf514096a66641a (diff) | |
Update Embassy.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rpi-pico-w/Cargo.toml | 15 | ||||
| -rw-r--r-- | examples/rpi-pico-w/src/main.rs | 21 |
2 files changed, 20 insertions, 16 deletions
diff --git a/examples/rpi-pico-w/Cargo.toml b/examples/rpi-pico-w/Cargo.toml index af558d8cd..98a3d105d 100644 --- a/examples/rpi-pico-w/Cargo.toml +++ b/examples/rpi-pico-w/Cargo.toml | |||
| @@ -6,17 +6,19 @@ edition = "2021" | |||
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | cyw43 = { path = "../../", features = ["defmt"]} | 8 | cyw43 = { path = "../../", features = ["defmt"]} |
| 9 | embassy-executor = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] } | 9 | embassy-executor = { version = "0.1.0", features = ["defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] } | ||
| 10 | embassy-util = { version = "0.1.0" } | 11 | embassy-util = { version = "0.1.0" } |
| 11 | embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] } | 12 | embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] } |
| 12 | embassy-net = { version = "0.1.0", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] } | 13 | embassy-net = { version = "0.1.0", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] } |
| 13 | atomic-polyfill = "0.1.5" | 14 | atomic-polyfill = "0.1.5" |
| 15 | static_cell = "1.0" | ||
| 14 | 16 | ||
| 15 | defmt = "0.3" | 17 | defmt = "0.3" |
| 16 | defmt-rtt = "0.3" | 18 | defmt-rtt = "0.3" |
| 17 | panic-probe = { version = "0.3", features = ["print-defmt"] } | 19 | panic-probe = { version = "0.3", features = ["print-defmt"] } |
| 18 | 20 | ||
| 19 | cortex-m = "0.7.3" | 21 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"]} |
| 20 | cortex-m-rt = "0.7.0" | 22 | cortex-m-rt = "0.7.0" |
| 21 | futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } | 23 | futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } |
| 22 | 24 | ||
| @@ -27,10 +29,11 @@ heapless = "0.7.15" | |||
| 27 | 29 | ||
| 28 | 30 | ||
| 29 | [patch.crates-io] | 31 | [patch.crates-io] |
| 30 | embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "6ffca81a38d2c7f57da667ff49b4296c4eba78e2" } | 32 | embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "53fbd0efb3e77e1e3de948afde2b5bf1a5a9735f" } |
| 31 | embassy-util = { git = "https://github.com/embassy-rs/embassy", rev = "6ffca81a38d2c7f57da667ff49b4296c4eba78e2" } | 33 | embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "53fbd0efb3e77e1e3de948afde2b5bf1a5a9735f" } |
| 32 | embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "6ffca81a38d2c7f57da667ff49b4296c4eba78e2" } | 34 | embassy-util = { git = "https://github.com/embassy-rs/embassy", rev = "53fbd0efb3e77e1e3de948afde2b5bf1a5a9735f" } |
| 33 | embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "6ffca81a38d2c7f57da667ff49b4296c4eba78e2" } | 35 | embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "53fbd0efb3e77e1e3de948afde2b5bf1a5a9735f" } |
| 36 | embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "53fbd0efb3e77e1e3de948afde2b5bf1a5a9735f" } | ||
| 34 | #embassy-executor = { path = "/home/dirbaio/embassy/embassy/embassy-executor" } | 37 | #embassy-executor = { path = "/home/dirbaio/embassy/embassy/embassy-executor" } |
| 35 | #embassy-util = { path = "/home/dirbaio/embassy/embassy/embassy-util" } | 38 | #embassy-util = { path = "/home/dirbaio/embassy/embassy/embassy-util" } |
| 36 | #embassy-rp = { path = "/home/dirbaio/embassy/embassy/embassy-rp" } | 39 | #embassy-rp = { path = "/home/dirbaio/embassy/embassy/embassy-rp" } |
diff --git a/examples/rpi-pico-w/src/main.rs b/examples/rpi-pico-w/src/main.rs index 569c9bf4c..986474ce3 100644 --- a/examples/rpi-pico-w/src/main.rs +++ b/examples/rpi-pico-w/src/main.rs | |||
| @@ -6,23 +6,22 @@ use core::convert::Infallible; | |||
| 6 | use core::future::Future; | 6 | use core::future::Future; |
| 7 | 7 | ||
| 8 | use defmt::*; | 8 | use defmt::*; |
| 9 | use embassy_executor::executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 10 | use embassy_net::tcp::TcpSocket; | 10 | use embassy_net::tcp::TcpSocket; |
| 11 | use embassy_net::{Stack, StackResources}; | 11 | use embassy_net::{Stack, StackResources}; |
| 12 | use embassy_rp::gpio::{Flex, Level, Output}; | 12 | use embassy_rp::gpio::{Flex, Level, Output}; |
| 13 | use embassy_rp::peripherals::{PIN_23, PIN_24, PIN_25, PIN_29}; | 13 | use embassy_rp::peripherals::{PIN_23, PIN_24, PIN_25, PIN_29}; |
| 14 | use embassy_rp::Peripherals; | ||
| 15 | use embassy_util::Forever; | ||
| 16 | use embedded_hal_1::spi::ErrorType; | 14 | use embedded_hal_1::spi::ErrorType; |
| 17 | use embedded_hal_async::spi::{ExclusiveDevice, SpiBusFlush, SpiBusRead, SpiBusWrite}; | 15 | use embedded_hal_async::spi::{ExclusiveDevice, SpiBusFlush, SpiBusRead, SpiBusWrite}; |
| 18 | use embedded_io::asynch::{Read, Write}; | 16 | use embedded_io::asynch::{Read, Write}; |
| 17 | use static_cell::StaticCell; | ||
| 19 | use {defmt_rtt as _, panic_probe as _}; | 18 | use {defmt_rtt as _, panic_probe as _}; |
| 20 | 19 | ||
| 21 | macro_rules! forever { | 20 | macro_rules! singleton { |
| 22 | ($val:expr) => {{ | 21 | ($val:expr) => {{ |
| 23 | type T = impl Sized; | 22 | type T = impl Sized; |
| 24 | static FOREVER: Forever<T> = Forever::new(); | 23 | static STATIC_CELL: StaticCell<T> = StaticCell::new(); |
| 25 | FOREVER.put_with(move || $val) | 24 | STATIC_CELL.init_with(move || $val) |
| 26 | }}; | 25 | }}; |
| 27 | } | 26 | } |
| 28 | 27 | ||
| @@ -39,9 +38,11 @@ async fn net_task(stack: &'static Stack<cyw43::NetDevice<'static>>) -> ! { | |||
| 39 | } | 38 | } |
| 40 | 39 | ||
| 41 | #[embassy_executor::main] | 40 | #[embassy_executor::main] |
| 42 | async fn main(spawner: Spawner, p: Peripherals) { | 41 | async fn main(spawner: Spawner) { |
| 43 | info!("Hello World!"); | 42 | info!("Hello World!"); |
| 44 | 43 | ||
| 44 | let p = embassy_rp::init(Default::default()); | ||
| 45 | |||
| 45 | // Include the WiFi firmware and Country Locale Matrix (CLM) blobs. | 46 | // Include the WiFi firmware and Country Locale Matrix (CLM) blobs. |
| 46 | let fw = include_bytes!("../../../firmware/43439A0.bin"); | 47 | let fw = include_bytes!("../../../firmware/43439A0.bin"); |
| 47 | let clm = include_bytes!("../../../firmware/43439A0_clm.bin"); | 48 | let clm = include_bytes!("../../../firmware/43439A0_clm.bin"); |
| @@ -63,7 +64,7 @@ async fn main(spawner: Spawner, p: Peripherals) { | |||
| 63 | let bus = MySpi { clk, dio }; | 64 | let bus = MySpi { clk, dio }; |
| 64 | let spi = ExclusiveDevice::new(bus, cs); | 65 | let spi = ExclusiveDevice::new(bus, cs); |
| 65 | 66 | ||
| 66 | let state = forever!(cyw43::State::new()); | 67 | let state = singleton!(cyw43::State::new()); |
| 67 | let (mut control, runner) = cyw43::new(state, pwr, spi, fw).await; | 68 | let (mut control, runner) = cyw43::new(state, pwr, spi, fw).await; |
| 68 | 69 | ||
| 69 | spawner.spawn(wifi_task(runner)).unwrap(); | 70 | spawner.spawn(wifi_task(runner)).unwrap(); |
| @@ -84,10 +85,10 @@ async fn main(spawner: Spawner, p: Peripherals) { | |||
| 84 | let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random. | 85 | let seed = 0x0123_4567_89ab_cdef; // chosen by fair dice roll. guarenteed to be random. |
| 85 | 86 | ||
| 86 | // Init network stack | 87 | // Init network stack |
| 87 | let stack = &*forever!(Stack::new( | 88 | let stack = &*singleton!(Stack::new( |
| 88 | net_device, | 89 | net_device, |
| 89 | config, | 90 | config, |
| 90 | forever!(StackResources::<1, 2, 8>::new()), | 91 | singleton!(StackResources::<1, 2, 8>::new()), |
| 91 | seed | 92 | seed |
| 92 | )); | 93 | )); |
| 93 | 94 | ||
