From a56224c339467bce1f17b5a9e92c59cba0787e17 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 24 Jan 2022 07:43:14 +0100 Subject: [PATCH 1/9] ptme axi interface --- bsp_q7s/boardconfig/busConf.h | 2 +- bsp_q7s/core/ObjectFactory.cpp | 15 +++-------- common/config/commonObjects.h | 4 ++- fsfw | 2 +- linux/obc/CMakeLists.txt | 1 + linux/obc/PtmeAxiConfig.cpp | 49 ++++++++++++++++++++++++++++++++++ linux/obc/PtmeAxiConfig.h | 40 +++++++++++++++++++++++++++ linux/obc/PtmeConfig.h | 3 ++- linux/obc/PtmeRateSetter.cpp | 38 ++++++++++++++++++-------- linux/obc/PtmeRateSetter.h | 42 ++++++++++++++--------------- linux/obc/TxRateSetterIF.h | 9 ++++++- mission/tmtc/CCSDSHandler.cpp | 4 +-- mission/tmtc/CCSDSHandler.h | 3 +++ tmtc | 2 +- 14 files changed, 163 insertions(+), 51 deletions(-) create mode 100644 linux/obc/PtmeAxiConfig.cpp create mode 100644 linux/obc/PtmeAxiConfig.h diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index e41ed093..5abd109b 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -17,6 +17,7 @@ static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL7"; static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0"; static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; static constexpr char UIO_PDEC_RAM[] = "/dev/uio3"; +static constexpr char UIO_PTME_CONFIG[] = "/dev/uio4"; namespace gpioNames { static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; @@ -69,7 +70,6 @@ static constexpr char RS485_EN_TX_DATA[] = "tx_data_enable_ltc2872"; static constexpr char RS485_EN_RX_CLOCK[] = "rx_clock_enable_ltc2872"; static constexpr char RS485_EN_RX_DATA[] = "rx_data_enable_ltc2872"; static constexpr char PDEC_RESET[] = "pdec_reset"; -static constexpr char BIT_RATE_SEL[] = "bit_rate_sel"; } // namespace gpioNames } // namespace q7s diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 7c089465..6db63f30 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -81,6 +81,7 @@ #include #include #include +#include ResetArgs resetArgsGnss0; ResetArgs resetArgsGnss1; @@ -943,17 +944,9 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { ptme->addVcInterface(ccsds::VC2, vc2); ptme->addVcInterface(ccsds::VC3, vc3); - GpioCookie* gpioCookieRateSetter = new GpioCookie; - consumer.str(""); - consumer << "ptme rate setter"; - // Init to low -> default bit rate is low bit rate (200 kbps in downlink with syrlinks) - gpio = new GpiodRegularByLineName(q7s::gpioNames::BIT_RATE_SEL, consumer.str(), gpio::DIR_OUT, - gpio::LOW); - gpioCookieRateSetter->addGpio(gpioIds::BIT_RATE_SEL, gpio); - gpioComIF->addGpios(gpioCookieRateSetter); - - TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(gpioIds::BIT_RATE_SEL, gpioComIF); - + PtmeAxiConfig* ptmeAxiConfig = new PtmeAxiConfig(objects::PTME_AXI_CONFIG, + std::string(q7s::UIO_PTME_CONFIG)); + TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(objects::TX_RATE_SETTER, ptmeAxiConfig); CCSDSHandler* ccsdsHandler = new CCSDSHandler( objects::CCSDS_HANDLER, objects::PTME, objects::CCSDS_PACKET_DISTRIBUTOR, txRateSetterIF, gpioComIF, gpioIds::RS485_EN_TX_CLOCK, gpioIds::RS485_EN_TX_DATA); diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index 135259d6..e29a2013 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -90,7 +90,9 @@ enum commonObjects: uint32_t { PLOC_UPDATER = 0x44330000, PLOC_MEMORY_DUMPER = 0x44330001, - STR_HELPER = 0x44330002 + STR_HELPER = 0x44330002, + PTME_AXI_CONFIG = 44330003, + TX_RATE_SETTER = 44330004 }; } diff --git a/fsfw b/fsfw index 9b770602..c1e0bcee 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 9b77060295c9c32ebfc2e7cf6517eb2e66216191 +Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 diff --git a/linux/obc/CMakeLists.txt b/linux/obc/CMakeLists.txt index 4119624c..d59a1a5f 100644 --- a/linux/obc/CMakeLists.txt +++ b/linux/obc/CMakeLists.txt @@ -4,6 +4,7 @@ target_sources(${TARGET_NAME} PUBLIC PdecHandler.cpp PdecConfig.cpp PtmeRateSetter.cpp + PtmeAxiConfig.cpp ) diff --git a/linux/obc/PtmeAxiConfig.cpp b/linux/obc/PtmeAxiConfig.cpp new file mode 100644 index 00000000..3ec45faa --- /dev/null +++ b/linux/obc/PtmeAxiConfig.cpp @@ -0,0 +1,49 @@ +#include +#include +#include "PtmeAxiConfig.h" +#include "fsfw/serviceinterface/ServiceInterface.h" + +PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio) : + SystemObject(objectId), configAxiUio(configAxiUio) { + mutex = MutexFactory::instance()->createMutex(); + if (mutex == nullptr) { + sif::warning << "Failed to create mutex" << std::endl; + } +} + +PtmeAxiConfig::~PtmeAxiConfig() { +} + +ReturnValue_t PtmeAxiConfig::initialize() { + int fd = open(configAxiUio.c_str(), O_RDWR); + if (fd < 1) { + sif::warning << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + + baseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, + fd, 0)); + + if (baseAddress == MAP_FAILED) { + sif::warning << "PtmeAxiConfig::initialize: Failed to map uio address" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + 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(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; +} + diff --git a/linux/obc/PtmeAxiConfig.h b/linux/obc/PtmeAxiConfig.h new file mode 100644 index 00000000..2b3e9d26 --- /dev/null +++ b/linux/obc/PtmeAxiConfig.h @@ -0,0 +1,40 @@ +#ifndef LINUX_OBC_PTMEAXICONFIG_H_ +#define LINUX_OBC_PTMEAXICONFIG_H_ + +#include +#include "fsfw/ipc/MutexIF.h" +#include "fsfw/returnvalues/HasReturnvaluesIF.h" +#include "fsfw/objectmanager/SystemObject.h" + +/** + * @brief Class providing low level access to the configuration interface of the PTME. + * + * @author J. Meier + */ +class PtmeAxiConfig : public SystemObject { +public: + /** + * @brief Constructor + * @param configAxiUio Device file of UIO belonging to the AXI configuration interface. + */ + PtmeAxiConfig(object_id_t objectId, std::string configAxiUio); + virtual ~PtmeAxiConfig(); + + virtual ReturnValue_t initialize() override; + ReturnValue_t writeCaduRateReg(uint8_t rateVal); + +private: + // Address of register storing the bitrate configuration parameter + static const uint32_t CADU_BITRATE_REG = 0x0; + static const int MAP_SIZE = 0x1000; + + std::string configAxiUio; + MutexIF* mutex = nullptr; + MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; + uint32_t mutexTimeout = 20; + + uint32_t* baseAddress = nullptr; + +}; + +#endif /* LINUX_OBC_PTMEAXICONFIG_H_ */ diff --git a/linux/obc/PtmeConfig.h b/linux/obc/PtmeConfig.h index b5b722ac..2dd7b7b2 100644 --- a/linux/obc/PtmeConfig.h +++ b/linux/obc/PtmeConfig.h @@ -25,7 +25,8 @@ static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #else static const char UIO_DEVICE_FILE[] = "/dev/uio1"; #endif - +// Bit clock frequency of PMTE IP core in Hz +static const uint32_t BIT_CLK_FREQ = 20000000; }; // namespace PtmeConfig #endif /* LINUX_OBC_PTMECONFIG_H_ */ diff --git a/linux/obc/PtmeRateSetter.cpp b/linux/obc/PtmeRateSetter.cpp index b5a6ee1c..4a81c361 100644 --- a/linux/obc/PtmeRateSetter.cpp +++ b/linux/obc/PtmeRateSetter.cpp @@ -2,24 +2,40 @@ #include "fsfw/serviceinterface/ServiceInterface.h" -PtmeRateSetter::PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif) - : bitrateSel(bitrateSel), gpioif(gpioif) {} +PtmeRateSetter::PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfig) + : SystemObject(objectId), ptmeAxiConfig(ptmeAxiConfig) {} PtmeRateSetter::~PtmeRateSetter() {} +ReturnValue_t PtmeRateSetter::initialize() { + if (ptmeAxiConfig == nullptr) { + sif::warning << "PtmeRateSetter::initialize: Invalid PtmeAxiConfig object" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + ReturnValue_t PtmeRateSetter::setRate(BitRates rate) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + uint8_t rateVal = 0; switch (rate) { - case RATE_2000KHZ: - result = gpioif->pullHigh(bitrateSel); + case RATE_2000KBPS: + rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 2000000 - 1); break; - case RATE_400KHZ: - result = gpioif->pullLow(bitrateSel); + case RATE_1000KBPS: + rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 1000000 - 1); + break; + case RATE_500KBPS: + rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 500000 - 1); + break; + case RATE_200KBPS: + rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 200000 - 1); + break; + case RATE_100KBPS: + rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 100000 - 1); break; default: - sif::debug << "PtmeRateSetter::setRate: Invalid rate" << std::endl; - result = HasReturnvaluesIF::RETURN_FAILED; - break; + sif::debug << "PtmeRateSetter::setRate: Unknown bit rate" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } - return result; + return ptmeAxiConfig->writeCaduRateReg(rateVal); } diff --git a/linux/obc/PtmeRateSetter.h b/linux/obc/PtmeRateSetter.h index 14dfec4b..6b9d6c5a 100644 --- a/linux/obc/PtmeRateSetter.h +++ b/linux/obc/PtmeRateSetter.h @@ -3,36 +3,36 @@ #include "TxRateSetterIF.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" -#include "fsfw_hal/common/gpio/GpioIF.h" -#include "fsfw_hal/common/gpio/gpioDefinitions.h" +#include "linux/obc/PtmeAxiConfig.h" +#include "linux/obc/PtmeConfig.h" +#include "fsfw/objectmanager/SystemObject.h" /** - * @brief Class to set the downlink bit rate by using the cadu_rate_switcher implemented in - * the programmable logic. + * @brief Class to set the downlink bit rate by writing to the AXI configuration interface of the + * PTME IP core. * - * @details The cadu_rate_switcher module sets the input rate to the syrlinks transceiver either - * to 2000 kHz (bitrateSel = 1) or 400 kHz (bitrate = 0). + * @details This is the bitrate of the CADU clock and not the downlink which has twice the bitrate + * of the CADU clock due to the convolutional code added by the s-Band transceiver. * * @author J. Meier */ -class PtmeRateSetter : public TxRateSetterIF { - public: - /** - * @brief Constructor - * - * @param bitrateSel GPIO ID of the GPIO connected to the bitrate_sel input of the - * cadu_rate_switcher. - * @param gpioif GPIO interface to drive the bitrateSel GPIO - */ - PtmeRateSetter(gpioId_t bitrateSel, GpioIF* gpioif); - virtual ~PtmeRateSetter(); +class PtmeRateSetter: public TxRateSetterIF, public SystemObject { +public: + /** + * @brief Constructor + * + * objectId Object id of system object + * ptmeAxiConfig Pointer to object providing access to PTME configuration registers. + */ + PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfig); + virtual ~PtmeRateSetter(); - virtual ReturnValue_t setRate(BitRates rate); + virtual ReturnValue_t initialize() override; + virtual ReturnValue_t setRate(BitRates rate); - private: - gpioId_t bitrateSel = gpio::NO_GPIO; +private: - GpioIF* gpioif = nullptr; + PtmeAxiConfig* ptmeAxiConfig = nullptr; }; #endif /* LINUX_OBC_PTMERATESETTER_H_ */ diff --git a/linux/obc/TxRateSetterIF.h b/linux/obc/TxRateSetterIF.h index 1eaded33..6090825f 100644 --- a/linux/obc/TxRateSetterIF.h +++ b/linux/obc/TxRateSetterIF.h @@ -3,7 +3,14 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -enum BitRates : uint32_t { RATE_2000KHZ, RATE_400KHZ }; +enum BitRates : uint32_t { + RATE_2000KBPS, + RATE_1000KBPS, + RATE_500KBPS, + RATE_400KBPS, + RATE_200KBPS, + RATE_100KBPS +}; /** * @brief Abstract class for objects implementing the functionality to switch the diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index ba34d273..3747b42d 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -191,11 +191,11 @@ ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t const uint8_t* data, size_t size) { switch (actionId) { case SET_LOW_RATE: { - txRateSetterIF->setRate(BitRates::RATE_400KHZ); + txRateSetterIF->setRate(BitRates::RATE_100KBPS); return EXECUTION_FINISHED; } case SET_HIGH_RATE: { - txRateSetterIF->setRate(BitRates::RATE_2000KHZ); + txRateSetterIF->setRate(BitRates::RATE_500KBPS); return EXECUTION_FINISHED; } case EN_TRANSMITTER: { diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index 3090c24e..aedeccff 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -23,6 +23,9 @@ * @brief This class handles the data exchange with the CCSDS IP cores implemented in the * programmable logic of the Q7S. * + * @details After reboot default CADU bitrate is always set to 100 kbps (results in downlink rate + * of 200 kbps due to convolutional code added by syrlinks transceiver) + * * @author J. Meier */ class CCSDSHandler : public SystemObject, diff --git a/tmtc b/tmtc index 6f24d6a8..580ac8b2 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 6f24d6a83995ca7a895c17a77a00bceac4d7f141 +Subproject commit 580ac8b2d7e73aa860f3de55066187d7684d2d64 From 512d339803fbfe52b45faf3eac4b78f66a1529c9 Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Mon, 24 Jan 2022 15:38:00 +0100 Subject: [PATCH 2/9] clang formatter setup eclipse --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 6ad16a87..7d27b092 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ 13. [Eclipse](#eclipse) 14. [Running the OBSW on a Raspberry Pi](#rpi) 15. [FSFW](#fsfw) +16. [Coding Style](#coding-style) # General information @@ -1151,3 +1152,15 @@ git merge upstream/master Alternatively, changes from other upstreams (forks) and branches can be merged like that in the same way. + +# Coding Style +* the formatting is based on the clang-format tools +## Setting up eclipse auto-fromatter with clang-format +1. Help → Install New Software → Add +2. In location insert the link http://www.cppstyle.com/luna +3. The software package CppStyle should now be available for installation +4. On windows download the clang-formatting tools from https://llvm.org/builds/. On linux clang-format can be installed with the package manager. +5. Navigate to Preferences → C/C++ → CppStyle +6. Insert the path to the clang-format executable +7. Under C/C++ → Code Style → Formatter, change the formatter to CppStyle (clang-format) +8. Code can now be formatted with the clang tool by using the key combination Ctrl + Shift + f \ No newline at end of file From a07468f7b710a626b4568d310027a83c28e813ed Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 24 Jan 2022 16:33:22 +0100 Subject: [PATCH 3/9] introduced uio mapper class --- bsp_q7s/boardconfig/busConf.h | 11 ++- bsp_q7s/core/InitMission.cpp | 2 + bsp_q7s/core/ObjectFactory.cpp | 24 +++--- linux/obc/PapbVcInterface.cpp | 137 +++++++++++++++++---------------- linux/obc/PapbVcInterface.h | 9 ++- linux/obc/Ptme.cpp | 7 +- linux/obc/Ptme.h | 2 +- linux/obc/PtmeAxiConfig.cpp | 22 ++---- linux/obc/PtmeAxiConfig.h | 6 +- linux/obc/VcInterfaceIF.h | 2 +- 10 files changed, 120 insertions(+), 102 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 5abd109b..3e8a4b49 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -17,7 +17,16 @@ static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ttyUL7"; static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0"; static constexpr char UIO_PDEC_CONFIG_MEMORY[] = "/dev/uio2"; static constexpr char UIO_PDEC_RAM[] = "/dev/uio3"; -static constexpr char UIO_PTME_CONFIG[] = "/dev/uio4"; +static constexpr char UIO_PTME[] = "/dev/uio1"; +static constexpr int MAP_ID_PTME_CONFIG = 3; + +namespace uiomapids { + static const int PTME_VC0 = 0; + static const int PTME_VC1 = 1; + static const int PTME_VC2 = 2; + static const int PTME_VC3 = 3; + static const int PTME_CONFIG = 4; +} namespace gpioNames { static constexpr char GYRO_0_ADIS_CS[] = "gyro_0_adis_chip_select"; diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 96a43a81..1828349b 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -115,12 +115,14 @@ void initmission::initTasks() { } #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ +#if OBSW_ADD_ACS_HANDLERS == 1 PeriodicTaskIF* acsCtrl = factory->createPeriodicTask( "ACS_CTRL", 40, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc); result = acsCtrl->addComponent(objects::GPS_CONTROLLER); if (result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("ACS_CTRL", objects::GPS_CONTROLLER); } +#endif /* OBSW_ADD_ACS_HANDLERS */ #if BOARD_TE0720 == 0 // FS task, task interval does not matter because it runs in permanent loop, priority low diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 6db63f30..a801852e 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -928,14 +928,18 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { gpioComIF->addGpios(gpioCookiePtmeIp); // Creating virtual channel interfaces - VcInterfaceIF* vc0 = new PapbVcInterface(objects::PAPB_VC0, gpioComIF, gpioIds::VC0_PAPB_BUSY, - gpioIds::VC0_PAPB_EMPTY, PtmeConfig::VC0_OFFSETT); - VcInterfaceIF* vc1 = new PapbVcInterface(objects::PAPB_VC1, gpioComIF, gpioIds::VC1_PAPB_BUSY, - gpioIds::VC1_PAPB_EMPTY, PtmeConfig::VC1_OFFSETT); - VcInterfaceIF* vc2 = new PapbVcInterface(objects::PAPB_VC2, gpioComIF, gpioIds::VC2_PAPB_BUSY, - gpioIds::VC2_PAPB_EMPTY, PtmeConfig::VC2_OFFSETT); - VcInterfaceIF* vc3 = new PapbVcInterface(objects::PAPB_VC3, gpioComIF, gpioIds::VC3_PAPB_BUSY, - gpioIds::VC3_PAPB_EMPTY, PtmeConfig::VC3_OFFSETT); + VcInterfaceIF* vc0 = + new PapbVcInterface(objects::PAPB_VC0, gpioComIF, gpioIds::VC0_PAPB_BUSY, + gpioIds::VC0_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC0); + VcInterfaceIF* vc1 = + new PapbVcInterface(objects::PAPB_VC1, gpioComIF, gpioIds::VC1_PAPB_BUSY, + gpioIds::VC1_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC1); + VcInterfaceIF* vc2 = + new PapbVcInterface(objects::PAPB_VC2, gpioComIF, gpioIds::VC2_PAPB_BUSY, + gpioIds::VC2_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC2); + VcInterfaceIF* vc3 = + new PapbVcInterface(objects::PAPB_VC3, gpioComIF, gpioIds::VC3_PAPB_BUSY, + gpioIds::VC3_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC3); // Creating ptme object and adding virtual channel interfaces Ptme* ptme = new Ptme(objects::PTME); @@ -944,8 +948,8 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { ptme->addVcInterface(ccsds::VC2, vc2); ptme->addVcInterface(ccsds::VC3, vc3); - PtmeAxiConfig* ptmeAxiConfig = new PtmeAxiConfig(objects::PTME_AXI_CONFIG, - std::string(q7s::UIO_PTME_CONFIG)); + PtmeAxiConfig* ptmeAxiConfig = + new PtmeAxiConfig(objects::PTME_AXI_CONFIG, q7s::UIO_PTME, q7s::uiomapids::PTME_CONFIG); TxRateSetterIF* txRateSetterIF = new PtmeRateSetter(objects::TX_RATE_SETTER, ptmeAxiConfig); CCSDSHandler* ccsdsHandler = new CCSDSHandler( objects::CCSDS_HANDLER, objects::PTME, objects::CCSDS_PACKET_DISTRIBUTOR, txRateSetterIF, diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index f144306c..50cee1d3 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -1,98 +1,101 @@ #include - +#include #include "fsfw/serviceinterface/ServiceInterface.h" PapbVcInterface::PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, - gpioId_t papbBusyId, gpioId_t papbEmptyId, uint32_t vcOffset) - : SystemObject(objectId), - gpioComIF(gpioComIF), - papbBusyId(papbBusyId), - papbEmptyId(papbEmptyId), - vcOffset(vcOffset) {} + gpioId_t papbBusyId, gpioId_t papbEmptyId, std::string uioFile, int mapNum) : + SystemObject(objectId), gpioComIF(gpioComIF), papbBusyId(papbBusyId), papbEmptyId( + papbEmptyId), uioFile(uioFile), mapNum(mapNum) { +} -PapbVcInterface::~PapbVcInterface() {} +PapbVcInterface::~PapbVcInterface() { +} -void PapbVcInterface::setRegisterAddress(uint32_t* ptmeBaseAddress) { - vcBaseReg = ptmeBaseAddress + vcOffset; +ReturnValue_t PapbVcInterface::initialize() { + UioMapper uioMapper(uioFile, mapNum); + return uioMapper.getMappedAdress(&vcBaseReg, UioMapper::Permissions::WRITE_ONLY); } ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { - if (pollPapbBusySignal() == RETURN_OK) { - startPacketTransfer(); - } - - for (size_t idx = 0; idx < size; idx++) { if (pollPapbBusySignal() == RETURN_OK) { - *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); - } else { - sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size << " data" - << std::endl; - return RETURN_FAILED; + startPacketTransfer(); } - } - - if (pollPapbBusySignal() == RETURN_OK) { - endPacketTransfer(); - } - return RETURN_OK; + for (size_t idx = 0; idx < size; idx++) { + if (pollPapbBusySignal() == RETURN_OK) { + *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); + } else { + sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size + << " data" << std::endl; + return RETURN_FAILED; + } + } + if (pollPapbBusySignal() == RETURN_OK) { + endPacketTransfer(); + } + return RETURN_OK; } -void PapbVcInterface::startPacketTransfer() { *vcBaseReg = CONFIG_START; } +void PapbVcInterface::startPacketTransfer() { + *vcBaseReg = CONFIG_START; +} -void PapbVcInterface::endPacketTransfer() { *vcBaseReg = CONFIG_END; } +void PapbVcInterface::endPacketTransfer() { + *vcBaseReg = CONFIG_END; +} ReturnValue_t PapbVcInterface::pollPapbBusySignal() { - int papbBusyState = 0; - ReturnValue_t result = RETURN_OK; + int papbBusyState = 0; + ReturnValue_t result = RETURN_OK; - /** Check if PAPB interface is ready to receive data */ - result = gpioComIF->readGpio(papbBusyId, &papbBusyState); - if (result != RETURN_OK) { - sif::warning << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" - << std::endl; - return RETURN_FAILED; - } - if (!papbBusyState) { - sif::warning << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; - return PAPB_BUSY; - } + /** Check if PAPB interface is ready to receive data */ + result = gpioComIF->readGpio(papbBusyId, &papbBusyState); + if (result != RETURN_OK) { + sif::warning << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" + << std::endl; + return RETURN_FAILED; + } + if (!papbBusyState) { + sif::warning << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; + return PAPB_BUSY; + } - return RETURN_OK; + return RETURN_OK; } void PapbVcInterface::isVcInterfaceBufferEmpty() { - ReturnValue_t result = RETURN_OK; - int papbEmptyState = 1; + ReturnValue_t result = RETURN_OK; + int papbEmptyState = 1; - result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); + result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); - if (result != RETURN_OK) { - sif::warning << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" - << std::endl; + if (result != RETURN_OK) { + sif::warning + << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" + << std::endl; + return; + } + + if (papbEmptyState == 1) { + sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is empty" << std::endl; + } else { + sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is not empty" << std::endl; + } return; - } - - if (papbEmptyState == 1) { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is empty" << std::endl; - } else { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is not empty" << std::endl; - } - return; } ReturnValue_t PapbVcInterface::sendTestFrame() { - /** Size of one complete transfer frame data field amounts to 1105 bytes */ - uint8_t testPacket[1105]; + /** Size of one complete transfer frame data field amounts to 1105 bytes */ + uint8_t testPacket[1105]; - /** Fill one test packet */ - for (int idx = 0; idx < 1105; idx++) { - testPacket[idx] = static_cast(idx & 0xFF); - } + /** Fill one test packet */ + for (int idx = 0; idx < 1105; idx++) { + testPacket[idx] = static_cast(idx & 0xFF); + } - ReturnValue_t result = write(testPacket, 1105); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = write(testPacket, 1105); + if (result != RETURN_OK) { + return result; + } - return RETURN_OK; + return RETURN_OK; } diff --git a/linux/obc/PapbVcInterface.h b/linux/obc/PapbVcInterface.h index e7d03a70..465d1bf9 100644 --- a/linux/obc/PapbVcInterface.h +++ b/linux/obc/PapbVcInterface.h @@ -27,14 +27,16 @@ class PapbVcInterface : public SystemObject, public VcInterfaceIF, public HasRet * @param papbEmptyId The ID of the GPIO which is connected to the PAPBEmpty signal of the * VcInterface IP Core. The signal is high when there are no packets in the * external buffer memory (BRAM). + * @param uioFile UIO file providing access to the PAPB bus + * @param mapNum Map number of UIO map associated with this virtual channel */ PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, - gpioId_t papbEmptyId, uint32_t vcOffset); + gpioId_t papbEmptyId, std::string uioFile, int mapNum); virtual ~PapbVcInterface(); ReturnValue_t write(const uint8_t* data, size_t size) override; - void setRegisterAddress(uint32_t* ptmeBaseAddress) override; + ReturnValue_t initialize() override; private: static const uint8_t INTERFACE_ID = CLASS_ID::CCSDS_IP_CORE_BRIDGE; @@ -69,6 +71,9 @@ class PapbVcInterface : public SystemObject, public VcInterfaceIF, public HasRet /** High when external buffer memory of virtual channel is empty */ gpioId_t papbEmptyId = gpio::NO_GPIO; + std::string uioFile; + int mapNum = 0; + uint32_t* vcBaseReg = nullptr; uint32_t vcOffset = 0; diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp index 237e66ab..3c3403e0 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/obc/Ptme.cpp @@ -1,7 +1,7 @@ #include #include #include - +#include #include "PtmeConfig.h" #include "fsfw/serviceinterface/ServiceInterface.h" @@ -20,7 +20,8 @@ ReturnValue_t Ptme::initialize() { * Map uio device in virtual address space * PROT_WRITE: Map uio device in writable only mode */ - ptmeBaseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE, MAP_SHARED, fd, 0)); + ptmeBaseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE, MAP_SHARED, fd, + 0 * getpagesize())); if (ptmeBaseAddress == MAP_FAILED) { sif::error << "Ptme::initialize: Failed to map uio address" << std::endl; @@ -29,7 +30,7 @@ ReturnValue_t Ptme::initialize() { VcInterfaceMapIter iter; for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) { - iter->second->setRegisterAddress(ptmeBaseAddress); + iter->second->initialize(); } return RETURN_OK; diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index d85885bc..4e4e6862 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -49,7 +49,7 @@ class Ptme : public PtmeIF, public SystemObject, public HasReturnvaluesIF { static const int MAP_SIZE = 0x40000; #else /** Size of mapped address space */ - static const int MAP_SIZE = 0x40000; + static const int MAP_SIZE = 0x1000; #endif /* BOARD_TE0720 == 1 */ /** diff --git a/linux/obc/PtmeAxiConfig.cpp b/linux/obc/PtmeAxiConfig.cpp index 3ec45faa..fdf810de 100644 --- a/linux/obc/PtmeAxiConfig.cpp +++ b/linux/obc/PtmeAxiConfig.cpp @@ -1,9 +1,8 @@ -#include -#include #include "PtmeAxiConfig.h" #include "fsfw/serviceinterface/ServiceInterface.h" +#include "fsfw_hal/linux/uio/UioMapper.h" -PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio) : +PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio, int mapNum) : SystemObject(objectId), configAxiUio(configAxiUio) { mutex = MutexFactory::instance()->createMutex(); if (mutex == nullptr) { @@ -15,18 +14,11 @@ PtmeAxiConfig::~PtmeAxiConfig() { } ReturnValue_t PtmeAxiConfig::initialize() { - int fd = open(configAxiUio.c_str(), O_RDWR); - if (fd < 1) { - sif::warning << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - - baseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, - fd, 0)); - - if (baseAddress == MAP_FAILED) { - sif::warning << "PtmeAxiConfig::initialize: Failed to map uio address" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; + 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; } return HasReturnvaluesIF::RETURN_OK; } diff --git a/linux/obc/PtmeAxiConfig.h b/linux/obc/PtmeAxiConfig.h index 2b3e9d26..1ea6c295 100644 --- a/linux/obc/PtmeAxiConfig.h +++ b/linux/obc/PtmeAxiConfig.h @@ -16,8 +16,9 @@ public: /** * @brief Constructor * @param configAxiUio Device file of UIO belonging to the AXI configuration interface. + * @param mapNum Number of map belonging to axi configuration interface. */ - PtmeAxiConfig(object_id_t objectId, std::string configAxiUio); + PtmeAxiConfig(object_id_t objectId, std::string configAxiUio, int mapNum); virtual ~PtmeAxiConfig(); virtual ReturnValue_t initialize() override; @@ -26,9 +27,10 @@ public: private: // Address of register storing the bitrate configuration parameter static const uint32_t CADU_BITRATE_REG = 0x0; - static const int MAP_SIZE = 0x1000; std::string configAxiUio; + std::string uioMap; + int mapNum = 0; MutexIF* mutex = nullptr; MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING; uint32_t mutexTimeout = 20; diff --git a/linux/obc/VcInterfaceIF.h b/linux/obc/VcInterfaceIF.h index 0aa95691..45226e21 100644 --- a/linux/obc/VcInterfaceIF.h +++ b/linux/obc/VcInterfaceIF.h @@ -24,7 +24,7 @@ class VcInterfaceIF { */ virtual ReturnValue_t write(const uint8_t* data, size_t size) = 0; - virtual void setRegisterAddress(uint32_t* ptmeBaseAddress) = 0; + virtual ReturnValue_t initialize() = 0; }; #endif /* LINUX_OBC_VCINTERFACEIF_H_ */ From 93e84fde292899dec6f6242d7f7b63be915f00f8 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 14:00:30 +0100 Subject: [PATCH 4/9] initialize map num --- linux/obc/PtmeAxiConfig.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/obc/PtmeAxiConfig.cpp b/linux/obc/PtmeAxiConfig.cpp index fdf810de..3750b831 100644 --- a/linux/obc/PtmeAxiConfig.cpp +++ b/linux/obc/PtmeAxiConfig.cpp @@ -3,7 +3,7 @@ #include "fsfw_hal/linux/uio/UioMapper.h" PtmeAxiConfig::PtmeAxiConfig(object_id_t objectId, std::string configAxiUio, int mapNum) : - SystemObject(objectId), configAxiUio(configAxiUio) { + SystemObject(objectId), configAxiUio(configAxiUio), mapNum(mapNum) { mutex = MutexFactory::instance()->createMutex(); if (mutex == nullptr) { sif::warning << "Failed to create mutex" << std::endl; From 38a1b496e7f75db3893247f43d6539034dd97779 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 14:33:06 +0100 Subject: [PATCH 5/9] papb interface no longer a system object --- bsp_q7s/core/ObjectFactory.cpp | 35 ++++----- common/config/commonObjects.h | 6 +- linux/obc/PapbVcInterface.cpp | 136 ++++++++++++++++----------------- linux/obc/PapbVcInterface.h | 9 +-- 4 files changed, 86 insertions(+), 100 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index a801852e..a25eb290 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -893,35 +893,32 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { GpioCookie* gpioCookiePtmeIp = new GpioCookie; GpiodRegularByLineName* gpio = nullptr; std::stringstream consumer; - consumer << "0x" << std::hex << objects::PAPB_VC0; + consumer.str("PAPB VC0"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC0, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_BUSY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC0; + consumer.str("PAPB VC0"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC0, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC0_PAPB_EMPTY, gpio); - consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC1; + consumer.str("PAPB VC 1"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC1, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_BUSY, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC1; - gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC1, consumer.str()); + consumer.str("PAPB VC 1"); gpioCookiePtmeIp->addGpio(gpioIds::VC1_PAPB_EMPTY, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC2; + consumer.str("PAPB VC 2"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC2, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_BUSY, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC2; + consumer.str("PAPB VC 2"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC2, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC2_PAPB_EMPTY, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC3; + consumer.str("PAPB VC 3"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_BUSY_SIGNAL_VC3, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_BUSY, gpio); consumer.str(""); - consumer << "0x" << std::hex << objects::PAPB_VC3; + consumer.str("PAPB VC 3"); gpio = new GpiodRegularByLineName(q7s::gpioNames::PAPB_EMPTY_SIGNAL_VC3, consumer.str()); gpioCookiePtmeIp->addGpio(gpioIds::VC3_PAPB_EMPTY, gpio); @@ -929,17 +926,17 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { // Creating virtual channel interfaces VcInterfaceIF* vc0 = - new PapbVcInterface(objects::PAPB_VC0, gpioComIF, gpioIds::VC0_PAPB_BUSY, - gpioIds::VC0_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC0); + new PapbVcInterface(gpioComIF, gpioIds::VC0_PAPB_BUSY, gpioIds::VC0_PAPB_EMPTY, q7s::UIO_PTME, + q7s::uiomapids::PTME_VC0); VcInterfaceIF* vc1 = - new PapbVcInterface(objects::PAPB_VC1, gpioComIF, gpioIds::VC1_PAPB_BUSY, - gpioIds::VC1_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC1); + new PapbVcInterface(gpioComIF, gpioIds::VC1_PAPB_BUSY, gpioIds::VC1_PAPB_EMPTY, q7s::UIO_PTME, + q7s::uiomapids::PTME_VC1); VcInterfaceIF* vc2 = - new PapbVcInterface(objects::PAPB_VC2, gpioComIF, gpioIds::VC2_PAPB_BUSY, - gpioIds::VC2_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC2); + new PapbVcInterface(gpioComIF, gpioIds::VC2_PAPB_BUSY, gpioIds::VC2_PAPB_EMPTY, q7s::UIO_PTME, + q7s::uiomapids::PTME_VC2); VcInterfaceIF* vc3 = - new PapbVcInterface(objects::PAPB_VC3, gpioComIF, gpioIds::VC3_PAPB_BUSY, - gpioIds::VC3_PAPB_EMPTY, q7s::UIO_PTME, q7s::uiomapids::PTME_VC3); + new PapbVcInterface(gpioComIF, gpioIds::VC3_PAPB_BUSY, gpioIds::VC3_PAPB_EMPTY, q7s::UIO_PTME, + q7s::uiomapids::PTME_VC3); // Creating ptme object and adding virtual channel interfaces Ptme* ptme = new Ptme(objects::PTME); diff --git a/common/config/commonObjects.h b/common/config/commonObjects.h index e29a2013..99096ba4 100644 --- a/common/config/commonObjects.h +++ b/common/config/commonObjects.h @@ -12,11 +12,7 @@ enum commonObjects: uint32_t { TMTC_POLLING_TASK = 0x50000400, FILE_SYSTEM_HANDLER = 0x50000500, PTME = 0x50000600, - PAPB_VC0 = 0x50000700, - PAPB_VC1 = 0x50000701, - PAPB_VC2 = 0x50000702, - PAPB_VC3 = 0x50000703, - PDEC_HANDLER = 0x50000704, + PDEC_HANDLER = 0x50000700, CCSDS_HANDLER = 0x50000800, /* 0x43 ('C') for Controllers */ diff --git a/linux/obc/PapbVcInterface.cpp b/linux/obc/PapbVcInterface.cpp index 50cee1d3..45358ee1 100644 --- a/linux/obc/PapbVcInterface.cpp +++ b/linux/obc/PapbVcInterface.cpp @@ -1,101 +1,97 @@ -#include #include +#include #include "fsfw/serviceinterface/ServiceInterface.h" -PapbVcInterface::PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, - gpioId_t papbBusyId, gpioId_t papbEmptyId, std::string uioFile, int mapNum) : - SystemObject(objectId), gpioComIF(gpioComIF), papbBusyId(papbBusyId), papbEmptyId( - papbEmptyId), uioFile(uioFile), mapNum(mapNum) { -} +PapbVcInterface::PapbVcInterface(LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, + gpioId_t papbEmptyId, std::string uioFile, int mapNum) + : gpioComIF(gpioComIF), + papbBusyId(papbBusyId), + papbEmptyId(papbEmptyId), + uioFile(uioFile), + mapNum(mapNum) {} -PapbVcInterface::~PapbVcInterface() { -} +PapbVcInterface::~PapbVcInterface() {} ReturnValue_t PapbVcInterface::initialize() { - UioMapper uioMapper(uioFile, mapNum); - return uioMapper.getMappedAdress(&vcBaseReg, UioMapper::Permissions::WRITE_ONLY); + UioMapper uioMapper(uioFile, mapNum); + return uioMapper.getMappedAdress(&vcBaseReg, UioMapper::Permissions::WRITE_ONLY); } ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) { + if (pollPapbBusySignal() == RETURN_OK) { + startPacketTransfer(); + } + for (size_t idx = 0; idx < size; idx++) { if (pollPapbBusySignal() == RETURN_OK) { - startPacketTransfer(); + *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); + } else { + sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size << " data" + << std::endl; + return RETURN_FAILED; } - for (size_t idx = 0; idx < size; idx++) { - if (pollPapbBusySignal() == RETURN_OK) { - *(vcBaseReg + DATA_REG_OFFSET) = static_cast(*(data + idx)); - } else { - sif::warning << "PapbVcInterface::write: Only written " << idx << " of " << size - << " data" << std::endl; - return RETURN_FAILED; - } - } - if (pollPapbBusySignal() == RETURN_OK) { - endPacketTransfer(); - } - return RETURN_OK; + } + if (pollPapbBusySignal() == RETURN_OK) { + endPacketTransfer(); + } + return RETURN_OK; } -void PapbVcInterface::startPacketTransfer() { - *vcBaseReg = CONFIG_START; -} +void PapbVcInterface::startPacketTransfer() { *vcBaseReg = CONFIG_START; } -void PapbVcInterface::endPacketTransfer() { - *vcBaseReg = CONFIG_END; -} +void PapbVcInterface::endPacketTransfer() { *vcBaseReg = CONFIG_END; } ReturnValue_t PapbVcInterface::pollPapbBusySignal() { - int papbBusyState = 0; - ReturnValue_t result = RETURN_OK; + int papbBusyState = 0; + ReturnValue_t result = RETURN_OK; - /** Check if PAPB interface is ready to receive data */ - result = gpioComIF->readGpio(papbBusyId, &papbBusyState); - if (result != RETURN_OK) { - sif::warning << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" - << std::endl; - return RETURN_FAILED; - } - if (!papbBusyState) { - sif::warning << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; - return PAPB_BUSY; - } + /** Check if PAPB interface is ready to receive data */ + result = gpioComIF->readGpio(papbBusyId, &papbBusyState); + if (result != RETURN_OK) { + sif::warning << "PapbVcInterface::pollPapbBusySignal: Failed to read papb busy signal" + << std::endl; + return RETURN_FAILED; + } + if (!papbBusyState) { + sif::warning << "PapbVcInterface::pollPapbBusySignal: PAPB busy" << std::endl; + return PAPB_BUSY; + } - return RETURN_OK; + return RETURN_OK; } void PapbVcInterface::isVcInterfaceBufferEmpty() { - ReturnValue_t result = RETURN_OK; - int papbEmptyState = 1; + ReturnValue_t result = RETURN_OK; + int papbEmptyState = 1; - result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); + result = gpioComIF->readGpio(papbEmptyId, &papbEmptyState); - if (result != RETURN_OK) { - sif::warning - << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" - << std::endl; - return; - } - - if (papbEmptyState == 1) { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is empty" << std::endl; - } else { - sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is not empty" << std::endl; - } + if (result != RETURN_OK) { + sif::warning << "PapbVcInterface::isVcInterfaceBufferEmpty: Failed to read papb empty signal" + << std::endl; return; + } + + if (papbEmptyState == 1) { + sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is empty" << std::endl; + } else { + sif::debug << "PapbVcInterface::isVcInterfaceBufferEmpty: Buffer is not empty" << std::endl; + } + return; } ReturnValue_t PapbVcInterface::sendTestFrame() { - /** Size of one complete transfer frame data field amounts to 1105 bytes */ - uint8_t testPacket[1105]; + /** Size of one complete transfer frame data field amounts to 1105 bytes */ + uint8_t testPacket[1105]; - /** Fill one test packet */ - for (int idx = 0; idx < 1105; idx++) { - testPacket[idx] = static_cast(idx & 0xFF); - } + /** Fill one test packet */ + for (int idx = 0; idx < 1105; idx++) { + testPacket[idx] = static_cast(idx & 0xFF); + } - ReturnValue_t result = write(testPacket, 1105); - if (result != RETURN_OK) { - return result; - } + ReturnValue_t result = write(testPacket, 1105); + if (result != RETURN_OK) { + return result; + } - return RETURN_OK; + return RETURN_OK; } diff --git a/linux/obc/PapbVcInterface.h b/linux/obc/PapbVcInterface.h index 465d1bf9..d4df659e 100644 --- a/linux/obc/PapbVcInterface.h +++ b/linux/obc/PapbVcInterface.h @@ -3,9 +3,7 @@ #include #include - #include "OBSWConfig.h" -#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/returnvalues/HasReturnvaluesIF.h" #include "linux/obc/VcInterfaceIF.h" @@ -15,12 +13,11 @@ * * @author J. Meier */ -class PapbVcInterface : public SystemObject, public VcInterfaceIF, public HasReturnvaluesIF { +class PapbVcInterface : public VcInterfaceIF, public HasReturnvaluesIF { public: /** * @brief Constructor * - * @param objectId * @param papbBusyId The ID of the GPIO which is connected to the PAPBBusy_N signal of the * VcInterface IP Core. A low logic level indicates the VcInterface is not * ready to receive more data. @@ -30,8 +27,8 @@ class PapbVcInterface : public SystemObject, public VcInterfaceIF, public HasRet * @param uioFile UIO file providing access to the PAPB bus * @param mapNum Map number of UIO map associated with this virtual channel */ - PapbVcInterface(object_id_t objectId, LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, - gpioId_t papbEmptyId, std::string uioFile, int mapNum); + PapbVcInterface(LinuxLibgpioIF* gpioComIF, gpioId_t papbBusyId, gpioId_t papbEmptyId, + std::string uioFile, int mapNum); virtual ~PapbVcInterface(); ReturnValue_t write(const uint8_t* data, size_t size) override; From 102385a70748a9b295eac00b0b14197b9ed5e342 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 18:55:52 +0100 Subject: [PATCH 6/9] introduced axi configuration interface for ptme ip core --- bsp_q7s/core/ObjectFactory.cpp | 3 +- common/config/commonClassIds.h | 1 + fsfw | 2 +- linux/obc/PdecHandler.cpp | 66 +++++----------------------------- linux/obc/PdecHandler.h | 19 ---------- linux/obc/PtmeRateSetter.cpp | 40 +++++++-------------- linux/obc/PtmeRateSetter.h | 38 ++++++++++++-------- linux/obc/TxRateSetterIF.h | 11 +----- mission/tmtc/CCSDSHandler.cpp | 20 ++++++++--- mission/tmtc/CCSDSHandler.h | 7 ++++ tmtc | 2 +- 11 files changed, 73 insertions(+), 136 deletions(-) diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index a25eb290..72627679 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -973,8 +973,7 @@ void ObjectFactory::createCcsdsComponents(LinuxLibgpioIF* gpioComIF) { gpioComIF->addGpios(gpioCookiePdec); new PdecHandler(objects::PDEC_HANDLER, objects::CCSDS_HANDLER, gpioComIF, gpioIds::PDEC_RESET, - std::string(q7s::UIO_PDEC_CONFIG_MEMORY), std::string(q7s::UIO_PDEC_RAM), - std::string(q7s::UIO_PDEC_REGISTERS)); + q7s::UIO_PDEC_CONFIG_MEMORY, q7s::UIO_PDEC_RAM, q7s::UIO_PDEC_REGISTERS); #if BOARD_TE0720 == 0 GpioCookie* gpioRS485Chip = new GpioCookie; diff --git a/common/config/commonClassIds.h b/common/config/commonClassIds.h index cd90272d..ab8e06d5 100644 --- a/common/config/commonClassIds.h +++ b/common/config/commonClassIds.h @@ -24,6 +24,7 @@ enum commonClassIds: uint8_t { PLOC_MEMORY_DUMPER, //PLMEMDUMP PDEC_HANDLER, //PDEC CCSDS_HANDLER, //CCSDS + RATE_SETTER, //RS ARCSEC_JSON_BASE, //JSONBASE NVM_PARAM_BASE, //NVMB COMMON_CLASS_ID_END // [EXPORT] : [END] diff --git a/fsfw b/fsfw index c1e0bcee..faf7da27 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c1e0bcee6db652d6c474c87a4099e61ecf86b694 +Subproject commit faf7da2743dcd30d83c3ab2f7b4d85277878e636 diff --git a/linux/obc/PdecHandler.cpp b/linux/obc/PdecHandler.cpp index a5ee98d6..7dfcfd66 100644 --- a/linux/obc/PdecHandler.cpp +++ b/linux/obc/PdecHandler.cpp @@ -1,16 +1,14 @@ -#include "PdecHandler.h" - #include #include - #include #include - #include "OBSWConfig.h" +#include "PdecHandler.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/tmtcservices/TmTcMessage.h" +#include "fsfw_hal/linux/uio/UioMapper.h" PdecHandler::PdecHandler(object_id_t objectId, object_id_t tcDestinationId, LinuxLibgpioIF* gpioComIF, gpioId_t pdecReset, std::string uioConfigMemory, @@ -44,17 +42,18 @@ ReturnValue_t PdecHandler::initialize() { ReturnValue_t result = RETURN_OK; - result = getRegisterAddress(); + UioMapper regMapper(uioRegisters); + result = regMapper.getMappedAdress(®isterBaseAddress, UioMapper::Permissions::READ_WRITE); if (result != RETURN_OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } - - result = getConfigMemoryBaseAddress(); + UioMapper configMemMapper(uioConfigMemory); + result = configMemMapper.getMappedAdress(&memoryBaseAddress, UioMapper::Permissions::READ_WRITE); if (result != RETURN_OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } - - result = getRamBaseAddress(); + UioMapper ramMapper(uioRamMemory); + result = ramMapper.getMappedAdress(&ramBaseAddress, UioMapper::Permissions::READ_WRITE); if (result != RETURN_OK) { return ObjectManagerIF::CHILD_INIT_FAILED; } @@ -76,55 +75,6 @@ ReturnValue_t PdecHandler::initialize() { MessageQueueId_t PdecHandler::getCommandQueue() const { return commandQueue->getId(); } -ReturnValue_t PdecHandler::getRegisterAddress() { - int fd = open(uioRegisters.c_str(), O_RDWR); - if (fd < 1) { - sif::warning << "PdecHandler::getRegisterAddress: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } - - registerBaseAddress = static_cast( - mmap(NULL, REGISTER_MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)); - - if (registerBaseAddress == MAP_FAILED) { - sif::error << "PdecHandler::getRegisterAddress: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } - - return RETURN_OK; -} - -ReturnValue_t PdecHandler::getConfigMemoryBaseAddress() { - int fd = open(uioConfigMemory.c_str(), O_RDWR); - if (fd < 1) { - sif::warning << "PdecHandler::getConfigMemoryBaseAddress: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } - - memoryBaseAddress = static_cast( - mmap(NULL, CONFIG_MEMORY_MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)); - - if (memoryBaseAddress == MAP_FAILED) { - sif::error << "PdecHandler::getConfigMemoryBaseAddress: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } - - return RETURN_OK; -} - -ReturnValue_t PdecHandler::getRamBaseAddress() { - int fd = open(uioRamMemory.c_str(), O_RDWR); - - ramBaseAddress = - static_cast(mmap(NULL, RAM_MAP_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0)); - - if (ramBaseAddress == MAP_FAILED) { - sif::error << "PdecHandler::getRamBaseAddress: Failed to map RAM base address" << std::endl; - return RETURN_FAILED; - } - return RETURN_OK; -} - void PdecHandler::writePdecConfig() { PdecConfig pdecConfig; diff --git a/linux/obc/PdecHandler.h b/linux/obc/PdecHandler.h index 2125800f..16a9abd4 100644 --- a/linux/obc/PdecHandler.h +++ b/linux/obc/PdecHandler.h @@ -231,25 +231,6 @@ class PdecHandler : public SystemObject, */ void readCommandQueue(void); - /** - * @brief Opens UIO device assigned to AXI to AHB converter giving access to the PDEC - * registers. The register base address will be mapped into the virtual address space. - */ - ReturnValue_t getRegisterAddress(); - - /** - * @brief Opens UIO device assigned to the base address of the PDEC memory space and maps the - * physical address into the virtual address space. - */ - ReturnValue_t getConfigMemoryBaseAddress(); - - /** - * @brief Opens UIO device assigned to the RAM section of the PDEC IP core memory map. - * - * @details A received TC segment will be written to this memory area. - */ - ReturnValue_t getRamBaseAddress(); - /** * @brief This functions writes the configuration parameters to the configuration * section of the PDEC. diff --git a/linux/obc/PtmeRateSetter.cpp b/linux/obc/PtmeRateSetter.cpp index 4a81c361..cace128b 100644 --- a/linux/obc/PtmeRateSetter.cpp +++ b/linux/obc/PtmeRateSetter.cpp @@ -8,34 +8,20 @@ PtmeRateSetter::PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfi PtmeRateSetter::~PtmeRateSetter() {} ReturnValue_t PtmeRateSetter::initialize() { - if (ptmeAxiConfig == nullptr) { - sif::warning << "PtmeRateSetter::initialize: Invalid PtmeAxiConfig object" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; - } - return HasReturnvaluesIF::RETURN_OK; + if (ptmeAxiConfig == nullptr) { + sif::warning << "PtmeRateSetter::initialize: Invalid PtmeAxiConfig object" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t PtmeRateSetter::setRate(BitRates rate) { - uint8_t rateVal = 0; - switch (rate) { - case RATE_2000KBPS: - rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 2000000 - 1); - break; - case RATE_1000KBPS: - rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 1000000 - 1); - break; - case RATE_500KBPS: - rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 500000 - 1); - break; - case RATE_200KBPS: - rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 200000 - 1); - break; - case RATE_100KBPS: - rateVal = static_cast(PtmeConfig::BIT_CLK_FREQ / 100000 - 1); - break; - default: - sif::debug << "PtmeRateSetter::setRate: Unknown bit rate" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; +ReturnValue_t PtmeRateSetter::setRate(uint32_t bitRate) { + if (bitRate == 0) { + return BAD_BIT_RATE; } - return ptmeAxiConfig->writeCaduRateReg(rateVal); + uint32_t rateVal = PtmeConfig::BIT_CLK_FREQ / bitRate - 1; + if (rateVal > 0xFF) { + return RATE_NOT_SUPPORTED; + } + return ptmeAxiConfig->writeCaduRateReg(static_cast(rateVal)); } diff --git a/linux/obc/PtmeRateSetter.h b/linux/obc/PtmeRateSetter.h index 6b9d6c5a..a5b1a8db 100644 --- a/linux/obc/PtmeRateSetter.h +++ b/linux/obc/PtmeRateSetter.h @@ -16,23 +16,33 @@ * * @author J. Meier */ -class PtmeRateSetter: public TxRateSetterIF, public SystemObject { -public: - /** - * @brief Constructor - * - * objectId Object id of system object - * ptmeAxiConfig Pointer to object providing access to PTME configuration registers. - */ - PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfig); - virtual ~PtmeRateSetter(); +class PtmeRateSetter : public TxRateSetterIF, public SystemObject, public HasReturnvaluesIF { + public: + /** + * @brief Constructor + * + * objectId Object id of system object + * ptmeAxiConfig Pointer to object providing access to PTME configuration registers. + */ + PtmeRateSetter(object_id_t objectId, PtmeAxiConfig* ptmeAxiConfig); + virtual ~PtmeRateSetter(); - virtual ReturnValue_t initialize() override; - virtual ReturnValue_t setRate(BitRates rate); + virtual ReturnValue_t initialize() override; + virtual ReturnValue_t setRate(uint32_t bitRate); -private: + private: - PtmeAxiConfig* ptmeAxiConfig = nullptr; + static const uint8_t INTERFACE_ID = CLASS_ID::RATE_SETTER; + + //! [EXPORT] : [COMMENT] The commanded rate is not supported by the current FPGA design + static const ReturnValue_t RATE_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA0); + //! [EXPORT] : [COMMENT] Bad bitrate has been commanded (e.g. 0) + static const ReturnValue_t BAD_BIT_RATE = MAKE_RETURN_CODE(0xA1); + + // Bitrate register field is only 8 bit wide + static const uint32_t MAX_BITRATE = 0xFF; + + PtmeAxiConfig* ptmeAxiConfig = nullptr; }; #endif /* LINUX_OBC_PTMERATESETTER_H_ */ diff --git a/linux/obc/TxRateSetterIF.h b/linux/obc/TxRateSetterIF.h index 6090825f..e8682551 100644 --- a/linux/obc/TxRateSetterIF.h +++ b/linux/obc/TxRateSetterIF.h @@ -3,15 +3,6 @@ #include "fsfw/returnvalues/HasReturnvaluesIF.h" -enum BitRates : uint32_t { - RATE_2000KBPS, - RATE_1000KBPS, - RATE_500KBPS, - RATE_400KBPS, - RATE_200KBPS, - RATE_100KBPS -}; - /** * @brief Abstract class for objects implementing the functionality to switch the * downlink bit rate. @@ -23,7 +14,7 @@ class TxRateSetterIF { TxRateSetterIF(){}; virtual ~TxRateSetterIF(){}; - virtual ReturnValue_t setRate(BitRates bitRate) = 0; + virtual ReturnValue_t setRate(uint32_t bitRate) = 0; }; #endif /* LINUX_OBC_TXRATESETTERIF_H_ */ diff --git a/mission/tmtc/CCSDSHandler.cpp b/mission/tmtc/CCSDSHandler.cpp index 3747b42d..5c7e19ff 100644 --- a/mission/tmtc/CCSDSHandler.cpp +++ b/mission/tmtc/CCSDSHandler.cpp @@ -5,6 +5,7 @@ #include "fsfw/events/EventManagerIF.h" #include "fsfw/ipc/QueueFactory.h" #include "fsfw/objectmanager/ObjectManager.h" +#include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/serviceInterfaceDefintions.h" @@ -189,14 +190,21 @@ MessageQueueId_t CCSDSHandler::getRequestQueue() { ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, size_t size) { + ReturnValue_t result = RETURN_OK; switch (actionId) { case SET_LOW_RATE: { - txRateSetterIF->setRate(BitRates::RATE_100KBPS); - return EXECUTION_FINISHED; + result = txRateSetterIF->setRate(RATE_100KBPS); + break; } case SET_HIGH_RATE: { - txRateSetterIF->setRate(BitRates::RATE_500KBPS); - return EXECUTION_FINISHED; + result = txRateSetterIF->setRate(RATE_500KBPS); + break; + } + case ARBITRARY_RATE: { + uint32_t bitrate = 0; + SerializeAdapter::deSerialize(&bitrate, &data, &size, SerializeIF::Endianness::BIG); + result = txRateSetterIF->setRate(bitrate); + break; } case EN_TRANSMITTER: { enableTransmit(); @@ -209,6 +217,10 @@ ReturnValue_t CCSDSHandler::executeAction(ActionId_t actionId, MessageQueueId_t default: return COMMAND_NOT_IMPLEMENTED; } + if (result != RETURN_OK) { + return result; + } + return EXECUTION_FINISHED; } void CCSDSHandler::checkEvents() { diff --git a/mission/tmtc/CCSDSHandler.h b/mission/tmtc/CCSDSHandler.h index aedeccff..d2782630 100644 --- a/mission/tmtc/CCSDSHandler.h +++ b/mission/tmtc/CCSDSHandler.h @@ -88,6 +88,13 @@ class CCSDSHandler : public SystemObject, static const ActionId_t SET_HIGH_RATE = 1; static const ActionId_t EN_TRANSMITTER = 2; static const ActionId_t DIS_TRANSMITTER = 3; + static const ActionId_t ARBITRARY_RATE = 4; + + // Syrlinks supports two bitrates (200 kbps and 1000 kbps) + // Due to convolutional code added by the syrlinks the input frequency must be half the + // target frequency + static const uint32_t RATE_100KBPS = 100000; + static const uint32_t RATE_500KBPS = 500000; //! [EXPORT] : [COMMENT] Received action message with unknown action id static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xA0); diff --git a/tmtc b/tmtc index 580ac8b2..598635ee 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 580ac8b2d7e73aa860f3de55066187d7684d2d64 +Subproject commit 598635ee4fb1eb246980564ae9f3a0feb1f4da30 From 03707f2d6af817bc84c6b4efb5be3c8bd8ab77dd Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 19:05:42 +0100 Subject: [PATCH 7/9] removed unsued code --- linux/obc/Ptme.cpp | 19 ------------------- linux/obc/Ptme.h | 8 -------- 2 files changed, 27 deletions(-) diff --git a/linux/obc/Ptme.cpp b/linux/obc/Ptme.cpp index 3c3403e0..8258fea0 100644 --- a/linux/obc/Ptme.cpp +++ b/linux/obc/Ptme.cpp @@ -10,29 +10,10 @@ Ptme::Ptme(object_id_t objectId) : SystemObject(objectId) {} Ptme::~Ptme() {} ReturnValue_t Ptme::initialize() { - int fd = open(PtmeConfig::UIO_DEVICE_FILE, O_RDWR); - if (fd < 1) { - sif::warning << "Ptme::initialize: Invalid UIO device file" << std::endl; - return RETURN_FAILED; - } - - /** - * Map uio device in virtual address space - * PROT_WRITE: Map uio device in writable only mode - */ - ptmeBaseAddress = static_cast(mmap(NULL, MAP_SIZE, PROT_WRITE, MAP_SHARED, fd, - 0 * getpagesize())); - - if (ptmeBaseAddress == MAP_FAILED) { - sif::error << "Ptme::initialize: Failed to map uio address" << std::endl; - return RETURN_FAILED; - } - VcInterfaceMapIter iter; for (iter = vcInterfaceMap.begin(); iter != vcInterfaceMap.end(); iter++) { iter->second->initialize(); } - return RETURN_OK; } diff --git a/linux/obc/Ptme.h b/linux/obc/Ptme.h index 4e4e6862..cdb2d6c6 100644 --- a/linux/obc/Ptme.h +++ b/linux/obc/Ptme.h @@ -44,14 +44,6 @@ class Ptme : public PtmeIF, public SystemObject, public HasReturnvaluesIF { static const ReturnValue_t UNKNOWN_VC_ID = MAKE_RETURN_CODE(0xA0); -#if BOARD_TE0720 == 1 - /** Size of mapped address space */ - static const int MAP_SIZE = 0x40000; -#else - /** Size of mapped address space */ - static const int MAP_SIZE = 0x1000; -#endif /* BOARD_TE0720 == 1 */ - /** * Configuration bits: * bit[1:0]: Size of data (1,2,3 or 4 bytes). 1 Byte <=> b00 From 8ad2114d4bc1b899a40fdb5074c575eba183f3b9 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 19:07:48 +0100 Subject: [PATCH 8/9] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index faf7da27..73608783 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit faf7da2743dcd30d83c3ab2f7b4d85277878e636 +Subproject commit 7360878390004a5749362775206902e95bf721aa From 90b65d4d8aecd1ea4d68d558ef19ec0658ef75e9 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 25 Jan 2022 19:47:34 +0100 Subject: [PATCH 9/9] update fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 73608783..faf7da27 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 7360878390004a5749362775206902e95bf721aa +Subproject commit faf7da2743dcd30d83c3ab2f7b4d85277878e636