add SW IF for manipulating poll threshold #550
@ -89,14 +89,12 @@ AxiPtmeConfig::IdlePollThreshold AxiPtmeConfig::readPollThreshold() {
|
|||||||
return static_cast<AxiPtmeConfig::IdlePollThreshold>((regVal >> 3) & 0b111);
|
return static_cast<AxiPtmeConfig::IdlePollThreshold>((regVal >> 3) & 0b111);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AxiPtmeConfig::writeCommonCfgReg(uint32_t value) { writeReg(COMMON_CONFIG_REG, value); }
|
||||||
|
uint32_t AxiPtmeConfig::readCommonCfgReg() { return readReg(COMMON_CONFIG_REG); }
|
||||||
|
|
||||||
void AxiPtmeConfig::writeBit(uint32_t regOffset, bool bitVal, BitPos bitPos) {
|
void AxiPtmeConfig::writeBit(uint32_t regOffset, bool bitVal, BitPos bitPos) {
|
||||||
uint32_t readVal = readReg(regOffset);
|
uint32_t readVal = readReg(regOffset);
|
||||||
uint32_t writeVal =
|
uint32_t writeVal =
|
||||||
(readVal & ~(1 << static_cast<uint32_t>(bitPos))) | bitVal << static_cast<uint32_t>(bitPos);
|
(readVal & ~(1 << static_cast<uint32_t>(bitPos))) | bitVal << static_cast<uint32_t>(bitPos);
|
||||||
writeReg(regOffset, writeVal);
|
writeReg(regOffset, writeVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t AxiPtmeConfig::readCommonCfgReg() {
|
|
||||||
MutexGuard mg(mutex, timeoutType, mutexTimeout);
|
|
||||||
return *(baseAddress + COMMON_CONFIG_REG / ADRESS_DIVIDER);
|
|
||||||
}
|
|
||||||
|
@ -104,7 +104,7 @@ class AxiPtmeConfig : public SystemObject {
|
|||||||
uint32_t readReg(uint32_t regOffset);
|
uint32_t readReg(uint32_t regOffset);
|
||||||
|
|
||||||
uint32_t readCommonCfgReg();
|
uint32_t readCommonCfgReg();
|
||||||
uint32_t writeCommonCfgReg(uint32_t value);
|
void writeCommonCfgReg(uint32_t value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Sets one bit in a register
|
* @brief Sets one bit in a register
|
||||||
|
@ -49,3 +49,7 @@ void PtmeConfig::enableBatPriorityBit(bool enable) {
|
|||||||
axiPtmeConfig->disableBatPriorityBit();
|
axiPtmeConfig->disableBatPriorityBit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PtmeConfig::setPollThreshold(AxiPtmeConfig::IdlePollThreshold pollThreshold) {
|
||||||
|
axiPtmeConfig->writePollThreshold(pollThreshold);
|
||||||
|
}
|
||||||
|
@ -64,6 +64,8 @@ class PtmeConfig : public SystemObject {
|
|||||||
*/
|
*/
|
||||||
void enableBatPriorityBit(bool enable);
|
void enableBatPriorityBit(bool enable);
|
||||||
|
|
||||||
|
void setPollThreshold(AxiPtmeConfig::IdlePollThreshold pollThreshold);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::RATE_SETTER;
|
static const uint8_t INTERFACE_ID = CLASS_ID::RATE_SETTER;
|
||||||
|
|
||||||
|
@ -75,11 +75,9 @@ ReturnValue_t CcsdsIpCoreHandler::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This also pulls the PTME out of reset state.
|
// This also pulls the PTME out of reset state.
|
||||||
if (batPriorityParam == 0) {
|
updateBatPriorityFromParam();
|
||||||
disablePrioritySelectMode();
|
ptmeConfig.setPollThreshold(
|
||||||
} else {
|
static_cast<AxiPtmeConfig::IdlePollThreshold>(params.pollThresholdParam));
|
||||||
enablePrioritySelectMode();
|
|
||||||
}
|
|
||||||
resetPtme();
|
resetPtme();
|
||||||
ptmeLocked = false;
|
ptmeLocked = false;
|
||||||
|
|
||||||
@ -123,7 +121,10 @@ ReturnValue_t CcsdsIpCoreHandler::getParameter(uint8_t domainId, uint8_t uniqueI
|
|||||||
ParameterWrapper* parameterWrapper,
|
ParameterWrapper* parameterWrapper,
|
||||||
const ParameterWrapper* newValues,
|
const ParameterWrapper* newValues,
|
||||||
uint16_t startAtIndex) {
|
uint16_t startAtIndex) {
|
||||||
if ((domainId == 0) and (uniqueIdentifier == ParamId::BAT_PRIORITY)) {
|
if (domainId != 0) {
|
||||||
|
return HasParametersIF::INVALID_DOMAIN_ID;
|
||||||
|
}
|
||||||
|
if (uniqueIdentifier == ParamId::BAT_PRIORITY) {
|
||||||
uint8_t newVal = 0;
|
uint8_t newVal = 0;
|
||||||
ReturnValue_t result = newValues->getElement(&newVal);
|
ReturnValue_t result = newValues->getElement(&newVal);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
@ -132,8 +133,8 @@ ReturnValue_t CcsdsIpCoreHandler::getParameter(uint8_t domainId, uint8_t uniqueI
|
|||||||
if (newVal > 1) {
|
if (newVal > 1) {
|
||||||
return HasParametersIF::INVALID_VALUE;
|
return HasParametersIF::INVALID_VALUE;
|
||||||
}
|
}
|
||||||
parameterWrapper->set(batPriorityParam);
|
parameterWrapper->set(params.batPriorityParam);
|
||||||
if (newVal != batPriorityParam) {
|
if (newVal != params.batPriorityParam) {
|
||||||
// This ensures that the BAT priority is updated at some point when an update of the PTME is
|
// This ensures that the BAT priority is updated at some point when an update of the PTME is
|
||||||
// allowed
|
// allowed
|
||||||
updateContext.updateBatPrio = true;
|
updateContext.updateBatPrio = true;
|
||||||
@ -144,6 +145,23 @@ ReturnValue_t CcsdsIpCoreHandler::getParameter(uint8_t domainId, uint8_t uniqueI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
|
} else if (uniqueIdentifier == ParamId::POLL_THRESHOLD) {
|
||||||
|
uint8_t newVal = 0;
|
||||||
|
ReturnValue_t result = newValues->getElement(&newVal);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
if (newVal > static_cast<uint8_t>(AxiPtmeConfig::NEVER)) {
|
||||||
|
return HasParametersIF::INVALID_VALUE;
|
||||||
|
}
|
||||||
|
parameterWrapper->set(newVal);
|
||||||
|
if (newVal != params.pollThresholdParam) {
|
||||||
|
updateContext.updatePollThreshold = true;
|
||||||
|
if (mode == MODE_OFF) {
|
||||||
|
initPtmeUpdateAfterXCycles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
return HasParametersIF::INVALID_IDENTIFIER_ID;
|
return HasParametersIF::INVALID_IDENTIFIER_ID;
|
||||||
}
|
}
|
||||||
@ -158,12 +176,18 @@ MessageQueueId_t CcsdsIpCoreHandler::getRequestQueue() const {
|
|||||||
ReturnValue_t CcsdsIpCoreHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
ReturnValue_t CcsdsIpCoreHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
|
||||||
const uint8_t* data, size_t size) {
|
const uint8_t* data, size_t size) {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
// TODO: Update directly when off, otherwise set update context.
|
|
||||||
switch (actionId) {
|
switch (actionId) {
|
||||||
case ARBITRARY_RATE: {
|
case ARBITRARY_RATE: {
|
||||||
uint32_t bitrate = 0;
|
uint32_t bitrate = 0;
|
||||||
SerializeAdapter::deSerialize(&bitrate, &data, &size, SerializeIF::Endianness::BIG);
|
result = SerializeAdapter::deSerialize(&bitrate, &data, &size, SerializeIF::Endianness::BIG);
|
||||||
result = ptmeConfig.setRate(bitrate);
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
ptmeConfig.setRate(bitrate);
|
||||||
|
updateContext.updateClockRate = true;
|
||||||
|
if (mode == MODE_OFF) {
|
||||||
|
initPtmeUpdateAfterXCycles();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ENABLE_TX_CLK_MANIPULATOR: {
|
case ENABLE_TX_CLK_MANIPULATOR: {
|
||||||
@ -272,7 +296,7 @@ void CcsdsIpCoreHandler::enablePrioritySelectMode() { ptmeConfig.enableBatPriori
|
|||||||
void CcsdsIpCoreHandler::disablePrioritySelectMode() { ptmeConfig.enableBatPriorityBit(false); }
|
void CcsdsIpCoreHandler::disablePrioritySelectMode() { ptmeConfig.enableBatPriorityBit(false); }
|
||||||
|
|
||||||
void CcsdsIpCoreHandler::updateBatPriorityFromParam() {
|
void CcsdsIpCoreHandler::updateBatPriorityFromParam() {
|
||||||
if (batPriorityParam == 0) {
|
if (params.batPriorityParam == 0) {
|
||||||
disablePrioritySelectMode();
|
disablePrioritySelectMode();
|
||||||
} else {
|
} else {
|
||||||
enablePrioritySelectMode();
|
enablePrioritySelectMode();
|
||||||
@ -291,9 +315,17 @@ void CcsdsIpCoreHandler::performPtmeUpdateWhenApplicable() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (updateContext.ptmeUpdateCycleCount >= 2) {
|
if (updateContext.ptmeUpdateCycleCount >= 2) {
|
||||||
|
bool doResetPtme = false;
|
||||||
if (updateContext.updateBatPrio) {
|
if (updateContext.updateBatPrio) {
|
||||||
updateBatPriorityFromParam();
|
updateBatPriorityFromParam();
|
||||||
updateContext.updateBatPrio = false;
|
updateContext.updateBatPrio = false;
|
||||||
|
doResetPtme = true;
|
||||||
|
}
|
||||||
|
if (updateContext.updatePollThreshold) {
|
||||||
|
ptmeConfig.setPollThreshold(
|
||||||
|
static_cast<AxiPtmeConfig::IdlePollThreshold>(params.pollThresholdParam));
|
||||||
|
updateContext.updatePollThreshold = false;
|
||||||
|
doResetPtme = true;
|
||||||
}
|
}
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
if (updateContext.updateClockRate) {
|
if (updateContext.updateClockRate) {
|
||||||
@ -313,10 +345,7 @@ void CcsdsIpCoreHandler::performPtmeUpdateWhenApplicable() {
|
|||||||
sif::error << "CcsdsIpCoreHandler: Setting datarate failed" << std::endl;
|
sif::error << "CcsdsIpCoreHandler: Setting datarate failed" << std::endl;
|
||||||
}
|
}
|
||||||
updateContext.updateClockRate = false;
|
updateContext.updateClockRate = false;
|
||||||
}
|
doResetPtme = true;
|
||||||
bool doResetPtme = true;
|
|
||||||
if (not updateContext.updateBatPrio and not updateContext.updateClockRate) {
|
|
||||||
doResetPtme = false;
|
|
||||||
}
|
}
|
||||||
finishPtmeUpdateAfterXCycles(doResetPtme);
|
finishPtmeUpdateAfterXCycles(doResetPtme);
|
||||||
return;
|
return;
|
||||||
|
@ -60,7 +60,7 @@ class CcsdsIpCoreHandler : public SystemObject,
|
|||||||
public ReceivesParameterMessagesIF,
|
public ReceivesParameterMessagesIF,
|
||||||
public HasActionsIF {
|
public HasActionsIF {
|
||||||
public:
|
public:
|
||||||
enum ParamId : uint8_t { BAT_PRIORITY = 0 };
|
enum ParamId : uint8_t { BAT_PRIORITY = 0, POLL_THRESHOLD = 1 };
|
||||||
|
|
||||||
static const bool LINK_UP = true;
|
static const bool LINK_UP = true;
|
||||||
static const bool LINK_DOWN = false;
|
static const bool LINK_DOWN = false;
|
||||||
@ -156,12 +156,17 @@ class CcsdsIpCoreHandler : public SystemObject,
|
|||||||
|
|
||||||
PtmeConfig& ptmeConfig;
|
PtmeConfig& ptmeConfig;
|
||||||
PtmeGpios ptmeGpios;
|
PtmeGpios ptmeGpios;
|
||||||
// BAT priority bit on by default to enable priority selection mode for the PTME.
|
struct Parameters {
|
||||||
uint8_t batPriorityParam = 0;
|
// BAT priority bit on by default to enable priority selection mode for the PTME.
|
||||||
|
uint8_t batPriorityParam = 0;
|
||||||
|
uint8_t pollThresholdParam = static_cast<uint8_t>(AxiPtmeConfig::IdlePollThreshold::POLL_4);
|
||||||
|
|
||||||
|
} params;
|
||||||
|
|
||||||
struct UpdateContext {
|
struct UpdateContext {
|
||||||
bool updateBatPrio = false;
|
bool updateBatPrio = false;
|
||||||
bool updateClockRate = false;
|
bool updateClockRate = false;
|
||||||
|
bool updatePollThreshold = false;
|
||||||
bool enableTransmitAfterPtmeUpdate = false;
|
bool enableTransmitAfterPtmeUpdate = false;
|
||||||
uint8_t ptmeUpdateCycleCount = 0;
|
uint8_t ptmeUpdateCycleCount = 0;
|
||||||
bool performPtmeUpdateAfterXCycles = false;
|
bool performPtmeUpdateAfterXCycles = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user