From 6e65282f185d94a8c449374e6d4ed4eefa5793a4 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Thu, 22 Jun 2023 21:10:58 +0200 Subject: [PATCH] esp-hosted: smaller delay after transfer, makes slightly better perf. --- embassy-net-esp-hosted/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/embassy-net-esp-hosted/src/lib.rs b/embassy-net-esp-hosted/src/lib.rs index 2a4601ce4..44dfbe89c 100644 --- a/embassy-net-esp-hosted/src/lib.rs +++ b/embassy-net-esp-hosted/src/lib.rs @@ -227,7 +227,12 @@ where } self.spi.transfer(&mut rx_buf, &tx_buf).await.unwrap(); - let delay_until = Instant::now() + Duration::from_millis(1); + + // The esp-hosted firmware deasserts the HANSHAKE pin a few us AFTER ending the SPI transfer + // If we check it again too fast, we'll see it's high from the previous transfer, and if we send it + // data it will get lost. + // Make sure we check it after 100us at minimum. + let delay_until = Instant::now() + Duration::from_micros(100); self.handle_rx(&mut rx_buf); Timer::at(delay_until).await; }