From 2e7b42fc5b62f134bc1c477e4817e0c512c399b3 Mon Sep 17 00:00:00 2001 From: David Lenfesty Date: Mon, 25 Apr 2022 19:57:09 -0600 Subject: embassy-stm32/eth: convert LAN8742 driver to generic SMI driver SMI Ethernet PHYs all share a common base set of registers that can do 90% of all tasks. The LAN8742 driver used some vendor-specific registers to check link negotiation status, but the need for that was debatable, so I migrated it to a generic driver instead, anybody who wants extra functionality can copy it and impl their own on top of it. --- examples/stm32f7/src/bin/eth.rs | 8 ++++---- examples/stm32h7/src/bin/eth.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'examples') diff --git a/examples/stm32f7/src/bin/eth.rs b/examples/stm32f7/src/bin/eth.rs index 446756c29..33e41de9c 100644 --- a/examples/stm32f7/src/bin/eth.rs +++ b/examples/stm32f7/src/bin/eth.rs @@ -11,7 +11,7 @@ use embassy::util::Forever; use embassy_net::{ Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator, TcpSocket, }; -use embassy_stm32::eth::lan8742a::LAN8742A; +use embassy_stm32::eth::generic_smi::GenericSMI; use embassy_stm32::eth::{Ethernet, State}; use embassy_stm32::interrupt; use embassy_stm32::peripherals::ETH; @@ -26,7 +26,7 @@ use panic_probe as _; #[embassy::task] async fn main_task( - device: &'static mut Ethernet<'static, ETH, LAN8742A, 4, 4>, + device: &'static mut Ethernet<'static, ETH, GenericSMI, 4, 4>, config: &'static mut StaticConfigurator, spawner: Spawner, ) { @@ -82,7 +82,7 @@ static mut RNG_INST: Option> = None; static EXECUTOR: Forever = Forever::new(); static STATE: Forever> = Forever::new(); -static ETH: Forever> = Forever::new(); +static ETH: Forever> = Forever::new(); static CONFIG: Forever = Forever::new(); static NET_RESOURCES: Forever> = Forever::new(); @@ -112,7 +112,7 @@ fn main() -> ! { let eth = unsafe { ETH.put(Ethernet::new( state, p.ETH, eth_int, p.PA1, p.PA2, p.PC1, p.PA7, p.PC4, p.PC5, p.PG13, p.PB13, - p.PG11, LAN8742A, mac_addr, 0, + p.PG11, GenericSMI, mac_addr, 0, )) }; diff --git a/examples/stm32h7/src/bin/eth.rs b/examples/stm32h7/src/bin/eth.rs index 4eb5421a8..9a2e7a33d 100644 --- a/examples/stm32h7/src/bin/eth.rs +++ b/examples/stm32h7/src/bin/eth.rs @@ -14,7 +14,7 @@ use embassy::util::Forever; use embassy_net::{ Config as NetConfig, Ipv4Address, Ipv4Cidr, StackResources, StaticConfigurator, TcpSocket, }; -use embassy_stm32::eth::lan8742a::LAN8742A; +use embassy_stm32::eth::generic_smi::GenericSMI; use embassy_stm32::eth::{Ethernet, State}; use embassy_stm32::interrupt; use embassy_stm32::peripherals::ETH; @@ -26,7 +26,7 @@ use heapless::Vec; #[embassy::task] async fn main_task( - device: &'static mut Ethernet<'static, ETH, LAN8742A, 4, 4>, + device: &'static mut Ethernet<'static, ETH, GenericSMI, 4, 4>, config: &'static mut StaticConfigurator, spawner: Spawner, ) { @@ -82,7 +82,7 @@ static mut RNG_INST: Option> = None; static EXECUTOR: Forever = Forever::new(); static STATE: Forever> = Forever::new(); -static ETH: Forever> = Forever::new(); +static ETH: Forever> = Forever::new(); static CONFIG: Forever = Forever::new(); static NET_RESOURCES: Forever> = Forever::new(); @@ -114,7 +114,7 @@ fn main() -> ! { let eth = unsafe { ETH.put(Ethernet::new( state, p.ETH, eth_int, p.PA1, p.PA2, p.PC1, p.PA7, p.PC4, p.PC5, p.PG13, p.PB13, - p.PG11, LAN8742A, mac_addr, 0, + p.PG11, GenericSMI, mac_addr, 0, )) }; -- cgit