aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32l5/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-09-11 22:06:26 +0200
committerDario Nieuwenhuis <[email protected]>2024-09-16 21:17:11 +0200
commitbe0d9775e3bcc3c1bd1448e357d7c6cd67b68991 (patch)
tree5e8c444b233a86ade113b096ab1e2934b7bbc7bd /examples/stm32l5/src
parent7648d42b7f23a2caad29ed6e16123b088ccdc8b5 (diff)
net: refactor to simplify lifetimes/generics.
Diffstat (limited to 'examples/stm32l5/src')
-rw-r--r--examples/stm32l5/src/bin/usb_ethernet.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs
index d02bac91d..095d50c73 100644
--- a/examples/stm32l5/src/bin/usb_ethernet.rs
+++ b/examples/stm32l5/src/bin/usb_ethernet.rs
@@ -4,7 +4,7 @@
4use defmt::*; 4use defmt::*;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_net::tcp::TcpSocket; 6use embassy_net::tcp::TcpSocket;
7use embassy_net::{Stack, StackResources}; 7use embassy_net::StackResources;
8use embassy_stm32::rng::Rng; 8use embassy_stm32::rng::Rng;
9use embassy_stm32::usb::Driver; 9use embassy_stm32::usb::Driver;
10use embassy_stm32::{bind_interrupts, peripherals, rng, usb, Config}; 10use embassy_stm32::{bind_interrupts, peripherals, rng, usb, Config};
@@ -36,8 +36,8 @@ async fn usb_ncm_task(class: Runner<'static, MyDriver, MTU>) -> ! {
36} 36}
37 37
38#[embassy_executor::task] 38#[embassy_executor::task]
39async fn net_task(stack: &'static Stack<Device<'static, MTU>>) -> ! { 39async fn net_task(mut runner: embassy_net::Runner<'static, Device<'static, MTU>>) -> ! {
40 stack.run().await 40 runner.run().await
41} 41}
42 42
43#[embassy_executor::main] 43#[embassy_executor::main]
@@ -121,11 +121,10 @@ async fn main(spawner: Spawner) {
121 let seed = rng.next_u64(); 121 let seed = rng.next_u64();
122 122
123 // Init network stack 123 // Init network stack
124 static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new();
125 static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); 124 static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new();
126 let stack = &*STACK.init(Stack::new(device, config, RESOURCES.init(StackResources::new()), seed)); 125 let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed);
127 126
128 unwrap!(spawner.spawn(net_task(stack))); 127 unwrap!(spawner.spawn(net_task(runner)));
129 128
130 // And now we can use it! 129 // And now we can use it!
131 130