Arduino Core for STM32  1.0
SPI transaction methods

Methods for data transaction. More...

Functions

virtual uint16_t HardwareSPI::transfer (uint16_t data, bool lastByte=false)
 SPI transfer is based on a simultaneous send and receive data. More...
 
virtual uint16_t HardwareSPI::transfer16 (uint16_t data, bool lastByte=false)
 SPI transfer is based on a simultaneous send and receive data. More...
 
virtual uint32_t HardwareSPI::transfer32 (uint32_t data, bool lastByte=false)
 SPI transfer is based on a simultaneous send and receive data. More...
 
virtual bool HardwareSPI::transfer (void *buf, uint16_t count, bool lastByte=false)
 SPI transfer is based on a simultaneous send and receive data. More...
 
virtual bool HardwareSPI::write (uint16_t data, bool lastByte=false)
 Sends data using SPI periphery. More...
 
virtual bool HardwareSPI::write16 (uint16_t data, bool lastByte=false)
 Sends data using SPI periphery. More...
 
virtual bool HardwareSPI::write32 (uint32_t data, bool lastByte=false)
 Sends data using SPI periphery. More...
 
virtual uint16_t HardwareSPI::receive (bool lastByte=false)
 Receives data from SPI periphery. More...
 
virtual uint16_t HardwareSPI::receive16 (bool lastByte=false)
 Receives data from SPI periphery. More...
 
virtual uint32_t HardwareSPI::receive32 (bool lastByte=false)
 Receives data from SPI periphery. More...
 
virtual bool HardwareSPI::writeBytes (const uint8_t *data, uint32_t size, bool lastByte=false)
 Sends data using SPI periphery in blocking mode. More...
 
virtual bool HardwareSPI::writeBytesNonBlocking (const uint8_t *data, uint32_t size, bool lastByte=false)
 Sends data using SPI periphery using DMA or IT (interrupt) mode. More...
 
virtual bool HardwareSPI::transferBytes (const uint8_t *out, uint8_t *in, uint32_t size, bool lastByte=false)
 Transfers data using SPI periphery in blocking mode, it is sending and receiving data simultaneously. More...
 
virtual bool HardwareSPI::transferBytesNonBlocking (const uint8_t *out, uint8_t *in, uint32_t size, bool lastByte=false)
 Transfers data using SPI periphery using DMA or IT (interrupt) mode, it is sending and receiving data simultaneously. More...
 
virtual bool HardwareSPI::receiveBytes (uint8_t *data, uint32_t size, bool lastByte=false)
 Receives data from SPI periphery in blocking mode. More...
 
virtual bool HardwareSPI::receiveBytesNonBlocking (uint8_t *data, uint32_t size, bool lastByte=false)
 Receives data from SPI periphery in non-blocking mode using DMA or IT (interrupt) mode. More...
 

Detailed Description

Methods for data transaction.

Three types of transaction methods

See also
Optimized transaction methods

Function Documentation

◆ transfer() [1/2]

uint16_t HardwareSPI::transfer ( uint16_t  data,
bool  lastByte = false 
)
virtual

SPI transfer is based on a simultaneous send and receive data.

Parameters
data8-bit data to send. When data size (using setDataBits()) is set to 16 bits, 16-bit data are sent.
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, not only bits, but also bytes will be swapped.
Returns
Returns received 8-bit (or when data size is set to 16, then 16-bit) data.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ transfer16()

uint16_t HardwareSPI::transfer16 ( uint16_t  data,
bool  lastByte = false 
)
virtual

SPI transfer is based on a simultaneous send and receive data.

Parameters
data16-bit data to send.
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, not only bits, but also bytes will be swapped.
Returns
Returns received 16-bit data.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ transfer32()

uint32_t HardwareSPI::transfer32 ( uint32_t  data,
bool  lastByte = false 
)
virtual

SPI transfer is based on a simultaneous send and receive data.

Parameters
data32-bit data to send.
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, not only bits, but also bytes will be swapped.
Returns
Returns received 32-bit data.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ transfer() [2/2]

