eive-obsw/linux/obc/PtmeAxiConfig.cpp

42 lines
1.5 KiB
C++
Raw Normal View History

2022-01-24 07:43:14 +01:00
#include "PtmeAxiConfig.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
2022-01-24 16:33:22 +01:00
#include "fsfw_hal/linux/uio/UioMapper.h"
2022-01-24 07:43:14 +01:00
2022-01-24 16:33:22 +01:00
PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio, int mapNum) :
2022-01-25 14:00:30 +01:00
SystemObject(objectId), configAxiUio(configAxiUio), mapNum(mapNum) {
2022-01-24 07:43:14 +01:00
mutex = MutexFactory::instance()->createMutex();
if (mutex == nullptr) {
sif::warning << "Failed to create mutex" << std::endl;
}
}
PtmeAxiConfig::~PtmeAxiConfig() {
}
ReturnValue_t PtmeAxiConfig::initialize() {
2022-01-24 16:33:22 +01:00
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
UioMapper uioMapper(configAxiUio, mapNum);
result = uioMapper.getMappedAdress(&baseAddress, UioMapper::Permissions::READ_WRITE);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
2022-01-24 07:43:14 +01:00
}
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;
}