Fix reads

This commit is contained in:
Pokechu22 2022-09-06 15:12:12 -07:00
commit 0658170681
2 changed files with 15 additions and 12 deletions

View file

@ -305,16 +305,7 @@ void I2CBus::SCLFallingEdge(const bool sda)
// SCL falling edge is used to advance bit_counter/change states and process writes. // SCL falling edge is used to advance bit_counter/change states and process writes.
if (state == State::SetI2CAddress || state == State::WriteToDevice) if (state == State::SetI2CAddress || state == State::WriteToDevice)
{ {
if (bit_counter == 8) if (bit_counter != 8)
{
// Acknowledge bit for *reads*.
if (sda)
{
WARN_LOG_FMT(WII_IPC, "Read NACK'd");
state = State::Inactive;
}
}
else
{ {
current_byte <<= 1; current_byte <<= 1;
if (sda) if (sda)
@ -337,7 +328,7 @@ void I2CBus::SCLFallingEdge(const bool sda)
else else
{ {
state = State::Inactive; // NACK 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 else
@ -350,7 +341,7 @@ void I2CBus::SCLFallingEdge(const bool sda)
else else
{ {
state = State::Inactive; // NACK 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);
} }
} }
} }
@ -392,6 +383,15 @@ void I2CBus::SCLFallingEdge(const bool sda)
state = State::ReadFromDevice; 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 else
{ {

View file

@ -261,8 +261,11 @@ void WiiIPC::InitState()
m_ppc_irq_masks |= INT_CAUSE_IPC_BROADWAY; m_ppc_irq_masks |= INT_CAUSE_IPC_BROADWAY;
ave_state.Reset();
i2c_state = {}; i2c_state = {};
ave_state.Reset(); ave_state.Reset();
ave_state.m_registers.video_output_config = 0x23;
i2c_state.AddSlave(&ave_state);
} }
void WiiIPC::Init() void WiiIPC::Init()