diff --git a/bsp_stm32_freertos/core/InitMission.cpp b/bsp_stm32_freertos/core/InitMission.cpp index e4fa9da..cc2fc75 100644 --- a/bsp_stm32_freertos/core/InitMission.cpp +++ b/bsp_stm32_freertos/core/InitMission.cpp @@ -124,7 +124,7 @@ void InitMission::createTasks() { #if OBSW_ADD_DEVICE_HANDLER_DEMO == 1 FixedTimeslotTaskIF* testDevicesTask = TaskFactory::instance()->createFixedTimeslotTask( - "PST_TEST_TASK", 10, 1024 * 2, 1.0, nullptr); + "PST_TEST_TASK", 7, 1024 * 2, 1.0, nullptr); result = pst::pollingSequenceDevices(testDevicesTask); if(result != HasReturnvaluesIF::RETURN_OK) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -151,6 +151,19 @@ void InitMission::createTasks() { task::printInitError("Test Task", objects::TEST_TASK); } +#if OBSW_PERIPHERAL_PST == 1 + FixedTimeslotTaskIF* peripheralPst = TaskFactory::instance()->createFixedTimeslotTask( + "PST_PERIPHERAL_TASK", 9, 1024 * 2, 2.0, nullptr); + result = pst::pstPeripheralsTest(peripheralPst); + if(result != HasReturnvaluesIF::RETURN_OK) { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "InitMission::createTasks: Test PST initialization failed!" << std::endl; +#else + sif::printError("InitMission::createTasks: Test PST initialization faiedl!\n"); +#endif + } +#endif + #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::info << "Starting tasks.." << std::endl; #else @@ -181,6 +194,10 @@ void InitMission::createTasks() { assemblyTask->startTask(); #endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */ +#if OBSW_PERIPHERAL_PST == 1 + peripheralPst->startTask(); +#endif /* OBSW_PERIPHERAL_PST == 1 */ + testTask->startTask(); #if FSFW_CPP_OSTREAM_ENABLED == 1 diff --git a/bsp_stm32_freertos/core/ObjectFactory.cpp b/bsp_stm32_freertos/core/ObjectFactory.cpp index 3c13e22..5a4aac3 100644 --- a/bsp_stm32_freertos/core/ObjectFactory.cpp +++ b/bsp_stm32_freertos/core/ObjectFactory.cpp @@ -10,6 +10,8 @@ #include #include + + #include #include #include @@ -17,6 +19,18 @@ #include #include +#if OBSW_PERFORM_L3GD20H_TEST == 1 +#include "fsfw_hal/stm32h7/spi/SpiCookie.h" +#include "fsfw_hal/stm32h7/spi/SpiComIF.h" +#include "fsfw_hal/devicehandlers/GyroL3GD20Handler.h" + +namespace spi { +SPI_TypeDef spiDriver = {}; +SPI_HandleTypeDef spiHandle = {}; +} + +#endif + void ObjectFactory::produce(void* args) { /* Located inside GenericFactory source file */ Factory::setStaticFrameworkObjectIds(); @@ -53,4 +67,15 @@ void ObjectFactory::produce(void* args) { /* Test Device Handler */ new STM32TestTask(objects::TEST_TASK, false, true); + +#if OBSW_PERFORM_L3GD20H_TEST == 1 + + new SpiComIF(objects::SPI_COM_IF, &spi::spiDriver, &spi::spiHandle, + spi::TransferModes::POLLING); + auto spiCookie = new SpiCookie(0, spi::SpiBus::SPI_1, 3900000, spi::SpiModes::MODE_3, + GPIO_PIN_14, GPIOD, 32); + auto gyroDevice = new GyroHandlerL3GD20H(objects::SPI_DEVICE_TEST, objects::SPI_COM_IF, + spiCookie); + gyroDevice->setStartUpImmediately(); +#endif } diff --git a/bsp_stm32_freertos/fsfwconfig/OBSWConfig.h.in b/bsp_stm32_freertos/fsfwconfig/OBSWConfig.h.in index f13b47b..bae7355 100644 --- a/bsp_stm32_freertos/fsfwconfig/OBSWConfig.h.in +++ b/bsp_stm32_freertos/fsfwconfig/OBSWConfig.h.in @@ -16,6 +16,11 @@ #define OBSW_ATTEMPT_DHCP_CONN 1 +#define OBSW_PERIPHERAL_PST 0 +#define OBSW_PERFORM_SPI_TEST 0 + +#define OBSW_PERFORM_L3GD20H_TEST 0 + #if OBSW_ATTEMPT_DHCP_CONN == 0 #define MAX_DHCP_TRIES 0 #else diff --git a/bsp_stm32_freertos/fsfwconfig/objects/systemObjectList.h b/bsp_stm32_freertos/fsfwconfig/objects/systemObjectList.h index f86c899..4f47a45 100644 --- a/bsp_stm32_freertos/fsfwconfig/objects/systemObjectList.h +++ b/bsp_stm32_freertos/fsfwconfig/objects/systemObjectList.h @@ -8,6 +8,10 @@ enum mission_objects { /* 0x62 ('b') Board and mission specific objects */ UDP_BRIDGE = 0x62000300, UDP_POLLING_TASK = 0x62000400, + + SPI_COM_IF = 0x63001000, + SPI_DEVICE_TEST = 0x74001000, + /* Generic name for FSFW static ID setter */ DOWNLINK_DESTINATION = UDP_BRIDGE }; diff --git a/bsp_stm32_freertos/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp b/bsp_stm32_freertos/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp index e94b472..cb99a43 100644 --- a/bsp_stm32_freertos/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp +++ b/bsp_stm32_freertos/fsfwconfig/pollingsequence/pollingSequenceFactory.cpp @@ -2,4 +2,31 @@ * Add polling sequence initialization which are not common to every BSP here. */ #include "pollingSequenceFactory.h" +#include "OBSWConfig.h" +#include +#include + +ReturnValue_t pst::pstPeripheralsTest(FixedTimeslotTaskIF *thisSequence) { + uint32_t length = thisSequence->getPeriodMs(); + +#if OBSW_PERFORM_L3GD20H_TEST == 1 + thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0, DeviceHandlerIF::PERFORM_OPERATION); + thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.3, DeviceHandlerIF::SEND_WRITE); + thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.45 * length, + DeviceHandlerIF::GET_WRITE); + thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.6 * length, DeviceHandlerIF::SEND_READ); + thisSequence->addSlot(objects::SPI_DEVICE_TEST, 0.8 * length, DeviceHandlerIF::GET_READ); +#endif + + if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) { + return HasReturnvaluesIF::RETURN_OK; + } +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "pst::pollingSequenceInitFunction: Initialization errors!" << std::endl; +#else + sif::printError("pst::pollingSequenceInitFunction: Initialization errors!\n"); +#endif + return HasReturnvaluesIF::RETURN_FAILED; + +} diff --git a/bsp_stm32_freertos/fsfwconfig/pollingsequence/pollingSequenceFactory.h b/bsp_stm32_freertos/fsfwconfig/pollingsequence/pollingSequenceFactory.h index 1e9184d..5776a29 100644 --- a/bsp_stm32_freertos/fsfwconfig/pollingsequence/pollingSequenceFactory.h +++ b/bsp_stm32_freertos/fsfwconfig/pollingsequence/pollingSequenceFactory.h @@ -7,6 +7,7 @@ class FixedTimeslotTaskIF; namespace pst { +ReturnValue_t pstPeripheralsTest(FixedTimeslotTaskIF *thisSequence); ReturnValue_t pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence); ReturnValue_t pollingSequenceDevices(FixedTimeslotTaskIF* thisSequence); } diff --git a/common/stm32_nucleo/STM32TestTask.cpp b/common/stm32_nucleo/STM32TestTask.cpp index 6c3feb2..780034e 100644 --- a/common/stm32_nucleo/STM32TestTask.cpp +++ b/common/stm32_nucleo/STM32TestTask.cpp @@ -22,7 +22,7 @@ ReturnValue_t STM32TestTask::performPeriodicAction() { } ReturnValue_t STM32TestTask::performOneShotAction() { - performSpiL3gd20hTest(); + // performSpiL3gd20hTest(); return HasReturnvaluesIF::RETURN_OK; }