From bf8f3db41c5af69f0ff06effae307f4d3088da65 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 25 May 2021 12:14:22 +0200 Subject: [PATCH] some tweaks to make callback usage more easy --- linux/spi/SpiComIF.cpp | 12 +++++++++++- linux/spi/SpiComIF.h | 8 ++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/linux/spi/SpiComIF.cpp b/linux/spi/SpiComIF.cpp index 68ae6da..abc272f 100644 --- a/linux/spi/SpiComIF.cpp +++ b/linux/spi/SpiComIF.cpp @@ -344,7 +344,13 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer, return HasReturnvaluesIF::RETURN_OK; } -MutexIF* SpiComIF::getMutex() { +MutexIF* SpiComIF::getMutex(MutexIF::TimeoutType* timeoutType, uint32_t* timeoutMs) { + if(timeoutType != nullptr) { + *timeoutType = this->timeoutType; + } + if(timeoutMs != nullptr) { + *timeoutMs = this->timeoutMs; + } return spiMutex; } @@ -362,6 +368,10 @@ ReturnValue_t SpiComIF::getReadBuffer(address_t spiAddress, uint8_t** buffer) { return HasReturnvaluesIF::RETURN_OK; } +GpioIF* SpiComIF::getGpioInterface() { + return gpioComIF; +} + void SpiComIF::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) { int retval = ioctl(spiFd, SPI_IOC_WR_MODE, reinterpret_cast(&mode)); if(retval != 0) { diff --git a/linux/spi/SpiComIF.h b/linux/spi/SpiComIF.h index 8978b78..67d2991 100644 --- a/linux/spi/SpiComIF.h +++ b/linux/spi/SpiComIF.h @@ -46,7 +46,7 @@ public: * @brief This function returns the mutex which can be used to protect the spi bus when * the chip select must be driven from outside of the com if. */ - MutexIF* getMutex(); + MutexIF* getMutex(MutexIF::TimeoutType* timeoutType = nullptr, uint32_t* timeoutMs = nullptr); /** * Perform a regular send operation using Linux iotcl. This is public so it can be used @@ -58,6 +58,10 @@ public: */ ReturnValue_t performRegularSendOperation(SpiCookie* spiCookie, const uint8_t *sendData, size_t sendLen); + + GpioIF* getGpioInterface(); + void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); + private: struct SpiInstance { @@ -78,7 +82,7 @@ private: ReturnValue_t performHalfDuplexReception(SpiCookie* spiCookie); ReturnValue_t getReadBuffer(address_t spiAddress, uint8_t** buffer); - void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); + }; #endif /* LINUX_SPI_SPICOMIF_H_ */