From cb0fa384ca7fbc79ba416c622a904cdbc1735fb1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 Feb 2021 17:05:48 +0100 Subject: [PATCH] continued test class --- linux/boardtest/SpiTestClass.cpp | 17 +++++++++++++++-- linux/boardtest/SpiTestClass.h | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index f3baa778..1065a2f4 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -42,12 +42,22 @@ ReturnValue_t SpiTestClass::performPeriodicAction() { return HasReturnvaluesIF::RETURN_OK; } -void SpiTestClass::performRm3100Test() { +void SpiTestClass::performRm3100Test(uint8_t mgmId) { /* Configure all SPI chip selects and pull them high */ acsInit(); /* Adapt accordingly */ - uint8_t chipSelectPin = mgm1Rm3100ChipSelect; + if(mgmId != mgm1Rm3100ChipSelect or mgmId != mgm3Rm3100ChipSelect) { + sif::warning << "SpiTestClass::performRm3100Test: Invalid MGM ID!" << std::endl; + } + gpioId_t currentGpioId = 0; + uint8_t chipSelectPin = mgmId; + if(chipSelectPin == mgm1Rm3100ChipSelect) { + currentGpioId = gpioIds::MGM_1_RM3100_CS; + } + else { + currentGpioId = gpioIds::MGM_3_RM3100_CS; + } uint32_t rm3100Speed = 3'900'000; uint8_t rm3100whoAmIReg = 0b0000'1111; int rm3100mode = SPI_MODE_3; @@ -75,6 +85,9 @@ void SpiTestClass::performRm3100Test() { utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI speed failed!"); } + gpioIF->pullLow(currentGpioId); + + } void SpiTestClass::acsInit() { diff --git a/linux/boardtest/SpiTestClass.h b/linux/boardtest/SpiTestClass.h index 9ca9f963..7a7c5f4c 100644 --- a/linux/boardtest/SpiTestClass.h +++ b/linux/boardtest/SpiTestClass.h @@ -29,7 +29,7 @@ private: std::array sendBuffer; struct spi_ioc_transfer spiTransferStruct; - void performRm3100Test(); + void performRm3100Test(uint8_t mgmId); /* ACS board specific code which pulls all GPIOs high */ void acsInit();