bit rate setter
This commit is contained in:
@ -3,6 +3,7 @@ target_sources(${TARGET_NAME} PUBLIC
|
||||
Ptme.cpp
|
||||
PdecHandler.cpp
|
||||
PdecConfig.cpp
|
||||
PtmeRateSetter.cpp
|
||||
)
|
||||
|
||||
|
||||
|
27
linux/obc/PtmeRateSetter.cpp
Normal file
27
linux/obc/PtmeRateSetter.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include "PtmeRateSetter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) :
|
||||
bitrateSel(bitrateSel), gpioif(gpioif) {
|
||||
}
|
||||
|
||||
PtmeRateSetter::~PtmeRateSetter() {
|
||||
}
|
||||
|
||||
ReturnValue_t PtmeRateSetter::setRate(BitRates rate) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
switch(rate) {
|
||||
case RATE_2000KHZ:
|
||||
result = gpioif->pullHigh(bitrateSel);
|
||||
break;
|
||||
case RATE_400KHZ:
|
||||
result = gpioif->pullLow(bitrateSel);
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl;
|
||||
result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
40
linux/obc/PtmeRateSetter.h
Normal file
40
linux/obc/PtmeRateSetter.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef LINUX_OBC_PTMERATESETTER_H_
|
||||
#define LINUX_OBC_PTMERATESETTER_H_
|
||||
|
||||
#include "TxRateSetterIF.h"
|
||||
#include "fsfw_hal/common/gpio/gpioDefinitions.h"
|
||||
#include "fsfw_hal/common/gpio/GpioIF.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
/**
|
||||
* @brief Class to set the downlink bit rate by using the cadu_rate_switcher implemented in
|
||||
* the programmable logic.
|
||||
*
|
||||
* @details The cadu_rate_switcher module sets the input rate to the syrlinks transceiver either
|
||||
* to 2000 kHz (bitrateSel = 1) or 400 kHz (bitrate = 0).
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
class PtmeRateSetter: public TxRateSetterIF {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* @param bitrateSel GPIO ID of the GPIO connected to the bitrate_sel input of the
|
||||
* cadu_rate_switcher.
|
||||
* @param gpioif GPIO interface to drive the bitrateSel GPIO
|
||||
*/
|
||||
PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif);
|
||||
virtual ~PtmeRateSetter();
|
||||
|
||||
virtual ReturnValue_t setRate(BitRates rate);
|
||||
|
||||
private:
|
||||
|
||||
gpioId_t bitrateSel = gpio::NO_GPIO;
|
||||
|
||||
GpioIF* gpioif = nullptr;
|
||||
};
|
||||
|
||||
#endif /* LINUX_OBC_PTMERATESETTER_H_ */
|
25
linux/obc/TxRateSetterIF.h
Normal file
25
linux/obc/TxRateSetterIF.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef LINUX_OBC_TXRATESETTERIF_H_
|
||||
#define LINUX_OBC_TXRATESETTERIF_H_
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
enum BitRates : uint32_t {
|
||||
RATE_2000KHZ,
|
||||
RATE_400KHZ
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstract class for objects implementing the functionality to switch the
|
||||
* downlink bit rate.
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
class TxRateSetterIF {
|
||||
public:
|
||||
TxRateSetterIF() {};
|
||||
virtual ~TxRateSetterIF() {};
|
||||
|
||||
virtual ReturnValue_t setRate(BitRates bitRate) = 0;
|
||||
};
|
||||
|
||||
#endif /* LINUX_OBC_TXRATESETTERIF_H_ */
|
Reference in New Issue
Block a user