diff --git a/bsp_linux_board/InitMission.cpp b/bsp_linux_board/InitMission.cpp index 531f9d47..154797dc 100644 --- a/bsp_linux_board/InitMission.cpp +++ b/bsp_linux_board/InitMission.cpp @@ -125,10 +125,10 @@ void initmission::initTasks() { initmission::printAddObjectError("PUS17", objects::PUS_SERVICE_17_TEST); } -#if RPI_TEST_ACS_BOARD == 1 - FixedTimeslotTaskIF* acsTask = factory->createFixedTimeslotTask( +#if OBSW_ADD_TEST_PST == 1 + FixedTimeslotTaskIF* pstTestTask = factory->createFixedTimeslotTask( "ACS_PST", 50, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 2.0, missedDeadlineFunc); - result = pst::pollingSequenceAcsTest(acsTask); + result = pst::pollingSequenceTest(pstTestTask); if(result != HasReturnvaluesIF::RETURN_OK) { sif::warning << "initmission::initTasks: ACS PST initialization failed!" << std::endl; } @@ -170,8 +170,8 @@ void initmission::initTasks() { testTask->startTask(); #endif /* OBSW_ADD_TEST_CODE == 1 */ -#if RPI_TEST_ACS_BOARD == 1 - acsTask->startTask(); +#if OBSW_ADD_TEST_PST == 1 + pstTestTask->startTask(); #endif /* RPI_TEST_ACS_BOARD == 1 */ sif::info << "Tasks started.." << std::endl; } diff --git a/bsp_linux_board/ObjectFactory.cpp b/bsp_linux_board/ObjectFactory.cpp index 6c195b38..04dd6f18 100644 --- a/bsp_linux_board/ObjectFactory.cpp +++ b/bsp_linux_board/ObjectFactory.cpp @@ -6,7 +6,7 @@ #include "OBSWConfig.h" #include "tmtc/apid.h" #include "tmtc/pusIds.h" -#include "devices/spi.h" +#include "spiConf.h" #include #include @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -120,4 +121,13 @@ void ObjectFactory::produce(){ gyroL3gHandler->setStartUpImmediately(); #endif /* RPI_TEST_ACS_BOARD == 1 */ + +#if RPI_TEST_ADIS16507 == 1 + std::string spiDev = "/dev/spidev0.0"; + SpiCookie* spiCookie = new SpiCookie(addresses::GYRO_0_ADIS, gpioIds::GYRO_0_ADIS_CS, spiDev, + ADIS16507::MAXIMUM_REPLY_SIZE, spi::DEFAULT_ADIS16507_MODE, spi::DEFAULT_ADIS16507_SPEED, + nullptr, nullptr); + auto adisGyroHandler = new GyroADIS16507Handler(objects::GYRO_0_ADIS_HANDLER, objects::SPI_COM_IF, spiCookie); + adisGyroHandler->setStartUpImmediately(); +#endif /* RPI_TEST_ADIS16507 == 1 */ } diff --git a/bsp_linux_board/boardconfig/rpi_config.h b/bsp_linux_board/boardconfig/rpi_config.h index a9f4fd9f..31d6c157 100644 --- a/bsp_linux_board/boardconfig/rpi_config.h +++ b/bsp_linux_board/boardconfig/rpi_config.h @@ -6,6 +6,8 @@ #define RPI_ADD_GPIO_TEST 0 #define RPI_LOOPBACK_TEST_GPIO 0 +#define RPI_TEST_ADIS16507 1 + /* Only one of those 2 should be enabled! */ #define RPI_ADD_SPI_TEST 0 #define RPI_TEST_ACS_BOARD 0 diff --git a/linux/fsfwconfig/devices/spi.h b/common/config/spiConf.h similarity index 77% rename from linux/fsfwconfig/devices/spi.h rename to common/config/spiConf.h index eb17786b..2632924d 100644 --- a/linux/fsfwconfig/devices/spi.h +++ b/common/config/spiConf.h @@ -1,5 +1,5 @@ -#ifndef FSFWCONFIG_DEVICES_SPI_H_ -#define FSFWCONFIG_DEVICES_SPI_H_ +#ifndef COMMON_CONFIG_SPICONF_H_ +#define COMMON_CONFIG_SPICONF_H_ #include #include @@ -23,8 +23,9 @@ static constexpr spi::SpiModes DEFAULT_L3G_MODE = spi::SpiModes::MODE_3; static constexpr uint32_t DEFAULT_MAX_1227_SPEED = 3'900'000; static constexpr spi::SpiModes DEFAULT_MAX_1227_MODE = spi::SpiModes::MODE_3; +static constexpr uint32_t DEFAULT_ADIS16507_SPEED = 976'000; +static constexpr spi::SpiModes DEFAULT_ADIS16507_MODE = spi::SpiModes::MODE_3; + } - - -#endif /* FSFWCONFIG_DEVICES_SPI_H_ */ +#endif /* COMMON_CONFIG_SPICONF_H_ */ diff --git a/fsfw_hal b/fsfw_hal index 2fe1a668..d801319c 160000 --- a/fsfw_hal +++ b/fsfw_hal @@ -1 +1 @@ -Subproject commit 2fe1a6683606eddb76aa810f88e5cf5d8cea94e5 +Subproject commit d801319c12713d08cbdbc571ee2a922ce2f0c851 diff --git a/linux/fsfwconfig/OBSWConfig.h b/linux/fsfwconfig/OBSWConfig.h index 9426d01b..88040233 100644 --- a/linux/fsfwconfig/OBSWConfig.h +++ b/linux/fsfwconfig/OBSWConfig.h @@ -19,6 +19,8 @@ debugging. */ #define OBSW_VERBOSE_LEVEL 1 #define OBSW_PRINT_MISSED_DEADLINES 1 #define OBSW_ADD_TEST_CODE 1 +#define OBSW_ADD_TEST_PST 1 + #define TEST_LIBGPIOD 0 #define TEST_RADIATION_SENSOR_HANDLER 1 #define TEST_SUS_HANDLER 1 diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index a8c7312b..64ffb4e1 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -471,28 +471,38 @@ ReturnValue_t pst::gomspacePstInit(FixedTimeslotTaskIF *thisSequence){ thisSequence->addSlot(objects::ACU_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); + if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { + sif::error << "Initialization of GomSpace PST failed" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t pst::pollingSequenceTest(FixedTimeslotTaskIF* thisSequence) { + /* Length of a communication cycle */ + uint32_t length = thisSequence->getPeriodMs(); #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_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_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); @@ -519,18 +529,18 @@ ReturnValue_t pst::gomspacePstInit(FixedTimeslotTaskIF *thisSequence){ thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0, - DeviceHandlerIF::PERFORM_OPERATION); - thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.2, - DeviceHandlerIF::SEND_WRITE); - thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.4, - DeviceHandlerIF::GET_WRITE); - thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.6, - DeviceHandlerIF::SEND_READ); - thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.8, - DeviceHandlerIF::GET_READ); + DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.2, + DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.4, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.6, + DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::GYRO_2_L3G_HANDLER, length * 0.8, + DeviceHandlerIF::GET_READ); - thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0, + 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); @@ -540,14 +550,23 @@ ReturnValue_t pst::gomspacePstInit(FixedTimeslotTaskIF *thisSequence){ DeviceHandlerIF::SEND_READ); thisSequence->addSlot(objects::MGM_3_RM3100_HANDLER, length * 0.8, DeviceHandlerIF::GET_READ); - #endif - if (thisSequence->checkSequence() != HasReturnvaluesIF::RETURN_OK) { - sif::error << "Initialization of GomSpace PST failed" << std::endl; - return HasReturnvaluesIF::RETURN_FAILED; +#if RPI_TEST_ADIS16507 == 1 + 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); +#endif + + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; } - return HasReturnvaluesIF::RETURN_OK; + + sif::error << "PollingSequence::initialize has errors!" << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; } ReturnValue_t pst::pollingSequenceTE0720(FixedTimeslotTaskIF *thisSequence) { diff --git a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h index 73cdc0bb..e05f96aa 100644 --- a/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/linux/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -34,7 +34,7 @@ ReturnValue_t pollingSequenceInitDefault(FixedTimeslotTaskIF *thisSequence); */ ReturnValue_t gomspacePstInit(FixedTimeslotTaskIF *thisSequence); -ReturnValue_t pollingSequenceAcsTest(FixedTimeslotTaskIF* thisSequence); +ReturnValue_t pollingSequenceTest(FixedTimeslotTaskIF* thisSequence); /** * @brief This polling sequence will be created when the software is compiled for the TE0720. diff --git a/mission/devices/GyroADIS16507Handler.cpp b/mission/devices/GyroADIS16507Handler.cpp index 7fb92ce6..8e0ca077 100644 --- a/mission/devices/GyroADIS16507Handler.cpp +++ b/mission/devices/GyroADIS16507Handler.cpp @@ -6,6 +6,12 @@ GyroADIS16507Handler::GyroADIS16507Handler(object_id_t objectId, } void GyroADIS16507Handler::doStartUp() { + if(internalState == InternalState::STARTUP) { + if(commandExecuted) { + commandExecuted = false; + internalState = InternalState::IDLE; + } + } } void GyroADIS16507Handler::doShutDown() { @@ -39,3 +45,7 @@ ReturnValue_t GyroADIS16507Handler::interpretDeviceReply(DeviceCommandId_t id, void GyroADIS16507Handler::setNormalDatapoolEntriesInvalid() { } + +uint32_t GyroADIS16507Handler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { + return 5000; +} diff --git a/mission/devices/GyroADIS16507Handler.h b/mission/devices/GyroADIS16507Handler.h index 1245a5a2..f03c49fb 100644 --- a/mission/devices/GyroADIS16507Handler.h +++ b/mission/devices/GyroADIS16507Handler.h @@ -2,6 +2,7 @@ #define MISSION_DEVICES_GYROADIS16507HANDLER_H_ #include +#include "devicedefinitions/GyroADIS16507Definitions.h" class GyroADIS16507Handler: public DeviceHandlerBase { public: @@ -20,8 +21,17 @@ public: ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; void setNormalDatapoolEntriesInvalid() override; + uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; private: + + enum class InternalState { + STARTUP, + IDLE + }; + + InternalState internalState = InternalState::STARTUP; + bool commandExecuted = false; }; diff --git a/mission/devices/devicedefinitions/GyroADIS16507Definitions.h b/mission/devices/devicedefinitions/GyroADIS16507Definitions.h index da791b75..311fd8bc 100644 --- a/mission/devices/devicedefinitions/GyroADIS16507Definitions.h +++ b/mission/devices/devicedefinitions/GyroADIS16507Definitions.h @@ -1,8 +1,11 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ +#include + namespace ADIS16507 { +static constexpr size_t MAXIMUM_REPLY_SIZE = 64; } #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GYROADIS16507DEFINITIONS_H_ */