From 981f988eed74ac6a0a8da3ab62b895d85c2e0cb3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 23 Feb 2021 16:58:22 +0100 Subject: [PATCH] more bugfixes --- linux/boardtest/SpiTestClass.cpp | 21 +++++++++++++++++++++ linux/spi/SpiComIF.cpp | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/linux/boardtest/SpiTestClass.cpp b/linux/boardtest/SpiTestClass.cpp index a0006b7d..537709fb 100644 --- a/linux/boardtest/SpiTestClass.cpp +++ b/linux/boardtest/SpiTestClass.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -44,6 +45,26 @@ ReturnValue_t SpiTestClass::performPeriodicAction() { void SpiTestClass::performRm3100Test() { /* Adapt accordingly */ uint8_t chipSelectPin = mgm1Rm3100ChipSelect; + uint32_t rm3100Speed = 3'900'000; + int rm3100mode = SPI_MODE_3; +#ifdef RASPBERRY_PI + std::string deviceName = "spidev0.0"; +#else +#endif + int fileDescriptor = 0; + + utility::UnixFileHelper fileHelper(deviceName, &fileDescriptor, O_RDWR, + "SpiComIF::initializeInterface: "); + if(fileHelper.getOpenResult()) { + sif::error << "SpiTestClass::performRm3100Test: File descriptor could not be opened!" + << std::endl; + return; + } + + int retval = ioctl(fileDescriptor, SPI_IOC_WR_MODE, rm3100Speed); + if(retval != 0) { + utility::handleIoctlError("SpiTestClass::performRm3100Test: Setting SPI mode failed!"); + } acsInit(); } diff --git a/linux/spi/SpiComIF.cpp b/linux/spi/SpiComIF.cpp index cc2d9288..7d5a5848 100644 --- a/linux/spi/SpiComIF.cpp +++ b/linux/spi/SpiComIF.cpp @@ -88,7 +88,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { return fileHelper.getOpenResult(); } - int retval = ioctl(fileDescriptor, SPI_IOC_WR_MODE, spiSpeed); + int retval = ioctl(fileDescriptor, SPI_IOC_WR_MODE, static_cast(spiMode)); if(retval != 0) { utility::handleIoctlError("SpiComIF::initializeInterface: Setting SPI mode failed!"); }