Add more options to spi_transfer
This commit is contained in:
parent
5407a673fc
commit
50e9a5fa33
@ -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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user