From 78e4d8266092fa0840108885b36b91a6902a9be2 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Thu, 29 Apr 2021 17:08:18 +0800 Subject: [PATCH] examples: Simplify & fix naming --- examples/tcp_stm32f407.rs | 13 ++++++------- examples/tx_stm32f407.rs | 18 +++++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/examples/tcp_stm32f407.rs b/examples/tcp_stm32f407.rs index cd3d18e..7728ca8 100644 --- a/examples/tcp_stm32f407.rs +++ b/examples/tcp_stm32f407.rs @@ -17,8 +17,7 @@ use stm32f4xx_hal::{ spi::Spi, time::Hertz }; -use enc424j600; -use enc424j600::{smoltcp_phy, EthController}; +use enc424j600::smoltcp_phy; use smoltcp::wire::{ EthernetAddress, IpAddress, IpCidr, Ipv6Cidr @@ -78,7 +77,7 @@ use stm32f4xx_hal::{ Alternate, AF5, Output, PushPull } }; -type BoosterSpiEth = enc424j600::SpiEth< +type SpiEth = enc424j600::Enc424j600< Spi>, PA6>, PA7>)>, PA4>, fn(u32) -> () @@ -102,7 +101,7 @@ const APP: () = { struct Resources { eth_iface: EthernetInterface< 'static, - smoltcp_phy::SmoltcpDevice>, + smoltcp_phy::SmoltcpDevice>, itm: ITM } @@ -157,11 +156,11 @@ const APP: () = { let delay_ns_fp: fn(u32) -> () = |time_ns| { cortex_m::asm::delay((time_ns*21)/125 + 1) }; - enc424j600::SpiEth::new(spi_eth_port, spi1_nss, delay_ns_fp) + SpiEth::new(spi_eth_port, spi1_nss, delay_ns_fp) }; // Init controller - match spi_eth.init_dev() { + match spi_eth.reset() { Ok(_) => { iprintln!(stim0, "Initializing Ethernet...") } @@ -172,7 +171,7 @@ const APP: () = { // Read MAC let mut eth_mac_addr: [u8; 6] = [0; 6]; - spi_eth.read_from_mac(&mut eth_mac_addr); + spi_eth.read_mac_addr(&mut eth_mac_addr); for i in 0..6 { let byte = eth_mac_addr[i]; match i { diff --git a/examples/tx_stm32f407.rs b/examples/tx_stm32f407.rs index 268e254..2a8619c 100644 --- a/examples/tx_stm32f407.rs +++ b/examples/tx_stm32f407.rs @@ -17,8 +17,7 @@ use stm32f4xx_hal::{ spi::Spi, time::Hertz }; -use enc424j600; -use enc424j600::EthController; +use enc424j600::EthPhy; /// use stm32f4xx_hal::{ @@ -28,15 +27,16 @@ use stm32f4xx_hal::{ Alternate, AF5, Output, PushPull }, }; -type BoosterSpiEth = enc424j600::SpiEth< +type SpiEth = enc424j600::Enc424j600< Spi>, PA6>, PA7>)>, PA4>, - fn(u32)>; + fn(u32) -> () +>; #[rtic::app(device = stm32f4xx_hal::stm32, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)] const APP: () = { struct Resources { - spi_eth: BoosterSpiEth, + spi_eth: SpiEth, delay: Delay, itm: ITM, } @@ -87,11 +87,11 @@ const APP: () = { let delay_ns: fn(u32) -> () = |time_ns| { cortex_m::asm::delay((time_ns*21)/125 + 1) }; - enc424j600::SpiEth::new(spi_eth_port, spi1_nss, delay_ns) + SpiEth::new(spi_eth_port, spi1_nss, delay_ns) }; // Init - match spi_eth.init_dev() { + match spi_eth.reset() { Ok(_) => { iprintln!(stim0, "Initializing Ethernet...") } @@ -102,7 +102,7 @@ const APP: () = { // Read MAC let mut eth_mac_addr: [u8; 6] = [0; 6]; - spi_eth.read_from_mac(&mut eth_mac_addr); + spi_eth.read_mac_addr(&mut eth_mac_addr); for i in 0..6 { let byte = eth_mac_addr[i]; match i { @@ -157,7 +157,7 @@ const APP: () = { _ => () }; } - c.resources.spi_eth.send_raw_packet(ð_tx_packet); + c.resources.spi_eth.send_packet(ð_tx_packet); iprintln!(stim0, "Packet sent"); c.resources.delay.delay_ms(100_u32); }