more bugfixes

This commit is contained in:
Robin Müller 2021-02-23 16:58:22 +01:00
parent 673cfc8747
commit 178c3e2540
2 changed files with 22 additions and 1 deletions

View File

@ -7,6 +7,7 @@
#include <fcntl.h>
#include <linux/gpio/gpioDefinitions.h>
#include <linux/gpio/GpioCookie.h>
#include <linux/utility/Utility.h>
#include <unistd.h>
#include <sys/ioctl.h>
@ -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();
}

View File

@ -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<int>(spiMode));
if(retval != 0) {
utility::handleIoctlError("SpiComIF::initializeInterface: Setting SPI mode failed!");
}