51 lines
1.3 KiB
C++
51 lines
1.3 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 RETURN_FAILED;
|
|
}
|
|
return RETURN_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));
|
|
}
|
|
|
|
ReturnValue_t PtmeConfig::invertTxClock(bool invert) {
|
|
ReturnValue_t result = RETURN_OK;
|
|
if (invert) {
|
|
result = axiPtmeConfig->enableTxclockInversion();
|
|
} else {
|
|
result = axiPtmeConfig->disableTxclockInversion();
|
|
}
|
|
if (result != RETURN_OK) {
|
|
return CLK_INVERSION_FAILED;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
ReturnValue_t PtmeConfig::configTxManipulator(bool enable) {
|
|
ReturnValue_t result = RETURN_OK;
|
|
if (enable) {
|
|
result = axiPtmeConfig->enableTxclockManipulator();
|
|
} else {
|
|
result = axiPtmeConfig->disableTxclockManipulator();
|
|
}
|
|
return result;
|
|
}
|