From c9b953a48e4f5e548adc06bcf1aafb34a07893c9 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Wed, 27 Dec 2023 14:41:30 +0100 Subject: [PATCH] i2c: disallow returning before transfer is finished. Fixes #455. --- embedded-hal/src/i2c.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/embedded-hal/src/i2c.rs b/embedded-hal/src/i2c.rs index c2a1efb3a..634d52248 100644 --- a/embedded-hal/src/i2c.rs +++ b/embedded-hal/src/i2c.rs @@ -38,6 +38,15 @@ //! you've received from a HAL and "split" it into multiple shared ones, to instantiate //! several drivers on the same bus. //! +//! # Flushing +//! +//! Implementations must flush the transfer, ensuring the bus has returned to an idle state before returning. +//! No pipelining is allowed. Users must be able to shut down the I2C peripheral immediately after a transfer +//! returns, without any risk of e.g. cutting short a stop condition. +//! +//! (Implementations must wait until the last ACK bit to report it as an error anyway. Therefore pipelining would only +//! yield very small time savings, not worth the complexity) +//! //! # For driver authors //! //! Drivers can select the adequate address length with `I2c` or `I2c` depending