bool HardwareSPI::transfer ( void *  buf,
uint16_t  count,
bool  lastByte = false 
)
virtual

SPI transfer is based on a simultaneous send and receive data.

Data are transfered in blocking mode.

Parameters
bufPointer to data, that have to be sent in blocking mode.
countThe size of data in bytes (8-bits). If you are sending whole array uint32_t[5], the count parameter have to be set to 4*5 = 20.
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, only bits will be swapped. Bytes will be sent from array begin also in MSBFIST mode.
When data size (using setDataBits()) is set to 16 and count value is odd, the real count will be then count+1 and the last byte will contain random value.
Returns
Returns received 32-bit data.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ write()

bool HardwareSPI::write ( uint16_t  data,
bool  lastByte = false 
)
virtual

Sends data using SPI periphery.

If any data was received, they will be discarded. This method is faster than transfer method.

Parameters
data8-bit data to send. When data size (using setDataBits()) is set to 16 bits, 16-bit data are sent.
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, not only bits, but also bytes will be swapped.
Returns
Returns true when data has been written.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ write16()

bool HardwareSPI::write16 ( uint16_t  data,
bool  lastByte = false 
)
virtual

Sends data using SPI periphery.

If any data was received, they will be discarded. This method is faster than transfer method. data 16-bit data to send.

Parameters
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, not only bits, but also bytes will be swapped.
Returns
Returns true when data has been written.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ write32()

bool HardwareSPI::write32 ( uint32_t  data,
bool  lastByte = false 
)
virtual

Sends data using SPI periphery.

If any data was received, they will be discarded. This method is faster than transfer method. data 32-bit data to send.

Parameters
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, not only bits, but also bytes will be swapped.
Returns
Returns true when data has been written.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ receive()

uint16_t HardwareSPI::receive ( bool  lastByte = false)
virtual

Receives data from SPI periphery.

During receiving zeros will be sent when mode is set to Master. It is recommended to use available() method to check, if any data are available in FIFO buffer, else this method will wait until timeout or until receiving data. To check, if timeout elapsed, use lastTransactionStatus() method.

Parameters
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, not only bits, but also bytes will be swapped.
Returns
Returns received 8-bit (or when data size is set to 16, then 16-bit) data.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ receive16()

uint16_t HardwareSPI::receive16 ( bool  lastByte = false)
virtual

Receives data from SPI periphery.

During receiving zeros will be sent when mode is set to Master. It is recommended to use available() method to check, if any data are available in FIFO buffer, else this method will wait until timeout or until receiving data. To check, if timeout elapsed, use lastTransactionStatus() method.

Parameters
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, not only bits, but also bytes will be swapped.
Returns
Returns received 16-bit data.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ receive32()

uint32_t HardwareSPI::receive32 ( bool  lastByte = false)
virtual

Receives data from SPI periphery.

During receiving zeros will be sent when mode is set to Master. It is recommended to use available() method to check, if any data are available in FIFO buffer, else this method will wait until timeout or until receiving data. To check, if timeout elapsed, use lastTransactionStatus() method.

Parameters
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, not only bits, but also bytes will be swapped.
Returns
Returns received 32-bit data.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ writeBytes()

bool HardwareSPI::writeBytes ( const uint8_t *  data,
uint32_t  size,
bool  lastByte = false 
)
virtual

Sends data using SPI periphery in blocking mode.

If any data was received, they will be discarded. This method is faster than transfer method.

Parameters
dataPointer to data, that have to be sent in blocking mode.
sizeThe size of data in bytes (8-bits).
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, only bits will be swapped. Bytes will be sent from array begin also in MSBFIST mode.
When data size (using setDataBits()) is set to 16 and count value is odd, the real count will be then count+1 and the last byte will contain random value.
Returns
Returns true when data has been written.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ writeBytesNonBlocking()

