|
|
|
@ -78,63 +78,16 @@ ReturnValue_t PdecHandler::initialize() {
|
|
|
|
|
return returnvalue::OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageQueueId_t PdecHandler::getCommandQueue() const { return commandQueue->getId(); }
|
|
|
|
|
|
|
|
|
|
void PdecHandler::writePdecConfig() {
|
|
|
|
|
PdecConfig pdecConfig;
|
|
|
|
|
|
|
|
|
|
*(memoryBaseAddress + FRAME_HEADER_OFFSET) = pdecConfig.getConfigWord(0);
|
|
|
|
|
*(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1);
|
|
|
|
|
|
|
|
|
|
// Configure interrupt mask register to enable interrupts
|
|
|
|
|
*(memoryBaseAddress + PDEC_IMR_OFFSET) = pdecConfig.getImrReg();
|
|
|
|
|
|
|
|
|
|
// Configure all MAP IDs as invalid
|
|
|
|
|
for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) {
|
|
|
|
|
*(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx / 4) =
|
|
|
|
|
NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory)
|
|
|
|
|
uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER);
|
|
|
|
|
*(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) =
|
|
|
|
|
(NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) | routeToPm;
|
|
|
|
|
|
|
|
|
|
// Write map id clock frequencies
|
|
|
|
|
for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) {
|
|
|
|
|
*(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) =
|
|
|
|
|
MAP_CLK_FREQ << 24 | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t PdecHandler::resetFarStatFlag() {
|
|
|
|
|
uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET);
|
|
|
|
|
if (pdecFar != FAR_RESET) {
|
|
|
|
|
sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value."
|
|
|
|
|
<< " Read value: 0x" << std::hex << static_cast<unsigned int>(pdecFar)
|
|
|
|
|
<< std::endl;
|
|
|
|
|
return returnvalue::FAILED;
|
|
|
|
|
}
|
|
|
|
|
#if OBSW_DEBUG_PDEC_HANDLER == 1
|
|
|
|
|
sif::debug << "PdecHandler::resetFarStatFlag: read FAR with value: 0x" << std::hex << pdecFar
|
|
|
|
|
<< std::endl;
|
|
|
|
|
#endif /* OBSW_DEBUG_PDEC_HANDLER == 1 */
|
|
|
|
|
return returnvalue::OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t PdecHandler::releasePdec() {
|
|
|
|
|
ReturnValue_t result = returnvalue::OK;
|
|
|
|
|
result = gpioComIF->pullHigh(pdecReset);
|
|
|
|
|
if (result != returnvalue::OK) {
|
|
|
|
|
sif::error << "PdecHandler::releasePdec: Failed to release PDEC reset signal" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) {
|
|
|
|
|
ReturnValue_t result = returnvalue::OK;
|
|
|
|
|
if (OP_MODE == Modes::POLLED) {
|
|
|
|
|
polledOperation();
|
|
|
|
|
} else if (OP_MODE == Modes::IRQ) {
|
|
|
|
|
irqOperation();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t PdecHandler::polledOperation() {
|
|
|
|
|
readCommandQueue();
|
|
|
|
|
|
|
|
|
|
switch (state) {
|
|
|
|
@ -164,6 +117,13 @@ ReturnValue_t PdecHandler::performOperation(uint8_t operationCode) {
|
|
|
|
|
return returnvalue::OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t PdecHandler::irqOperation() {
|
|
|
|
|
while (true) {
|
|
|
|
|
readCommandQueue();
|
|
|
|
|
}
|
|
|
|
|
return returnvalue::OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PdecHandler::readCommandQueue(void) {
|
|
|
|
|
CommandMessage commandMessage;
|
|
|
|
|
ReturnValue_t result = returnvalue::FAILED;
|
|
|
|
@ -181,6 +141,61 @@ void PdecHandler::readCommandQueue(void) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageQueueId_t PdecHandler::getCommandQueue() const { return commandQueue->getId(); }
|
|
|
|
|
|
|
|
|
|
void PdecHandler::writePdecConfig() {
|
|
|
|
|
PdecConfig pdecConfig;
|
|
|
|
|
|
|
|
|
|
*(memoryBaseAddress + FRAME_HEADER_OFFSET) = pdecConfig.getConfigWord(0);
|
|
|
|
|
*(memoryBaseAddress + FRAME_HEADER_OFFSET + 1) = pdecConfig.getConfigWord(1);
|
|
|
|
|
|
|
|
|
|
if (OP_MODE == Modes::IRQ) {
|
|
|
|
|
// Configure interrupt mask register to enable interrupts
|
|
|
|
|
*(memoryBaseAddress + PDEC_IMR_OFFSET) = pdecConfig.getImrReg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Configure all MAP IDs as invalid
|
|
|
|
|
for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) {
|
|
|
|
|
*(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx / 4) =
|
|
|
|
|
NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// All TCs with MAP ID 7 will be routed to the PM module (can then be read from memory)
|
|
|
|
|
uint8_t routeToPm = calcMapAddrEntry(PM_BUFFER);
|
|
|
|
|
*(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + 1) =
|
|
|
|
|
(NO_DESTINATION << 24) | (NO_DESTINATION << 16) | (NO_DESTINATION << 8) | routeToPm;
|
|
|
|
|
|
|
|
|
|
// Write map id clock frequencies
|
|
|
|
|
for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) {
|
|
|
|
|
*(memoryBaseAddress + MAP_CLK_FREQ_OFFSET + idx / 4) =
|
|
|
|
|
MAP_CLK_FREQ << 24 | MAP_CLK_FREQ << 16 | MAP_CLK_FREQ << 8 | MAP_CLK_FREQ;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t PdecHandler::resetFarStatFlag() {
|
|
|
|
|
uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET);
|
|
|
|
|
if (pdecFar != FAR_RESET) {
|
|
|
|
|
sif::warning << "PdecHandler::resetFarStatFlag: FAR register did not match expected value."
|
|
|
|
|
<< " Read value: 0x" << std::hex << static_cast<unsigned int>(pdecFar)
|
|
|
|
|
<< std::endl;
|
|
|
|
|
return returnvalue::FAILED;
|
|
|
|
|
}
|
|
|
|
|
#if OBSW_DEBUG_PDEC_HANDLER == 1
|
|
|
|
|
sif::debug << "PdecHandler::resetFarStatFlag: read FAR with value: 0x" << std::hex << pdecFar
|
|
|
|
|
<< std::endl;
|
|
|
|
|
#endif /* OBSW_DEBUG_PDEC_HANDLER == 1 */
|
|
|
|
|
return returnvalue::OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReturnValue_t PdecHandler::releasePdec() {
|
|
|
|
|
ReturnValue_t result = returnvalue::OK;
|
|
|
|
|
result = gpioComIF->pullHigh(pdecReset);
|
|
|
|
|
if (result != returnvalue::OK) {
|
|
|
|
|
sif::error << "PdecHandler::releasePdec: Failed to release PDEC reset signal" << std::endl;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool PdecHandler::newTcReceived() {
|
|
|
|
|
uint32_t pdecFar = *(registerBaseAddress + PDEC_FAR_OFFSET);
|
|
|
|
|
|
|
|
|
|