diff --git a/pslab/bus/i2c.py b/pslab/bus/i2c.py index e111a9c..4704fec 100644 --- a/pslab/bus/i2c.py +++ b/pslab/bus/i2c.py @@ -139,8 +139,12 @@ def _start(self, address: int, mode: int) -> int: ackstat : int ACK (0) or NACK (1) from addressed peripheral. """ - if self._mode == mode: - return self._ACK + if self._mode is not None: + msg = ( + f"An I2C transaction is already active on peripheral 0x{address:X}. " + "Use _restart instead." + ) + raise RuntimeError(msg) self._device.send_byte(CP.I2C_HEADER) secondary = CP.I2C_START if not self._running else CP.I2C_RESTART