From cd92f4a6112e7e50af5916debee55e378acfcb76 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Mon, 20 Sep 2021 16:30:50 +0200 Subject: [PATCH] open gpio by label test on te0720 --- bsp_q7s/core/InitMission.cpp | 2 ++ bsp_q7s/core/ObjectFactory.cpp | 16 +++++++++---- bsp_q7s/simple/simple.cpp | 4 ++++ linux/boardtest/LibgpiodTest.cpp | 39 ++++++++++++++++++++++++++++++-- linux/boardtest/LibgpiodTest.h | 3 ++- linux/fsfwconfig/OBSWConfig.h.in | 1 + 6 files changed, 57 insertions(+), 8 deletions(-) diff --git a/bsp_q7s/core/InitMission.cpp b/bsp_q7s/core/InitMission.cpp index 5ddb6b9b..481d4060 100644 --- a/bsp_q7s/core/InitMission.cpp +++ b/bsp_q7s/core/InitMission.cpp @@ -292,10 +292,12 @@ void initmission::createTestTasks(TaskFactory& factory, TaskDeadlineMissedFuncti ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; PeriodicTaskIF* testTask = factory.createPeriodicTask( "TEST_TASK", 60, PeriodicTaskIF::MINIMUM_STACK_SIZE, 1, missedDeadlineFunc); +#if OBSW_ADD_TEST_TASK == 1 result = testTask->addComponent(objects::TEST_TASK); if(result != HasReturnvaluesIF::RETURN_OK) { initmission::printAddObjectError("TEST_TASK", objects::TEST_TASK); } +#endif /* OBSW_ADD_TEST_TASK == 1 */ #if OBSW_ADD_SPI_TEST_CODE == 1 result = testTask->addComponent(objects::SPI_TEST); diff --git a/bsp_q7s/core/ObjectFactory.cpp b/bsp_q7s/core/ObjectFactory.cpp index bdad3dac..ad452c8d 100644 --- a/bsp_q7s/core/ObjectFactory.cpp +++ b/bsp_q7s/core/ObjectFactory.cpp @@ -529,8 +529,10 @@ void ObjectFactory::createHeaterComponents() { GpioCookie* heaterGpiosCookie = new GpioCookie; /* Pin H2-11 on stack connector */ - GpiodRegular* gpioConfigHeater0 = new GpiodRegular(q7s::GPIO_HEATER_CHIP, - q7s::GPIO_HEATER_0_PIN, "Heater0", gpio::OUT, 0); + GpiodRegular* gpioConfigHeater0 = new GpiodRegular("Heater0", gpio::OUT, 0, "axi_gpio_q7_3v3", + q7s::GPIO_HEATER_0_PIN); +// GpiodRegular* gpioConfigHeater0 = new GpiodRegular(q7s::GPIO_HEATER_CHIP, +// q7s::GPIO_HEATER_0_PIN, "Heater0", gpio::OUT, 0); heaterGpiosCookie->addGpio(gpioIds::HEATER_0, gpioConfigHeater0); /* Pin H2-12 on stack connector */ @@ -822,11 +824,15 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) { #endif #if BOARD_TE0720 == 1 && OBSW_TEST_LIBGPIOD == 1 +#if OBSW_TEST_GPIO_LABEL == 1 /* Configure MIO0 as input */ - GpiodRegular gpioConfigMio0(std::string("gpiochip0"), 0, - std::string("MIO0"), gpio::IN, 0); + GpiodRegular* testGpio = new GpiodRegular("MIO0", gpio::OUT, 0, "/amba_pl/gpio@41200000", 0); +#else + /* Configure MIO0 as input */ + GpiodRegular* testGpio = new GpiodRegular("gpiochip0", 0, "MIO0", gpio::IN, 0); +#endif /* OBSW_TEST_GPIO_LABEL == 1 */ GpioCookie* gpioCookie = new GpioCookie; - gpioCookie->addGpio(gpioIds::TEST_ID_0, gpioConfigMio0); + gpioCookie->addGpio(gpioIds::TEST_ID_0, testGpio); new LibgpiodTest(objects::LIBGPIOD_TEST, objects::GPIO_IF, gpioCookie); #endif diff --git a/bsp_q7s/simple/simple.cpp b/bsp_q7s/simple/simple.cpp index a6bb9fdf..960aa7db 100644 --- a/bsp_q7s/simple/simple.cpp +++ b/bsp_q7s/simple/simple.cpp @@ -11,6 +11,10 @@ int simple::simple() { { FileSystemTest fileSystemTest; } +#endif + +#if TE0720_GPIO_TEST + #endif return 0; } diff --git a/linux/boardtest/LibgpiodTest.cpp b/linux/boardtest/LibgpiodTest.cpp index 39e863b4..8eb9b536 100644 --- a/linux/boardtest/LibgpiodTest.cpp +++ b/linux/boardtest/LibgpiodTest.cpp @@ -15,7 +15,7 @@ LibgpiodTest::LibgpiodTest(object_id_t objectId, object_id_t gpioIfobjectId, sif::error << "LibgpiodTest::LibgpiodTest: Invalid Gpio interface." << std::endl; } gpioInterface->addGpios(gpioCookie); - testCase = TestCases::LOOPBACK; + testCase = TestCases::BLINK; } LibgpiodTest::~LibgpiodTest() { @@ -29,7 +29,7 @@ ReturnValue_t LibgpiodTest::performPeriodicAction() { case(TestCases::READ): { result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); if (result != RETURN_OK) { - sif::debug << "LibgpiodTest::performPeriodicAction: Failed to read gpio " + sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " << std::endl; return RETURN_FAILED; } @@ -42,6 +42,38 @@ ReturnValue_t LibgpiodTest::performPeriodicAction() { case(TestCases::LOOPBACK): { break; } + case(TestCases::BLINK): { + result = gpioInterface->readGpio(gpioIds::TEST_ID_0, &gpioState); + if (result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Failed to read gpio " + << std::endl; + return RETURN_FAILED; + } + if (gpioState == 1) { + result = gpioInterface->pullLow(gpioIds::TEST_ID_0); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO low!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + } + else if (gpioState == 0) { + result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "LibgpiodTest::performPeriodicAction: Could not pull GPIO high!" + << std::endl; + return HasReturnvaluesIF::RETURN_FAILED; + } + } + else { + sif::warning << "LibgpiodTest::performPeriodicAction: Invalid GPIO state" << std::endl; + } + + break; + } + default: + sif::debug << "LibgpiodTest::performPeriodicAction: Invalid test case" << std::endl; + break; } @@ -56,6 +88,9 @@ ReturnValue_t LibgpiodTest::performOneShotAction() { case(TestCases::READ): { break; } + case(TestCases::BLINK): { + break; + } case(TestCases::LOOPBACK): { result = gpioInterface->pullHigh(gpioIds::TEST_ID_0); if(result == HasReturnvaluesIF::RETURN_OK) { diff --git a/linux/boardtest/LibgpiodTest.h b/linux/boardtest/LibgpiodTest.h index a18c618e..718d0209 100644 --- a/linux/boardtest/LibgpiodTest.h +++ b/linux/boardtest/LibgpiodTest.h @@ -14,7 +14,8 @@ class LibgpiodTest: public TestTask { public: enum TestCases { READ = 0, - LOOPBACK = 1 + LOOPBACK = 1, + BLINK }; TestCases testCase; diff --git a/linux/fsfwconfig/OBSWConfig.h.in b/linux/fsfwconfig/OBSWConfig.h.in index dc397635..04a9fedd 100644 --- a/linux/fsfwconfig/OBSWConfig.h.in +++ b/linux/fsfwconfig/OBSWConfig.h.in @@ -59,6 +59,7 @@ debugging. */ #define OBSW_TEST_CCSDS_BRIDGE 0 #define OBSW_TEST_CCSDS_PTME 0 #define OBSW_TEST_TE7020_HEATER 0 +#define OBSW_TEST_GPIO_LABEL 0 #define OBSW_DEBUG_P60DOCK 0 #define OBSW_DEBUG_PDU1 0