This repository has been archived on 2021-11-24. You can view files and clone it, but cannot push or open issues or pull requests.
fsfw_example_public/common/stm32_nucleo/STM32TestTask.cpp

42 lines
1.1 KiB
C++
Raw Normal View History

2021-05-31 17:08:08 +02:00
#include "STM32TestTask.h"
#include "stm32h7xx_nucleo.h"
#include "OBSWConfig.h"
2021-04-27 17:22:34 +02:00
2021-05-31 20:40:58 +02:00
#include "fsfw_hal/stm32h7/devicetest/GyroL3GD20H.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
2021-04-27 17:22:34 +02:00
STM32TestTask::STM32TestTask(object_id_t objectId, bool enablePrintout,
bool blinkyLed): TestTask(objectId, enablePrintout),
blinkyLed(blinkyLed) {
}
ReturnValue_t STM32TestTask::performPeriodicAction() {
if(blinkyLed) {
#if OBSW_ETHERNET_USE_LEDS == 0
BSP_LED_Toggle(LED1);
BSP_LED_Toggle(LED2);
#endif
BSP_LED_Toggle(LED3);
}
2021-06-10 14:19:26 +02:00
if(gyro != nullptr) {
gyro->performOperation();
}
2021-04-27 17:22:34 +02:00
return TestTask::performPeriodicAction();
}
2021-05-31 17:01:11 +02:00
ReturnValue_t STM32TestTask::performOneShotAction() {
2021-06-10 12:06:51 +02:00
// Might be confusing but if this is defined to 1, the real device handler is tested and we
// should not mess with the SPI bus
#if OBSW_PERFORM_L3GD20H_TEST == 0
performSpiL3gd20hTest();
#endif
2021-05-31 17:01:11 +02:00
return HasReturnvaluesIF::RETURN_OK;
}
2021-05-31 20:40:58 +02:00
void STM32TestTask::performSpiL3gd20hTest() {
2021-06-10 19:09:56 +02:00
gyro = new GyroL3GD20H(&spiHandle, spi::TransferModes::DMA);
2021-06-10 14:19:26 +02:00
gyro->initialize();
gyro->performOperation();
2021-05-31 20:40:58 +02:00
}