Skip to content
Snippets Groups Projects
Commit 50e9a5fa authored by Gregory Nutt's avatar Gregory Nutt
Browse files

Add more options to spi_transfer

parent 5407a673
No related branches found
No related tags found
No related merge requests found
......@@ -39,6 +39,7 @@
#include <nuttx/config.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <debug.h>
......@@ -48,22 +49,6 @@
#ifdef CONFIG_SPI_EXCHANGE
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
......@@ -142,9 +127,27 @@ int spi_transfer(FAR struct spi_dev_s *spi, FAR struct spi_sequence_s *seq)
}
#endif
/* [Re-]select the SPI device in preparation for the transfer */
SPI_SELECT(spi, seq->dev, true);
/* Perform the transfer */
SPI_EXCHANGE(spi, trans->txbuffer, trans->rxbuffer, trans->nwords);
/* Possibly de-select the SPI device after the transfer */
if (trans->deselect)
{
SPI_SELECT(spi, seq->dev, false);
}
/* Perform any requested inter-transfer delay */
if (trans->delay > 0)
{
usleep(trans->delay);
}
}
SPI_SELECT(spi, seq->dev, false);
......
......@@ -76,12 +76,14 @@ struct spi_trans_s
{
/* SPI attributes for unique to this transaction */
bool deselect; /* De-select after transfer */
#ifdef CONFIG_SPI_CMDDATA
bool cmd; /* true=command; false=data */
#endif
#ifdef CONFIG_SPI_HWFEATURES
spi_hwfeatures_t hwfeat; /* Hard features to enable on this transfer */
#endif
uint32_t delay; /* Microsecond delay after transfer */
/* These describe the single data transfer */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment