net: Set stm32 link speed with the Phy Speed read

master
linuswck 2024-02-28 12:58:57 +08:00
parent 76477065be
commit 6fc800e562
1 changed files with 16 additions and 0 deletions

View File

@ -12,6 +12,7 @@ use smoltcp::{
};
use stm32_eth::{
Parts, EthPins, PartsIn,
mac::Speed,
dma::{
TxRingEntry, RxRingEntry, EthernetDMA
}};
@ -148,6 +149,20 @@ impl ServerHandle {
);
phy.phy_init();
while !phy.phy_link_up() {}
if let Some(speed) = phy.speed().map(|s| match s {
PhySpeed::HalfDuplexBase10T => Speed::HalfDuplexBase10T,
PhySpeed::FullDuplexBase10T => Speed::FullDuplexBase10T,
PhySpeed::HalfDuplexBase100Tx => Speed::HalfDuplexBase100Tx,
PhySpeed::FullDuplexBase100Tx => Speed::FullDuplexBase100Tx,
}) {
phy.get_miim().set_speed(speed);
info!("Detected link speed: {:?}", speed);
} else {
debug!("Failed to detect link speed.");
}
} else {
info!("Not resetting unsupported PHY.");
}
@ -218,6 +233,7 @@ use ieee802_3_miim::{
phy::{
lan87xxa::{LAN8720A, LAN8742A},
BarePhy, KSZ8081R,
PhySpeed
},
Miim, Pause, Phy,
};