eive-obsw/linux/ipcore/PtmeConfig.cpp

61 lines
1.5 KiB
C++
Raw Normal View History

#include "PtmeConfig.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
PtmeConfig::PtmeConfig(object_id_t objectId, AxiPtmeConfig* axiPtmeConfig)
: SystemObject(objectId), axiPtmeConfig(axiPtmeConfig) {}
PtmeConfig::~PtmeConfig() {}
ReturnValue_t PtmeConfig::initialize() {
if (axiPtmeConfig == nullptr) {
sif::warning << "PtmeConfig::initialize: Invalid AxiPtmeConfig object" << std::endl;
2022-08-24 17:27:47 +02:00
return returnvalue::FAILED;
}
2022-08-24 17:27:47 +02:00
return returnvalue::OK;
}
ReturnValue_t PtmeConfig::setRate(uint32_t bitRate) {
if (bitRate == 0) {
return BAD_BIT_RATE;
}
uint32_t rateVal = BIT_CLK_FREQ / bitRate - 1;
if (rateVal > 0xFF) {
return RATE_NOT_SUPPORTED;
}
return axiPtmeConfig->writeCaduRateReg(static_cast<uint8_t>(rateVal));
}
2023-06-26 14:39:03 +02:00
uint32_t PtmeConfig::getRate() {
uint8_t rateReg = axiPtmeConfig->readCaduRateReg();
return (BIT_CLK_FREQ / (rateReg + 1));
}
void PtmeConfig::invertTxClock(bool invert) {
2022-01-31 08:09:58 +01:00
if (invert) {
axiPtmeConfig->enableTxclockInversion();
2022-01-31 08:09:58 +01:00
} else {
axiPtmeConfig->disableTxclockInversion();
2022-01-31 08:09:58 +01:00
}
}
void PtmeConfig::configTxManipulator(bool enable) {
2022-01-31 08:09:58 +01:00
if (enable) {
axiPtmeConfig->enableTxclockManipulator();
2022-01-31 08:09:58 +01:00
} else {
axiPtmeConfig->disableTxclockManipulator();
2022-01-31 08:09:58 +01:00
}
}
void PtmeConfig::enableBatPriorityBit(bool enable) {
if (enable) {
axiPtmeConfig->enableBatPriorityBit();
} else {
axiPtmeConfig->disableBatPriorityBit();
}
}
2023-04-02 15:32:04 +02:00
void PtmeConfig::setPollThreshold(AxiPtmeConfig::IdlePollThreshold pollThreshold) {
axiPtmeConfig->writePollThreshold(pollThreshold);
}