aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/std/src/bin/net.rs5
-rw-r--r--examples/stm32h7/src/bin/eth.rs9
2 files changed, 11 insertions, 3 deletions
diff --git a/examples/std/src/bin/net.rs b/examples/std/src/bin/net.rs
index 5a726e5d2..344a6e4d3 100644
--- a/examples/std/src/bin/net.rs
+++ b/examples/std/src/bin/net.rs
@@ -19,6 +19,7 @@ use crate::tuntap::TunTapDevice;
19 19
20static DEVICE: Forever<TunTapDevice> = Forever::new(); 20static DEVICE: Forever<TunTapDevice> = Forever::new();
21static CONFIG: Forever<DhcpConfigurator> = Forever::new(); 21static CONFIG: Forever<DhcpConfigurator> = Forever::new();
22static NET_RESOURCES: Forever<StackResources<1, 2, 8>> = Forever::new();
22 23
23#[derive(Clap)] 24#[derive(Clap)]
24#[clap(version = "1.0")] 25#[clap(version = "1.0")]
@@ -51,8 +52,10 @@ async fn main_task(spawner: Spawner) {
51 // DHCP configruation 52 // DHCP configruation
52 let config = DhcpConfigurator::new(); 53 let config = DhcpConfigurator::new();
53 54
55 let net_resources = StackResources::new();
56
54 // Init network stack 57 // Init network stack
55 embassy_net::init(DEVICE.put(device), CONFIG.put(config)); 58 embassy_net::init(DEVICE.put(device), CONFIG.put(config), NET_RESOURCES.put(net_resources));
56 59
57 // Launch network task 60 // Launch network task
58 spawner.spawn(net_task()).unwrap(); 61 spawner.spawn(net_task()).unwrap();
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs
index 57997da0a..7d7ff941e 100644
--- a/examples/stm32h7/src/bin/eth.rs
+++ b/examples/stm32h7/src/bin/eth.rs
@@ -16,7 +16,9 @@ use embassy::io::AsyncWriteExt;
16use embassy::time::{Duration, Timer}; 16use embassy::time::{Duration, Timer};
17use embassy::util::Forever; 17use embassy::util::Forever;
18use embassy_macros::interrupt_take; 18use embassy_macros::interrupt_take;
19use embassy_net::{Config as NetConfig, Ipv4Address, Ipv4Cidr, StaticConfigurator, TcpSocket}; 19use embassy_net::{
20 Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator, TcpSocket,
21};
20use embassy_stm32::clock::{Alarm, Clock}; 22use embassy_stm32::clock::{Alarm, Clock};
21use embassy_stm32::eth::lan8742a::LAN8742A; 23use embassy_stm32::eth::lan8742a::LAN8742A;
22use embassy_stm32::eth::Ethernet; 24use embassy_stm32::eth::Ethernet;
@@ -43,8 +45,10 @@ async fn main_task(
43 config: &'static mut StaticConfigurator, 45 config: &'static mut StaticConfigurator,
44 spawner: Spawner, 46 spawner: Spawner,
45) { 47) {
48 let net_resources = NET_RESOURCES.put(StackResources::new());
49
46 // Init network stack 50 // Init network stack
47 embassy_net::init(device, config); 51 embassy_net::init(device, config, net_resources);
48 52
49 // Launch network task 53 // Launch network task
50 unwrap!(spawner.spawn(net_task())); 54 unwrap!(spawner.spawn(net_task()));
@@ -97,6 +101,7 @@ static ALARM: Forever<Alarm<TIM2>> = Forever::new();
97static ETH: Forever<Ethernet<'static, LAN8742A, 4, 4>> = Forever::new(); 101static ETH: Forever<Ethernet<'static, LAN8742A, 4, 4>> = Forever::new();
98static DEVICE: Forever<Pin<&'static mut Ethernet<'static, LAN8742A, 4, 4>>> = Forever::new(); 102static DEVICE: Forever<Pin<&'static mut Ethernet<'static, LAN8742A, 4, 4>>> = Forever::new();
99static CONFIG: Forever<StaticConfigurator> = Forever::new(); 103static CONFIG: Forever<StaticConfigurator> = Forever::new();
104static NET_RESOURCES: Forever<StackResources<1, 2, 8>> = Forever::new();
100 105
101#[entry] 106#[entry]
102fn main() -> ! { 107fn main() -> ! {