From 46ea0a079e104b5718ea3b7d4196d9fbb8751759 Mon Sep 17 00:00:00 2001 From: liebman Date: Fri, 30 Aug 2024 14:11:52 -0700 Subject: [PATCH] handle write_read when the read bufer is empty --- esp-hal/src/i2c.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/esp-hal/src/i2c.rs b/esp-hal/src/i2c.rs index c154fa2c16..396a94baf0 100644 --- a/esp-hal/src/i2c.rs +++ b/esp-hal/src/i2c.rs @@ -926,11 +926,13 @@ mod asynch { addr, bytes, true, - false, + buffer.is_empty(), // if the read buffer is empty, then issue a stop &mut self.peripheral.register_block().comd_iter(), ) .await?; self.peripheral.clear_all_interrupts(); + // this will be a no-op if the buffer is empty, in that case we issued the stop + // with the write self.read_operation( addr, buffer, @@ -2142,10 +2144,12 @@ pub trait Instance: crate::private::Sealed { addr, bytes, true, - false, + buffer.is_empty(), // if the read buffer is empty, then issue a stop &mut self.register_block().comd_iter(), )?; self.clear_all_interrupts(); + // this will be a no-op if the buffer is empty, in that case we issued the stop + // with the write self.read_operation( addr, buffer,