eive-obsw/linux/obc/PtmeRateSetter.cpp

26 lines
697 B
C++
Raw Normal View History

2021-11-21 18:07:05 +01:00
#include "PtmeRateSetter.h"
2022-01-18 11:41:19 +01:00
2021-11-21 18:07:05 +01:00
#include "fsfw/serviceinterface/ServiceInterface.h"
2022-01-18 11:41:19 +01:00
PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif)
: bitrateSel(bitrateSel), gpioif(gpioif) {}
2021-11-21 18:07:05 +01:00
2022-01-18 11:41:19 +01:00
PtmeRateSetter::~PtmeRateSetter() {}
2021-11-21 18:07:05 +01:00
ReturnValue_t PtmeRateSetter::setRate(BitRates rate) {
2022-01-18 11:41:19 +01:00
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
switch (rate) {
2021-11-21 18:07:05 +01:00
case RATE_2000KHZ:
2022-01-18 11:41:19 +01:00
result = gpioif->pullHigh(bitrateSel);
break;
2021-11-21 18:07:05 +01:00
case RATE_400KHZ:
2022-01-18 11:41:19 +01:00
result = gpioif->pullLow(bitrateSel);
break;
2021-11-21 18:07:05 +01:00
default:
2022-01-18 11:41:19 +01:00
sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl;
result = HasReturnvaluesIF::RETURN_FAILED;
break;
}
return result;
2021-11-21 18:07:05 +01:00
}