aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-08-22 17:24:43 +0200
committerDario Nieuwenhuis <[email protected]>2022-08-22 17:26:05 +0200
commit945449b10fe815dd10875f55482d4777d6d801b7 (patch)
treea8abaf8af7fcdc23029b6c4865b6dcbc5af7eaad /examples
parent79c7be3fc65315c2822cae139bf514096a66641a (diff)
Update Embassy.
Diffstat (limited to 'examples')
-rw-r--r--examples/rpi-pico-w/Cargo.toml15
-rw-r--r--examples/rpi-pico-w/src/main.rs21
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]
8cyw43 = { path = "../../", features = ["defmt"]} 8cyw43 = { path = "../../", features = ["defmt"]}
9embassy-executor = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] } 9embassy-executor = { version = "0.1.0", features = ["defmt", "integrated-timers"] }
10embassy-time = { version = "0.1.0", features = ["defmt", "defmt-timestamp-uptime"] }
10embassy-util = { version = "0.1.0" } 11embassy-util = { version = "0.1.0" }
11embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] } 12embassy-rp = { version = "0.1.0", features = ["defmt", "unstable-traits", "nightly", "unstable-pac"] }
12embassy-net = { version = "0.1.0", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] } 13embassy-net = { version = "0.1.0", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "pool-16"] }
13atomic-polyfill = "0.1.5" 14atomic-polyfill = "0.1.5"
15static_cell = "1.0"
14 16
15defmt = "0.3" 17defmt = "0.3"
16defmt-rtt = "0.3" 18defmt-rtt = "0.3"
17panic-probe = { version = "0.3", features = ["print-defmt"] } 19panic-probe = { version = "0.3", features = ["print-defmt"] }
18 20
19cortex-m = "0.7.3" 21cortex-m = { version = "0.7.6", features = ["critical-section-single-core"]}
20cortex-m-rt = "0.7.0" 22cortex-m-rt = "0.7.0"
21futures = { version = "0.3.17", default-features = false, features = ["async-await", "cfg-target-has-atomic", "unstable"] } 23futures = { 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]
30embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "6ffca81a38d2c7f57da667ff49b4296c4eba78e2" } 32embassy-executor = { git = "https://github.com/embassy-rs/embassy", rev = "53fbd0efb3e77e1e3de948afde2b5bf1a5a9735f" }
31embassy-util = { git = "https://github.com/embassy-rs/embassy", rev = "6ffca81a38d2c7f57da667ff49b4296c4eba78e2" } 33embassy-time = { git = "https://github.com/embassy-rs/embassy", rev = "53fbd0efb3e77e1e3de948afde2b5bf1a5a9735f" }
32embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "6ffca81a38d2c7f57da667ff49b4296c4eba78e2" } 34embassy-util = { git = "https://github.com/embassy-rs/embassy", rev = "53fbd0efb3e77e1e3de948afde2b5bf1a5a9735f" }
33embassy-net = { git = "https://github.com/embassy-rs/embassy", rev = "6ffca81a38d2c7f57da667ff49b4296c4eba78e2" } 35embassy-rp = { git = "https://github.com/embassy-rs/embassy", rev = "53fbd0efb3e77e1e3de948afde2b5bf1a5a9735f" }
36embassy-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;
6use core::future::Future; 6use core::future::Future;
7 7
8use defmt::*; 8use defmt::*;
9use embassy_executor::executor::Spawner; 9use embassy_executor::Spawner;
10use embassy_net::tcp::TcpSocket; 10use embassy_net::tcp::TcpSocket;
11use embassy_net::{Stack, StackResources}; 11use embassy_net::{Stack, StackResources};
12use embassy_rp::gpio::{Flex, Level, Output}; 12use embassy_rp::gpio::{Flex, Level, Output};
13use embassy_rp::peripherals::{PIN_23, PIN_24, PIN_25, PIN_29}; 13use embassy_rp::peripherals::{PIN_23, PIN_24, PIN_25, PIN_29};
14use embassy_rp::Peripherals;
15use embassy_util::Forever;
16use embedded_hal_1::spi::ErrorType; 14use embedded_hal_1::spi::ErrorType;
17use embedded_hal_async::spi::{ExclusiveDevice, SpiBusFlush, SpiBusRead, SpiBusWrite}; 15use embedded_hal_async::spi::{ExclusiveDevice, SpiBusFlush, SpiBusRead, SpiBusWrite};
18use embedded_io::asynch::{Read, Write}; 16use embedded_io::asynch::{Read, Write};
17use static_cell::StaticCell;
19use {defmt_rtt as _, panic_probe as _}; 18use {defmt_rtt as _, panic_probe as _};
20 19
21macro_rules! forever { 20macro_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]
42async fn main(spawner: Spawner, p: Peripherals) { 41async 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