Generic mbed Extensions used by STM Expansion Board Firmware Packages.

Dependents:   X_NUCLEO_IKS01A1 X_NUCLEO_6180XA1 1-DoorCloser 1-DoorCloser ... more

Fork of X_NUCLEO_COMMON by ST Expansion SW Team

Embed: (wiki syntax)

« Back to documentation index

DevSPI Class Reference

DevSPI Class Reference

Helper class DevSPI providing functions for synchronous SPI communication common for a series of SPI devices. More...

#include <DevSPI.h>

Public Member Functions

int spi_write (uint8_t *pBuffer, DigitalOut &ssel, uint16_t NumBytesToWrite)
 Writes a buffer to the SPI peripheral device in 8-bit data mode using synchronous SPI communication.
int spi_read (uint8_t *pBuffer, DigitalOut &ssel, uint16_t NumBytesToRead)
 Reads a buffer from the SPI peripheral device in 8-bit data mode using synchronous SPI communication.
int spi_read_write (uint8_t *pBufferToRead, uint8_t *pBufferToWrite, DigitalOut &ssel, uint16_t NumBytes)
 Reads and write a buffer from/to the SPI peripheral device at the same time in 8-bit data mode using synchronous SPI communication.
int spi_write (uint16_t *pBuffer, DigitalOut &ssel, uint16_t NumValuesToWrite)
 Writes a buffer to the SPI peripheral device in 16-bit data mode using synchronous SPI communication.
int spi_read (uint16_t *pBuffer, DigitalOut &ssel, uint16_t NumValuesToRead)
 Reads a buffer from the SPI peripheral device in 16-bit data mode using synchronous SPI communication.
int spi_read_write (uint16_t *pBufferToRead, uint16_t *pBufferToWrite, DigitalOut &ssel, uint16_t NumValues)
 Reads and write a buffer from/to the SPI peripheral device at the same time in 16-bit data mode using synchronous SPI communication.

Detailed Description

Helper class DevSPI providing functions for synchronous SPI communication common for a series of SPI devices.

Definition at line 57 of file DevSPI.h.


Member Function Documentation

int spi_read ( uint8_t *  pBuffer,
DigitalOut &  ssel,
uint16_t  NumBytesToRead 
)

Reads a buffer from the SPI peripheral device in 8-bit data mode using synchronous SPI communication.

Parameters:
[out]pBufferpointer to the buffer to read data into.
[in]sselGPIO of the SSEL pin of the SPI device to be used for communication.
[in]NumBytesToReadnumber of bytes to read.
Return values:
0if ok.
-1if data format error.
Note:
When using the SPI in Interrupt-mode, remember to disable interrupts before calling this function and to enable them again after.

Definition at line 141 of file DevSPI.h.

int spi_read ( uint16_t *  pBuffer,
DigitalOut &  ssel,
uint16_t  NumValuesToRead 
)

Reads a buffer from the SPI peripheral device in 16-bit data mode using synchronous SPI communication.

Parameters:
[out]pBufferpointer to the buffer to read data into.
[in]sselGPIO of the SSEL pin of the SPI device to be used for communication.
[in]NumValuesToReadnumber of 16-bit values to read.
Return values:
0if ok.
-1if data format error.
Note:
When using the SPI in Interrupt-mode, remember to disable interrupts before calling this function and to enable them again after.
In order to guarantee this method to work correctly you have to pass buffers which are correctly aligned.

Definition at line 236 of file DevSPI.h.

int spi_read_write ( uint8_t *  pBufferToRead,
uint8_t *  pBufferToWrite,
DigitalOut &  ssel,
uint16_t  NumBytes 
)

Reads and write a buffer from/to the SPI peripheral device at the same time in 8-bit data mode using synchronous SPI communication.

Parameters:
[out]pBufferToReadpointer to the buffer to read data into.
[in]pBufferToWritepointer to the buffer of data to send.
[in]sselGPIO of the SSEL pin of the SPI device to be used for communication.
[in]NumBytesnumber of bytes to read and write.
Return values:
0if ok.
-1if data format error.
Note:
When using the SPI in Interrupt-mode, remember to disable interrupts before calling this function and to enable them again after.

Definition at line 172 of file DevSPI.h.

int spi_read_write ( uint16_t *  pBufferToRead,
uint16_t *  pBufferToWrite,
DigitalOut &  ssel,
uint16_t  NumValues 
)

Reads and write a buffer from/to the SPI peripheral device at the same time in 16-bit data mode using synchronous SPI communication.

Parameters:
[out]pBufferToReadpointer to the buffer to read data into.
[in]pBufferToWritepointer to the buffer of data to send.
[in]sselGPIO of the SSEL pin of the SPI device to be used for communication.
[in]NumValuesnumber of 16-bit values to read and write.
Return values:
0if ok.
-1if data format error.
Note:
When using the SPI in Interrupt-mode, remember to disable interrupts before calling this function and to enable them again after.
In order to guarantee this method to work correctly you have to pass buffers which are correctly aligned.

Definition at line 269 of file DevSPI.h.

int spi_write ( uint8_t *  pBuffer,
DigitalOut &  ssel,
uint16_t  NumBytesToWrite 
)

Writes a buffer to the SPI peripheral device in 8-bit data mode using synchronous SPI communication.

Parameters:
[in]pBufferpointer to the buffer of data to send.
[in]sselGPIO of the SSEL pin of the SPI device to be used for communication.
[in]NumBytesToWritenumber of bytes to write.
Return values:
0if ok.
-1if data format error.
Note:
When using the SPI in Interrupt-mode, remember to disable interrupts before calling this function and to enable them again after.

Definition at line 111 of file DevSPI.h.

int spi_write ( uint16_t *  pBuffer,
DigitalOut &  ssel,
uint16_t  NumValuesToWrite 
)

Writes a buffer to the SPI peripheral device in 16-bit data mode using synchronous SPI communication.

Parameters:
[in]pBufferpointer to the buffer of data to send.
[in]sselGPIO of the SSEL pin of the SPI device to be used for communication.
[in]NumValuesToWritenumber of 16-bit values to write.
Return values:
0if ok.
-1if data format error.
Note:
When using the SPI in Interrupt-mode, remember to disable interrupts before calling this function and to enable them again after.
In order to guarantee this method to work correctly you have to pass buffers which are correctly aligned.

Definition at line 204 of file DevSPI.h.