diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-01-26 21:52:43 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-01-26 21:52:43 +0000 |
| commit | ecc1aab867ede9f0b5146b758a5797dbc595d486 (patch) | |
| tree | 6fd7b65aa4e66c0874c71112b1d486bcb68928e6 | |
| parent | c8d29a1e2cd3f28c3afdd52a679fcb49f67e812c (diff) | |
| parent | b1245858f355e764a17eda819198f68ad83883ab (diff) | |
Merge pull request #3813 from embassy-rs/stm32-eth-simplify-smi
stm32/eth: rename PHY->Phy, GenericSMI -> GenericPhy. Remove unneeded unsafes.
| -rw-r--r-- | embassy-stm32/src/eth/generic_phy.rs (renamed from embassy-stm32/src/eth/generic_smi.rs) | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/eth/mod.rs | 38 | ||||
| -rw-r--r-- | embassy-stm32/src/eth/v1/mod.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/eth/v2/mod.rs | 8 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/eth.rs | 7 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/eth_compliance_test.rs | 7 | ||||
| -rw-r--r-- | examples/stm32f7/src/bin/eth.rs | 7 | ||||
| -rw-r--r-- | examples/stm32h5/src/bin/eth.rs | 7 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/eth.rs | 7 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/eth_client.rs | 7 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/eth_client_mii.rs | 7 | ||||
| -rw-r--r-- | tests/stm32/src/bin/eth.rs | 7 |
12 files changed, 56 insertions, 66 deletions
diff --git a/embassy-stm32/src/eth/generic_smi.rs b/embassy-stm32/src/eth/generic_phy.rs index 239c52634..774beef80 100644 --- a/embassy-stm32/src/eth/generic_smi.rs +++ b/embassy-stm32/src/eth/generic_phy.rs | |||
| @@ -7,7 +7,7 @@ use embassy_time::{Duration, Timer}; | |||
| 7 | #[cfg(feature = "time")] | 7 | #[cfg(feature = "time")] |
| 8 | use futures_util::FutureExt; | 8 | use futures_util::FutureExt; |
| 9 | 9 | ||
| 10 | use super::{StationManagement, PHY}; | 10 | use super::{Phy, StationManagement}; |
| 11 | 11 | ||
| 12 | #[allow(dead_code)] | 12 | #[allow(dead_code)] |
| 13 | mod phy_consts { | 13 | mod phy_consts { |
| @@ -43,13 +43,13 @@ mod phy_consts { | |||
| 43 | use self::phy_consts::*; | 43 | use self::phy_consts::*; |
| 44 | 44 | ||
| 45 | /// Generic SMI Ethernet PHY implementation | 45 | /// Generic SMI Ethernet PHY implementation |
| 46 | pub struct GenericSMI { | 46 | pub struct GenericPhy { |
| 47 | phy_addr: u8, | 47 | phy_addr: u8, |
| 48 | #[cfg(feature = "time")] | 48 | #[cfg(feature = "time")] |
| 49 | poll_interval: Duration, | 49 | poll_interval: Duration, |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | impl GenericSMI { | 52 | impl GenericPhy { |
| 53 | /// Construct the PHY. It assumes the address `phy_addr` in the SMI communication | 53 | /// Construct the PHY. It assumes the address `phy_addr` in the SMI communication |
| 54 | /// | 54 | /// |
| 55 | /// # Panics | 55 | /// # Panics |
| @@ -89,7 +89,7 @@ fn blocking_delay_us(us: u32) { | |||
| 89 | } | 89 | } |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | unsafe impl PHY for GenericSMI { | 92 | impl Phy for GenericPhy { |
| 93 | fn phy_reset<S: StationManagement>(&mut self, sm: &mut S) { | 93 | fn phy_reset<S: StationManagement>(&mut self, sm: &mut S) { |
| 94 | // Detect SMI address | 94 | // Detect SMI address |
| 95 | if self.phy_addr == 0xFF { | 95 | if self.phy_addr == 0xFF { |
| @@ -148,7 +148,7 @@ unsafe impl PHY for GenericSMI { | |||
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | /// Public functions for the PHY | 150 | /// Public functions for the PHY |
| 151 | impl GenericSMI { | 151 | impl GenericPhy { |
| 152 | /// Set the SMI polling interval. | 152 | /// Set the SMI polling interval. |
| 153 | #[cfg(feature = "time")] | 153 | #[cfg(feature = "time")] |
| 154 | pub fn set_poll_interval(&mut self, poll_interval: Duration) { | 154 | pub fn set_poll_interval(&mut self, poll_interval: Duration) { |
diff --git a/embassy-stm32/src/eth/mod.rs b/embassy-stm32/src/eth/mod.rs index 773452bf2..109ceeeb3 100644 --- a/embassy-stm32/src/eth/mod.rs +++ b/embassy-stm32/src/eth/mod.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | #[cfg_attr(any(eth_v1a, eth_v1b, eth_v1c), path = "v1/mod.rs")] | 4 | #[cfg_attr(any(eth_v1a, eth_v1b, eth_v1c), path = "v1/mod.rs")] |
| 5 | #[cfg_attr(eth_v2, path = "v2/mod.rs")] | 5 | #[cfg_attr(eth_v2, path = "v2/mod.rs")] |
| 6 | mod _version; | 6 | mod _version; |
| 7 | pub mod generic_smi; | 7 | mod generic_phy; |
| 8 | 8 | ||
| 9 | use core::mem::MaybeUninit; | 9 | use core::mem::MaybeUninit; |
| 10 | use core::task::Context; | 10 | use core::task::Context; |
| @@ -13,6 +13,7 @@ use embassy_net_driver::{Capabilities, HardwareAddress, LinkState}; | |||
| 13 | use embassy_sync::waitqueue::AtomicWaker; | 13 | use embassy_sync::waitqueue::AtomicWaker; |
| 14 | 14 | ||
| 15 | pub use self::_version::{InterruptHandler, *}; | 15 | pub use self::_version::{InterruptHandler, *}; |
| 16 | pub use self::generic_phy::*; | ||
| 16 | use crate::rcc::RccPeripheral; | 17 | use crate::rcc::RccPeripheral; |
| 17 | 18 | ||
| 18 | #[allow(unused)] | 19 | #[allow(unused)] |
| @@ -71,7 +72,7 @@ impl<const TX: usize, const RX: usize> PacketQueue<TX, RX> { | |||
| 71 | 72 | ||
| 72 | static WAKER: AtomicWaker = AtomicWaker::new(); | 73 | static WAKER: AtomicWaker = AtomicWaker::new(); |
| 73 | 74 | ||
| 74 | impl<'d, T: Instance, P: PHY> embassy_net_driver::Driver for Ethernet<'d, T, P> { | 75 | impl<'d, T: Instance, P: Phy> embassy_net_driver::Driver for Ethernet<'d, T, P> { |
| 75 | type RxToken<'a> | 76 | type RxToken<'a> |
| 76 | = RxToken<'a, 'd> | 77 | = RxToken<'a, 'd> |
| 77 | where | 78 | where |
| @@ -156,23 +157,15 @@ impl<'a, 'd> embassy_net_driver::TxToken for TxToken<'a, 'd> { | |||
| 156 | } | 157 | } |
| 157 | 158 | ||
| 158 | /// Station Management Interface (SMI) on an ethernet PHY | 159 | /// Station Management Interface (SMI) on an ethernet PHY |
| 159 | /// | 160 | pub trait StationManagement { |
| 160 | /// # Safety | ||
| 161 | /// | ||
| 162 | /// The methods cannot move out of self | ||
| 163 | pub unsafe trait StationManagement { | ||
| 164 | /// Read a register over SMI. | 161 | /// Read a register over SMI. |
| 165 | fn smi_read(&mut self, phy_addr: u8, reg: u8) -> u16; | 162 | fn smi_read(&mut self, phy_addr: u8, reg: u8) -> u16; |
| 166 | /// Write a register over SMI. | 163 | /// Write a register over SMI. |
| 167 | fn smi_write(&mut self, phy_addr: u8, reg: u8, val: u16); | 164 | fn smi_write(&mut self, phy_addr: u8, reg: u8, val: u16); |
| 168 | } | 165 | } |
| 169 | 166 | ||
| 170 | /// Traits for an Ethernet PHY | 167 | /// Trait for an Ethernet PHY |
| 171 | /// | 168 | pub trait Phy { |
| 172 | /// # Safety | ||
| 173 | /// | ||
| 174 | /// The methods cannot move S | ||
| 175 | pub unsafe trait PHY { | ||
| 176 | /// Reset PHY and wait for it to come out of reset. | 169 | /// Reset PHY and wait for it to come out of reset. |
| 177 | fn phy_reset<S: StationManagement>(&mut self, sm: &mut S); | 170 | fn phy_reset<S: StationManagement>(&mut self, sm: &mut S); |
| 178 | /// PHY initialisation. | 171 | /// PHY initialisation. |
| @@ -181,18 +174,23 @@ pub unsafe trait PHY { | |||
| 181 | fn poll_link<S: StationManagement>(&mut self, sm: &mut S, cx: &mut Context) -> bool; | 174 | fn poll_link<S: StationManagement>(&mut self, sm: &mut S, cx: &mut Context) -> bool; |
| 182 | } | 175 | } |
| 183 | 176 | ||
| 184 | impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { | 177 | impl<'d, T: Instance, P: Phy> Ethernet<'d, T, P> { |
| 185 | /// Directly expose the SMI interface used by the Ethernet driver. | 178 | /// Directly expose the SMI interface used by the Ethernet driver. |
| 186 | /// | 179 | /// |
| 187 | /// This can be used to for example configure special PHY registers for compliance testing. | 180 | /// This can be used to for example configure special PHY registers for compliance testing. |
| 188 | /// | 181 | pub fn station_management(&mut self) -> &mut impl StationManagement { |
| 189 | /// # Safety | ||
| 190 | /// | ||
| 191 | /// Revert any temporary PHY register changes such as to enable test modes before handing | ||
| 192 | /// the Ethernet device over to the networking stack otherwise things likely won't work. | ||
| 193 | pub unsafe fn station_management(&mut self) -> &mut impl StationManagement { | ||
| 194 | &mut self.station_management | 182 | &mut self.station_management |
| 195 | } | 183 | } |
| 184 | |||
| 185 | /// Access the user-supplied `Phy`. | ||
| 186 | pub fn phy(&self) -> &P { | ||
| 187 | &self.phy | ||
| 188 | } | ||
| 189 | |||
| 190 | /// Mutably access the user-supplied `Phy`. | ||
| 191 | pub fn phy_mut(&mut self) -> &mut P { | ||
| 192 | &mut self.phy | ||
| 193 | } | ||
| 196 | } | 194 | } |
| 197 | 195 | ||
| 198 | trait SealedInstance { | 196 | trait SealedInstance { |
diff --git a/embassy-stm32/src/eth/v1/mod.rs b/embassy-stm32/src/eth/v1/mod.rs index 438b28020..e12ac2fef 100644 --- a/embassy-stm32/src/eth/v1/mod.rs +++ b/embassy-stm32/src/eth/v1/mod.rs | |||
| @@ -46,7 +46,7 @@ impl interrupt::typelevel::Handler<interrupt::typelevel::ETH> for InterruptHandl | |||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | /// Ethernet driver. | 48 | /// Ethernet driver. |
| 49 | pub struct Ethernet<'d, T: Instance, P: PHY> { | 49 | pub struct Ethernet<'d, T: Instance, P: Phy> { |
| 50 | _peri: PeripheralRef<'d, T>, | 50 | _peri: PeripheralRef<'d, T>, |
| 51 | pub(crate) tx: TDesRing<'d>, | 51 | pub(crate) tx: TDesRing<'d>, |
| 52 | pub(crate) rx: RDesRing<'d>, | 52 | pub(crate) rx: RDesRing<'d>, |
| @@ -91,7 +91,7 @@ macro_rules! config_pins { | |||
| 91 | }; | 91 | }; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { | 94 | impl<'d, T: Instance, P: Phy> Ethernet<'d, T, P> { |
| 95 | /// safety: the returned instance is not leak-safe | 95 | /// safety: the returned instance is not leak-safe |
| 96 | pub fn new<const TX: usize, const RX: usize>( | 96 | pub fn new<const TX: usize, const RX: usize>( |
| 97 | queue: &'d mut PacketQueue<TX, RX>, | 97 | queue: &'d mut PacketQueue<TX, RX>, |
| @@ -272,12 +272,12 @@ impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { | |||
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | /// Ethernet station management interface. | 274 | /// Ethernet station management interface. |
| 275 | pub struct EthernetStationManagement<T: Instance> { | 275 | pub(crate) struct EthernetStationManagement<T: Instance> { |
| 276 | peri: PhantomData<T>, | 276 | peri: PhantomData<T>, |
| 277 | clock_range: Cr, | 277 | clock_range: Cr, |
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | unsafe impl<T: Instance> StationManagement for EthernetStationManagement<T> { | 280 | impl<T: Instance> StationManagement for EthernetStationManagement<T> { |
| 281 | fn smi_read(&mut self, phy_addr: u8, reg: u8) -> u16 { | 281 | fn smi_read(&mut self, phy_addr: u8, reg: u8) -> u16 { |
| 282 | let mac = T::regs().ethernet_mac(); | 282 | let mac = T::regs().ethernet_mac(); |
| 283 | 283 | ||
| @@ -307,7 +307,7 @@ unsafe impl<T: Instance> StationManagement for EthernetStationManagement<T> { | |||
| 307 | } | 307 | } |
| 308 | } | 308 | } |
| 309 | 309 | ||
| 310 | impl<'d, T: Instance, P: PHY> Drop for Ethernet<'d, T, P> { | 310 | impl<'d, T: Instance, P: Phy> Drop for Ethernet<'d, T, P> { |
| 311 | fn drop(&mut self) { | 311 | fn drop(&mut self) { |
| 312 | let dma = T::regs().ethernet_dma(); | 312 | let dma = T::regs().ethernet_dma(); |
| 313 | let mac = T::regs().ethernet_mac(); | 313 | let mac = T::regs().ethernet_mac(); |
diff --git a/embassy-stm32/src/eth/v2/mod.rs b/embassy-stm32/src/eth/v2/mod.rs index 9dd7f7d95..26e4eeb63 100644 --- a/embassy-stm32/src/eth/v2/mod.rs +++ b/embassy-stm32/src/eth/v2/mod.rs | |||
| @@ -36,7 +36,7 @@ impl interrupt::typelevel::Handler<interrupt::typelevel::ETH> for InterruptHandl | |||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | /// Ethernet driver. | 38 | /// Ethernet driver. |
| 39 | pub struct Ethernet<'d, T: Instance, P: PHY> { | 39 | pub struct Ethernet<'d, T: Instance, P: Phy> { |
| 40 | _peri: PeripheralRef<'d, T>, | 40 | _peri: PeripheralRef<'d, T>, |
| 41 | pub(crate) tx: TDesRing<'d>, | 41 | pub(crate) tx: TDesRing<'d>, |
| 42 | pub(crate) rx: RDesRing<'d>, | 42 | pub(crate) rx: RDesRing<'d>, |
| @@ -63,7 +63,7 @@ macro_rules! config_pins { | |||
| 63 | }; | 63 | }; |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | impl<'d, T: Instance, P: PHY> Ethernet<'d, T, P> { | 66 | impl<'d, T: Instance, P: Phy> Ethernet<'d, T, P> { |
| 67 | /// Create a new RMII ethernet driver using 9 pins. | 67 | /// Create a new RMII ethernet driver using 9 pins. |
| 68 | pub fn new<const TX: usize, const RX: usize>( | 68 | pub fn new<const TX: usize, const RX: usize>( |
| 69 | queue: &'d mut PacketQueue<TX, RX>, | 69 | queue: &'d mut PacketQueue<TX, RX>, |
| @@ -304,7 +304,7 @@ pub struct EthernetStationManagement<T: Instance> { | |||
| 304 | clock_range: u8, | 304 | clock_range: u8, |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | unsafe impl<T: Instance> StationManagement for EthernetStationManagement<T> { | 307 | impl<T: Instance> StationManagement for EthernetStationManagement<T> { |
| 308 | fn smi_read(&mut self, phy_addr: u8, reg: u8) -> u16 { | 308 | fn smi_read(&mut self, phy_addr: u8, reg: u8) -> u16 { |
| 309 | let mac = T::regs().ethernet_mac(); | 309 | let mac = T::regs().ethernet_mac(); |
| 310 | 310 | ||
| @@ -334,7 +334,7 @@ unsafe impl<T: Instance> StationManagement for EthernetStationManagement<T> { | |||
| 334 | } | 334 | } |
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | impl<'d, T: Instance, P: PHY> Drop for Ethernet<'d, T, P> { | 337 | impl<'d, T: Instance, P: Phy> Drop for Ethernet<'d, T, P> { |
| 338 | fn drop(&mut self) { | 338 | fn drop(&mut self) { |
| 339 | let dma = T::regs().ethernet_dma(); | 339 | let dma = T::regs().ethernet_dma(); |
| 340 | let mac = T::regs().ethernet_mac(); | 340 | let mac = T::regs().ethernet_mac(); |
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::*; | |||
| 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, StackResources}; | 7 | use embassy_net::{Ipv4Address, StackResources}; |
| 8 | use embassy_stm32::eth::generic_smi::GenericSMI; | 8 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; |
| 9 | use embassy_stm32::eth::{Ethernet, PacketQueue}; | ||
| 10 | use embassy_stm32::peripherals::ETH; | 9 | use embassy_stm32::peripherals::ETH; |
| 11 | use embassy_stm32::rng::Rng; | 10 | use embassy_stm32::rng::Rng; |
| 12 | use embassy_stm32::time::Hertz; | 11 | use 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 | ||
| 24 | type Device = Ethernet<'static, ETH, GenericSMI>; | 23 | type Device = Ethernet<'static, ETH, GenericPhy>; |
| 25 | 24 | ||
| 26 | #[embassy_executor::task] | 25 | #[embassy_executor::task] |
| 27 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { | 26 | async 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 | ||
| 4 | use defmt::*; | 4 | use defmt::*; |
| 5 | use embassy_executor::Spawner; | 5 | use embassy_executor::Spawner; |
| 6 | use embassy_stm32::eth::generic_smi::GenericSMI; | 6 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue, StationManagement}; |
| 7 | use embassy_stm32::eth::{Ethernet, PacketQueue, StationManagement}; | ||
| 8 | use embassy_stm32::time::Hertz; | 7 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 8 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| 10 | use embassy_time::Timer; | 9 | use 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); |
diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index f353af674..17ab7fc00 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs | |||
| @@ -5,8 +5,7 @@ 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, StackResources}; | 7 | use embassy_net::{Ipv4Address, StackResources}; |
| 8 | use embassy_stm32::eth::generic_smi::GenericSMI; | 8 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; |
| 9 | use embassy_stm32::eth::{Ethernet, PacketQueue}; | ||
| 10 | use embassy_stm32::peripherals::ETH; | 9 | use embassy_stm32::peripherals::ETH; |
| 11 | use embassy_stm32::rng::Rng; | 10 | use embassy_stm32::rng::Rng; |
| 12 | use embassy_stm32::time::Hertz; | 11 | use embassy_stm32::time::Hertz; |
| @@ -22,7 +21,7 @@ bind_interrupts!(struct Irqs { | |||
| 22 | HASH_RNG => rng::InterruptHandler<peripherals::RNG>; | 21 | HASH_RNG => rng::InterruptHandler<peripherals::RNG>; |
| 23 | }); | 22 | }); |
| 24 | 23 | ||
| 25 | type Device = Ethernet<'static, ETH, GenericSMI>; | 24 | type Device = Ethernet<'static, ETH, GenericPhy>; |
| 26 | 25 | ||
| 27 | #[embassy_executor::task] | 26 | #[embassy_executor::task] |
| 28 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { | 27 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { |
| @@ -77,7 +76,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 77 | p.PG13, | 76 | p.PG13, |
| 78 | p.PB13, | 77 | p.PB13, |
| 79 | p.PG11, | 78 | p.PG11, |
| 80 | GenericSMI::new_auto(), | 79 | GenericPhy::new_auto(), |
| 81 | mac_addr, | 80 | mac_addr, |
| 82 | ); | 81 | ); |
| 83 | 82 | ||
diff --git a/examples/stm32h5/src/bin/eth.rs b/examples/stm32h5/src/bin/eth.rs index ead346741..4034b552c 100644 --- a/examples/stm32h5/src/bin/eth.rs +++ b/examples/stm32h5/src/bin/eth.rs | |||
| @@ -5,8 +5,7 @@ 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, StackResources}; | 7 | use embassy_net::{Ipv4Address, StackResources}; |
| 8 | use embassy_stm32::eth::generic_smi::GenericSMI; | 8 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; |
| 9 | use embassy_stm32::eth::{Ethernet, PacketQueue}; | ||
| 10 | use embassy_stm32::peripherals::ETH; | 9 | use embassy_stm32::peripherals::ETH; |
| 11 | use embassy_stm32::rcc::{ | 10 | use embassy_stm32::rcc::{ |
| 12 | AHBPrescaler, APBPrescaler, Hse, HseMode, Pll, PllDiv, PllMul, PllPreDiv, PllSource, Sysclk, VoltageScale, | 11 | AHBPrescaler, APBPrescaler, Hse, HseMode, Pll, PllDiv, PllMul, PllPreDiv, PllSource, Sysclk, VoltageScale, |
| @@ -25,7 +24,7 @@ bind_interrupts!(struct Irqs { | |||
| 25 | RNG => rng::InterruptHandler<peripherals::RNG>; | 24 | RNG => rng::InterruptHandler<peripherals::RNG>; |
| 26 | }); | 25 | }); |
| 27 | 26 | ||
| 28 | type Device = Ethernet<'static, ETH, GenericSMI>; | 27 | type Device = Ethernet<'static, ETH, GenericPhy>; |
| 29 | 28 | ||
| 30 | #[embassy_executor::task] | 29 | #[embassy_executor::task] |
| 31 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { | 30 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { |
| @@ -80,7 +79,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 80 | p.PG13, | 79 | p.PG13, |
| 81 | p.PB15, | 80 | p.PB15, |
| 82 | p.PG11, | 81 | p.PG11, |
| 83 | GenericSMI::new_auto(), | 82 | GenericPhy::new_auto(), |
| 84 | mac_addr, | 83 | mac_addr, |
| 85 | ); | 84 | ); |
| 86 | 85 | ||
diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 6665cd1d0..da7aa4af5 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs | |||
| @@ -5,8 +5,7 @@ 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, StackResources}; | 7 | use embassy_net::{Ipv4Address, StackResources}; |
| 8 | use embassy_stm32::eth::generic_smi::GenericSMI; | 8 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; |
| 9 | use embassy_stm32::eth::{Ethernet, PacketQueue}; | ||
| 10 | use embassy_stm32::peripherals::ETH; | 9 | use embassy_stm32::peripherals::ETH; |
| 11 | use embassy_stm32::rng::Rng; | 10 | use embassy_stm32::rng::Rng; |
| 12 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 11 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| @@ -21,7 +20,7 @@ bind_interrupts!(struct Irqs { | |||
| 21 | RNG => rng::InterruptHandler<peripherals::RNG>; | 20 | RNG => rng::InterruptHandler<peripherals::RNG>; |
| 22 | }); | 21 | }); |
| 23 | 22 | ||
| 24 | type Device = Ethernet<'static, ETH, GenericSMI>; | 23 | type Device = Ethernet<'static, ETH, GenericPhy>; |
| 25 | 24 | ||
| 26 | #[embassy_executor::task] | 25 | #[embassy_executor::task] |
| 27 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { | 26 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { |
| @@ -79,7 +78,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 79 | p.PG13, // TX_D0: Transmit Bit 0 | 78 | p.PG13, // TX_D0: Transmit Bit 0 |
| 80 | p.PB13, // TX_D1: Transmit Bit 1 | 79 | p.PB13, // TX_D1: Transmit Bit 1 |
| 81 | p.PG11, // TX_EN: Transmit Enable | 80 | p.PG11, // TX_EN: Transmit Enable |
| 82 | GenericSMI::new_auto(), | 81 | GenericPhy::new_auto(), |
| 83 | mac_addr, | 82 | mac_addr, |
| 84 | ); | 83 | ); |
| 85 | 84 | ||
diff --git a/examples/stm32h7/src/bin/eth_client.rs b/examples/stm32h7/src/bin/eth_client.rs index 4fbe10f31..10485109a 100644 --- a/examples/stm32h7/src/bin/eth_client.rs +++ b/examples/stm32h7/src/bin/eth_client.rs | |||
| @@ -7,8 +7,7 @@ use defmt::*; | |||
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_net::tcp::client::{TcpClient, TcpClientState}; | 8 | use embassy_net::tcp::client::{TcpClient, TcpClientState}; |
| 9 | use embassy_net::StackResources; | 9 | use embassy_net::StackResources; |
| 10 | use embassy_stm32::eth::generic_smi::GenericSMI; | 10 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; |
| 11 | use embassy_stm32::eth::{Ethernet, PacketQueue}; | ||
| 12 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 13 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 14 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| @@ -24,7 +23,7 @@ bind_interrupts!(struct Irqs { | |||
| 24 | RNG => rng::InterruptHandler<peripherals::RNG>; | 23 | RNG => rng::InterruptHandler<peripherals::RNG>; |
| 25 | }); | 24 | }); |
| 26 | 25 | ||
| 27 | type Device = Ethernet<'static, ETH, GenericSMI>; | 26 | type Device = Ethernet<'static, ETH, GenericPhy>; |
| 28 | 27 | ||
| 29 | #[embassy_executor::task] | 28 | #[embassy_executor::task] |
| 30 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { | 29 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { |
| @@ -81,7 +80,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 81 | p.PG13, | 80 | p.PG13, |
| 82 | p.PB13, | 81 | p.PB13, |
| 83 | p.PG11, | 82 | p.PG11, |
| 84 | GenericSMI::new_auto(), | 83 | GenericPhy::new_auto(), |
| 85 | mac_addr, | 84 | mac_addr, |
| 86 | ); | 85 | ); |
| 87 | 86 | ||
diff --git a/examples/stm32h7/src/bin/eth_client_mii.rs b/examples/stm32h7/src/bin/eth_client_mii.rs index 53f86ac80..849173615 100644 --- a/examples/stm32h7/src/bin/eth_client_mii.rs +++ b/examples/stm32h7/src/bin/eth_client_mii.rs | |||
| @@ -7,8 +7,7 @@ use defmt::*; | |||
| 7 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| 8 | use embassy_net::tcp::client::{TcpClient, TcpClientState}; | 8 | use embassy_net::tcp::client::{TcpClient, TcpClientState}; |
| 9 | use embassy_net::StackResources; | 9 | use embassy_net::StackResources; |
| 10 | use embassy_stm32::eth::generic_smi::GenericSMI; | 10 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; |
| 11 | use embassy_stm32::eth::{Ethernet, PacketQueue}; | ||
| 12 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 13 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 14 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; | 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng, Config}; |
| @@ -24,7 +23,7 @@ bind_interrupts!(struct Irqs { | |||
| 24 | RNG => rng::InterruptHandler<peripherals::RNG>; | 23 | RNG => rng::InterruptHandler<peripherals::RNG>; |
| 25 | }); | 24 | }); |
| 26 | 25 | ||
| 27 | type Device = Ethernet<'static, ETH, GenericSMI>; | 26 | type Device = Ethernet<'static, ETH, GenericPhy>; |
| 28 | 27 | ||
| 29 | #[embassy_executor::task] | 28 | #[embassy_executor::task] |
| 30 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { | 29 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { |
| @@ -86,7 +85,7 @@ async fn main(spawner: Spawner) -> ! { | |||
| 86 | p.PC2, | 85 | p.PC2, |
| 87 | p.PE2, | 86 | p.PE2, |
| 88 | p.PG11, | 87 | p.PG11, |
| 89 | GenericSMI::new_auto(), | 88 | GenericPhy::new_auto(), |
| 90 | mac_addr, | 89 | mac_addr, |
| 91 | ); | 90 | ); |
| 92 | info!("Device created"); | 91 | info!("Device created"); |
diff --git a/tests/stm32/src/bin/eth.rs b/tests/stm32/src/bin/eth.rs index 4ab6e234f..a7e76fd8e 100644 --- a/tests/stm32/src/bin/eth.rs +++ b/tests/stm32/src/bin/eth.rs | |||
| @@ -7,8 +7,7 @@ mod common; | |||
| 7 | use common::*; | 7 | use common::*; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_net::StackResources; | 9 | use embassy_net::StackResources; |
| 10 | use embassy_stm32::eth::generic_smi::GenericSMI; | 10 | use embassy_stm32::eth::{Ethernet, GenericPhy, PacketQueue}; |
| 11 | use embassy_stm32::eth::{Ethernet, PacketQueue}; | ||
| 12 | use embassy_stm32::peripherals::ETH; | 11 | use embassy_stm32::peripherals::ETH; |
| 13 | use embassy_stm32::rng::Rng; | 12 | use embassy_stm32::rng::Rng; |
| 14 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng}; | 13 | use embassy_stm32::{bind_interrupts, eth, peripherals, rng}; |
| @@ -29,7 +28,7 @@ bind_interrupts!(struct Irqs { | |||
| 29 | RNG => rng::InterruptHandler<peripherals::RNG>; | 28 | RNG => rng::InterruptHandler<peripherals::RNG>; |
| 30 | }); | 29 | }); |
| 31 | 30 | ||
| 32 | type Device = Ethernet<'static, ETH, GenericSMI>; | 31 | type Device = Ethernet<'static, ETH, GenericPhy>; |
| 33 | 32 | ||
| 34 | #[embassy_executor::task] | 33 | #[embassy_executor::task] |
| 35 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { | 34 | async fn net_task(mut runner: embassy_net::Runner<'static, Device>) -> ! { |
| @@ -87,7 +86,7 @@ async fn main(spawner: Spawner) { | |||
| 87 | #[cfg(feature = "stm32h563zi")] | 86 | #[cfg(feature = "stm32h563zi")] |
| 88 | p.PB15, | 87 | p.PB15, |
| 89 | p.PG11, | 88 | p.PG11, |
| 90 | GenericSMI::new_auto(), | 89 | GenericPhy::new_auto(), |
| 91 | mac_addr, | 90 | mac_addr, |
| 92 | ); | 91 | ); |
| 93 | 92 | ||
