diff --git a/linux/obc/PdecConfig.cpp b/linux/obc/PdecConfig.cpp index ac762a6c..eaa32512 100644 --- a/linux/obc/PdecConfig.cpp +++ b/linux/obc/PdecConfig.cpp @@ -31,3 +31,8 @@ uint32_t PdecConfig::getConfigWord(uint8_t wordNo) { } return configWords[wordNo]; } + +uint32_t PdecConfig::getImrReg() { + return static_cast(enableNewFarIrq << 2) | static_cast(enableTcAbortIrq << 1) + | static_cast(enableTcNewIrq); +} diff --git a/linux/obc/PdecConfig.h b/linux/obc/PdecConfig.h index e037dd56..284af6ef 100644 --- a/linux/obc/PdecConfig.h +++ b/linux/obc/PdecConfig.h @@ -23,6 +23,7 @@ class PdecConfig { * @brief Returns the configuration word by specifying the position. */ uint32_t getConfigWord(uint8_t wordNo); + uint32_t getImrReg(); private: // TC transfer frame configuration parameters @@ -45,6 +46,9 @@ class PdecConfig { static const uint8_t CONFIG_WORDS_NUM = 2; uint32_t configWords[CONFIG_WORDS_NUM]; + bool enableTcNewIrq = true; + bool enableTcAbortIrq = true; + bool enableNewFarIrq = true; void initialize(); }; diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index c009d8a6..a04b9128 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -86,10 +86,12 @@ void PdecHandler::writePdecConfig() { *(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) { - // TODO: adding 1 / 4 results in + 0. Check correctness - *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx + 1 / 4) = + *(memoryBaseAddress + MAP_ADDR_LUT_OFFSET + idx / 4) = NO_DESTINATION << 24 | NO_DESTINATION << 16 | NO_DESTINATION << 8 | NO_DESTINATION; } @@ -100,10 +102,10 @@ void PdecHandler::writePdecConfig() { // Write map id clock frequencies for (int idx = 0; idx <= MAX_MAP_ADDR; idx += 4) { - // TODO: adding 1 / 4 results in + 0. Check correctness *(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() { diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 57adfa9f..20a9642d 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -147,6 +147,8 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasAc * UIO is 4 byte aligned. Thus offset is calculated with "true offset" / 4 * Example: PDEC_FAR = 0x2840 => Offset in virtual address space is 0xA10 */ + static constexpr uint32_t PDEC_PIR_OFFSET = 0xA03; + static constexpr uint32_t PDEC_IMR_OFFSET = 0xA04; static const uint32_t PDEC_FAR_OFFSET = 0xA10; static const uint32_t PDEC_CLCW_OFFSET = 0xA12; static const uint32_t PDEC_BFREE_OFFSET = 0xA24;