This commit is contained in:
@ -4,6 +4,7 @@ target_sources(${TARGET_NAME} PUBLIC
|
||||
PdecHandler.cpp
|
||||
PdecConfig.cpp
|
||||
PtmeRateSetter.cpp
|
||||
PtmeAxiConfig.cpp
|
||||
)
|
||||
|
||||
|
||||
|
49
linux/obc/PtmeAxiConfig.cpp
Normal file
49
linux/obc/PtmeAxiConfig.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include "PtmeAxiConfig.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio) :
|
||||
SystemObject(objectId), configAxiUio(configAxiUio) {
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
if (mutex == nullptr) {
|
||||
sif::warning << "Failed to create mutex" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
PtmeAxiConfig::~PtmeAxiConfig() {
|
||||
}
|
||||
|
||||
ReturnValue_t PtmeAxiConfig::initialize() {
|
||||
int fd = open(configAxiUio.c_str(), O_RDWR);
|
||||
if (fd < 1) {
|
||||
sif::warning << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
baseAddress = static_cast<uint32_t*>(mmap(NULL, MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED,
|
||||
fd, 0));
|
||||
|
||||
if (baseAddress == MAP_FAILED) {
|
||||
sif::warning << "PtmeAxiConfig::initialize: Failed to map uio address" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PtmeAxiConfig::writeCaduRateReg(uint8_t rateVal) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = mutex->lockMutex(timeoutType, mutexTimeout);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "PtmeAxiConfig::writeCaduRateReg: Failed to lock mutex" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
*(baseAddress + CADU_BITRATE_REG) = static_cast<uint32_t>(rateVal);
|
||||
result = mutex->unlockMutex();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "PtmeAxiConfig::writeCaduRateReg: Failed to unlock mutex" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
40
linux/obc/PtmeAxiConfig.h
Normal file
40
linux/obc/PtmeAxiConfig.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef LINUX_OBC_PTMEAXICONFIG_H_
|
||||
#define LINUX_OBC_PTMEAXICONFIG_H_
|
||||
|
||||
#include <string>
|
||||
#include "fsfw/ipc/MutexIF.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
|
||||
/**
|
||||
* @brief Class providing low level access to the configuration interface of the PTME.
|
||||
*
|
||||
* @author J. Meier
|
||||
*/
|
||||
class PtmeAxiConfig : public SystemObject {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
* @param configAxiUio Device file of UIO belonging to the AXI configuration interface.
|
||||
*/
|
||||
PtmeAxiConfig(object_id_t objectId, std::string configAxiUio);
|
||||
virtual ~PtmeAxiConfig();
|
||||
|
||||
virtual ReturnValue_t initialize() override;
|
||||
ReturnValue_t writeCaduRateReg(uint8_t rateVal);
|
||||
|
||||
private:
|
||||
// Address of register storing the bitrate configuration parameter
|
||||
static const uint32_t CADU_BITRATE_REG = 0x0;
|
||||
static const int MAP_SIZE = 0x1000;
|
||||
|
||||
std::string configAxiUio;
|
||||
MutexIF* mutex = nullptr;
|
||||
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
|
||||
uint32_t mutexTimeout = 20;
|
||||
|
||||
uint32_t* baseAddress = nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif /* LINUX_OBC_PTMEAXICONFIG_H_ */
|
@ -25,7 +25,8 @@ static const char UIO_DEVICE_FILE[] = "/dev/uio1";
|
||||
#else
|
||||
static const char UIO_DEVICE_FILE[] = "/dev/uio1";
|
||||
#endif
|
||||
|
||||
// Bit clock frequency of PMTE IP core in Hz
|
||||
static const uint32_t BIT_CLK_FREQ = 20000000;
|
||||
}; // namespace PtmeConfig
|
||||
|
||||
#endif /* LINUX_OBC_PTMECONFIG_H_ */
|
||||
|
@ -2,24 +2,40 @@
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif)
|
||||
: bitrateSel(bitrateSel), gpioif(gpioif) {}
|
||||
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(BitRates rate) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
uint8_t rateVal = 0;
|
||||
switch (rate) {
|
||||
case RATE_2000KHZ:
|
||||
result = gpioif->pullHigh(bitrateSel);
|
||||
case RATE_2000KBPS:
|
||||
rateVal = static_cast<uint8_t>(PtmeConfig::BIT_CLK_FREQ / 2000000 - 1);
|
||||
break;
|
||||
case RATE_400KHZ:
|
||||
result = gpioif->pullLow(bitrateSel);
|
||||
case RATE_1000KBPS:
|
||||
rateVal = static_cast<uint8_t>(PtmeConfig::BIT_CLK_FREQ / 1000000 - 1);
|
||||
break;
|
||||
case RATE_500KBPS:
|
||||
rateVal = static_cast<uint8_t>(PtmeConfig::BIT_CLK_FREQ / 500000 - 1);
|
||||
break;
|
||||
case RATE_200KBPS:
|
||||
rateVal = static_cast<uint8_t>(PtmeConfig::BIT_CLK_FREQ / 200000 - 1);
|
||||
break;
|
||||
case RATE_100KBPS:
|
||||
rateVal = static_cast<uint8_t>(PtmeConfig::BIT_CLK_FREQ / 100000 - 1);
|
||||
break;
|
||||
default:
|
||||
sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl;
|
||||
result = HasReturnvaluesIF::RETURN_FAILED;
|
||||
break;
|
||||
sif::debug << "PtmeRateSetter::setRate: Unknown bit rate" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return result;
|
||||
return ptmeAxiConfig->writeCaduRateReg(rateVal);
|
||||
}
|
||||
|
@ -3,36 +3,36 @@
|
||||
|
||||
#include "TxRateSetterIF.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw_hal/common/gpio/GpioIF.h"
|
||||
#include "fsfw_hal/common/gpio/gpioDefinitions.h"
|
||||
#include "linux/obc/PtmeAxiConfig.h"
|
||||
#include "linux/obc/PtmeConfig.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
|
||||
/**
|
||||
* @brief Class to set the downlink bit rate by using the cadu_rate_switcher implemented in
|
||||
* the programmable logic.
|
||||
* @brief Class to set the downlink bit rate by writing to the AXI configuration interface of the
|
||||
* PTME IP core.
|
||||
*
|
||||
* @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).
|
||||
* @details This is the bitrate of the CADU clock and not the downlink which has twice the bitrate
|
||||
* of the CADU clock due to the convolutional code added by the s-Band transceiver.
|
||||
*
|
||||
* @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();
|
||||
class PtmeRateSetter: public TxRateSetterIF, public SystemObject {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor
|
||||
*
|
||||
* objectId Object id of system object
|
||||
* ptmeAxiConfig Pointer to object providing access to PTME configuration registers.
|
||||
*/
|
||||
PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfig);
|
||||
virtual ~PtmeRateSetter();
|
||||
|
||||
virtual ReturnValue_t setRate(BitRates rate);
|
||||
virtual ReturnValue_t initialize() override;
|
||||
virtual ReturnValue_t setRate(BitRates rate);
|
||||
|
||||
private:
|
||||
gpioId_t bitrateSel = gpio::NO_GPIO;
|
||||
private:
|
||||
|
||||
GpioIF* gpioif = nullptr;
|
||||
PtmeAxiConfig* ptmeAxiConfig = nullptr;
|
||||
};
|
||||
|
||||
#endif /* LINUX_OBC_PTMERATESETTER_H_ */
|
||||
|
@ -3,7 +3,14 @@
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
enum BitRates : uint32_t { RATE_2000KHZ, RATE_400KHZ };
|
||||
enum BitRates : uint32_t {
|
||||
RATE_2000KBPS,
|
||||
RATE_1000KBPS,
|
||||
RATE_500KBPS,
|
||||
RATE_400KBPS,
|
||||
RATE_200KBPS,
|
||||
RATE_100KBPS
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Abstract class for objects implementing the functionality to switch the
|
||||
|
Reference in New Issue
Block a user