Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Emulator/Peripherals/Peripherals/I2C/OpenCoresI2C.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,19 @@ private void HandleReadFromSlaveCommand()

private void SendDataToSlave()
{
if(dataToSlave.Count == 0 || selectedSlave == null)
// Empty TX queue is legitimate: this method is invoked unconditionally
// from the STOP and repeated-START handlers, but a read-only transaction
// never enqueues anything. Silently no-op rather than warn.
if(dataToSlave.Count == 0)
{
this.Log(LogLevel.Warning, "Trying to send data to slave, but either no data is available or the slave is not selected");
return;
}

// Queue has data but no slave selected -- internal state inconsistency.
if(selectedSlave == null)
{
this.Log(LogLevel.Warning, "Have queued TX data but no slave is currently selected; dropping {0} byte(s)", dataToSlave.Count);
dataToSlave.Clear();
return;
}

Expand Down