Spi COM IF update #7

Merged
meierj merged 15 commits from mueller/master into master 2021-05-27 13:47:27 +02:00
3 changed files with 32 additions and 8 deletions
Showing only changes of commit 3c19e0f9eb - Show all commits

View File

@ -50,7 +50,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

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

@ -6,6 +6,17 @@
#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 +43,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 +65,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);
/**