From 9dff2e14790671797d46b1f44b66a97aab17fd42 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 11 Sep 2021 17:40:13 +0200 Subject: [PATCH 01/16] enable periodci reply now --- fsfw | 2 +- mission/devices/GPSHyperionHandler.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 40adca5f..c9bfc846 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 40adca5f1d13ef8d6c712842ebc37e37fe449446 +Subproject commit c9bfc8464aede0f79c167e18c5c0c79ded2444ce diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 80331c58..fe50d292 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -23,6 +23,7 @@ GPSHyperionHandler::~GPSHyperionHandler() {} void GPSHyperionHandler::doStartUp() { if(internalState == InternalStates::NONE) { commandExecuted = false; + enablePeriodicReply(GpsHyperion::GPS_REPLY); internalState = InternalStates::WAIT_FIRST_MESSAGE; } From 9f389fb9204ca95202334ecdee9627665d478d7d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Sep 2021 10:25:58 +0200 Subject: [PATCH 02/16] added newline --- mission/devices/GPSHyperionHandler.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 80331c58..b7790c76 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -144,6 +144,7 @@ ReturnValue_t GPSHyperionHandler::scanForReply(const uint8_t *start, size_t len, gpsFile.open(filename, std::ofstream::out); } gpsFile.open(filename, std::ofstream::out | std::ofstream::app); + gpsFile.write("\n", 1); gpsFile.write(reinterpret_cast(start), len); #endif } From 63ec5d6338d521674742096e1b642b956c44fd2e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Sep 2021 10:26:20 +0200 Subject: [PATCH 03/16] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index c9bfc846..40adca5f 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit c9bfc8464aede0f79c167e18c5c0c79ded2444ce +Subproject commit 40adca5f1d13ef8d6c712842ebc37e37fe449446 From c67a7ef1d842387ccf896ff22082b5e117a88f7f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Sep 2021 11:48:11 +0200 Subject: [PATCH 04/16] added more package pin comments --- bsp_q7s/boardconfig/busConf.h | 22 +++++++++++-------- fsfw | 2 +- .../pollingSequenceFactory.cpp | 20 ++++++++--------- mission/devices/GPSHyperionHandler.cpp | 2 +- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 74c91708..ba4eda03 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -33,17 +33,21 @@ static const char* const GPIO_RW_DEFAULT_CHIP = GPIO_FLEX_OBC1F_B0; static const char* const GPIO_RAD_SENSOR_CHIP = GPIO_FLEX_OBC1F_B0; static constexpr uint32_t GPIO_RW_0_CS = 7; // B20 -static constexpr uint32_t GPIO_RW_1_CS = 3; -static constexpr uint32_t GPIO_RW_2_CS = 11; -static constexpr uint32_t GPIO_RW_3_CS = 6; +static constexpr uint32_t GPIO_RW_1_CS = 3; // G22 +static constexpr uint32_t GPIO_RW_2_CS = 11; // E18 +static constexpr uint32_t GPIO_RW_3_CS = 6; // B19 -static constexpr uint32_t GPIO_GYRO_1_L3G_CS = 18; -static constexpr uint32_t GPIO_GYRO_3_L3G_CS = 1; -static constexpr uint32_t GPIO_MGM_0_LIS3_CS = 5; -static constexpr uint32_t GPIO_MGM_1_RM3100_CS = 16; +static constexpr uint32_t GPIO_GYRO_1_L3G_CS = 18; // N22 +static constexpr uint32_t GPIO_GYRO_3_L3G_CS = 1; // M21 +static constexpr uint32_t GPIO_MGM_0_LIS3_CS = 5; // C18 +// MGM_2 is part of gpiochip6 +static constexpr uint32_t GPIO_MGM_1_RM3100_CS = 16; // A16 +static constexpr uint32_t GPIO_MGM_3_RM3100_CS = 10; // C17 -static constexpr uint32_t GPIO_MGM_3_RM3100_CS = 10; -// Active low reset pin +// Active low enable pin (needs to be driven low for regular operations) +static constexpr uint32_t GPIO_GYRO_0_ENABLE = 2; // H22 + +// Active low reset pin (needs to be driven high for regular operations) static constexpr uint32_t GPIO_RESET_GNSS_0 = 9; // C22 static constexpr uint32_t GPIO_RESET_GNSS_1 = 12; // B21 diff --git a/fsfw b/fsfw index 40adca5f..97494a84 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 40adca5f1d13ef8d6c712842ebc37e37fe449446 +Subproject commit 97494a84dfd0acb9dc32770ae9d142f80d4bbcfa diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 9eb1bd12..5f7bfd35 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -436,16 +436,16 @@ ReturnValue_t pst::pstSpi(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::MGM_2_LIS3_HANDLER, length * 0, // DeviceHandlerIF::PERFORM_OPERATION); diff --git a/mission/devices/GPSHyperionHandler.cpp b/mission/devices/GPSHyperionHandler.cpp index 3149a051..5e44f89c 100644 --- a/mission/devices/GPSHyperionHandler.cpp +++ b/mission/devices/GPSHyperionHandler.cpp @@ -23,7 +23,7 @@ GPSHyperionHandler::~GPSHyperionHandler() {} void GPSHyperionHandler::doStartUp() { if(internalState == InternalStates::NONE) { commandExecuted = false; - enablePeriodicReply(GpsHyperion::GPS_REPLY); + updatePeriodicReply(true, GpsHyperion::GPS_REPLY); internalState = InternalStates::WAIT_FIRST_MESSAGE; } From 3354f2a69649355e963a853f9233515a56e90c32 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Sep 2021 18:07:07 +0200 Subject: [PATCH 05/16] acd board tests continued --- .../fsfwconfig/devices/powerSwitcherList.h | 4 +- bsp_q7s/boardconfig/busConf.h | 3 +- bsp_q7s/core/InitMission.cpp | 4 +- bsp_q7s/core/ObjectFactory.cpp | 23 ++++--- bsp_q7s/core/ObjectFactory.h | 2 +- linux/boardtest/SpiTestClass.cpp | 68 +++++++++---------- linux/boardtest/SpiTestClass.h | 22 +++--- linux/fsfwconfig/devices/gpioIds.h | 3 + linux/fsfwconfig/devices/powerSwitcherList.h | 4 +- mission/devices/MGMHandlerRM3100.cpp | 30 ++++---- mission/devices/MGMHandlerRM3100.h | 7 +- mission/devices/PCDUHandler.cpp | 4 +- tmtc | 2 +- 13 files changed, 99 insertions(+), 77 deletions(-) diff --git a/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h b/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h index cacd23a1..c216c828 100644 --- a/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h +++ b/bsp_hosted/fsfwconfig/devices/powerSwitcherList.h @@ -5,7 +5,7 @@ namespace pcduSwitches { /* Switches are uint8_t datatype and go from 0 to 255 */ - enum switcherList { + enum SwitcherList { Q7S, PAYLOAD_PCDU_CH1, RW, @@ -22,7 +22,7 @@ namespace pcduSwitches { SUS_NOMINAL, SOLAR_CELL_EXP, PLOC, - ACS_BORAD_SIDE_A, + ACS_BOARD_SIDE_A, NUMBER_OF_SWITCHES }; diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index ba4eda03..491930db 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -58,7 +58,7 @@ static constexpr uint32_t GPIO_RAD_SENSOR_CS = 19; // R18 /**************************************************************/ static constexpr char GPIO_FLEX_OBC1F_B1[] = "gpiochip6"; static const char* const GPIO_MGM2_LIS3_CHIP = GPIO_FLEX_OBC1F_B1; -static constexpr uint32_t GPIO_MGM_2_LIS3_CS = 0; +static constexpr uint32_t GPIO_MGM_2_LIS3_CS = 0; // D18 /**************************************************************/ /** OBC1C */ @@ -74,6 +74,7 @@ static constexpr uint32_t GPIO_HEATER_4_PIN = 3; static constexpr uint32_t GPIO_HEATER_5_PIN = 0; static constexpr uint32_t GPIO_HEATER_6_PIN = 1; static constexpr uint32_t GPIO_HEATER_7_PIN = 11; +static constexpr uint32_t GPIO_GYRO_2_ENABLE = 18; // F22 static constexpr uint32_t GPIO_SOL_DEPL_SA_0_PIN = 4; static constexpr uint32_t GPIO_SOL_DEPL_SA_1_PIN = 2; diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 1b5f10fd..49e9d8ca 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -121,7 +121,7 @@ void initmission::initTasks() { std::vector pstTasks; createPstTasks(*factory, missedDeadlineFunc, pstTasks); -#if OBSW_ADD_TEST_TASK == 1 +#if OBSW_ADD_TEST_CODE == 1 std::vector testTasks; createTestTasks(*factory, missedDeadlineFunc, testTasks); #endif @@ -147,7 +147,7 @@ void initmission::initTasks() { taskStarter(pstTasks, "PST task vector"); taskStarter(pusTasks, "PUS task vector"); -#if OBSW_ADD_TEST_TASK == 1 +#if OBSW_ADD_TEST_CODE == 1 taskStarter(testTasks, "Test task vector"); #endif diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index 8fcbfa52..e529fe09 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -97,6 +97,8 @@ void Factory::setStaticFrameworkObjectIds() { CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; + //DeviceHandlerBase::powerSwitcherId = objects::PCDU_HANDLER; + DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT; TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; // No storage object for now. TmFunnel::storageDestination = objects::NO_OBJECT; @@ -121,6 +123,7 @@ void ObjectFactory::produce(void* args){ createPcduComponents(); createRadSensorComponent(gpioComIF); createSunSensorComponents(gpioComIF, spiComIF); + #if OBSW_ADD_ACS_BOARD == 1 createAcsBoardComponents(gpioComIF, uartComIF); #endif /* OBSW_ADD_ACS_BOARD == 1 */ @@ -183,7 +186,7 @@ void ObjectFactory::produce(void* args){ /* Test Task */ #if OBSW_ADD_TEST_CODE == 1 - createTestComponents(); + createTestComponents(gpioComIF); #endif /* OBSW_ADD_TEST_CODE == 1 */ new PlocUpdater(objects::PLOC_UPDATER); @@ -431,10 +434,15 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI "GNSS_1_NRESET", gpio::OUT, gpio::HIGH); gpioCookieAcsBoard->addGpio(gpioIds::GNSS_1_NRESET, gpio); + // Enable pins must be pulled low for regular operations + gpio = new GpiodRegular(q7s::GPIO_FLEX_OBC1F_B0, q7s::GPIO_GYRO_0_ENABLE, + "GYRO_0_ENABLE", gpio::OUT, gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_0_ENABLE, gpio); + gpio = new GpiodRegular(q7s::GPIO_3V3_OBC1C, q7s::GPIO_GYRO_2_ENABLE, + "GYRO_2_ENABLE", gpio::OUT, gpio::LOW); + gpioCookieAcsBoard->addGpio(gpioIds::GYRO_2_ENABLE, gpio); - - // GNSS enable pins must be pulled high - + // TODO: Add enable pins for GPS as soon as new interface board design is finished gpioComIF->addGpios(gpioCookieAcsBoard); std::string spiDev = q7s::SPI_DEFAULT_DEV; @@ -447,7 +455,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); auto mgmRm3100Handler = new MGMHandlerRM3100(objects::MGM_1_RM3100_HANDLER, - objects::SPI_COM_IF, spiCookie); + objects::SPI_COM_IF, spiCookie, pcduSwitches::SwitcherList::ACS_BOARD_SIDE_A); mgmRm3100Handler->setStartUpImmediately(); spiCookie = new SpiCookie(addresses::MGM_2_LIS3, gpioIds::MGM_2_LIS3_CS, spiDev, @@ -459,10 +467,9 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI 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); + objects::SPI_COM_IF, spiCookie, pcduSwitches::SwitcherList::ACS_BOARD_SIDE_B); mgmRm3100Handler->setStartUpImmediately(); - // Commented until ACS board V2 in in clean room again // Gyro 0 Side A spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, @@ -806,7 +813,7 @@ void ObjectFactory::createReactionWheelComponents(LinuxLibgpioIF* gpioComIF) { rw4SpiCookie->setCallbackArgs(rwHandler4); } -void ObjectFactory::createTestComponents() { +void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { #if BOARD_TE0720 == 0 new Q7STestTask(objects::TEST_TASK); diff --git a/bsp_q7s/core/ObjectFactory.h b/bsp_q7s/core/ObjectFactory.h index 0e7ff9ff..ad9533a5 100644 --- a/bsp_q7s/core/ObjectFactory.h +++ b/bsp_q7s/core/ObjectFactory.h @@ -22,7 +22,7 @@ void createSolarArrayDeploymentComponents(); void createSyrlinksComponents(); void createRtdComponents(LinuxLibgpioIF* gpioComIF); void createReactionWheelComponents(LinuxLibgpioIF* gpioComIF); -void createTestComponents(); +void createTestComponents(LinuxLibgpioIF* gpioComIF); }; diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index 730a1743..ee08bc41 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -1,5 +1,4 @@ #include "SpiTestClass.h" -#include "OBSWConfig.h" #include "devices/gpioIds.h" @@ -20,7 +19,6 @@ #include #include - SpiTestClass::SpiTestClass(object_id_t objectId, GpioIF* gpioIF): TestTask(objectId), gpioIF(gpioIF) { if(gpioIF == nullptr) { @@ -37,11 +35,11 @@ ReturnValue_t SpiTestClass::performOneShotAction() { break; } case(TestModes::MGM_LIS3MDL): { - performLis3MdlTest(mgm2Lis3mdlChipSelect); + performLis3MdlTest(mgm0Lis3mdlChipSelect); break; } case(TestModes::MGM_RM3100): { - performRm3100Test(mgm3Rm3100ChipSelect); + performRm3100Test(mgm1Rm3100ChipSelect); break; } case(TestModes::GYRO_L3GD20H): { @@ -150,10 +148,10 @@ void SpiTestClass::performRm3100Test(uint8_t mgmId) { float fieldStrengthY = rawY * scaleFactor; float fieldStrengthZ = rawZ * scaleFactor; - sif::info << "RM3100 measured field strenghts in microtesla:" << std::endl; - sif::info << "Field Strength X: " << fieldStrengthX << " \xC2\xB5T" << std::endl; - sif::info << "Field Strength Y: " << fieldStrengthY << " \xC2\xB5T" << std::endl; - sif::info << "Field Strength Z: " << fieldStrengthZ << " \xC2\xB5T" << std::endl; + sif::info << "RM3100 measured field strengths in microtesla:" << std::endl; + sif::info << "Field Strength X: " << fieldStrengthX << " uT" << std::endl; + sif::info << "Field Strength Y: " << fieldStrengthY << " uT" << std::endl; + sif::info << "Field Strength Z: " << fieldStrengthZ << " uT" << std::endl; } void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) { @@ -174,8 +172,8 @@ void SpiTestClass::performLis3MdlTest(uint8_t lis3Id) { else { currentGpioId = gpioIds::MGM_2_LIS3_CS; } - uint32_t spiSpeed = 3'900'000; - spi::SpiModes spiMode = spi::SpiModes::MODE_3; + uint32_t spiSpeed = 10'000'000; + spi::SpiModes spiMode = spi::SpiModes::MODE_0; #ifdef RASPBERRY_PI std::string deviceName = "/dev/spidev0.0"; #else @@ -208,10 +206,10 @@ void SpiTestClass::performL3gTest(uint8_t l3gId) { /* Configure all SPI chip selects and pull them high */ acsInit(); - l3gId = gyro2L3gd20ChipSelect; + l3gId = gyro3L3gd20ChipSelect; /* Adapt accordingly */ - if(l3gId != gyro1L3gd20ChipSelect and l3gId != gyro2L3gd20ChipSelect) { + if(l3gId != gyro1L3gd20ChipSelect and l3gId != gyro3L3gd20ChipSelect) { sif::warning << "SpiTestClass::performLis3MdlTest: Invalid MGM ID!" << std::endl; } gpioId_t currentGpioId = 0; @@ -331,36 +329,32 @@ void SpiTestClass::acsInit() { gpio::Direction::OUT, 1); gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); #elif defined(XIPHOS_Q7S) - std::string q7sGpioName5 = "gpiochip5"; - std::string q7sGpioName6 = "gpiochip6"; - gpio = new GpiodRegular(q7sGpioName5, mgm0Lis3mdlChipSelect, "MGM_0_LIS3", - gpio::Direction::OUT, gpio::HIGH); + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, mgm0Lis3mdlChipSelect, + "MGM_0_LIS3", gpio::Direction::OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_0_LIS3_CS, gpio); - - gpio = new GpiodRegular(q7sGpioName5, mgm1Rm3100ChipSelect, "MGM_1_RM3100", - gpio::Direction::OUT, gpio::HIGH); + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, mgm1Rm3100ChipSelect, + "MGM_1_RM3100", gpio::Direction::OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_1_RM3100_CS, gpio); - - gpio = new GpiodRegular(q7sGpioName5, gyro0AdisChipSelect, "GYRO_0_ADIS", - gpio::Direction::OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); - - gpio = new GpiodRegular(q7sGpioName5, gyro1L3gd20ChipSelect, "GYRO_1_L3G", - gpio::Direction::OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); - - gpio = new GpiodRegular(q7sGpioName5, gyro2L3gd20ChipSelect, "GYRO_2_L3G", - gpio::Direction::OUT, gpio::HIGH); - gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); - - gpio = new GpiodRegular(q7sGpioName6, mgm2Lis3mdlChipSelect, "MGM_2_LIS3", - gpio::Direction::OUT, gpio::HIGH); + gpio = new GpiodRegular(q7s::GPIO_MGM2_LIS3_CHIP, mgm2Lis3mdlChipSelect, + "MGM_2_LIS3", gpio::Direction::OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_2_LIS3_CS, gpio); - - gpio = new GpiodRegular(q7sGpioName5, mgm3Rm3100ChipSelect, "MGM_3_RM3100", - gpio::Direction::OUT, gpio::HIGH); + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, mgm3Rm3100ChipSelect, + "MGM_3_RM3100", gpio::Direction::OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::MGM_3_RM3100_CS, gpio); + + gpio = new GpiodRegular(q7s::GPIO_GYRO_ADIS_CHIP, gyro0AdisChipSelect, + "GYRO_0_ADIS", gpio::Direction::OUT, gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_0_ADIS_CS, gpio); + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, gyro1L3gd20ChipSelect, + "GYRO_1_L3G", gpio::Direction::OUT, gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_1_L3G_CS, gpio); + gpio = new GpiodRegular(q7s::GPIO_GYRO_ADIS_CHIP, gyro2AdisChipSelect, + "GYRO_2_ADIS", gpio::Direction::OUT, gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_2_ADIS_CS, gpio); + gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, gyro3L3gd20ChipSelect, + "GYRO_3_L3G", gpio::Direction::OUT, gpio::HIGH); + gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); #endif if(gpioIF != nullptr) { gpioIF->addGpios(gpioCookie); diff --git a/linux/boardtest/SpiTestClass.h b/linux/boardtest/SpiTestClass.h index dd112a0e..d5309a1e 100644 --- a/linux/boardtest/SpiTestClass.h +++ b/linux/boardtest/SpiTestClass.h @@ -1,6 +1,12 @@ #ifndef LINUX_BOARDTEST_SPITESTCLASS_H_ #define LINUX_BOARDTEST_SPITESTCLASS_H_ +#include "OBSWConfig.h" + +#if defined(XIPHOS_Q7S) +#include "busConf.h" +#endif + #include #include #include @@ -47,14 +53,14 @@ private: uint8_t mgm2Lis3mdlChipSelect = 17; uint8_t mgm3Rm3100ChipSelect = 27; #elif defined(XIPHOS_Q7S) - uint8_t mgm0Lis3mdlChipSelect = 5; - uint8_t mgm1Rm3100ChipSelect = 17; - uint8_t gyro0AdisResetLine = 20; - uint8_t gyro0AdisChipSelect = 21; - uint8_t gyro1L3gd20ChipSelect = 10; - uint8_t gyro2L3gd20ChipSelect = 3; - uint8_t mgm2Lis3mdlChipSelect = 0; - uint8_t mgm3Rm3100ChipSelect = 23; + uint8_t mgm0Lis3mdlChipSelect = q7s::GPIO_MGM_0_LIS3_CS; + uint8_t mgm1Rm3100ChipSelect = q7s::GPIO_MGM_1_RM3100_CS; + uint8_t gyro0AdisChipSelect = q7s::GPIO_GYRO_0_ADIS_CS; + uint8_t gyro2AdisChipSelect = q7s::GPIO_GYRO_2_ADIS_CS; + uint8_t gyro1L3gd20ChipSelect = q7s::GPIO_GYRO_1_L3G_CS; + uint8_t gyro3L3gd20ChipSelect = q7s::GPIO_GYRO_3_L3G_CS; + uint8_t mgm2Lis3mdlChipSelect = q7s::GPIO_MGM_2_LIS3_CS; + uint8_t mgm3Rm3100ChipSelect = q7s::GPIO_MGM_3_RM3100_CS; #else uint8_t mgm0Lis3mdlChipSelect = 0; uint8_t mgm1Rm3100ChipSelect = 0; diff --git a/linux/fsfwconfig/devices/gpioIds.h b/linux/fsfwconfig/devices/gpioIds.h index e8709f2e..b450bf8b 100644 --- a/linux/fsfwconfig/devices/gpioIds.h +++ b/linux/fsfwconfig/devices/gpioIds.h @@ -28,6 +28,9 @@ enum gpioId_t { GNSS_0_NRESET, GNSS_1_NRESET, + GYRO_0_ENABLE, + GYRO_2_ENABLE, + TEST_ID_0, TEST_ID_1, diff --git a/linux/fsfwconfig/devices/powerSwitcherList.h b/linux/fsfwconfig/devices/powerSwitcherList.h index 9facfd80..bc5731fd 100644 --- a/linux/fsfwconfig/devices/powerSwitcherList.h +++ b/linux/fsfwconfig/devices/powerSwitcherList.h @@ -5,7 +5,7 @@ namespace pcduSwitches { /* Switches are uint8_t datatype and go from 0 to 255 */ - enum switcherList { + enum SwitcherList: uint8_t { Q7S, PAYLOAD_PCDU_CH1, RW, @@ -22,7 +22,7 @@ namespace pcduSwitches { SUS_NOMINAL, SOLAR_CELL_EXP, PLOC, - ACS_BORAD_SIDE_A, + ACS_BOARD_SIDE_A, NUMBER_OF_SWITCHES }; diff --git a/mission/devices/MGMHandlerRM3100.cpp b/mission/devices/MGMHandlerRM3100.cpp index 0f7fc729..a4878b95 100644 --- a/mission/devices/MGMHandlerRM3100.cpp +++ b/mission/devices/MGMHandlerRM3100.cpp @@ -8,9 +8,9 @@ MGMHandlerRM3100::MGMHandlerRM3100(object_id_t objectId, - object_id_t deviceCommunication, CookieIF* comCookie): + object_id_t deviceCommunication, CookieIF* comCookie, uint8_t switchId): DeviceHandlerBase(objectId, deviceCommunication, comCookie), - primaryDataset(this) { + primaryDataset(this), switchId(switchId) { #if OBSW_VERBOSE_LEVEL >= 1 debugDivider = new PeriodicOperationDivider(5); #endif @@ -300,16 +300,16 @@ ReturnValue_t MGMHandlerRM3100::handleTmrcConfigCommand( } void MGMHandlerRM3100::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(RM3100::CONFIGURE_CMM, 1); - insertInCommandAndReplyMap(RM3100::READ_CMM, 1); + insertInCommandAndReplyMap(RM3100::CONFIGURE_CMM, 3); + insertInCommandAndReplyMap(RM3100::READ_CMM, 3); - insertInCommandAndReplyMap(RM3100::CONFIGURE_TMRC, 1); - insertInCommandAndReplyMap(RM3100::READ_TMRC, 1); + insertInCommandAndReplyMap(RM3100::CONFIGURE_TMRC, 3); + insertInCommandAndReplyMap(RM3100::READ_TMRC, 3); - insertInCommandAndReplyMap(RM3100::CONFIGURE_CYCLE_COUNT, 1); - insertInCommandAndReplyMap(RM3100::READ_CYCLE_COUNT, 1); + insertInCommandAndReplyMap(RM3100::CONFIGURE_CYCLE_COUNT, 3); + insertInCommandAndReplyMap(RM3100::READ_CYCLE_COUNT, 3); - insertInCommandAndReplyMap(RM3100::READ_DATA, 1, &primaryDataset); + insertInCommandAndReplyMap(RM3100::READ_DATA, 3, &primaryDataset); } void MGMHandlerRM3100::modeChanged(void) { @@ -328,6 +328,12 @@ uint32_t MGMHandlerRM3100::getTransitionDelayMs(Mode_t from, Mode_t to) { return 10000; } +ReturnValue_t MGMHandlerRM3100::getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) { + *switches = &switchId; + *numberOfSwitches = 1; + return HasReturnvaluesIF::RETURN_OK; +} + ReturnValue_t MGMHandlerRM3100::handleDataReadout(const uint8_t *packet) { /* Analyze data here. The sensor generates 24 bit signed values so we need to do some bitshift * trickery here to calculate the raw values first */ @@ -345,9 +351,9 @@ ReturnValue_t MGMHandlerRM3100::handleDataReadout(const uint8_t *packet) { sif::info << "MGMHandlerRM3100: Magnetic field strength in" " microtesla:" << std::endl; /* Set terminal to utf-8 if there is an issue with micro printout. */ - sif::info << "X: " << fieldStrengthX << " \xC2\xB5T" << std::endl; - sif::info << "Y: " << fieldStrengthY << " \xC2\xB5T" << std::endl; - sif::info << "Z: " << fieldStrengthZ << " \xC2\xB5T" << std::endl; + sif::info << "X: " << fieldStrengthX << " uT" << std::endl; + sif::info << "Y: " << fieldStrengthY << " uT" << std::endl; + sif::info << "Z: " << fieldStrengthZ << " uT" << std::endl; } #endif diff --git a/mission/devices/MGMHandlerRM3100.h b/mission/devices/MGMHandlerRM3100.h index 48173e65..a499c568 100644 --- a/mission/devices/MGMHandlerRM3100.h +++ b/mission/devices/MGMHandlerRM3100.h @@ -2,6 +2,7 @@ #define MISSION_DEVICES_MGMRM3100HANDLER_H_ #include "OBSWConfig.h" +#include "devices/powerSwitcherList.h" #include "devicedefinitions/MGMHandlerRM3100Definitions.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" @@ -31,7 +32,7 @@ public: SUBSYSTEM_ID::MGM_RM3100, 0x01, severity::INFO); MGMHandlerRM3100(object_id_t objectId, object_id_t deviceCommunication, - CookieIF* comCookie); + CookieIF* comCookie, uint8_t switchId); virtual ~MGMHandlerRM3100(); protected: @@ -50,6 +51,8 @@ protected: DeviceCommandId_t *foundId, size_t *foundLen) override; ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; + ReturnValue_t getSwitches(const uint8_t **switches, + uint8_t *numberOfSwitches) override; void fillCommandAndReplyMap() override; void modeChanged(void) override; @@ -87,6 +90,8 @@ private: float scaleFactorY = 1 / RM3100::DEFAULT_GAIN; float scaleFactorZ = 1 / RM3100::DEFAULT_GAIN; + uint8_t switchId; + ReturnValue_t handleCycleCountConfigCommand(DeviceCommandId_t deviceCommand, const uint8_t *commandData,size_t commandDataLen); ReturnValue_t handleCycleCommand(bool oneCycleValue, diff --git a/mission/devices/PCDUHandler.cpp b/mission/devices/PCDUHandler.cpp index ba0e8667..fe7294ea 100644 --- a/mission/devices/PCDUHandler.cpp +++ b/mission/devices/PCDUHandler.cpp @@ -93,7 +93,7 @@ void PCDUHandler::initializeSwitchStates() { switchStates[pcduSwitches::SUS_NOMINAL] = pcduSwitches::INIT_STATE_SUS_NOMINAL; switchStates[pcduSwitches::SOLAR_CELL_EXP] = pcduSwitches::INIT_STATE_SOLAR_CELL_EXP; switchStates[pcduSwitches::PLOC] = pcduSwitches::INIT_STATE_PLOC; - switchStates[pcduSwitches::ACS_BORAD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A; + switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pcduSwitches::INIT_STATE_ACS_BOARD_SIDE_A; } void PCDUHandler::readCommandQueue() { @@ -186,7 +186,7 @@ void PCDUHandler::updatePdu1SwitchStates() { switchStates[pcduSwitches::SUS_NOMINAL] = pdu1HkTableDataset.voltageOutSUSNominal.value; switchStates[pcduSwitches::SOLAR_CELL_EXP] = pdu1HkTableDataset.voltageOutSolarCellExp.value; switchStates[pcduSwitches::PLOC] = pdu1HkTableDataset.voltageOutPLOC.value; - switchStates[pcduSwitches::ACS_BORAD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value; + switchStates[pcduSwitches::ACS_BOARD_SIDE_A] = pdu1HkTableDataset.voltageOutACSBoardSideA.value; } else { sif::debug << "PCDUHandler::updatePdu1SwitchStates: Failed to read dataset" << std::endl; diff --git a/tmtc b/tmtc index 90f85b7d..d9968031 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 90f85b7dae63e93a3c5686fab9dd0d4a8147e96b +Subproject commit d9968031d641249ca0ad62e7c1c19ed22390078c From 10f5933c1e9910faf49246470bf13d0433b1ff41 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 13 Sep 2021 18:10:24 +0200 Subject: [PATCH 06/16] enable pins --- linux/boardtest/SpiTestClass.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index ee08bc41..a5a773d1 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -24,7 +24,7 @@ gpioIF(gpioIF) { if(gpioIF == nullptr) { sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; } - testMode = TestModes::GYRO_L3GD20H; + testMode = TestModes::MGM_RM3100; spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); } @@ -355,6 +355,14 @@ void SpiTestClass::acsInit() { gpio = new GpiodRegular(q7s::GPIO_ACS_BOARD_DEFAULT_CHIP, gyro3L3gd20ChipSelect, "GYRO_3_L3G", gpio::Direction::OUT, gpio::HIGH); gpioCookie->addGpio(gpioIds::GYRO_3_L3G_CS, gpio); + + // Enable pins must be pulled low for regular operations + gpio = new GpiodRegular(q7s::GPIO_FLEX_OBC1F_B0, q7s::GPIO_GYRO_0_ENABLE, + "GYRO_0_ENABLE", gpio::OUT, gpio::LOW); + gpioCookie->addGpio(gpioIds::GYRO_0_ENABLE, gpio); + gpio = new GpiodRegular(q7s::GPIO_3V3_OBC1C, q7s::GPIO_GYRO_2_ENABLE, + "GYRO_2_ENABLE", gpio::OUT, gpio::LOW); + gpioCookie->addGpio(gpioIds::GYRO_2_ENABLE, gpio); #endif if(gpioIF != nullptr) { gpioIF->addGpios(gpioCookie); From 39acc24535a7d9c5036e1a8e8c45462042e3f0d6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Sep 2021 13:41:13 +0200 Subject: [PATCH 07/16] testing ADIS handler --- linux/boardtest/SpiTestClass.cpp | 2 +- .../pollingSequenceFactory.cpp | 40 +++++++++---------- mission/devices/GyroADIS16507Handler.cpp | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index a5a773d1..21af4a2f 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -24,7 +24,7 @@ gpioIF(gpioIF) { if(gpioIF == nullptr) { sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; } - testMode = TestModes::MGM_RM3100; + testMode = TestModes::MGM_LIS3MDL; spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); } diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 5f7bfd35..5a12943a 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -436,16 +436,16 @@ ReturnValue_t pst::pstSpi(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::MGM_2_LIS3_HANDLER, length * 0, // DeviceHandlerIF::PERFORM_OPERATION); @@ -469,16 +469,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { // thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.8, // DeviceHandlerIF::GET_READ); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, -// DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, -// DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, -// DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, -// DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, -// DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); // thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, // DeviceHandlerIF::PERFORM_OPERATION); diff --git a/mission/devices/GyroADIS16507Handler.cpp b/mission/devices/GyroADIS16507Handler.cpp index c744ff51..6f6fe2a6 100644 --- a/mission/devices/GyroADIS16507Handler.cpp +++ b/mission/devices/GyroADIS16507Handler.cpp @@ -201,7 +201,7 @@ ReturnValue_t GyroADIS16507Handler::interpretDeviceReply(DeviceCommandId_t id, uint16_t readProdId = packet[10] << 8 | packet[11]; if (readProdId != ADIS16507::PROD_ID) { #if OBSW_VERBOSE_LEVEL >= 1 - sif::debug << "GyroADIS16507Handler::interpretDeviceReply: Invalid product ID!" + sif::warning << "GyroADIS16507Handler::interpretDeviceReply: Invalid product ID!" << std::endl; #endif return HasReturnvaluesIF::RETURN_FAILED; From c7d0a9551e12e06042437bdafd2a2823887af64a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Sep 2021 17:26:23 +0200 Subject: [PATCH 08/16] small bugfix for rm3100 --- bsp_q7s/callbacks/rwSpiCallback.cpp | 2 +- bsp_q7s/core/ObjectFactory.cpp | 6 ++- fsfw | 2 +- linux/fsfwconfig/FSFWConfig.h.in | 1 + .../pollingSequenceFactory.cpp | 34 ++++++++--------- mission/devices/GyroADIS16507Handler.cpp | 2 +- mission/devices/MGMHandlerLIS3MDL.cpp | 16 ++++---- mission/devices/MGMHandlerRM3100.cpp | 38 ++++++++----------- .../MGMHandlerRM3100Definitions.h | 2 +- tmtc | 2 +- 10 files changed, 51 insertions(+), 54 deletions(-) diff --git a/bsp_q7s/callbacks/rwSpiCallback.cpp b/bsp_q7s/callbacks/rwSpiCallback.cpp index 70fa3ebe..73516fb4 100644 --- a/bsp_q7s/callbacks/rwSpiCallback.cpp +++ b/bsp_q7s/callbacks/rwSpiCallback.cpp @@ -212,7 +212,7 @@ ReturnValue_t spiCallback(SpiComIF* comIf, SpiCookie *cookie, const uint8_t *sen result = HasReturnvaluesIF::RETURN_OK; } - cookie->assignTransferSize(decodedFrameLen); + cookie->setTransferSize(decodedFrameLen); closeSpi(gpioId, gpioIF, mutex); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index e529fe09..e3a284fc 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -482,8 +482,9 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI 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); + objects::SPI_COM_IF, spiCookie, 0); gyroL3gHandler->setStartUpImmediately(); + //gyroL3gHandler->setGoNormalModeAtStartup(); // Gyro 2 Side B spiCookie = new SpiCookie(addresses::GYRO_2_ADIS, gpioIds::GYRO_2_ADIS_CS, spiDev, ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, @@ -495,8 +496,9 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI spiCookie = new SpiCookie(addresses::GYRO_3_L3G, gpioIds::GYRO_3_L3G_CS, spiDev, L3GD20H::MAX_BUFFER_SIZE, spi::DEFAULT_L3G_MODE, spi::DEFAULT_L3G_SPEED); gyroL3gHandler = new GyroHandlerL3GD20H(objects::GYRO_3_L3G_HANDLER, - objects::SPI_COM_IF, spiCookie); + objects::SPI_COM_IF, spiCookie, 0); gyroL3gHandler->setStartUpImmediately(); + //gyroL3gHandler->setGoNormalModeAtStartup(); resetArgsGnss1.gnss1 = true; resetArgsGnss1.gpioComIF = gpioComIF; diff --git a/fsfw b/fsfw index 97494a84..bdd7d59d 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 97494a84dfd0acb9dc32770ae9d142f80d4bbcfa +Subproject commit bdd7d59d82a0b9290d77844fbcc5be61c61bcbcb diff --git a/linux/fsfwconfig/FSFWConfig.h.in b/linux/fsfwconfig/FSFWConfig.h.in index 7d1521dc..89d8b9a7 100644 --- a/linux/fsfwconfig/FSFWConfig.h.in +++ b/linux/fsfwconfig/FSFWConfig.h.in @@ -74,5 +74,6 @@ static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048; #define FSFW_HAL_LINUX_SPI_WIRETAPPING 0 #define FSFW_DEV_HYPERION_GPS_CREATE_NMEA_CSV 0 +#define FSFW_HAL_L3GD20_GYRO_DEBUG 0 #endif /* CONFIG_FSFWCONFIG_H_ */ diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 5a12943a..8342b3cb 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -446,7 +446,7 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { // DeviceHandlerIF::SEND_READ); // 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, @@ -469,28 +469,28 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { // thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.8, // DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); - -// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0, +// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, // DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.2, +// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.2, // DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.4, +// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.4, // DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.6, +// thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0.6, // DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::GYRO_1_L3G_HANDLER, length * 0.8, +// thisSequence->addSlot(objects::GYRO_0_ADIS_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_2_ADIS_HANDLER, length * 0, // DeviceHandlerIF::PERFORM_OPERATION); // thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.2, diff --git a/mission/devices/GyroADIS16507Handler.cpp b/mission/devices/GyroADIS16507Handler.cpp index 6f6fe2a6..793aad66 100644 --- a/mission/devices/GyroADIS16507Handler.cpp +++ b/mission/devices/GyroADIS16507Handler.cpp @@ -403,7 +403,7 @@ ReturnValue_t GyroADIS16507Handler::spiSendCallback(SpiComIF *comIf, SpiCookie * cookie->getSpiParameters(spiMode, spiSpeed, nullptr); comIf->setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed); cookie->assignWriteBuffer(sendData); - cookie->assignTransferSize(2); + cookie->setTransferSize(2); gpioId_t gpioId = cookie->getChipSelectPin(); GpioIF* gpioIF = comIf->getGpioInterface(); diff --git a/mission/devices/MGMHandlerLIS3MDL.cpp b/mission/devices/MGMHandlerLIS3MDL.cpp index 0291d8b0..0e1da93e 100644 --- a/mission/devices/MGMHandlerLIS3MDL.cpp +++ b/mission/devices/MGMHandlerLIS3MDL.cpp @@ -292,14 +292,14 @@ ReturnValue_t MGMHandlerLIS3MDL::interpretDeviceReply(DeviceCommandId_t id, #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "MGMHandlerLIS3: Magnetic field strength in" " microtesla:" << std::endl; - sif::info << "X: " << mgmX << " \xC2\xB5T" << std::endl; - sif::info << "Y: " << mgmY << " \xC2\xB5T" << std::endl; - sif::info << "Z: " << mgmZ << " \xC2\xB5T" << std::endl; + sif::info << "X: " << mgmX << " uT" << std::endl; + sif::info << "Y: " << mgmY << " uT" << std::endl; + sif::info << "Z: " << mgmZ << " uT" << std::endl; #else sif::printInfo("MGMHandlerLIS3: Magnetic field strength in microtesla:\n"); - sif::printInfo("X: %f " "\xC2\xB5" "T\n", mgmX); - sif::printInfo("Y: %f " "\xC2\xB5" "T\n", mgmY); - sif::printInfo("Z: %f " "\xC2\xB5" "T\n", mgmZ); + sif::printInfo("X: %f uT\n", mgmX); + sif::printInfo("Y: %f uT\n", mgmY); + sif::printInfo("Z: %f uT\n", mgmZ); #endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */ } #endif /* OBSW_VERBOSE_LEVEL >= 1 */ @@ -320,10 +320,10 @@ ReturnValue_t MGMHandlerLIS3MDL::interpretDeviceReply(DeviceCommandId_t id, if(debugDivider->check()) { /* Set terminal to utf-8 if there is an issue with micro printout. */ #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " \xC2\xB0" << "C" << + sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " C" << std::endl; #else - sif::printInfo("MGMHandlerLIS3: Temperature: %f" "\xC2\xB0" "C\n"); + sif::printInfo("MGMHandlerLIS3: Temperature: %f C\n"); #endif } #endif diff --git a/mission/devices/MGMHandlerRM3100.cpp b/mission/devices/MGMHandlerRM3100.cpp index a4878b95..71c3e524 100644 --- a/mission/devices/MGMHandlerRM3100.cpp +++ b/mission/devices/MGMHandlerRM3100.cpp @@ -63,6 +63,7 @@ void MGMHandlerRM3100::doShutDown() { ReturnValue_t MGMHandlerRM3100::buildTransitionDeviceCommand( DeviceCommandId_t *id) { + size_t commandLen = 0; switch(internalState) { case(InternalState::NONE): case(InternalState::NORMAL): { @@ -77,6 +78,8 @@ ReturnValue_t MGMHandlerRM3100::buildTransitionDeviceCommand( break; } case(InternalState::STATE_CONFIGURE_TMRC): { + commandBuffer[0] = RM3100::TMRC_DEFAULT_VALUE; + commandLen = 1; *id = RM3100::CONFIGURE_TMRC; break; } @@ -85,18 +88,17 @@ ReturnValue_t MGMHandlerRM3100::buildTransitionDeviceCommand( break; } default: - /* Might be a configuration error. */ - sif::debug << "GyroHandler::buildTransitionDeviceCommand: Unknown internal state!" << + // Might be a configuration error + sif::warning << "MGMHandlerRM3100::buildTransitionDeviceCommand: Unknown internal state!" << std::endl; return HasReturnvaluesIF::RETURN_OK; } - return buildCommandFromCommand(*id, nullptr, 0); + return buildCommandFromCommand(*id, commandBuffer, commandLen); } -ReturnValue_t MGMHandlerRM3100::buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) { +ReturnValue_t MGMHandlerRM3100::buildCommandFromCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, size_t commandDataLen) { switch(deviceCommand) { case(RM3100::CONFIGURE_CMM): { commandBuffer[0] = RM3100::CMM_REGISTER; @@ -113,8 +115,7 @@ ReturnValue_t MGMHandlerRM3100::buildCommandFromCommand( break; } case(RM3100::CONFIGURE_TMRC): { - return handleTmrcConfigCommand(deviceCommand, commandData, - commandDataLen); + return handleTmrcConfigCommand(deviceCommand, commandData, commandDataLen); } case(RM3100::READ_TMRC): { commandBuffer[0] = RM3100::TMRC_REGISTER | RM3100::READ_MASK; @@ -124,8 +125,7 @@ ReturnValue_t MGMHandlerRM3100::buildCommandFromCommand( break; } case(RM3100::CONFIGURE_CYCLE_COUNT): { - return handleCycleCountConfigCommand(deviceCommand, commandData, - commandDataLen); + return handleCycleCountConfigCommand(deviceCommand, commandData, commandDataLen); } case(RM3100::READ_CYCLE_COUNT): { commandBuffer[0] = RM3100::CYCLE_COUNT_START_REGISTER | RM3100::READ_MASK; @@ -162,8 +162,7 @@ ReturnValue_t MGMHandlerRM3100::scanForReply(const uint8_t *start, return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t MGMHandlerRM3100::interpretDeviceReply( - DeviceCommandId_t id, const uint8_t *packet) { +ReturnValue_t MGMHandlerRM3100::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; switch(id) { case(RM3100::CONFIGURE_CMM): @@ -281,19 +280,14 @@ ReturnValue_t MGMHandlerRM3100::handleCycleCommand(bool oneCycleValue, return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t MGMHandlerRM3100::handleTmrcConfigCommand( - DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) { - if(commandData == nullptr) { - return DeviceHandlerIF::INVALID_COMMAND_PARAMETER; - } - - if(commandDataLen != 1) { +ReturnValue_t MGMHandlerRM3100::handleTmrcConfigCommand(DeviceCommandId_t deviceCommand, + const uint8_t *commandData, size_t commandDataLen) { + if(commandData == nullptr or commandDataLen != 1) { return DeviceHandlerIF::INVALID_COMMAND_PARAMETER; } commandBuffer[0] = RM3100::TMRC_REGISTER; - commandBuffer[1] = commandData[1]; + commandBuffer[1] = commandData[0]; rawPacketLen = 2; rawPacket = commandBuffer; return HasReturnvaluesIF::RETURN_OK; @@ -325,7 +319,7 @@ ReturnValue_t MGMHandlerRM3100::initializeLocalDataPool( } uint32_t MGMHandlerRM3100::getTransitionDelayMs(Mode_t from, Mode_t to) { - return 10000; + return 25000; } ReturnValue_t MGMHandlerRM3100::getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) { diff --git a/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h b/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h index 08f80dd9..4f00bba9 100644 --- a/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h +++ b/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h @@ -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_DEFAULT_37HZ_VALUE; +static constexpr uint8_t TMRC_DEFAULT_VALUE = TMRC_75HZ_VALUE; static constexpr uint8_t MEASUREMENT_REG_START = 0x24; static constexpr uint8_t BIST_REGISTER = 0x33; diff --git a/tmtc b/tmtc index d9968031..dff569e9 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit d9968031d641249ca0ad62e7c1c19ed22390078c +Subproject commit dff569e93ff3cb5e62627c89cfa2229f464c76de From df5b0a19de3c047a8c832e11071d5462d3bc4119 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Sep 2021 17:38:26 +0200 Subject: [PATCH 09/16] improved preprocessor defines --- bsp_q7s/boardconfig/q7sConfig.h.in | 5 --- bsp_q7s/core/InitMission.cpp | 4 +- bsp_q7s/core/ObjectFactory.cpp | 6 +-- linux/boardtest/SpiTestClass.cpp | 2 +- linux/fsfwconfig/OBSWConfig.h.in | 4 +- .../pollingSequenceFactory.cpp | 40 +++++++++---------- 6 files changed, 29 insertions(+), 32 deletions(-) diff --git a/bsp_q7s/boardconfig/q7sConfig.h.in b/bsp_q7s/boardconfig/q7sConfig.h.in index 0eb4f759..40b5a510 100644 --- a/bsp_q7s/boardconfig/q7sConfig.h.in +++ b/bsp_q7s/boardconfig/q7sConfig.h.in @@ -30,11 +30,6 @@ #define Q7S_CHECK_FOR_ALREADY_RUNNING_IMG 1 #define Q7S_ADD_RTD_DEVICES 0 -// Only one of those 2 should be enabled! -#if OBSW_ADD_ACS_BOARD == 0 -#define Q7S_ADD_SPI_TEST 0 -#endif - #define Q7S_SIMPLE_ADD_FILE_SYSTEM_TEST 0 namespace config { diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 49e9d8ca..5ddb6b9b 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -167,7 +167,7 @@ void initmission::createPstTasks(TaskFactory& factory, ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; #if BOARD_TE0720 == 0 /* Polling Sequence Table Default */ -#if Q7S_ADD_SPI_TEST == 0 +#if OBSW_ADD_SPI_TEST_CODE == 0 FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( "PST_TASK_DEFAULT", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 3.0, missedDeadlineFunc); @@ -297,7 +297,7 @@ void initmission::createTestTasks(TaskFactory& factory, TaskDeadlineMissedFuncti initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); } -#if Q7S_ADD_SPI_TEST == 1 +#if OBSW_ADD_SPI_TEST_CODE == 1 result = testTask->addComponent(objects::SPI_TEST); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("SPI_TEST", objects::SPI_TEST); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index e3a284fc..d8b34aac 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -229,9 +229,9 @@ void ObjectFactory::createCommunicationInterfaces(LinuxLibgpioIF **gpioComIF, new CspComIF(objects::CSP_COM_IF); new I2cComIF(objects::I2C_COM_IF); *uartComIF = new UartComIF(objects::UART_COM_IF); -#if Q7S_ADD_SPI_TEST == 0 +#if OBSW_ADD_SPI_TEST_CODE == 0 *spiComIF = new SpiComIF(objects::SPI_COM_IF, *gpioComIF); -#endif /* Q7S_ADD_SPI_TEST == 0 */ +#endif /* Q7S_ADD_SPI_TEST_CODE == 0 */ #if BOARD_TE0720 == 0 /* Adding gpios for chip select decoding to the gpioComIf */ @@ -903,7 +903,7 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { plocSupervisor->setStartUpImmediately(); #endif -#if Q7S_ADD_SPI_TEST == 1 +#if OBSW_ADD_SPI_TEST_CODE == 1 new SpiTestClass(objects::SPI_TEST, gpioComIF); #endif diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index 21af4a2f..a5a773d1 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -24,7 +24,7 @@ gpioIF(gpioIF) { if(gpioIF == nullptr) { sif::error << "SpiTestClass::SpiTestClass: Invalid GPIO ComIF!" << std::endl; } - testMode = TestModes::MGM_LIS3MDL; + testMode = TestModes::MGM_RM3100; spiTransferStruct.rx_buf = reinterpret_cast<__u64>(recvBuffer.data()); spiTransferStruct.tx_buf = reinterpret_cast<__u64>(sendBuffer.data()); } diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index 5db0243c..dc397635 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -47,7 +47,9 @@ debugging. */ //! /* Can be used to switch device to NORMAL mode immediately */ #define OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP 1 #define OBSW_PRINT_MISSED_DEADLINES 1 -#define OBSW_ADD_TEST_CODE 0 +// If this is enabled, all other SPI code should be disabled +#define OBSW_ADD_TEST_CODE 1 +#define OBSW_ADD_SPI_TEST_CODE 0 #define OBSW_ADD_TEST_PST 0 #define OBSW_ADD_TEST_TASK 0 #define OBSW_TEST_LIBGPIOD 0 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 8342b3cb..0074ecec 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -458,16 +458,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { // thisSequence->addSlot(objects::MGM_2_LIS3_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); + 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); // thisSequence->addSlot(objects::GYRO_0_ADIS_HANDLER, length * 0, // DeviceHandlerIF::PERFORM_OPERATION); @@ -480,16 +480,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { // thisSequence->addSlot(objects::GYRO_0_ADIS_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, +// 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_2_ADIS_HANDLER, length * 0, // DeviceHandlerIF::PERFORM_OPERATION); From 2630d7fae7e74a7c526b64676c6241436a998710 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Sep 2021 17:49:15 +0200 Subject: [PATCH 10/16] tweak for rm3100 --- mission/devices/MGMHandlerRM3100.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/devices/MGMHandlerRM3100.cpp b/mission/devices/MGMHandlerRM3100.cpp index 71c3e524..ccbf05c8 100644 --- a/mission/devices/MGMHandlerRM3100.cpp +++ b/mission/devices/MGMHandlerRM3100.cpp @@ -288,6 +288,7 @@ ReturnValue_t MGMHandlerRM3100::handleTmrcConfigCommand(DeviceCommandId_t device commandBuffer[0] = RM3100::TMRC_REGISTER; commandBuffer[1] = commandData[0]; + tmrcRegValue = commandData[0]; rawPacketLen = 2; rawPacket = commandBuffer; return HasReturnvaluesIF::RETURN_OK; From bdd5a7dd2161fcfefd774e7a960c0899c8648c50 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 15 Sep 2021 18:50:23 +0200 Subject: [PATCH 11/16] more storage for events --- common/config/devConf.h | 4 +- fsfw | 2 +- linux/boardtest/SpiTestClass.cpp | 2 +- .../pollingSequenceFactory.cpp | 106 +++++++++--------- mission/core/GenericFactory.cpp | 8 +- tmtc | 2 +- 6 files changed, 62 insertions(+), 62 deletions(-) diff --git a/common/config/devConf.h b/common/config/devConf.h index 7f3094fa..41126fdd 100644 --- a/common/config/devConf.h +++ b/common/config/devConf.h @@ -11,13 +11,13 @@ namespace spi { /* Default values, changing them is not supported for now */ -static constexpr uint32_t DEFAULT_LIS3_SPEED = 3'900'000; +static constexpr uint32_t DEFAULT_LIS3_SPEED = 976'000; static constexpr spi::SpiModes DEFAULT_LIS3_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_RM3100_SPEED = 976'000; static constexpr spi::SpiModes DEFAULT_RM3100_MODE = spi::SpiModes::MODE_3; -static constexpr uint32_t DEFAULT_L3G_SPEED = 3'900'000; +static constexpr uint32_t DEFAULT_L3G_SPEED = 976'000; static constexpr spi::SpiModes DEFAULT_L3G_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 3'900'000; diff --git a/fsfw b/fsfw index bdd7d59d..bc6b29e6 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit bdd7d59d82a0b9290d77844fbcc5be61c61bcbcb +Subproject commit bc6b29e652a90f5a14bb32a1bcc2a956e410e678 diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index a5a773d1..08d7c14c 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -113,7 +113,7 @@ void SpiTestClass::performRm3100Test(uint8_t mgmId) { sif::info << "Cycle count Y: " << cycleCountY << std::endl; sif::info << "Cycle count z: " << cycleCountZ << std::endl; - writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x95); + writeRegister(fileDescriptor, currentGpioId, 0x0B, 0x96); uint8_t tmrcReg = readRm3100Register(fileDescriptor, currentGpioId, 0x0B); sif::info << "SpiTestClass::performRm3100Test: TMRC register value: " << std::hex << "0x" << static_cast(tmrcReg) << std::dec << std::endl; diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index 0074ecec..f45f5f32 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -425,39 +425,39 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { thisSequence->addSlot(objects::RW4, length * 0.8, DeviceHandlerIF::GET_READ); #if OBSW_ADD_ACS_BOARD == 1 -// thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0, -// DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, -// DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.4, -// DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, -// 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, -// 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_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_0_LIS3_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::MGM_0_LIS3_HANDLER, length * 0.6, + 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, + 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_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_3_RM3100_HANDLER, length * 0, DeviceHandlerIF::PERFORM_OPERATION); thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.2, @@ -480,16 +480,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { // thisSequence->addSlot(objects::GYRO_0_ADIS_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, + 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_2_ADIS_HANDLER, length * 0, // DeviceHandlerIF::PERFORM_OPERATION); @@ -502,16 +502,16 @@ ReturnValue_t pst::pstSpi(FixedTimeslotTaskIF *thisSequence) { // thisSequence->addSlot(objects::GYRO_2_ADIS_HANDLER, length * 0.8, // DeviceHandlerIF::GET_READ); -// thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, -// DeviceHandlerIF::PERFORM_OPERATION); -// thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.2, -// DeviceHandlerIF::SEND_WRITE); -// thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.4, -// DeviceHandlerIF::GET_WRITE); -// thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, -// DeviceHandlerIF::SEND_READ); -// thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.8, -// DeviceHandlerIF::GET_READ); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0, + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_3_L3G_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); #endif /* OBSW_ADD_ACS_BOARD == 1 */ if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { diff --git a/mission/core/GenericFactory.cpp b/mission/core/GenericFactory.cpp index cc1b88e5..4ee1ff70 100644 --- a/mission/core/GenericFactory.cpp +++ b/mission/core/GenericFactory.cpp @@ -36,22 +36,22 @@ void ObjectFactory::produceGenericObjects() { { PoolManager::LocalPoolConfig poolCfg = { - {100, 16}, {50, 32}, {25, 64}, {15, 128}, {10, 1024}, {5, 2048} + {300, 16}, {300, 32}, {200, 64}, {200, 128}, {100, 1024}, {10, 2048} }; new PoolManager(objects::TC_STORE, poolCfg); } { PoolManager::LocalPoolConfig poolCfg = { - {100, 16}, {50, 32}, {25, 64}, {15, 128}, {10, 1024}, {5, 2048} + {300, 16}, {300, 32}, {100, 64}, {100, 128}, {100, 1024}, {10, 2048} }; new PoolManager(objects::TM_STORE, poolCfg); } { PoolManager::LocalPoolConfig poolCfg = { - { 100, 16 }, { 100, 32 }, { 100, 64 }, - { 100, 128 }, { 50, 256 }, { 50, 512 }, { 50, 1024 }, { 10, 2048 } + { 300, 16 }, { 200, 32 }, { 150, 64 }, + { 150, 128 }, { 100, 256 }, { 50, 512 }, { 50, 1024 }, { 10, 2048 } }; new PoolManager(objects::IPC_STORE, poolCfg); } diff --git a/tmtc b/tmtc index dff569e9..b3bc1fe2 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit dff569e93ff3cb5e62627c89cfa2229f464c76de +Subproject commit b3bc1fe28c73d51f0b8319cf67705807596e5518 From 8af3a91b5a5f588d30e0aff74b2bbae2ee06329b Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Sep 2021 11:11:25 +0200 Subject: [PATCH 12/16] correct RW pin --- bsp_q7s/boardconfig/busConf.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/boardconfig/busConf.h b/bsp_q7s/boardconfig/busConf.h index 491930db..257883cd 100644 --- a/bsp_q7s/boardconfig/busConf.h +++ b/bsp_q7s/boardconfig/busConf.h @@ -80,7 +80,8 @@ static constexpr uint32_t GPIO_SOL_DEPL_SA_0_PIN = 4; static constexpr uint32_t GPIO_SOL_DEPL_SA_1_PIN = 2; static constexpr char GPIO_RW_SPI_MUX_CHIP[] = "gpiochip11"; -static constexpr uint32_t GPIO_RW_SPI_MUX_CS = 57; +// Uses EMIO interface to PL, starts at 54 +static constexpr uint32_t GPIO_RW_SPI_MUX_CS = 54; } From 799e90f617a03b42fdc7be1ac33b22107c78e3be Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Sep 2021 11:15:14 +0200 Subject: [PATCH 13/16] reverted some change --- mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h b/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h index 4f00bba9..08f80dd9 100644 --- a/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h +++ b/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h @@ -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; From b8b6cd8872d55e708dcc4d567e2b54643423cc1c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Sep 2021 11:34:07 +0200 Subject: [PATCH 14/16] moved RM3100 handler to framework --- bsp_q7s/core/ObjectFactory.cpp | 6 +- fsfw | 2 +- mission/devices/CMakeLists.txt | 1 - mission/devices/MGMHandlerRM3100.cpp | 364 ------------------ mission/devices/MGMHandlerRM3100.h | 109 ------ .../MGMHandlerRM3100Definitions.h | 132 ------- 6 files changed, 4 insertions(+), 610 deletions(-) delete mode 100644 mission/devices/MGMHandlerRM3100.cpp delete mode 100644 mission/devices/MGMHandlerRM3100.h delete mode 100644 mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index d8b34aac..bdad3dac 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -37,7 +37,6 @@ #include "mission/devices/IMTQHandler.h" #include "mission/devices/SyrlinksHkHandler.h" #include "mission/devices/MGMHandlerLIS3MDL.h" -#include "mission/devices/MGMHandlerRM3100.h" #include "mission/devices/PlocMPSoCHandler.h" #include "mission/devices/RadiationSensorHandler.h" #include "mission/devices/RwHandler.h" @@ -55,6 +54,7 @@ #include "fsfw_hal/linux/uart/UartComIF.h" #include "fsfw_hal/linux/uart/UartCookie.h" #include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" +#include "fsfw_hal/devicehandlers/MgmRM3100Handler.h" #include "fsfw_hal/linux/i2c/I2cCookie.h" #include "fsfw_hal/linux/i2c/I2cComIF.h" #include "fsfw_hal/linux/spi/SpiCookie.h" @@ -454,7 +454,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI spiCookie = new SpiCookie(addresses::MGM_1_RM3100, gpioIds::MGM_1_RM3100_CS, spiDev, RM3100::MAX_BUFFER_SIZE, spi::DEFAULT_RM3100_MODE, spi::DEFAULT_RM3100_SPEED); - auto mgmRm3100Handler = new MGMHandlerRM3100(objects::MGM_1_RM3100_HANDLER, + auto mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_1_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, pcduSwitches::SwitcherList::ACS_BOARD_SIDE_A); mgmRm3100Handler->setStartUpImmediately(); @@ -466,7 +466,7 @@ void ObjectFactory::createAcsBoardComponents(LinuxLibgpioIF *gpioComIF, UartComI 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, + mgmRm3100Handler = new MgmRM3100Handler(objects::MGM_3_RM3100_HANDLER, objects::SPI_COM_IF, spiCookie, pcduSwitches::SwitcherList::ACS_BOARD_SIDE_B); mgmRm3100Handler->setStartUpImmediately(); diff --git a/fsfw b/fsfw index bc6b29e6..823c6ec5 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit bc6b29e652a90f5a14bb32a1bcc2a956e410e678 +Subproject commit 823c6ec5fc6357d342f4d0e3edc68d89ff492b87 diff --git a/mission/devices/CMakeLists.txt b/mission/devices/CMakeLists.txt index 4ed60dfd..b5a1e20f 100644 --- a/mission/devices/CMakeLists.txt +++ b/mission/devices/CMakeLists.txt @@ -1,7 +1,6 @@ target_sources(${TARGET_NAME} PUBLIC GPSHyperionHandler.cpp MGMHandlerLIS3MDL.cpp - MGMHandlerRM3100.cpp GomspaceDeviceHandler.cpp Tmp1075Handler.cpp PCDUHandler.cpp diff --git a/mission/devices/MGMHandlerRM3100.cpp b/mission/devices/MGMHandlerRM3100.cpp deleted file mode 100644 index ccbf05c8..00000000 --- a/mission/devices/MGMHandlerRM3100.cpp +++ /dev/null @@ -1,364 +0,0 @@ -#include "MGMHandlerRM3100.h" - -#include "fsfw/datapool/PoolReadGuard.h" -#include "fsfw/globalfunctions/bitutility.h" -#include "fsfw/devicehandlers/DeviceHandlerMessage.h" -#include "fsfw/objectmanager/SystemObjectIF.h" -#include "fsfw/returnvalues/HasReturnvaluesIF.h" - - -MGMHandlerRM3100::MGMHandlerRM3100(object_id_t objectId, - object_id_t deviceCommunication, CookieIF* comCookie, uint8_t switchId): - DeviceHandlerBase(objectId, deviceCommunication, comCookie), - primaryDataset(this), switchId(switchId) { -#if OBSW_VERBOSE_LEVEL >= 1 - debugDivider = new PeriodicOperationDivider(5); -#endif -} - -MGMHandlerRM3100::~MGMHandlerRM3100() {} - -void MGMHandlerRM3100::doStartUp() { - switch(internalState) { - case(InternalState::NONE): { - internalState = InternalState::CONFIGURE_CMM; - break; - } - case(InternalState::CONFIGURE_CMM): { - internalState = InternalState::READ_CMM; - break; - } - case(InternalState::READ_CMM): { - if(commandExecuted) { - internalState = InternalState::STATE_CONFIGURE_TMRC; - } - break; - } - case(InternalState::STATE_CONFIGURE_TMRC): { - if(commandExecuted) { - internalState = InternalState::STATE_READ_TMRC; - } - break; - } - case(InternalState::STATE_READ_TMRC): { - if(commandExecuted) { - internalState = InternalState::NORMAL; -#if OBSW_SWITCH_TO_NORMAL_MODE_AFTER_STARTUP == 1 - setMode(MODE_NORMAL); -#else - setMode(_MODE_TO_ON); -#endif - } - break; - } - default: { - break; - } - } -} - -void MGMHandlerRM3100::doShutDown() { - setMode(_MODE_POWER_DOWN); -} - -ReturnValue_t MGMHandlerRM3100::buildTransitionDeviceCommand( - DeviceCommandId_t *id) { - size_t commandLen = 0; - switch(internalState) { - case(InternalState::NONE): - case(InternalState::NORMAL): { - return HasReturnvaluesIF::RETURN_OK; - } - case(InternalState::CONFIGURE_CMM): { - *id = RM3100::CONFIGURE_CMM; - break; - } - case(InternalState::READ_CMM): { - *id = RM3100::READ_CMM; - break; - } - case(InternalState::STATE_CONFIGURE_TMRC): { - commandBuffer[0] = RM3100::TMRC_DEFAULT_VALUE; - commandLen = 1; - *id = RM3100::CONFIGURE_TMRC; - break; - } - case(InternalState::STATE_READ_TMRC): { - *id = RM3100::READ_TMRC; - break; - } - default: - // Might be a configuration error - sif::warning << "MGMHandlerRM3100::buildTransitionDeviceCommand: Unknown internal state!" << - std::endl; - return HasReturnvaluesIF::RETURN_OK; - } - - return buildCommandFromCommand(*id, commandBuffer, commandLen); -} - -ReturnValue_t MGMHandlerRM3100::buildCommandFromCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen) { - switch(deviceCommand) { - case(RM3100::CONFIGURE_CMM): { - commandBuffer[0] = RM3100::CMM_REGISTER; - commandBuffer[1] = RM3100::CMM_VALUE; - rawPacket = commandBuffer; - rawPacketLen = 2; - break; - } - case(RM3100::READ_CMM): { - commandBuffer[0] = RM3100::CMM_REGISTER | RM3100::READ_MASK; - commandBuffer[1] = 0; - rawPacket = commandBuffer; - rawPacketLen = 2; - break; - } - case(RM3100::CONFIGURE_TMRC): { - return handleTmrcConfigCommand(deviceCommand, commandData, commandDataLen); - } - case(RM3100::READ_TMRC): { - commandBuffer[0] = RM3100::TMRC_REGISTER | RM3100::READ_MASK; - commandBuffer[1] = 0; - rawPacket = commandBuffer; - rawPacketLen = 2; - break; - } - case(RM3100::CONFIGURE_CYCLE_COUNT): { - return handleCycleCountConfigCommand(deviceCommand, commandData, commandDataLen); - } - case(RM3100::READ_CYCLE_COUNT): { - commandBuffer[0] = RM3100::CYCLE_COUNT_START_REGISTER | RM3100::READ_MASK; - std::memset(commandBuffer + 1, 0, 6); - rawPacket = commandBuffer; - rawPacketLen = 7; - break; - } - case(RM3100::READ_DATA): { - commandBuffer[0] = RM3100::MEASUREMENT_REG_START | RM3100::READ_MASK; - std::memset(commandBuffer + 1, 0, 9); - rawPacketLen = 10; - break; - } - default: - return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; - } - return RETURN_OK; -} - -ReturnValue_t MGMHandlerRM3100::buildNormalDeviceCommand( - DeviceCommandId_t *id) { - *id = RM3100::READ_DATA; - return buildCommandFromCommand(*id, nullptr, 0); -} - -ReturnValue_t MGMHandlerRM3100::scanForReply(const uint8_t *start, - size_t len, DeviceCommandId_t *foundId, - size_t *foundLen) { - - /* For SPI, ID will always be the one of the last sent command. */ - *foundId = this->getPendingCommand(); - *foundLen = len; - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t MGMHandlerRM3100::interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) { - ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; - switch(id) { - case(RM3100::CONFIGURE_CMM): - case(RM3100::CONFIGURE_CYCLE_COUNT): - case(RM3100::CONFIGURE_TMRC): { - /* We can only check whether write was successful with read operation. */ - if(mode == _MODE_START_UP) { - commandExecuted = true; - } - break; - } - case(RM3100::READ_CMM): { - uint8_t cmmValue = packet[1]; - /* We clear the seventh bit in any case - * because this one is zero sometimes for some reason */ - bitutil::bitClear(&cmmValue, 6); - if(cmmValue == cmmRegValue and internalState == InternalState::READ_CMM) { - commandExecuted = true; - } - else { - /* Attempt reconfiguration. */ - internalState = InternalState::CONFIGURE_CMM; - return DeviceHandlerIF::DEVICE_REPLY_INVALID; - } - break; - } - case(RM3100::READ_TMRC): { - if(packet[1] == tmrcRegValue) { - commandExecuted = true; - /* Reading TMRC was commanded. Trigger event to inform ground. */ - if(mode != _MODE_START_UP) { - triggerEvent(tmrcSet, tmrcRegValue, 0); - } - } - else { - /* Attempt reconfiguration. */ - internalState = InternalState::STATE_CONFIGURE_TMRC; - return DeviceHandlerIF::DEVICE_REPLY_INVALID; - } - break; - } - case(RM3100::READ_CYCLE_COUNT): { - uint16_t cycleCountX = packet[1] << 8 | packet[2]; - uint16_t cycleCountY = packet[3] << 8 | packet[4]; - uint16_t cycleCountZ = packet[5] << 8 | packet[6]; - if(cycleCountX != cycleCountRegValueX or cycleCountY != cycleCountRegValueY or - cycleCountZ != cycleCountRegValueZ) { - return DeviceHandlerIF::DEVICE_REPLY_INVALID; - } - /* Reading TMRC was commanded. Trigger event to inform ground. */ - if(mode != _MODE_START_UP) { - uint32_t eventParam1 = (cycleCountX << 16) | cycleCountY; - triggerEvent(cycleCountersSet, eventParam1, cycleCountZ); - } - break; - } - case(RM3100::READ_DATA): { - result = handleDataReadout(packet); - break; - } - default: - return DeviceHandlerIF::UNKNOWN_DEVICE_REPLY; - } - - return result; -} - -ReturnValue_t MGMHandlerRM3100::handleCycleCountConfigCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen) { - if(commandData == nullptr) { - return DeviceHandlerIF::INVALID_COMMAND_PARAMETER; - } - - // Set cycle count - if(commandDataLen == 2) { - handleCycleCommand(true, commandData, commandDataLen); - } - else if(commandDataLen == 6) { - handleCycleCommand(false, commandData, commandDataLen); - } - else { - return DeviceHandlerIF::INVALID_COMMAND_PARAMETER; - } - - commandBuffer[0] = RM3100::CYCLE_COUNT_VALUE; - std::memcpy(commandBuffer + 1, &cycleCountRegValueX, 2); - std::memcpy(commandBuffer + 3, &cycleCountRegValueY, 2); - std::memcpy(commandBuffer + 5, &cycleCountRegValueZ, 2); - rawPacketLen = 7; - rawPacket = commandBuffer; - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t MGMHandlerRM3100::handleCycleCommand(bool oneCycleValue, - const uint8_t *commandData, size_t commandDataLen) { - RM3100::CycleCountCommand command(oneCycleValue); - ReturnValue_t result = command.deSerialize(&commandData, &commandDataLen, - SerializeIF::Endianness::BIG); - if(result != HasReturnvaluesIF::RETURN_OK) { - return result; - } - - /* Data sheet p.30 "while noise limits the useful upper range to ~400 cycle counts." */ - if(command.cycleCountX > 450 ) { - return DeviceHandlerIF::INVALID_COMMAND_PARAMETER; - } - - if(not oneCycleValue and (command.cycleCountY > 450 or command.cycleCountZ > 450)) { - return DeviceHandlerIF::INVALID_COMMAND_PARAMETER; - } - - cycleCountRegValueX = command.cycleCountX; - cycleCountRegValueY = command.cycleCountY; - cycleCountRegValueZ = command.cycleCountZ; - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t MGMHandlerRM3100::handleTmrcConfigCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData, size_t commandDataLen) { - if(commandData == nullptr or commandDataLen != 1) { - return DeviceHandlerIF::INVALID_COMMAND_PARAMETER; - } - - commandBuffer[0] = RM3100::TMRC_REGISTER; - commandBuffer[1] = commandData[0]; - tmrcRegValue = commandData[0]; - rawPacketLen = 2; - rawPacket = commandBuffer; - return HasReturnvaluesIF::RETURN_OK; -} - -void MGMHandlerRM3100::fillCommandAndReplyMap() { - insertInCommandAndReplyMap(RM3100::CONFIGURE_CMM, 3); - insertInCommandAndReplyMap(RM3100::READ_CMM, 3); - - insertInCommandAndReplyMap(RM3100::CONFIGURE_TMRC, 3); - insertInCommandAndReplyMap(RM3100::READ_TMRC, 3); - - insertInCommandAndReplyMap(RM3100::CONFIGURE_CYCLE_COUNT, 3); - insertInCommandAndReplyMap(RM3100::READ_CYCLE_COUNT, 3); - - insertInCommandAndReplyMap(RM3100::READ_DATA, 3, &primaryDataset); -} - -void MGMHandlerRM3100::modeChanged(void) { - internalState = InternalState::NONE; -} - -ReturnValue_t MGMHandlerRM3100::initializeLocalDataPool( - localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) { - localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_X, new PoolEntry({0.0})); - localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Y, new PoolEntry({0.0})); - localDataPoolMap.emplace(RM3100::FIELD_STRENGTH_Z, new PoolEntry({0.0})); - return HasReturnvaluesIF::RETURN_OK; -} - -uint32_t MGMHandlerRM3100::getTransitionDelayMs(Mode_t from, Mode_t to) { - return 25000; -} - -ReturnValue_t MGMHandlerRM3100::getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) { - *switches = &switchId; - *numberOfSwitches = 1; - return HasReturnvaluesIF::RETURN_OK; -} - -ReturnValue_t MGMHandlerRM3100::handleDataReadout(const uint8_t *packet) { - /* Analyze data here. The sensor generates 24 bit signed values so we need to do some bitshift - * trickery here to calculate the raw values first */ - int32_t fieldStrengthRawX = ((packet[1] << 24) | (packet[2] << 16) | (packet[3] << 8)) >> 8; - int32_t fieldStrengthRawY = ((packet[4] << 24) | (packet[5] << 16) | (packet[6] << 8)) >> 8; - int32_t fieldStrengthRawZ = ((packet[7] << 24) | (packet[8] << 16) | (packet[3] << 8)) >> 8; - - /* Now scale to physical value in microtesla */ - float fieldStrengthX = fieldStrengthRawX * scaleFactorX; - float fieldStrengthY = fieldStrengthRawY * scaleFactorX; - float fieldStrengthZ = fieldStrengthRawZ * scaleFactorX; - -#if OBSW_VERBOSE_LEVEL >= 1 - if(debugDivider->checkAndIncrement()) { - sif::info << "MGMHandlerRM3100: Magnetic field strength in" - " microtesla:" << std::endl; - /* Set terminal to utf-8 if there is an issue with micro printout. */ - sif::info << "X: " << fieldStrengthX << " uT" << std::endl; - sif::info << "Y: " << fieldStrengthY << " uT" << std::endl; - sif::info << "Z: " << fieldStrengthZ << " uT" << std::endl; - } -#endif - - /* TODO: Sanity check on values */ - PoolReadGuard readGuard(&primaryDataset); - if(readGuard.getReadResult() == HasReturnvaluesIF::RETURN_OK) { - primaryDataset.fieldStrengthX = fieldStrengthX; - primaryDataset.fieldStrengthY = fieldStrengthY; - primaryDataset.fieldStrengthZ = fieldStrengthZ; - primaryDataset.setValidity(true, true); - } - return RETURN_OK; -} diff --git a/mission/devices/MGMHandlerRM3100.h b/mission/devices/MGMHandlerRM3100.h deleted file mode 100644 index a499c568..00000000 --- a/mission/devices/MGMHandlerRM3100.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef MISSION_DEVICES_MGMRM3100HANDLER_H_ -#define MISSION_DEVICES_MGMRM3100HANDLER_H_ - -#include "OBSWConfig.h" -#include "devices/powerSwitcherList.h" -#include "devicedefinitions/MGMHandlerRM3100Definitions.h" -#include "fsfw/devicehandlers/DeviceHandlerBase.h" - -#if OBSW_VERBOSE_LEVEL >= 1 -#include "fsfw/globalfunctions/PeriodicOperationDivider.h" -#endif - -/** - * @brief Device Handler for the RM3100 geomagnetic magnetometer sensor - * (https://www.pnicorp.com/rm3100/) - * @details - * Flight manual: - * https://egit.irs.uni-stuttgart.de/redmine/projects/eive-flight-manual/wiki/RM3100_MGM - */ -class MGMHandlerRM3100: public DeviceHandlerBase { -public: - static const uint8_t INTERFACE_ID = CLASS_ID::MGM_RM3100; - - //! [EXPORT] : [COMMENT] P1: TMRC value which was set, P2: 0 - static constexpr Event tmrcSet = event::makeEvent(SUBSYSTEM_ID::MGM_RM3100, - 0x00, severity::INFO); - - //! [EXPORT] : [COMMENT] Cycle counter set. P1: First two bytes new Cycle Count X - //! P1: Second two bytes new Cycle Count Y - //! P2: New cycle count Z - static constexpr Event cycleCountersSet = event::makeEvent( - SUBSYSTEM_ID::MGM_RM3100, 0x01, severity::INFO); - - MGMHandlerRM3100(object_id_t objectId, object_id_t deviceCommunication, - CookieIF* comCookie, uint8_t switchId); - virtual ~MGMHandlerRM3100(); - -protected: - - /* DeviceHandlerBase overrides */ - ReturnValue_t buildTransitionDeviceCommand( - DeviceCommandId_t *id) override; - void doStartUp() override; - void doShutDown() override; - ReturnValue_t buildNormalDeviceCommand( - DeviceCommandId_t *id) override; - ReturnValue_t buildCommandFromCommand( - DeviceCommandId_t deviceCommand, const uint8_t *commandData, - size_t commandDataLen) override; - ReturnValue_t scanForReply(const uint8_t *start, size_t len, - DeviceCommandId_t *foundId, size_t *foundLen) override; - ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, - const uint8_t *packet) override; - ReturnValue_t getSwitches(const uint8_t **switches, - uint8_t *numberOfSwitches) override; - - void fillCommandAndReplyMap() override; - void modeChanged(void) override; - uint32_t getTransitionDelayMs(Mode_t from, Mode_t to) override; - ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap, - LocalDataPoolManager &poolManager) override; - -private: - - enum class InternalState { - NONE, - CONFIGURE_CMM, - READ_CMM, - // The cycle count states are propably not going to be used because - // the default cycle count will be used. - STATE_CONFIGURE_CYCLE_COUNT, - STATE_READ_CYCLE_COUNT, - STATE_CONFIGURE_TMRC, - STATE_READ_TMRC, - NORMAL - }; - InternalState internalState = InternalState::NONE; - bool commandExecuted = false; - RM3100::Rm3100PrimaryDataset primaryDataset; - - uint8_t commandBuffer[10]; - uint8_t commandBufferLen = 0; - - uint8_t cmmRegValue = RM3100::CMM_VALUE; - uint8_t tmrcRegValue = RM3100::TMRC_DEFAULT_VALUE; - uint16_t cycleCountRegValueX = RM3100::CYCLE_COUNT_VALUE; - uint16_t cycleCountRegValueY = RM3100::CYCLE_COUNT_VALUE; - uint16_t cycleCountRegValueZ = RM3100::CYCLE_COUNT_VALUE; - float scaleFactorX = 1 / RM3100::DEFAULT_GAIN; - float scaleFactorY = 1 / RM3100::DEFAULT_GAIN; - float scaleFactorZ = 1 / RM3100::DEFAULT_GAIN; - - uint8_t switchId; - - ReturnValue_t handleCycleCountConfigCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData,size_t commandDataLen); - ReturnValue_t handleCycleCommand(bool oneCycleValue, - const uint8_t *commandData, size_t commandDataLen); - - ReturnValue_t handleTmrcConfigCommand(DeviceCommandId_t deviceCommand, - const uint8_t *commandData,size_t commandDataLen); - - ReturnValue_t handleDataReadout(const uint8_t* packet); -#if OBSW_VERBOSE_LEVEL >= 1 - PeriodicOperationDivider* debugDivider; -#endif -}; - -#endif /* MISSION_DEVICEHANDLING_MGMRM3100HANDLER_H_ */ diff --git a/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h b/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h deleted file mode 100644 index 08f80dd9..00000000 --- a/mission/devices/devicedefinitions/MGMHandlerRM3100Definitions.h +++ /dev/null @@ -1,132 +0,0 @@ -#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_ -#define MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_ - -#include -#include -#include -#include -#include - -namespace RM3100 { - -/* Actually 10, we round up a little bit */ -static constexpr size_t MAX_BUFFER_SIZE = 12; - -static constexpr uint8_t READ_MASK = 0x80; - -/*----------------------------------------------------------------------------*/ -/* CMM Register */ -/*----------------------------------------------------------------------------*/ -static constexpr uint8_t SET_CMM_CMZ = 1 << 6; -static constexpr uint8_t SET_CMM_CMY = 1 << 5; -static constexpr uint8_t SET_CMM_CMX = 1 << 4; -static constexpr uint8_t SET_CMM_DRDM = 1 << 2; -static constexpr uint8_t SET_CMM_START = 1; -static constexpr uint8_t CMM_REGISTER = 0x01; - -static constexpr uint8_t CMM_VALUE = SET_CMM_CMZ | SET_CMM_CMY | SET_CMM_CMX | - SET_CMM_DRDM | SET_CMM_START; - -/*----------------------------------------------------------------------------*/ -/* Cycle count register */ -/*----------------------------------------------------------------------------*/ -// Default value (200) -static constexpr uint8_t CYCLE_COUNT_VALUE = 0xC8; - -static constexpr float DEFAULT_GAIN = static_cast(CYCLE_COUNT_VALUE) / - 100 * 38; -static constexpr uint8_t CYCLE_COUNT_START_REGISTER = 0x04; - -/*----------------------------------------------------------------------------*/ -/* TMRC register */ -/*----------------------------------------------------------------------------*/ -static constexpr uint8_t TMRC_150HZ_VALUE = 0x94; -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_DEFAULT_37HZ_VALUE; - -static constexpr uint8_t MEASUREMENT_REG_START = 0x24; -static constexpr uint8_t BIST_REGISTER = 0x33; -static constexpr uint8_t DATA_READY_VAL = 0b1000'0000; -static constexpr uint8_t STATUS_REGISTER = 0x34; -static constexpr uint8_t REVID_REGISTER = 0x36; - -// Range in Microtesla. 1 T equals 10000 Gauss (for comparison with LIS3 MGM) -static constexpr uint16_t RANGE = 800; - -static constexpr DeviceCommandId_t READ_DATA = 0; - -static constexpr DeviceCommandId_t CONFIGURE_CMM = 1; -static constexpr DeviceCommandId_t READ_CMM = 2; - -static constexpr DeviceCommandId_t CONFIGURE_TMRC = 3; -static constexpr DeviceCommandId_t READ_TMRC = 4; - -static constexpr DeviceCommandId_t CONFIGURE_CYCLE_COUNT = 5; -static constexpr DeviceCommandId_t READ_CYCLE_COUNT = 6; - -class CycleCountCommand: public SerialLinkedListAdapter { -public: - CycleCountCommand(bool oneCycleCount = true): oneCycleCount(oneCycleCount) { - setLinks(oneCycleCount); - } - - ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) override { - ReturnValue_t result = SerialLinkedListAdapter::deSerialize(buffer, - size, streamEndianness); - if(oneCycleCount) { - cycleCountY = cycleCountX; - cycleCountZ = cycleCountX; - } - return result; - } - - SerializeElement cycleCountX; - SerializeElement cycleCountY; - SerializeElement cycleCountZ; - -private: - void setLinks(bool oneCycleCount) { - setStart(&cycleCountX); - if(not oneCycleCount) { - cycleCountX.setNext(&cycleCountY); - cycleCountY.setNext(&cycleCountZ); - } - } - - bool oneCycleCount; -}; - -static constexpr uint32_t MGM_DATASET_ID = READ_DATA; - -enum MgmPoolIds: lp_id_t { - FIELD_STRENGTH_X, - FIELD_STRENGTH_Y, - FIELD_STRENGTH_Z, -}; - -class Rm3100PrimaryDataset: public StaticLocalDataSet<3 * sizeof(float)> { -public: - Rm3100PrimaryDataset(HasLocalDataPoolIF* hkOwner): - StaticLocalDataSet(hkOwner, MGM_DATASET_ID) {} - - Rm3100PrimaryDataset(object_id_t mgmId): - StaticLocalDataSet(sid_t(mgmId, MGM_DATASET_ID)) {} - - // Field strengths in micro Tesla. - lp_var_t fieldStrengthX = lp_var_t(sid.objectId, - FIELD_STRENGTH_X, this); - lp_var_t fieldStrengthY = lp_var_t(sid.objectId, - FIELD_STRENGTH_Y, this); - lp_var_t fieldStrengthZ = lp_var_t(sid.objectId, - FIELD_STRENGTH_Z, this); -}; - -} - - - -#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_MGMHANDLERRM3100DEFINITIONS_H_ */ From ad052462c1b8c28db86945c1c83fa1e2143596ee Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Sep 2021 11:36:40 +0200 Subject: [PATCH 15/16] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 823c6ec5..0df8d358 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 823c6ec5fc6357d342f4d0e3edc68d89ff492b87 +Subproject commit 0df8d358020be603d0224104882951813656233a From 086d0762625a925952295a83308764f317267fb2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 16 Sep 2021 11:46:55 +0200 Subject: [PATCH 16/16] fsfw update --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 0df8d358..8f3edc90 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 0df8d358020be603d0224104882951813656233a +Subproject commit 8f3edc90ba844b9a4551bb77a71e6dcbdae6e9ee