net: refactor to simplify lifetimes/generics.

This commit is contained in:
Dario Nieuwenhuis
2024-09-11 22:06:26 +02:00
parent 7648d42b7f
commit be0d9775e3
43 changed files with 500 additions and 604 deletions

View File

@@ -6,7 +6,7 @@
mod common;
use common::*;
use embassy_executor::Spawner;
use embassy_net::{Stack, StackResources};
use embassy_net::StackResources;
use embassy_stm32::eth::generic_smi::GenericSMI;
use embassy_stm32::eth::{Ethernet, PacketQueue};
use embassy_stm32::peripherals::ETH;
@@ -32,8 +32,8 @@ bind_interrupts!(struct Irqs {
type Device = Ethernet<'static, ETH, GenericSMI>;
#[embassy_executor::task]
async fn net_task(stack: &'static Stack<Device>) -> ! {
stack.run().await
async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! {
runner.run().await
}
#[embassy_executor::main]
@@ -99,12 +99,11 @@ async fn main(spawner: Spawner) {
//});
// Init network stack
static STACK: StaticCell<Stack<Device>> = StaticCell::new();
static RESOURCES: StaticCell<StackResources<2>> = StaticCell::new();
let stack = &*STACK.init(Stack::new(device, config, RESOURCES.init(StackResources::new()), seed));
let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed);
// Launch network task
unwrap!(spawner.spawn(net_task(&stack)));
unwrap!(spawner.spawn(net_task(runner)));
perf_client::run(
stack,