aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32h7/src/bin/eth.rs43
-rw-r--r--examples/stm32h7/src/bin/eth_client.rs43
2 files changed, 42 insertions, 44 deletions
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs
index 4ccc0b5ef..551325ca4 100644
--- a/examples/stm32h7/src/bin/eth.rs
+++ b/examples/stm32h7/src/bin/eth.rs
@@ -7,7 +7,7 @@ use embassy_executor::Spawner;
7use embassy_net::tcp::TcpSocket; 7use embassy_net::tcp::TcpSocket;
8use embassy_net::{Ipv4Address, Stack, StackResources}; 8use embassy_net::{Ipv4Address, Stack, StackResources};
9use embassy_stm32::eth::generic_smi::GenericSMI; 9use embassy_stm32::eth::generic_smi::GenericSMI;
10use embassy_stm32::eth::{Ethernet, State}; 10use embassy_stm32::eth::{Ethernet, PacketQueue};
11use embassy_stm32::peripherals::ETH; 11use embassy_stm32::peripherals::ETH;
12use embassy_stm32::rng::Rng; 12use embassy_stm32::rng::Rng;
13use embassy_stm32::time::mhz; 13use embassy_stm32::time::mhz;
@@ -22,11 +22,12 @@ macro_rules! singleton {
22 ($val:expr) => {{ 22 ($val:expr) => {{
23 type T = impl Sized; 23 type T = impl Sized;
24 static STATIC_CELL: StaticCell<T> = StaticCell::new(); 24 static STATIC_CELL: StaticCell<T> = StaticCell::new();
25 STATIC_CELL.init_with(move || $val) 25 let (x,) = STATIC_CELL.init(($val,));
26 x
26 }}; 27 }};
27} 28}
28 29
29type Device = Ethernet<'static, ETH, GenericSMI, 4, 4>; 30type Device = Ethernet<'static, ETH, GenericSMI>;
30 31
31#[embassy_executor::task] 32#[embassy_executor::task]
32async fn net_task(stack: &'static Stack<Device>) -> ! { 33async fn net_task(stack: &'static Stack<Device>) -> ! {
@@ -51,25 +52,23 @@ async fn main(spawner: Spawner) -> ! {
51 let eth_int = interrupt::take!(ETH); 52 let eth_int = interrupt::take!(ETH);
52 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; 53 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
53 54
54 let device = unsafe { 55 let device = Ethernet::new(
55 Ethernet::new( 56 singleton!(PacketQueue::<16, 16>::new()),
56 singleton!(State::new()), 57 p.ETH,
57 p.ETH, 58 eth_int,
58 eth_int, 59 p.PA1,
59 p.PA1, 60 p.PA2,
60 p.PA2, 61 p.PC1,
61 p.PC1, 62 p.PA7,
62 p.PA7, 63 p.PC4,
63 p.PC4, 64 p.PC5,
64 p.PC5, 65 p.PG13,
65 p.PG13, 66 p.PB13,
66 p.PB13, 67 p.PG11,
67 p.PG11, 68 GenericSMI,
68 GenericSMI, 69 mac_addr,
69 mac_addr, 70 0,
70 0, 71 );
71 )
72 };
73 72
74 let config = embassy_net::ConfigStrategy::Dhcp; 73 let config = embassy_net::ConfigStrategy::Dhcp;
75 //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config { 74 //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config {
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs
index 64fd84141..61a08ae10 100644
--- a/examples/stm32h7/src/bin/eth_client.rs
+++ b/examples/stm32h7/src/bin/eth_client.rs
@@ -7,7 +7,7 @@ use embassy_executor::Spawner;
7use embassy_net::tcp::client::{TcpClient, TcpClientState}; 7use embassy_net::tcp::client::{TcpClient, TcpClientState};
8use embassy_net::{Stack, StackResources}; 8use embassy_net::{Stack, StackResources};
9use embassy_stm32::eth::generic_smi::GenericSMI; 9use embassy_stm32::eth::generic_smi::GenericSMI;
10use embassy_stm32::eth::{Ethernet, State}; 10use embassy_stm32::eth::{Ethernet, PacketQueue};
11use embassy_stm32::peripherals::ETH; 11use embassy_stm32::peripherals::ETH;
12use embassy_stm32::rng::Rng; 12use embassy_stm32::rng::Rng;
13use embassy_stm32::time::mhz; 13use embassy_stm32::time::mhz;
@@ -23,11 +23,12 @@ macro_rules! singleton {
23 ($val:expr) => {{ 23 ($val:expr) => {{
24 type T = impl Sized; 24 type T = impl Sized;
25 static STATIC_CELL: StaticCell<T> = StaticCell::new(); 25 static STATIC_CELL: StaticCell<T> = StaticCell::new();
26 STATIC_CELL.init_with(move || $val) 26 let (x,) = STATIC_CELL.init(($val,));
27 x
27 }}; 28 }};
28} 29}
29 30
30type Device = Ethernet<'static, ETH, GenericSMI, 4, 4>; 31type Device = Ethernet<'static, ETH, GenericSMI>;
31 32
32#[embassy_executor::task] 33#[embassy_executor::task]
33async fn net_task(stack: &'static Stack<Device>) -> ! { 34async fn net_task(stack: &'static Stack<Device>) -> ! {
@@ -52,25 +53,23 @@ async fn main(spawner: Spawner) -> ! {
52 let eth_int = interrupt::take!(ETH); 53 let eth_int = interrupt::take!(ETH);
53 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF]; 54 let mac_addr = [0x00, 0x00, 0xDE, 0xAD, 0xBE, 0xEF];
54 55
55 let device = unsafe { 56 let device = Ethernet::new(
56 Ethernet::new( 57 singleton!(PacketQueue::<16, 16>::new()),
57 singleton!(State::new()), 58 p.ETH,
58 p.ETH, 59 eth_int,
59 eth_int, 60 p.PA1,
60 p.PA1, 61 p.PA2,
61 p.PA2, 62 p.PC1,
62 p.PC1, 63 p.PA7,
63 p.PA7, 64 p.PC4,
64 p.PC4, 65 p.PC5,
65 p.PC5, 66 p.PG13,
66 p.PG13, 67 p.PB13,
67 p.PB13, 68 p.PG11,
68 p.PG11, 69 GenericSMI,
69 GenericSMI, 70 mac_addr,
70 mac_addr, 71 0,
71 0, 72 );
72 )
73 };
74 73
75 let config = embassy_net::ConfigStrategy::Dhcp; 74 let config = embassy_net::ConfigStrategy::Dhcp;
76 //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config { 75 //let config = embassy_net::ConfigStrategy::Static(embassy_net::Config {