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/stm32l4/src | |
| parent | 7648d42b7f23a2caad29ed6e16123b088ccdc8b5 (diff) | |
net: refactor to simplify lifetimes/generics.
Diffstat (limited to 'examples/stm32l4/src')
| -rw-r--r-- | examples/stm32l4/src/bin/spe_adin1110_http_server.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs index bd633cecb..be4270ada 100644 --- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs | |||
| @@ -206,12 +206,11 @@ async fn main(spawner: Spawner) { | |||
| 206 | }; | 206 | }; |
| 207 | 207 | ||
| 208 | // Init network stack | 208 | // Init network stack |
| 209 | static STACK: StaticCell<Stack<Device<'static>>> = StaticCell::new(); | ||
| 210 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | 209 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); |
| 211 | let stack = &*STACK.init(Stack::new(device, ip_cfg, RESOURCES.init(StackResources::new()), seed)); | 210 | let (stack, runner) = embassy_net::new(device, ip_cfg, RESOURCES.init(StackResources::new()), seed); |
| 212 | 211 | ||
| 213 | // Launch network task | 212 | // Launch network task |
| 214 | unwrap!(spawner.spawn(net_task(stack))); | 213 | unwrap!(spawner.spawn(net_task(runner))); |
| 215 | 214 | ||
| 216 | let cfg = wait_for_config(stack).await; | 215 | let cfg = wait_for_config(stack).await; |
| 217 | let local_addr = cfg.address.address(); | 216 | let local_addr = cfg.address.address(); |
| @@ -274,7 +273,7 @@ async fn main(spawner: Spawner) { | |||
| 274 | } | 273 | } |
| 275 | } | 274 | } |
| 276 | 275 | ||
| 277 | async fn wait_for_config(stack: &'static Stack<Device<'static>>) -> embassy_net::StaticConfigV4 { | 276 | async fn wait_for_config(stack: Stack<'static>) -> embassy_net::StaticConfigV4 { |
| 278 | loop { | 277 | loop { |
| 279 | if let Some(config) = stack.config_v4() { | 278 | if let Some(config) = stack.config_v4() { |
| 280 | return config; | 279 | return config; |
| @@ -323,8 +322,8 @@ async fn ethernet_task(runner: Runner<'static, SpeSpiCs, SpeInt, SpeRst>) -> ! { | |||
| 323 | } | 322 | } |
| 324 | 323 | ||
| 325 | #[embassy_executor::task] | 324 | #[embassy_executor::task] |
| 326 | async fn net_task(stack: &'static Stack<Device<'static>>) -> ! { | 325 | async fn net_task(mut runner: embassy_net::Runner<'static, Device<'static>>) -> ! { |
| 327 | stack.run().await | 326 | runner.run().await |
| 328 | } | 327 | } |
| 329 | 328 | ||
| 330 | // same panicking *behavior* as `panic-probe` but doesn't print a panic message | 329 | // same panicking *behavior* as `panic-probe` but doesn't print a panic message |
