59 lines
1.5 KiB
C++
59 lines
1.5 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));
|
|
}
|
|
|
|
ReturnValue_t PtmeConfig::invertTxClock(bool invert) {
|
|
ReturnValue_t result = returnvalue::OK;
|
|
if (invert) {
|
|
result = axiPtmeConfig->enableTxclockInversion();
|
|
} else {
|
|
result = axiPtmeConfig->disableTxclockInversion();
|
|
}
|
|
if (result != returnvalue::OK) {
|
|
return CLK_INVERSION_FAILED;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
ReturnValue_t PtmeConfig::configTxManipulator(bool enable) {
|
|
ReturnValue_t result = returnvalue::OK;
|
|
if (enable) {
|
|
result = axiPtmeConfig->enableTxclockManipulator();
|
|
} else {
|
|
result = axiPtmeConfig->disableTxclockManipulator();
|
|
}
|
|
return result;
|
|
}
|
|
|
|
ReturnValue_t PtmeConfig::enableBatPriorityBit(bool enable) {
|
|
if (enable) {
|
|
return axiPtmeConfig->enableBatPriorityBit();
|
|
} else {
|
|
return axiPtmeConfig->disableBatPriorityBit();
|
|
}
|
|
}
|