43 lines
1.0 KiB
C++
43 lines
1.0 KiB
C++
#include "SpiTest.h"
|
|
|
|
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
|
|
|
#include <fcntl.h>
|
|
#include <sys/ioctl.h>
|
|
#include <wiringPi.h>
|
|
|
|
SpiTest::SpiTest(object_id_t objectId): SystemObject(objectId) {
|
|
wiringPiSetupGpio();
|
|
|
|
int spiFd = open(spiDeviceName.c_str(), O_RDWR);
|
|
if (spiFd < 0){
|
|
sif::error << "Could not open SPI device!" << std::endl;
|
|
}
|
|
|
|
spiMode = SPI_MODE_3;
|
|
int ret = ioctl(spiFd, SPI_IOC_WR_MODE, &spiMode);
|
|
if(ret < 0) {
|
|
sif::error << "Could not set write mode!" << std::endl;
|
|
}
|
|
|
|
/* Datenrate setzen */
|
|
ret = ioctl(spiFd, SPI_IOC_WR_MAX_SPEED_HZ, &spiSpeed);
|
|
if(ret < 0) {
|
|
sif::error << "Could not SPI speed!" << std::endl;
|
|
}
|
|
}
|
|
|
|
ReturnValue_t SpiTest::performOperation(uint8_t opCode) {
|
|
if(oneShot) {
|
|
|
|
}
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
}
|
|
|
|
ReturnValue_t SpiTest::initialize() {
|
|
//transferHandle.rx_buf = reinterpret_cast<__u64>(receiveBuffer);
|
|
//transferHandle.tx_buf = reinterpret_cast<__u64>(sendBuffer);
|
|
//transferHandle.speed_hz = 976000;
|
|
//transferHandle.len = 2;
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
} |