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