From 0658170681059d81e2638e2f44dd97b6b349da75 Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Tue, 6 Sep 2022 15:12:12 -0700 Subject: [PATCH] Fix reads --- Source/Core/Common/I2C.cpp | 24 ++++++++++++------------ Source/Core/Core/HW/WII_IPC.cpp | 3 +++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Source/Core/Common/I2C.cpp b/Source/Core/Common/I2C.cpp index 82c2a57e9f..9f572d9d4f 100644 --- a/Source/Core/Common/I2C.cpp +++ b/Source/Core/Common/I2C.cpp @@ -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) @@ -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 @@ -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); } } } @@ -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 { diff --git a/Source/Core/Core/HW/WII_IPC.cpp b/Source/Core/Core/HW/WII_IPC.cpp index cd2647e07a..817261780b 100644 --- a/Source/Core/Core/HW/WII_IPC.cpp +++ b/Source/Core/Core/HW/WII_IPC.cpp @@ -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()