Skip to content

Commit

Permalink
Fix reads
Browse files Browse the repository at this point in the history
  • Loading branch information
Pokechu22 committed Jan 14, 2024
1 parent d4c181a commit 7a93ac7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
24 changes: 12 additions & 12 deletions Source/Core/Common/I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,16 +305,7 @@ void I2CBus::SCLFallingEdge(const bool sda)
// SCL falling edge is used to advance bit_counter/change states and process writes.
if (state == State::SetI2CAddress || state == State::WriteToDevice)
{
if (bit_counter == 8)
{
// Acknowledge bit for *reads*.
if (sda)
{
WARN_LOG_FMT(WII_IPC, "Read NACK'd");
state = State::Inactive;
}
}
else
if (bit_counter != 8)
{
current_byte <<= 1;
if (sda)
Expand All @@ -337,7 +328,7 @@ void I2CBus::SCLFallingEdge(const bool sda)
else
{
state = State::Inactive; // NACK
WARN_LOG_FMT(WII_IPC, "I2C: No device responded to read from {:02x}", current_byte);
WARN_LOG_FMT(WII_IPC, "I2C: No device responded to read from {:02x}", slave_addr);
}
}
else
Expand All @@ -350,7 +341,7 @@ void I2CBus::SCLFallingEdge(const bool sda)
else
{
state = State::Inactive; // NACK
WARN_LOG_FMT(WII_IPC, "I2C: No device responded to write to {:02x}", current_byte);
WARN_LOG_FMT(WII_IPC, "I2C: No device responded to write to {:02x}", slave_addr);
}
}
}
Expand Down Expand Up @@ -392,6 +383,15 @@ void I2CBus::SCLFallingEdge(const bool sda)
state = State::ReadFromDevice;
}
}
else if (state == State::ReadFromDevice)
{
// Acknowledge bit for *reads*.
if (sda)
{
WARN_LOG_FMT(WII_IPC, "Read NACK'd");
state = State::Inactive;
}
}
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/HW/WII_IPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,11 @@ void WiiIPC::InitState()

m_ppc_irq_masks |= INT_CAUSE_IPC_BROADWAY;

ave_state.Reset();
i2c_state = {};
ave_state.Reset();
ave_state.m_registers.video_output_config = 0x23;
i2c_state.AddSlave(&ave_state);
}

void WiiIPC::Init()
Expand Down

0 comments on commit 7a93ac7

Please sign in to comment.