Compare commits

4 Commits

Author SHA1 Message Date
9e5e6da6f8 include corrections 2021-05-25 15:35:53 +02:00
c69f314441 additional doc 2021-05-25 15:34:44 +02:00
3c19e0f9eb some doc added 2021-05-25 15:33:50 +02:00
836296b3af indentation 2021-05-25 15:18:05 +02:00
4 changed files with 41 additions and 15 deletions

View File

@@ -20,8 +20,8 @@
#define FSFW_HAL_LINUX_SPI_WIRETAPPING 0
#endif
SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF): SystemObject(objectId),
gpioComIF(gpioComIF) {
SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF):
SystemObject(objectId), gpioComIF(gpioComIF) {
if(gpioComIF == nullptr) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1

View File

@@ -2,8 +2,8 @@
#define LINUX_SPI_SPICOMIF_H_
#include "spiDefinitions.h"
#include <returnvalues/classIds.h>
#include <fsfw_hal/common/gpio/GpioIF.h>
#include "returnvalues/classIds.h"
#include "../../common/gpio/GpioIF.h"
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
#include <fsfw/objectmanager/SystemObject.h>
@@ -16,7 +16,8 @@ class SpiCookie;
/**
* @brief Encapsulates access to linux SPI driver for FSFW objects
* @details
* Right now, only full-duplex SPI is supported.
* Right now, only full-duplex SPI is supported. Most device specific transfer properties
* are contained in the SPI cookie.
* @author R. Mueller
*/
class SpiComIF: public DeviceCommunicationIF, public SystemObject {
@@ -50,7 +51,7 @@ public:
/**
* Perform a regular send operation using Linux iotcl. This is public so it can be used
* in the user callback if special handling is only necessary for certain commands.
* in functions like a user callback if special handling is only necessary for certain commands.
* @param spiCookie
* @param sendData
* @param sendLen
@@ -83,7 +84,6 @@ private:
ReturnValue_t performHalfDuplexReception(SpiCookie* spiCookie);
ReturnValue_t getReadBuffer(address_t spiAddress, uint8_t** buffer);
};
#endif /* LINUX_SPI_SPICOMIF_H_ */

View File

@@ -12,18 +12,19 @@ SpiCookie::SpiCookie(address_t spiAddress, std::string spiDev, const size_t maxS
SpiCookie(spiAddress, gpio::NO_GPIO, spiDev, maxSize, spiMode, spiSpeed) {
}
SpiCookie::SpiCookie(address_t spiAddress, gpioId_t chipSelect, std::string spiDev, const size_t maxSize,
spi::SpiModes spiMode, uint32_t spiSpeed, spi::send_callback_function_t callback, void *args):
SpiCookie::SpiCookie(address_t spiAddress, gpioId_t chipSelect, std::string spiDev,
const size_t maxSize, spi::SpiModes spiMode, uint32_t spiSpeed,
spi::send_callback_function_t callback, void *args):
SpiCookie(spi::SpiComIfModes::CALLBACK, spiAddress, chipSelect, spiDev, maxSize,
spiMode, spiSpeed, callback, args) {
}
SpiCookie::SpiCookie(spi::SpiComIfModes comIfMode, address_t spiAddress, gpioId_t chipSelect,
std::string spiDev, const size_t maxSize, spi::SpiModes spiMode, uint32_t spiSpeed,
spi::send_callback_function_t callback, void* args): spiAddress(spiAddress),
chipSelectPin(chipSelect), spiDevice(spiDev), comIfMode(comIfMode),
maxSize(maxSize), spiMode(spiMode), spiSpeed(spiSpeed), sendCallback(callback),
callbackArgs(args) {
spi::send_callback_function_t callback, void* args):
spiAddress(spiAddress), chipSelectPin(chipSelect), spiDevice(spiDev),
comIfMode(comIfMode), maxSize(maxSize), spiMode(spiMode), spiSpeed(spiSpeed),
sendCallback(callback), callbackArgs(args) {
}
spi::SpiComIfModes SpiCookie::getComIfMode() const {

View File

@@ -2,10 +2,23 @@
#define LINUX_SPI_SPICOOKIE_H_
#include "spiDefinitions.h"
#include "../../common/gpio/gpioDefinitions.h"
#include <fsfw/devicehandlers/CookieIF.h>
#include <fsfw_hal/common/gpio/gpioDefinitions.h>
#include <linux/spi/spidev.h>
/**
* @brief This cookie class is passed to the SPI communication interface
* @details
* This cookie contains device specific properties like speed and SPI mode or the SPI transfer
* struct required by the Linux SPI driver. It also contains a handle to a GPIO interface
* to perform slave select switching when necessary.
*
* The user can specify gpio::NO_GPIO as the GPIO ID or use a custom send callback to meet
* special requirements like expander slave select switching (e.g. GPIO or I2C expander)
* or special timing related requirements.
*/
class SpiCookie: public CookieIF {
public:
/**
@@ -32,8 +45,14 @@ public:
* function here or by using the setter function #setCallbackMode
*/
SpiCookie(address_t spiAddress, gpioId_t chipSelect, std::string spiDev, const size_t maxSize,
spi::SpiModes spiMode, uint32_t spiSpeed, spi::send_callback_function_t callback, void *args);
spi::SpiModes spiMode, uint32_t spiSpeed, spi::send_callback_function_t callback,
void *args);
/**
* Get the callback function
* @param callback
* @param args
*/
void getCallback(spi::send_callback_function_t* callback, void** args);
address_t getSpiAddress() const;
@@ -48,6 +67,12 @@ public:
/** Enables changing the SPI mode at run-time */
void setSpiMode(spi::SpiModes newMode);
/**
* Set the SPI to callback mode and assigns the user supplied callback and an argument
* passed to the callback.
* @param callback
* @param args
*/
void setCallbackMode(spi::send_callback_function_t callback, void* args);
/**