eive-obsw/linux/ipcore/PtmeConfig.cpp
Robin Mueller 703eaaa9aa
Some checks are pending
EIVE/eive-obsw/pipeline/pr-develop Build started...
poll threshold param cmd handling
2023-04-02 15:32:04 +02:00

56 lines
1.4 KiB
C++

#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;
return returnvalue::FAILED;
}
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));
}
void PtmeConfig::invertTxClock(bool invert) {
if (invert) {
axiPtmeConfig->enableTxclockInversion();
} else {
axiPtmeConfig->disableTxclockInversion();
}
}
void PtmeConfig::configTxManipulator(bool enable) {
if (enable) {
axiPtmeConfig->enableTxclockManipulator();
} else {
axiPtmeConfig->disableTxclockManipulator();
}
}
void PtmeConfig::enableBatPriorityBit(bool enable) {
if (enable) {
axiPtmeConfig->enableBatPriorityBit();
} else {
axiPtmeConfig->disableBatPriorityBit();
}
}
void PtmeConfig::setPollThreshold(AxiPtmeConfig::IdlePollThreshold pollThreshold) {
axiPtmeConfig->writePollThreshold(pollThreshold);
}