aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32f4/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-01-26 22:42:13 +0100
committerDario Nieuwenhuis <[email protected]>2025-01-26 22:43:28 +0100
commitb1245858f355e764a17eda819198f68ad83883ab (patch)
tree6fd7b65aa4e66c0874c71112b1d486bcb68928e6 /examples/stm32f4/src
parentc8d29a1e2cd3f28c3afdd52a679fcb49f67e812c (diff)
stm32/eth: rename PHY->Phy, GenericSMI -> GenericPhy. Remove unneeded unsafes.
We shouldn't use `unsafe` to mark merely "dangerous" actions, only actions that actually cause UB.
Diffstat (limited to 'examples/stm32f4/src')
-rw-r--r--examples/stm32f4/src/bin/eth.rs7
-rw-r--r--examples/stm32f4/src/bin/eth_compliance_test.rs7
2 files changed, 6 insertions, 8 deletions
diff --git a/examples/stm32f4/src/bin/eth.rs b/examples/stm32f4/src/bin/eth.rs
index a3af8f75c..634d8e2c6 100644
--- a/examples/stm32f4/src/bin/eth.rs
+++ b/examples/stm32f4/src/bin/eth.rs
@@ -5,8 +5,7 @@ use defmt::*;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_net::tcp::TcpSocket; 6use embassy_net::tcp::TcpSocket;
7use embassy_net::{Ipv4Address, StackResources}; 7use embassy_net::{Ipv4Address, StackResources};
8use embassy_stm32::eth::generic_smi::GenericSMI; 8use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue};
9use embassy_stm32::eth::{Ethernet, PacketQueue};
10use embassy_stm32::peripherals::ETH; 9use embassy_stm32::peripherals::ETH;
11use embassy_stm32::rng::Rng; 10use embassy_stm32::rng::Rng;
12use embassy_stm32::time::Hertz; 11use embassy_stm32::time::Hertz;
@@ -21,7 +20,7 @@ bind_interrupts!(struct Irqs {
21 HASH_RNG => rng::InterruptHandler<peripherals::RNG>; 20 HASH_RNG => rng::InterruptHandler<peripherals::RNG>;
22}); 21});
23 22
24type Device = Ethernet<'static, ETH, GenericSMI>; 23type Device = Ethernet<'static, ETH, GenericPhy>;
25 24
26#[embassy_executor::task] 25#[embassy_executor::task]
27async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { 26async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! {
@@ -76,7 +75,7 @@ async fn main(spawner: Spawner) -> ! {
76 p.PG13, 75 p.PG13,
77 p.PB13, 76 p.PB13,
78 p.PG11, 77 p.PG11,
79 GenericSMI::new_auto(), 78 GenericPhy::new_auto(),
80 mac_addr, 79 mac_addr,
81 ); 80 );
82 81
diff --git a/examples/stm32f4/src/bin/eth_compliance_test.rs b/examples/stm32f4/src/bin/eth_compliance_test.rs
index 5946fed79..52f9d57f6 100644
--- a/examples/stm32f4/src/bin/eth_compliance_test.rs
+++ b/examples/stm32f4/src/bin/eth_compliance_test.rs
@@ -3,8 +3,7 @@
3 3
4use defmt::*; 4use defmt::*;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_stm32::eth::generic_smi::GenericSMI; 6use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue, StationManagement};
7use embassy_stm32::eth::{Ethernet, PacketQueue, StationManagement};
8use embassy_stm32::time::Hertz; 7use embassy_stm32::time::Hertz;
9use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; 8use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config};
10use embassy_time::Timer; 9use embassy_time::Timer;
@@ -59,11 +58,11 @@ async fn main(_spawner: Spawner) -> ! {
59 p.PG13, 58 p.PG13,
60 p.PB13, 59 p.PB13,
61 p.PG11, 60 p.PG11,
62 GenericSMI::new(PHY_ADDR), 61 GenericPhy::new(PHY_ADDR),
63 mac_addr, 62 mac_addr,
64 ); 63 );
65 64
66 let sm = unsafe { device.station_management() }; 65 let sm = device.station_management();
67 66
68 // Just an example. Exact register settings depend on the specific PHY and test. 67 // Just an example. Exact register settings depend on the specific PHY and test.
69 sm.smi_write(PHY_ADDR, 0, 0x2100); 68 sm.smi_write(PHY_ADDR, 0, 0x2100);