diff --git a/devices/common/i2c/athens.cpp b/devices/common/i2c/athens.cpp index 1cc242b..c1b9b8a 100644 --- a/devices/common/i2c/athens.cpp +++ b/devices/common/i2c/athens.cpp @@ -1,6 +1,6 @@ /* DingusPPC - The Experimental PowerPC Macintosh emulator -Copyright (C) 2018-22 divingkatae and maximum +Copyright (C) 2018-24 divingkatae and maximum (theweirdo) spatium (Contact divingkatae#1017 or powermax#2286 on Discord for more info) @@ -44,8 +44,16 @@ AthensClocks::AthensClocks(uint8_t dev_addr) this->my_addr = dev_addr; - // set up power on values + // This initialization is not prescribed + // but let's set them to acceptable values anyway + this->regs[AthensRegs::D2] = 2; + this->regs[AthensRegs::N2] = 2; + + // set P2_MUX2 on power up as follows: + // - dot clock VCO is disabled + // - dot clock = reference clock / 2 this->regs[AthensRegs::P2_MUX2] = 0x62; + } void AthensClocks::start_transaction() @@ -72,9 +80,6 @@ bool AthensClocks::send_byte(uint8_t data) return false; // return NACK } this->regs[this->reg_num] = data; - if (reg_num == 3) { - LOG_F(INFO, "Athens: dot clock frequency set to %d Hz", get_dot_freq()); - } break; default: LOG_F(WARNING, "Athens: too much data received!"); @@ -138,5 +143,7 @@ int AthensClocks::get_dot_freq() break; } + LOG_F(INFO, "Athens: dot clock frequency set to %f Hz", out_freq); + return static_cast(out_freq + 0.5f); } diff --git a/devices/common/i2c/athens.h b/devices/common/i2c/athens.h index 13217c8..d828af7 100644 --- a/devices/common/i2c/athens.h +++ b/devices/common/i2c/athens.h @@ -1,6 +1,6 @@ /* DingusPPC - The Experimental PowerPC Macintosh emulator -Copyright (C) 2018-22 divingkatae and maximum +Copyright (C) 2018-24 divingkatae and maximum (theweirdo) spatium (Contact divingkatae#1017 or powermax#2286 on Discord for more info) @@ -31,7 +31,8 @@ along with this program. If not, see . #define ATHENS_NUM_REGS 8 -constexpr auto ATHENS_XTAL = 31334400.0f; // external crystal oscillator frequency +/** Default external crystal oscillator frequency. */ +constexpr auto ATHENS_XTAL = 31334400.0f; namespace AthensRegs { @@ -69,7 +70,7 @@ private: uint8_t reg_num = 0; int pos = 0; - uint8_t regs[ATHENS_NUM_REGS]; + uint8_t regs[ATHENS_NUM_REGS] = {}; }; #endif // ATHENS_H