From 1cc62238c2f35af3186e9d7cff77295f59770faf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 26 Jun 2023 14:39:03 +0200 Subject: [PATCH] only reset PTME on rate change init --- linux/ipcore/AxiPtmeConfig.cpp | 6 ++++++ linux/ipcore/AxiPtmeConfig.h | 1 + linux/ipcore/PtmeConfig.cpp | 5 +++++ linux/ipcore/PtmeConfig.h | 1 + mission/com/CcsdsIpCoreHandler.cpp | 1 + 5 files changed, 14 insertions(+) diff --git a/linux/ipcore/AxiPtmeConfig.cpp b/linux/ipcore/AxiPtmeConfig.cpp index 6dee3e2f..d3d5662a 100644 --- a/linux/ipcore/AxiPtmeConfig.cpp +++ b/linux/ipcore/AxiPtmeConfig.cpp @@ -41,6 +41,12 @@ ReturnValue_t AxiPtmeConfig::writeCaduRateReg(uint8_t rateVal) { return returnvalue::OK; } +uint8_t AxiPtmeConfig::readCaduRateReg() { + ReturnValue_t result = returnvalue::OK; + MutexGuard mg(mutex); + return static_cast(*(baseAddress + CADU_BITRATE_REG)); +} + void AxiPtmeConfig::enableTxclockManipulator() { writeBit(COMMON_CONFIG_REG, true, BitPos::EN_TX_CLK_MANIPULATOR); } diff --git a/linux/ipcore/AxiPtmeConfig.h b/linux/ipcore/AxiPtmeConfig.h index 98188775..ebdf4d38 100644 --- a/linux/ipcore/AxiPtmeConfig.h +++ b/linux/ipcore/AxiPtmeConfig.h @@ -38,6 +38,7 @@ class AxiPtmeConfig : public SystemObject { * frequency of the clock connected to the bit clock input of PTME. */ ReturnValue_t writeCaduRateReg(uint8_t rateVal); + uint8_t readCaduRateReg(); /** * @brief Next to functions control the tx clock manipulator component diff --git a/linux/ipcore/PtmeConfig.cpp b/linux/ipcore/PtmeConfig.cpp index 5f247b54..5b6b9343 100644 --- a/linux/ipcore/PtmeConfig.cpp +++ b/linux/ipcore/PtmeConfig.cpp @@ -26,6 +26,11 @@ ReturnValue_t PtmeConfig::setRate(uint32_t bitRate) { return axiPtmeConfig->writeCaduRateReg(static_cast(rateVal)); } +uint32_t PtmeConfig::getRate() { + uint8_t rateReg = axiPtmeConfig->readCaduRateReg(); + return (BIT_CLK_FREQ / (rateReg + 1)); +} + void PtmeConfig::invertTxClock(bool invert) { if (invert) { axiPtmeConfig->enableTxclockInversion(); diff --git a/linux/ipcore/PtmeConfig.h b/linux/ipcore/PtmeConfig.h index 87614187..11eeff7d 100644 --- a/linux/ipcore/PtmeConfig.h +++ b/linux/ipcore/PtmeConfig.h @@ -32,6 +32,7 @@ class PtmeConfig : public SystemObject { * of the CADU clock due to the convolutional code added by the s-Band transceiver. */ ReturnValue_t setRate(uint32_t bitRate); + uint32_t getRate(); /** * @brief Will change the time the tx data signal is updated with respect to the tx clock diff --git a/mission/com/CcsdsIpCoreHandler.cpp b/mission/com/CcsdsIpCoreHandler.cpp index 625c90cd..766fd67c 100644 --- a/mission/com/CcsdsIpCoreHandler.cpp +++ b/mission/com/CcsdsIpCoreHandler.cpp @@ -255,6 +255,7 @@ void CcsdsIpCoreHandler::startTransition(Mode_t mode, Submode_t submode) { updateContext.setModeAfterUpdate = true; return; } + if(ptmeConfig.setRate(bitRate)) // No rate change, so enable transmitter right away. enableTransmit(); } else if (mode == HasModesIF::MODE_OFF) {