Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of XYZ_sensor_Platform by
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_write_reg (uint8_t *pBuffer, uint8_t regAddr, DigitalInOut &ssel, uint16_t NumBytes) |
| Writes a buffer to the SPI peripheral device in 8-bit data mode using synchronous SPI communication. | |
| int | spi_read_reg (uint8_t *pBuffer, uint8_t regAddr, DigitalInOut &ssel, uint16_t NumBytes) |
| 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 | ( | 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] pBuffer pointer to the buffer to read data into. [in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. [in] NumValuesToRead number of 16-bit values to read.
- Return values:
-
0 if ok. -1 if 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.
| 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] pBuffer pointer to the buffer to read data into. [in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. [in] NumBytesToRead number of bytes to read.
- Return values:
-
0 if ok. -1 if 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.
| int spi_read_reg | ( | uint8_t * | pBuffer, |
| uint8_t | regAddr, | ||
| DigitalInOut & | ssel, | ||
| uint16_t | NumBytes | ||
| ) |
Reads a buffer from the SPI peripheral device in 8-bit data mode using synchronous SPI communication.
- Parameters:
-
[out] pBufferToRead pointer to the buffer to read data into. [in] regAddr register address to send. [in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. [in] NumBytes number of bytes to read.
- Return values:
-
0 if ok. -1 if 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.
| 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] pBufferToRead pointer to the buffer to read data into. [in] pBufferToWrite pointer to the buffer of data to send. [in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. [in] NumValues number of 16-bit values to read and write.
- Return values:
-
0 if ok. -1 if 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.
| 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] pBufferToRead pointer to the buffer to read data into. [in] pBufferToWrite pointer to the buffer of data to send. [in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. [in] NumBytes number of bytes to read and write.
- Return values:
-
0 if ok. -1 if 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.
| 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] pBuffer pointer to the buffer of data to send. [in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. [in] NumValuesToWrite number of 16-bit values to write.
- Return values:
-
0 if ok. -1 if 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.
| 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] pBuffer pointer to the buffer of data to send. [in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. [in] NumBytesToWrite number of bytes to write.
- Return values:
-
0 if ok. -1 if 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.
| int spi_write_reg | ( | uint8_t * | pBuffer, |
| uint8_t | regAddr, | ||
| DigitalInOut & | ssel, | ||
| uint16_t | NumBytes | ||
| ) |
Writes a buffer to the SPI peripheral device in 8-bit data mode using synchronous SPI communication.
- Parameters:
-
[in] pBuffer pointer to the buffer of data to send. [in] ssel GPIO of the SSEL pin of the SPI device to be used for communication. [in] NumBytesToWrite number of bytes to write.
- Return values:
-
0 if ok. -1 if 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.
Generated on Sat Jul 16 2022 03:43:28 by
1.7.2
