Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 77150c2

Browse files
committed
Fix w5500 imports & DMA
1 parent 4cc62e3 commit 77150c2

File tree

1 file changed

+41
-38
lines changed

1 file changed

+41
-38
lines changed

src/main.rs

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -256,52 +256,55 @@ fn main() -> Result<()> {
256256
#[cfg(feature = "qemu")]
257257
let eth = eth_configure(
258258
&sysloop,
259-
Box::new(esp_idf_svc::eth::EspEth::wrap(EthDriver::new_openeth(
260-
peripherals.mac,
261-
sysloop.clone(),
262-
)?)?),
259+
Box::new(esp_idf_svc::eth::EspEth::wrap(
260+
esp_idf_svc::eth::EthDriver::new_openeth(peripherals.mac, sysloop.clone())?,
261+
)?),
263262
)?;
264263

265264
#[allow(clippy::redundant_clone)]
266265
#[cfg(feature = "ip101")]
267266
let eth = eth_configure(
268267
&sysloop,
269-
Box::new(esp_idf_svc::eth::EspEth::wrap(EthDriver::new_rmii(
270-
peripherals.mac,
271-
pins.gpio25,
272-
pins.gpio26,
273-
pins.gpio27,
274-
pins.gpio23,
275-
pins.gpio22,
276-
pins.gpio21,
277-
pins.gpio19,
278-
pins.gpio18,
279-
RmiiClockConfig::<gpio::Gpio0, gpio::Gpio16, gpio::Gpio17>::Input(pins.gpio0),
280-
Some(pins.gpio5),
281-
RmiiEthChipset::IP101,
282-
None,
283-
sysloop.clone(),
284-
)?)?),
268+
Box::new(esp_idf_svc::eth::EspEth::wrap(
269+
esp_idf_svc::eth::EthDriver::new_rmii(
270+
peripherals.mac,
271+
pins.gpio25,
272+
pins.gpio26,
273+
pins.gpio27,
274+
pins.gpio23,
275+
pins.gpio22,
276+
pins.gpio21,
277+
pins.gpio19,
278+
pins.gpio18,
279+
RmiiClockConfig::<gpio::Gpio0, gpio::Gpio16, gpio::Gpio17>::Input(pins.gpio0),
280+
Some(pins.gpio5),
281+
esp_idf_svc::eth::RmiiEthChipset::IP101,
282+
None,
283+
sysloop.clone(),
284+
)?,
285+
)?),
285286
)?;
286287

287288
#[cfg(feature = "w5500")]
288289
let eth = eth_configure(
289290
&sysloop,
290-
Box::new(esp_idf_svc::eth::EspEth::wrap(EthDriver::new_spi(
291-
peripherals.spi2,
292-
pins.gpio13,
293-
pins.gpio12,
294-
pins.gpio26,
295-
pins.gpio27,
296-
esp_idf_hal::spi::Dma::Disabled,
297-
Some(pins.gpio14),
298-
Some(pins.gpio25),
299-
SpiEthChipset::W5500,
300-
20.MHz().into(),
301-
Some(&[0x02, 0x00, 0x00, 0x12, 0x34, 0x56]),
302-
None,
303-
sysloop.clone(),
304-
)?)?),
291+
Box::new(esp_idf_svc::eth::EspEth::wrap(
292+
esp_idf_svc::eth::EthDriver::new_spi(
293+
peripherals.spi2,
294+
pins.gpio13,
295+
pins.gpio12,
296+
pins.gpio26,
297+
pins.gpio27,
298+
esp_idf_hal::spi::Dma::Auto(4096),
299+
Some(pins.gpio14),
300+
Some(pins.gpio25),
301+
esp_idf_svc::eth::SpiEthChipset::W5500,
302+
20.MHz().into(),
303+
Some(&[0x02, 0x00, 0x00, 0x12, 0x34, 0x56]),
304+
None,
305+
sysloop.clone(),
306+
)?,
307+
)?),
305308
)?;
306309

307310
test_tcp()?;
@@ -1453,8 +1456,8 @@ fn wifi(
14531456
#[cfg(any(feature = "qemu", feature = "w5500", feature = "ip101"))]
14541457
fn eth_configure(
14551458
sysloop: &EspSystemEventLoop,
1456-
mut eth: Box<EspEth<'static>>,
1457-
) -> Result<Box<EspEth<'static>>> {
1459+
mut eth: Box<esp_idf_svc::eth::EspEth<'static>>,
1460+
) -> Result<Box<esp_idf_svc::eth::EspEth<'static>>> {
14581461
use std::net::Ipv4Addr;
14591462

14601463
info!("Eth created");
@@ -1463,7 +1466,7 @@ fn eth_configure(
14631466

14641467
info!("Starting eth...");
14651468

1466-
if !EthWait::new(eth.driver(), sysloop)?
1469+
if !esp_idf_svc::eth::EthWait::new(eth.driver(), sysloop)?
14671470
.wait_with_timeout(Duration::from_secs(20), || eth.is_started().unwrap())
14681471
{
14691472
bail!("Eth did not start");

0 commit comments

Comments
 (0)