Skip to content

Commit d86fbfa

Browse files
committed
Raise exception on _start on already active peripheral
1 parent 05c135d commit d86fbfa

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pslab/bus/i2c.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,12 @@ def _start(self, address: int, mode: int) -> int:
139139
ackstat : int
140140
ACK (0) or NACK (1) from addressed peripheral.
141141
"""
142-
if self._mode == mode:
143-
return self._ACK
142+
if self._mode is not None:
143+
msg = (
144+
f"An I2C transaction is already active on peripheral 0x{address:X}. "
145+
"Use _restart instead."
146+
)
147+
raise RuntimeError(msg)
144148

145149
self._device.send_byte(CP.I2C_HEADER)
146150
secondary = CP.I2C_START if not self._running else CP.I2C_RESTART

0 commit comments

Comments
 (0)