bool HardwareSPI::writeBytesNonBlocking ( const uint8_t *  data,
uint32_t  size,
bool  lastByte = false 
)
virtual

Sends data using SPI periphery using DMA or IT (interrupt) mode.

If any data was received, they will be discarded. This method is faster than transfer method.

Parameters
dataPointer to data, that have to be sent in non-blocking mode.
sizeThe size of data in bytes (8-bits).
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, only bits will be swapped. Bytes will be sent from array begin also in MSBFIST mode.
When data size (using setDataBits()) is set to 16 and count value is odd, the real count will be then count+1 and the last byte will contain random value.
Warning
Data have to be available on same pointer until they are sent.
Returns
Returns true when data has been written.
Here is the call graph for this function:

◆ transferBytes()

bool HardwareSPI::transferBytes ( const uint8_t *  out,
uint8_t *  in,
uint32_t  size,
bool  lastByte = false 
)
virtual

Transfers data using SPI periphery in blocking mode, it is sending and receiving data simultaneously.

Parameters
outPointer to data, that have to be sent in blocking mode.
inPointer to array, where will be stored received data. It can also pointing same address as out parameter without any error.
sizeThe size of data in bytes (8-bits). Out and in parameter must have same size.
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, only bits will be swapped. Bytes will be sent from array begin also in MSBFIST mode.
When data size (using setDataBits()) is set to 16 and count value is odd, the real count will be then count+1 and the last byte will contain random value.
Returns
Returns true when data has been transfered.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ transferBytesNonBlocking()

bool HardwareSPI::transferBytesNonBlocking ( const uint8_t *  out,
uint8_t *  in,
uint32_t  size,
bool  lastByte = false 
)
virtual

Transfers data using SPI periphery using DMA or IT (interrupt) mode, it is sending and receiving data simultaneously.

Parameters
outPointer to data, that have to be sent in non-blocking mode.
inPointer to array, where will be stored received data. It can also pointing same address as out parameter without any error.
sizeThe size of data in bytes (8-bits). Out and in parameter must have same size.
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, only bits will be swapped. Bytes will be sent from array begin also in MSBFIST mode.
When data size (using setDataBits()) is set to 16 and count value is odd, the real count will be then count+1 and the last byte will contain random value.
Warning
Out and In data have to be available on same pointer until they are transfered.
Returns
Returns true when data has been transfered.
Here is the call graph for this function:

◆ receiveBytes()

bool HardwareSPI::receiveBytes ( uint8_t *  data,
uint32_t  size,
bool  lastByte = false 
)
virtual

Receives data from SPI periphery in blocking mode.

During receiving zeros will be sent when mode is set to Master. It is recommended to use available() method to check, if any data are available in FIFO buffer, else this method will wait until timeout or until receiving data. To check, if timeout elapsed, use lastTransactionStatus() method.

Parameters
dataPointer to array, where will be stored received data.
sizeThe size of data in bytes (8-bits).
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, only bits will be swapped. Bytes will be sent from array begin also in MSBFIST mode.
Returns
Returns true when data has been received.

Reimplemented in HardwareSPI_O.

Here is the call graph for this function:

◆ receiveBytesNonBlocking()

bool HardwareSPI::receiveBytesNonBlocking ( uint8_t *  data,
uint32_t  size,
bool  lastByte = false 
)
virtual

Receives data from SPI periphery in non-blocking mode using DMA or IT (interrupt) mode.

During receiving zeros will be sent when mode is set to Master. It is recommended to use available() method to check, if any data are available in FIFO buffer, else this method will wait until timeout or until receiving data. To check, if timeout elapsed, use lastTransactionStatus() method.

Parameters
dataPointer to array, where will be stored received data.
sizeThe size of data in bytes (8-bits).
lastByteUnused in HardwareSPI.
Note
When you have changed bit order to MSBFIRST, only bits will be swapped. Bytes will be sent from array begin also in MSBFIST mode.
Warning
Data have to be available on same pointer until they are received.
Returns
Returns true when data has been received.
Here is the call graph for this function: