diff options
Diffstat (limited to 'examples/stm32f4/src/bin/eth.rs')
| -rw-r--r-- | examples/stm32f4/src/bin/eth.rs | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/examples/stm32f4/src/bin/eth.rs b/examples/stm32f4/src/bin/eth.rs index 9388c64bf..baed96449 100644 --- a/examples/stm32f4/src/bin/eth.rs +++ b/examples/stm32f4/src/bin/eth.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::{Ipv4Address, Stack, StackResources}; | 7 | use embassy_net::{Ipv4Address, StackResources}; |
| 8 | use embassy_stm32::eth::generic_smi::GenericSMI; | 8 | use embassy_stm32::eth::generic_smi::GenericSMI; |
| 9 | use embassy_stm32::eth::{Ethernet, PacketQueue}; | 9 | use embassy_stm32::eth::{Ethernet, PacketQueue}; |
| 10 | use embassy_stm32::peripherals::ETH; | 10 | use embassy_stm32::peripherals::ETH; |
| @@ -24,8 +24,8 @@ bind_interrupts!(struct Irqs { | |||
| 24 | type Device = Ethernet<'static, ETH, GenericSMI>; | 24 | type Device = Ethernet<'static, ETH, GenericSMI>; |
| 25 | 25 | ||
| 26 | #[embassy_executor::task] | 26 | #[embassy_executor::task] |
| 27 | async fn net_task(stack: &'static Stack<Device>) -> ! { | 27 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { |
| 28 | stack.run().await | 28 | runner.run().await |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | #[embassy_executor::main] | 31 | #[embassy_executor::main] |
| @@ -88,12 +88,11 @@ async fn main(spawner: Spawner) -> ! { | |||
| 88 | //}); | 88 | //}); |
| 89 | 89 | ||
| 90 | // Init network stack | 90 | // Init network stack |
| 91 | static STACK: StaticCell<Stack<Device>> = StaticCell::new(); | ||
| 92 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); | 91 | static RESOURCES: StaticCell<StackResources<3>> = StaticCell::new(); |
| 93 | let stack = &*STACK.init(Stack::new(device, config, RESOURCES.init(StackResources::new()), seed)); | 92 | let (stack, runner) = embassy_net::new(device, config, RESOURCES.init(StackResources::new()), seed); |
| 94 | 93 | ||
| 95 | // Launch network task | 94 | // Launch network task |
| 96 | unwrap!(spawner.spawn(net_task(stack))); | 95 | unwrap!(spawner.spawn(net_task(runner))); |
| 97 | 96 | ||
| 98 | // Ensure DHCP configuration is up before trying connect | 97 | // Ensure DHCP configuration is up before trying connect |
| 99 | stack.wait_config_up().await; | 98 | stack.wait_config_up().await; |
| @@ -105,7 +104,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 105 | let mut tx_buffer = [0; 4096]; | 104 | let mut tx_buffer = [0; 4096]; |
| 106 | 105 | ||
| 107 | loop { | 106 | loop { |
| 108 | let mut socket = TcpSocket::new(&stack, &mut rx_buffer, &mut tx_buffer); | 107 | let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer); |
| 109 | 108 | ||
| 110 | socket.set_timeout(Some(embassy_time::Duration::from_secs(10))); | 109 | socket.set_timeout(Some(embassy_time::Duration::from_secs(10))); |
| 111 | 110 | ||
