From 8509e15736096e3c58faaeb8a17f331f9b32a20c Mon Sep 17 00:00:00 2001 From: "Jakob.Meier" Date: Thu, 29 Apr 2021 17:45:19 +0200 Subject: [PATCH] integrated gyro and mgm handler --- bsp_q7s/InitMission.cpp | 2 +- bsp_q7s/ObjectFactory.cpp | 32 ++++++-- bsp_q7s/boardconfig/q7s_config.h | 2 +- fsfwconfig/OBSWConfig.h | 2 +- .../pollingSequenceFactory.cpp | 78 ++++++++++++------- .../MGMHandlerRM3100Definitions.h | 4 +- tmtc | 2 +- 7 files changed, 82 insertions(+), 40 deletions(-) diff --git a/bsp_q7s/InitMission.cpp b/bsp_q7s/InitMission.cpp index e5d33fdc..a8ba7d1d 100644 --- a/bsp_q7s/InitMission.cpp +++ b/bsp_q7s/InitMission.cpp @@ -151,7 +151,7 @@ void initmission::initTasks() { FixedTimeslotTaskIF* gomSpacePstTask = factory-> createFixedTimeslotTask("GS_PST_TASK", 50, - PeriodicTaskIF::MINIMUM_STACK_SIZE*8, 3.0, missedDeadlineFunc); + PeriodicTaskIF::MINIMUM_STACK_SIZE*8, 1.0, missedDeadlineFunc); result = pst::gomspacePstInit(gomSpacePstTask); if(result != HasReturnvaluesIF::RETURN_OK) { sif::error << "InitMission::initTasks: GomSpace PST initialization failed!" << std::endl; diff --git a/bsp_q7s/ObjectFactory.cpp b/bsp_q7s/ObjectFactory.cpp index 0815b81d..77148be8 100644 --- a/bsp_q7s/ObjectFactory.cpp +++ b/bsp_q7s/ObjectFactory.cpp @@ -107,11 +107,11 @@ void ObjectFactory::produce(){ Tmp1075Handler* tmp1075Handler_1 = new Tmp1075Handler( objects::TMP1075_HANDLER_1, objects::I2C_COM_IF, i2cCookieTmp1075tcs1); - tmp1075Handler_1->setStartUpImmediately(); +// tmp1075Handler_1->setStartUpImmediately(); Tmp1075Handler* tmp1075Handler_2 = new Tmp1075Handler( objects::TMP1075_HANDLER_2, objects::I2C_COM_IF, i2cCookieTmp1075tcs2); - tmp1075Handler_2->setStartUpImmediately(); +// tmp1075Handler_2->setStartUpImmediately(); GpioCookie* heaterGpiosCookie = new GpioCookie; @@ -152,13 +152,13 @@ void ObjectFactory::produce(){ #if OBSW_ADD_ACS_BOARD == 1 GpioCookie* gpioCookieAcsBoard = new GpioCookie(); GpiodRegular* gpio = nullptr; - gpio = new GpiodRegular(std::string("gpiochip5"), 1, std::string("CS_GYRO_1_ADIS"), + gpio = new GpiodRegular(std::string("gpiochip5"), 1, std::string("CS_GYRO_0_ADIS"), gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - gpio = new GpiodRegular(std::string("gpiochip5"), 7, std::string("CS_GYRO_2_L3G"), + gpio = new GpiodRegular(std::string("gpiochip5"), 7, std::string("CS_GYRO_1_L3G"), gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - gpio = new GpiodRegular(std::string("gpiochip5"), 3, std::string("CS_GYRO_3_L3G"), + gpio = new GpiodRegular(std::string("gpiochip5"), 3, std::string("CS_GYRO_2_L3G"), gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_L3G_CS, gpio); @@ -166,7 +166,7 @@ void ObjectFactory::produce(){ gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - gpio = new GpiodRegular(std::string("gpiochip5"), 17, std::string("CS_MGM_1_RM3100_A"), + gpio = new GpiodRegular(std::string("gpiochip5"), 16, std::string("CS_MGM_1_RM3100_A"), gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); @@ -199,11 +199,27 @@ void ObjectFactory::produce(){ objects::SPI_COM_IF, spiCookie); mgmRm3100Handler->setStartUpImmediately(); + spiCookie = new SpiCookie(addresses::MGM_3_RM3100, gpioIds::MGM_3_RM3100_CS, spiDev, + RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); + mgmRm3100Handler = new MGMHandlerRM3100(objects::MGM_3_RM3100_HANDLER, + objects::SPI_COM_IF, spiCookie); + mgmRm3100Handler->setStartUpImmediately(); + + //TODO: Adis Gyro (Gyro 0 Side A) + + /* Gyro 1 Side A */ spiCookie = new SpiCookie(addresses::GYRO_1_L3G, gpioIds::GYRO_1_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); auto gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_1_L3G_HANDLER, objects::SPI_COM_IF, spiCookie); gyroL3gHandler->setStartUpImmediately(); + + /* Gyro 2 Side B */ + spiCookie = new SpiCookie(addresses::GYRO_2_L3G, gpioIds::GYRO_2_L3G_CS, spiDev, + L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); + gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_2_L3G_HANDLER, objects::SPI_COM_IF, + spiCookie); + gyroL3gHandler->setStartUpImmediately(); #endif /* Pin H2-11 on stack connector */ @@ -411,13 +427,13 @@ void ObjectFactory::produce(){ I2cCookie* imtqI2cCookie = new I2cCookie(addresses::IMTQ, IMTQ::MAX_REPLY_SIZE, std::string("/dev/i2c-0")); IMTQHandler* imtqHandler = new IMTQHandler(objects::IMTQ_HANDLER, objects::I2C_COM_IF, imtqI2cCookie); - imtqHandler->setStartUpImmediately(); +// imtqHandler->setStartUpImmediately(); UartCookie* plocUartCookie = new UartCookie(std::string("/dev/ttyUL3"), 115200, PLOC::MAX_REPLY_SIZE); PlocHandler* plocHandler = new PlocHandler(objects::PLOC_HANDLER, objects::UART_COM_IF, plocUartCookie); - plocHandler->setStartUpImmediately(); +// plocHandler->setStartUpImmediately(); #endif /* TE0720 == 0 */ diff --git a/bsp_q7s/boardconfig/q7s_config.h b/bsp_q7s/boardconfig/q7s_config.h index 782ecf4f..3d1bc8ad 100644 --- a/bsp_q7s/boardconfig/q7s_config.h +++ b/bsp_q7s/boardconfig/q7s_config.h @@ -5,7 +5,7 @@ /* Only one of those 2 should be enabled! */ /* Add code for ACS board */ -#define OBSW_ADD_ACS_BOARD 0 +#define OBSW_ADD_ACS_BOARD 1 #define Q7S_ADD_SPI_TEST 0 diff --git a/fsfwconfig/OBSWConfig.h b/fsfwconfig/OBSWConfig.h index c1a6c313..0b9320e1 100644 --- a/fsfwconfig/OBSWConfig.h +++ b/fsfwconfig/OBSWConfig.h @@ -21,7 +21,7 @@ debugging. */ #define OBSW_ADD_TEST_CODE 1 #define TEST_LIBGPIOD 0 -#define TE0720 1 +#define TE0720 0 #define TE0720_HEATER_TEST 0 #define P60DOCK_DEBUG 0 diff --git a/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index fe728b12..01f47b39 100644 --- a/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -212,7 +212,7 @@ ReturnValue_t pst::gomspacePstInit(FixedTimeslotTaskIF *thisSequence){ // DeviceHandlerIF::SEND_READ); // thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.8, // DeviceHandlerIF::GET_READ); -// + // thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, // DeviceHandlerIF::PERFORM_OPERATION); // thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.2, @@ -224,27 +224,53 @@ ReturnValue_t pst::gomspacePstInit(FixedTimeslotTaskIF *thisSequence){ // thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.8, // DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); +// thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0, +// DeviceHandlerIF::PERFORM_OPERATION); +// thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.2, +// DeviceHandlerIF::SEND_WRITE); +// thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.4, +// DeviceHandlerIF::GET_WRITE); +// thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.6, +// DeviceHandlerIF::SEND_READ); +// thisSequence->addSlot(objects::MGM_2_LIS3_HANDLER, length * 0.8, +// DeviceHandlerIF::GET_READ); +// +// +// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, +// DeviceHandlerIF::PERFORM_OPERATION); +// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.2, +// DeviceHandlerIF::SEND_WRITE); +// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.4, +// DeviceHandlerIF::GET_WRITE); +// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, +// DeviceHandlerIF::SEND_READ); +// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.8, +// DeviceHandlerIF::GET_READ); -// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, + +// thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0, // DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.2, +// thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.2, // DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.4, +// thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.4, // DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, +// thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.6, // DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.8, +// thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.8, // DeviceHandlerIF::GET_READ); + + + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); + #endif if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { @@ -268,16 +294,16 @@ ReturnValue_t pst::pollingSequenceAcsTest(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); +// thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0, +// DeviceHandlerIF::PERFORM_OPERATION); +// thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.2, +// DeviceHandlerIF::SEND_WRITE); +// thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.4, +// DeviceHandlerIF::GET_WRITE); +// thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.6, +// DeviceHandlerIF::SEND_READ); +// thisSequence->addSlot(objects::MGM_1_RM3100_HANDLER, length * 0.8, +// DeviceHandlerIF::GET_READ); thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); diff --git a/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h b/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h index 2856c170..08f80dd9 100644 --- a/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h +++ b/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h @@ -12,7 +12,7 @@ namespace RM3100 { /* Actually 10, we round up a little bit */ static constexpr size_t MAX_BUFFER_SIZE = 12; -static constexpr uint8_t READ_MASK = 0b1000'0000; +static constexpr uint8_t READ_MASK = 0x80; /*----------------------------------------------------------------------------*/ /* CMM Register */ @@ -45,7 +45,7 @@ static constexpr uint8_t TMRC_75HZ_VALUE = 0x95; static constexpr uint8_t TMRC_DEFAULT_37HZ_VALUE = 0x96; static constexpr uint8_t TMRC_REGISTER = 0x0B; -static constexpr uint8_t TMRC_DEFAULT_VALUE = TMRC_75HZ_VALUE; +static constexpr uint8_t TMRC_DEFAULT_VALUE = TMRC_DEFAULT_37HZ_VALUE; static constexpr uint8_t MEASUREMENT_REG_START = 0x24; static constexpr uint8_t BIST_REGISTER = 0x33; diff --git a/tmtc b/tmtc index e23bc116..06750809 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit e23bc116088fc673aaec45768c7a07c20d75a2f6 +Subproject commit 06750809cb52044392e0683896538a652f11a512