diff options
| author | Thales Fragoso <[email protected]> | 2021-06-20 16:46:26 -0300 |
|---|---|---|
| committer | Thales Fragoso <[email protected]> | 2021-06-20 17:15:18 -0300 |
| commit | aca0fb10651359b5a3939f7424ac0a78ef20cc27 (patch) | |
| tree | e47b640f37c9daab65f2577f6a23e4e2b12be290 /examples/stm32h7/src | |
| parent | 06d69a802856f9064c41dae814070b4e1ad5cf02 (diff) | |
net: Make the user pass in the StackResources in init
By having the user pass in the resources, we can make them generic, this way
the user can choose the size of the individual resources
Diffstat (limited to 'examples/stm32h7/src')
| -rw-r--r-- | examples/stm32h7/src/bin/eth.rs | 9 |
1 files changed, 7 insertions, 2 deletions
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; | |||
| 16 | use embassy::time::{Duration, Timer}; | 16 | use embassy::time::{Duration, Timer}; |
| 17 | use embassy::util::Forever; | 17 | use embassy::util::Forever; |
| 18 | use embassy_macros::interrupt_take; | 18 | use embassy_macros::interrupt_take; |
| 19 | use embassy_net::{Config as NetConfig, Ipv4Address, Ipv4Cidr, StaticConfigurator, TcpSocket}; | 19 | use embassy_net::{ |
| 20 | Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator, TcpSocket, | ||
| 21 | }; | ||
| 20 | use embassy_stm32::clock::{Alarm, Clock}; | 22 | use embassy_stm32::clock::{Alarm, Clock}; |
| 21 | use embassy_stm32::eth::lan8742a::LAN8742A; | 23 | use embassy_stm32::eth::lan8742a::LAN8742A; |
| 22 | use embassy_stm32::eth::Ethernet; | 24 | use 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(); | |||
| 97 | static ETH: Forever<Ethernet<'static, LAN8742A, 4, 4>> = Forever::new(); | 101 | static ETH: Forever<Ethernet<'static, LAN8742A, 4, 4>> = Forever::new(); |
| 98 | static DEVICE: Forever<Pin<&'static mut Ethernet<'static, LAN8742A, 4, 4>>> = Forever::new(); | 102 | static DEVICE: Forever<Pin<&'static mut Ethernet<'static, LAN8742A, 4, 4>>> = Forever::new(); |
| 99 | static CONFIG: Forever<StaticConfigurator> = Forever::new(); | 103 | static CONFIG: Forever<StaticConfigurator> = Forever::new(); |
| 104 | static NET_RESOURCES: Forever<StackResources<1, 2, 8>> = Forever::new(); | ||
| 100 | 105 | ||
| 101 | #[entry] | 106 | #[entry] |
| 102 | fn main() -> ! { | 107 | fn main() -> ! { |
