diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-09-11 22:06:26 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-09-16 21:17:11 +0200 |
| commit | be0d9775e3bcc3c1bd1448e357d7c6cd67b68991 (patch) | |
| tree | 5e8c444b233a86ade113b096ab1e2934b7bbc7bd /examples/stm32f4/src/bin/usb_ethernet.rs | |
| parent | 7648d42b7f23a2caad29ed6e16123b088ccdc8b5 (diff) | |
net: refactor to simplify lifetimes/generics.
Diffstat (limited to 'examples/stm32f4/src/bin/usb_ethernet.rs')
| -rw-r--r-- | examples/stm32f4/src/bin/usb_ethernet.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/stm32f4/src/bin/usb_ethernet.rs b/examples/stm32f4/src/bin/usb_ethernet.rs index 94e51c338..a9504ec04 100644 --- a/examples/stm32f4/src/bin/usb_ethernet.rs +++ b/examples/stm32f4/src/bin/usb_ethernet.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_net::tcp::TcpSocket; | 6 | use embassy_net::tcp::TcpSocket; |
| 7 | use embassy_net::{Stack, StackResources}; | 7 | use embassy_net::StackResources; |
| 8 | use embassy_stm32::rng::{self, Rng}; | 8 | use embassy_stm32::rng::{self, Rng}; |
| 9 | use embassy_stm32::time::Hertz; | 9 | use embassy_stm32::time::Hertz; |
| 10 | use embassy_stm32::usb::Driver; | 10 | use embassy_stm32::usb::Driver; |
| @@ -31,8 +31,8 @@ async fn usb_ncm_task(class: Runner<'static, UsbDriver, MTU>) -> ! { | |||
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | #[embassy_executor::task] | 33 | #[embassy_executor::task] |
| 34 | async fn net_task(stack: &'static Stack<Device<'static, MTU>>) -> ! { | 34 | async fn net_task(mut runner: embassy_net::Runner<'static, Device<'static, MTU>>) -> ! { |
| 35 | stack.run().await | 35 | runner.run().await |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | bind_interrupts!(struct Irqs { | 38 | bind_interrupts!(struct Irqs { |
| @@ -144,11 +144,10 @@ async fn main(spawner: Spawner) { | |||
| 144 | let seed = u64::from_le_bytes(seed); | 144 | let seed = u64::from_le_bytes(seed); |
| 145 | 145 | ||
| 146 | // Init network stack | 146 | // Init network stack |
| 147 | static STACK: StaticCell<Stack<Device<'static, MTU>>> = StaticCell::new(); | ||
| 148 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | 147 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); |
| 149 | let stack = &*STACK.init(Stack::new(device, config, RESOURCES.init(StackResources::new()), seed)); | 148 | let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed); |
| 150 | 149 | ||
| 151 | unwrap!(spawner.spawn(net_task(stack))); | 150 | unwrap!(spawner.spawn(net_task(runner))); |
| 152 | 151 | ||
| 153 | // And now we can use it! | 152 | // And now we can use it! |
| 154 | 153 | ||
