#include "PtmeRateSetter.h" #include "fsfw/serviceinterface/ServiceInterface.h" PtmeRateSetter::PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfig) : SystemObject(objectId), ptmeAxiConfig(ptmeAxiConfig) {} PtmeRateSetter::~PtmeRateSetter() {} ReturnValue_t PtmeRateSetter::initialize() { if (ptmeAxiConfig == nullptr) { sif::warning << "PtmeRateSetter::initialize: Invalid PtmeAxiConfig object" << std::endl; return HasReturnvaluesIF::RETURN_FAILED; } return HasReturnvaluesIF::RETURN_OK; } ReturnValue_t PtmeRateSetter::setRate(uint32_t bitRate) { if (bitRate == 0) { return BAD_BIT_RATE; } uint32_t rateVal = PtmeConfig::BIT_CLK_FREQ / bitRate - 1; if (rateVal > 0xFF) { return RATE_NOT_SUPPORTED; } return ptmeAxiConfig->writeCaduRateReg(static_cast(rateVal)); }