Even more refactoring

This commit is contained in:
Pokechu22 2022-08-28 12:13:11 -07:00
commit 74f1ed4c4b

View file

@ -159,6 +159,8 @@ public:
private:
void Start();
void Stop();
void SCLRisingEdge(const bool sda);
void SCLFallingEdge(const bool sda);
bool WriteExpected() const;
};
I2CBus i2c_state;
@ -414,6 +416,17 @@ void I2CBus::Update(Core::System& system, const bool old_scl, const bool new_scl
else if (active)
{
if (!old_scl && new_scl)
{
SCLRisingEdge(new_sda);
}
else if (old_scl && !new_scl)
{
SCLFallingEdge(new_sda);
}
}
}
void I2CBus::SCLRisingEdge(const bool sda)
{
// INFO_LOG_FMT(WII_IPC, "AVE: {} rising edge: {} (write expected: {})", bit_counter, new_sda,
// WriteExpected());
@ -435,13 +448,12 @@ void I2CBus::Update(Core::System& system, const bool old_scl, const bool new_scl
acknowledge = false;
}
}
// Dolphin_Debugger::PrintCallstack(Common::Log::LogType::WII_IPC,
// Common::Log::LogLevel::LINFO);
// Dolphin_Debugger::PrintCallstack(Common::Log::LogType::WII_IPC, Common::Log::LogLevel::LINFO);
}
else if (old_scl && !new_scl)
void I2CBus::SCLFallingEdge(const bool sda)
{
// INFO_LOG_FMT(WII_IPC, "AVE: {} falling edge: {} (write expected: {})", bit_counter,
// new_sda,
// INFO_LOG_FMT(WII_IPC, "AVE: {} falling edge: {} (write expected: {})", bit_counter, new_sda,
// WriteExpected());
// SCL falling edge is used to advance bit_counter and process wri'tes.
if (bit_counter != 9 && WriteExpected())
@ -449,13 +461,13 @@ void I2CBus::Update(Core::System& system, const bool old_scl, const bool new_scl
if (bit_counter == 8)
{
// Acknowledge bit for *reads*.
if (new_sda)
if (sda)
WARN_LOG_FMT(WII_IPC, "Read NACK'd");
}
else
{
current_byte <<= 1;
if (new_sda)
if (sda)
current_byte |= 1;
if (bit_counter == 7)
@ -509,10 +521,7 @@ void I2CBus::Update(Core::System& system, const bool old_scl, const bool new_scl
{
bit_counter++;
}
// Dolphin_Debugger::PrintCallstack(Common::Log::LogType::WII_IPC,
// Common::Log::LogLevel::LINFO);
}
}
// Dolphin_Debugger::PrintCallstack(Common::Log::LogType::WII_IPC, Common::Log::LogLevel::LINFO);
}
void WiiIPC::RegisterMMIO(MMIO::Mapping* mmio, u32 base)