Merge pull request 'HAL Linux SPI: set transfer size to 0, better name' (#475) from eive/fsfw:mueller/hal-spi-improvement into development
Reviewed-on: fsfw/fsfw#475
This commit is contained in:
commit
01c833f001
@ -15,11 +15,6 @@
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
/* Can be used for low-level debugging of the SPI bus */
|
|
||||||
#ifndef FSFW_HAL_LINUX_SPI_WIRETAPPING
|
|
||||||
#define FSFW_HAL_LINUX_SPI_WIRETAPPING 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF):
|
SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF):
|
||||||
SystemObject(objectId), gpioComIF(gpioComIF) {
|
SystemObject(objectId), gpioComIF(gpioComIF) {
|
||||||
if(gpioComIF == nullptr) {
|
if(gpioComIF == nullptr) {
|
||||||
@ -193,7 +188,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie *spiCookie, const
|
|||||||
spiCookie->getSpiParameters(spiMode, spiSpeed, nullptr);
|
spiCookie->getSpiParameters(spiMode, spiSpeed, nullptr);
|
||||||
setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
|
setSpiSpeedAndMode(fileDescriptor, spiMode, spiSpeed);
|
||||||
spiCookie->assignWriteBuffer(sendData);
|
spiCookie->assignWriteBuffer(sendData);
|
||||||
spiCookie->assignTransferSize(sendLen);
|
spiCookie->setTransferSize(sendLen);
|
||||||
|
|
||||||
bool fullDuplex = spiCookie->isFullDuplex();
|
bool fullDuplex = spiCookie->isFullDuplex();
|
||||||
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
||||||
@ -335,6 +330,7 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
|||||||
|
|
||||||
*buffer = rxBuf;
|
*buffer = rxBuf;
|
||||||
*size = spiCookie->getCurrentTransferSize();
|
*size = spiCookie->getCurrentTransferSize();
|
||||||
|
spiCookie->setTransferSize(0);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef LINUX_SPI_SPICOMIF_H_
|
#ifndef LINUX_SPI_SPICOMIF_H_
|
||||||
#define LINUX_SPI_SPICOMIF_H_
|
#define LINUX_SPI_SPICOMIF_H_
|
||||||
|
|
||||||
|
#include "fsfw/FSFW.h"
|
||||||
#include "spiDefinitions.h"
|
#include "spiDefinitions.h"
|
||||||
#include "returnvalues/classIds.h"
|
#include "returnvalues/classIds.h"
|
||||||
#include "fsfw_hal/common/gpio/GpioIF.h"
|
#include "fsfw_hal/common/gpio/GpioIF.h"
|
||||||
|
@ -121,7 +121,7 @@ bool SpiCookie::isFullDuplex() const {
|
|||||||
return not this->halfDuplex;
|
return not this->halfDuplex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpiCookie::assignTransferSize(size_t transferSize) {
|
void SpiCookie::setTransferSize(size_t transferSize) {
|
||||||
spiTransferStruct.len = transferSize;
|
spiTransferStruct.len = transferSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,10 +103,10 @@ public:
|
|||||||
void assignReadBuffer(uint8_t* rx);
|
void assignReadBuffer(uint8_t* rx);
|
||||||
void assignWriteBuffer(const uint8_t* tx);
|
void assignWriteBuffer(const uint8_t* tx);
|
||||||
/**
|
/**
|
||||||
* Assign size for the next transfer.
|
* Set size for the next transfer. Set to 0 for no transfer
|
||||||
* @param transferSize
|
* @param transferSize
|
||||||
*/
|
*/
|
||||||
void assignTransferSize(size_t transferSize);
|
void setTransferSize(size_t transferSize);
|
||||||
size_t getCurrentTransferSize() const;
|
size_t getCurrentTransferSize() const;
|
||||||
|
|
||||||
struct UncommonParameters {
|
struct UncommonParameters {
|
||||||
@ -158,8 +158,6 @@ private:
|
|||||||
std::string spiDev, const size_t maxSize, spi::SpiModes spiMode, uint32_t spiSpeed,
|
std::string spiDev, const size_t maxSize, spi::SpiModes spiMode, uint32_t spiSpeed,
|
||||||
spi::send_callback_function_t callback, void* args);
|
spi::send_callback_function_t callback, void* args);
|
||||||
|
|
||||||
size_t currentTransferSize = 0;
|
|
||||||
|
|
||||||
address_t spiAddress;
|
address_t spiAddress;
|
||||||
gpioId_t chipSelectPin;
|
gpioId_t chipSelectPin;
|
||||||
std::string spiDevice;
|
std::string spiDevice;
|
||||||
|
Loading…
Reference in New Issue
Block a user