From 13c85e52c80838cdee28aa3476c95f9f3cc0d57b Mon Sep 17 00:00:00 2001 From: bjoernQ Date: Wed, 24 Aug 2022 12:37:53 +0200 Subject: [PATCH] Fix embedded-hal 0.2.x SPI implementation --- esp-hal-common/src/spi.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/esp-hal-common/src/spi.rs b/esp-hal-common/src/spi.rs index f2c58d78040..0af38c8fba3 100644 --- a/esp-hal-common/src/spi.rs +++ b/esp-hal-common/src/spi.rs @@ -203,7 +203,9 @@ where type Error = Infallible; fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { - self.spi.write_bytes(words) + self.spi.write_bytes(words)?; + self.spi.flush()?; + Ok(()) } } @@ -592,6 +594,9 @@ pub trait Instance { // Wait for all chunks to complete except the last one. // The function is allowed to return before the bus is idle. // see [embedded-hal flushing](https://docs.rs/embedded-hal/1.0.0-alpha.8/embedded_hal/spi/blocking/index.html#flushing) + // + // THIS IS NOT TRUE FOR EH 0.2.X! MAKE SURE TO FLUSH IN EH 0.2.X TRAIT + // IMPLEMENTATIONS! if i < num_chunks { while reg_block.cmd.read().usr().bit_is_set() { // wait