athens: use component's name in logging messages.

This commit is contained in:
Maxim Poliakovski 2024-04-15 14:17:37 +02:00
parent 751f964139
commit ffa221192d

View File

@ -40,6 +40,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
AthensClocks::AthensClocks(uint8_t dev_addr)
{
set_name("Athens");
supports_types(HWCompType::I2C_DEV);
this->my_addr = dev_addr;
@ -63,7 +64,7 @@ void AthensClocks::start_transaction()
bool AthensClocks::send_subaddress(uint8_t sub_addr)
{
LOG_F(INFO, "Athens: subaddress set to 0x%X", sub_addr);
LOG_F(INFO, "%s: subaddress set to 0x%X", this->name.c_str(), sub_addr);
return true;
}
@ -76,13 +77,14 @@ bool AthensClocks::send_byte(uint8_t data)
break;
case 1:
if (this->reg_num >= ATHENS_NUM_REGS) {
LOG_F(WARNING, "Athens: invalid register number %d", this->reg_num);
LOG_F(WARNING, "%s: invalid register number %d", this->name.c_str(),
this->reg_num);
return false; // return NACK
}
this->regs[this->reg_num] = data;
break;
default:
LOG_F(WARNING, "Athens: too much data received!");
LOG_F(WARNING, "%s: too much data received!", this->name.c_str());
return false; // return NACK
}
return true;
@ -107,7 +109,7 @@ int AthensClocks::get_dot_freq()
};
if (this->regs[AthensRegs::P2_MUX2] & 0xC0) {
LOG_F(INFO, "Athens: dot clock disabled");
LOG_F(INFO, "%s: dot clock disabled", this->name.c_str());
return 0;
}
@ -119,11 +121,11 @@ int AthensClocks::get_dot_freq()
int post_div = 1 << (3 - (this->regs[AthensRegs::P2_MUX2] & 3));
if (std::find(D2_commons.begin(), D2_commons.end(), d2) == D2_commons.end()) {
LOG_F(WARNING, "Athens: untested D2 value %d", d2);
LOG_F(WARNING, "%s: untested D2 value %d", this->name.c_str(), d2);
}
if (std::find(N2_commons.begin(), N2_commons.end(), n2) == N2_commons.end()) {
LOG_F(WARNING, "Athens: untested N2 value %d", d2);
LOG_F(WARNING, "%s: untested N2 value %d", this->name.c_str(), d2);
}
int mux = (this->regs[AthensRegs::P2_MUX2] >> 4) & 3;
@ -133,17 +135,17 @@ int AthensClocks::get_dot_freq()
out_freq = ATHENS_XTAL * ((float)n2 / (float)(d2 * post_div));
break;
case 1: // clock source -> system clock VCO
LOG_F(WARNING, "Athens: system clock VCO not supported yet!");
LOG_F(WARNING, "%s: system clock VCO not supported yet!", this->name.c_str());
break;
case 2: // clock source -> crystal frequency
out_freq = ATHENS_XTAL / post_div;
break;
case 3:
LOG_F(WARNING, "Athens: attempt to use reserved Mux value!");
LOG_F(WARNING, "%s: attempt to use reserved Mux value!", this->name.c_str());
break;
}
LOG_F(INFO, "Athens: dot clock frequency set to %f Hz", out_freq);
LOG_F(INFO, "%s: dot clock frequency set to %f Hz", this->name.c_str(), out_freq);
return static_cast<int>(out_freq + 0.5f);
}