|
IotSPIHandle_t | iot_spi_open (int32_t lSPIInstance) |
| Initializes SPI peripheral with default configuration. More...
|
|
void | iot_spi_set_callback (IotSPIHandle_t const pxSPIPeripheral, IotSPICallback_t xCallback, void *pvUserContext) |
| Sets the application callback to be called on completion of an operation. More...
|
|
int32_t | iot_spi_ioctl (IotSPIHandle_t const pxSPIPeripheral, IotSPIIoctlRequest_t xSPIRequest, void *const pvBuffer) |
| Configures the SPI port with user configuration. More...
|
|
int32_t | iot_spi_read_sync (IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvBuffer, size_t xBytes) |
| The SPI master starts reading from the slave synchronously. More...
|
|
int32_t | iot_spi_read_async (IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvBuffer, size_t xBytes) |
| The SPI master starts reading from the slave asynchronously. More...
|
|
int32_t | iot_spi_write_sync (IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvBuffer, size_t xBytes) |
| The SPI master starts transmission of data to the slave synchronously. More...
|
|
int32_t | iot_spi_write_async (IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvBuffer, size_t xBytes) |
| The SPI master starts transmission of data to the slave asynchronously. More...
|
|
int32_t | iot_spi_transfer_sync (IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvTxBuffer, uint8_t *const pvRxBuffer, size_t xBytes) |
| The SPI master starts a synchronous transfer between master and the slave. More...
|
|
int32_t | iot_spi_transfer_async (IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvTxBuffer, uint8_t *const pvRxBuffer, size_t xBytes) |
| The SPI master starts a asynchronous transfer between master and the slave. More...
|
|
int32_t | iot_spi_close (IotSPIHandle_t const pxSPIPeripheral) |
| Stops the ongoing operation on SPI bus and de-initializes the SPI peripheral. More...
|
|
int32_t | iot_spi_cancel (IotSPIHandle_t const pxSPIPeripheral) |
| This function is used to cancel the current operation in progress, if the underlying driver allows the cancellation. More...
|
|
int32_t | iot_spi_select_slave (int32_t lSPIInstance, int32_t lSPISlave) |
| This function is used to select spi slave. More...
|
|
int32_t iot_spi_read_async |
( |
IotSPIHandle_t const |
pxSPIPeripheral, |
|
|
uint8_t *const |
pvBuffer, |
|
|
size_t |
xBytes |
|
) |
| |
The SPI master starts reading from the slave asynchronously.
This function attempts to read certain number of bytes from a pre-allocated buffer, in asynchronous way. It returns immediately when the operation is started and the status can be check by calling iot_spi_ioctl.
Once the operation completes successfully, the user callback will be invoked. If the operation encounters an error, the user callback will be invoked. The callback is not invoked on paritial read, unless there is an error. And the number of bytes that have been actually read can be obtained by calling iot_spi_ioctl.
- Note
- Dummy data will be written to slave while reading. The dummy data value can be configured with iot_spi_ioctl.
-
In order to get notification when the asynchronous call is completed, iot_spi_set_callback must be called prior to this.
- Warning
- pvBuffer must be valid before callback is invoked.
-
None of other read or write functions shall be called during this function or before user callback.
- Parameters
-
[in] | pxSPIPeripheral | The SPI peripheral handle returned in open() call. |
[out] | pvBuffer | The buffer to store the received data. |
[in] | xBytes | The number of bytes to read. |
- Returns
- IOT_SPI_SUCCESS, on success (all the requested bytes have been read)
- IOT_SPI_INVALID_VALUE, if
- pxSPIPeripheral is NULL
- pxSPIPeripheral is not opened yet
- pucBuffer is NULL
- xBytes is 0
- IOT_SPI_READ_ERROR, if there is some unknown driver error.
- IOT_SPI_BUSY, if the bus is busy which means there is an ongoing operation.
int32_t iot_spi_write_async |
( |
IotSPIHandle_t const |
pxSPIPeripheral, |
|
|
uint8_t *const |
pvBuffer, |
|
|
size_t |
xBytes |
|
) |
| |
The SPI master starts transmission of data to the slave asynchronously.
This function attempts to read certain number of bytes from a pre-allocated buffer, in asynchronous way. It returns immediately when the operation is started and the status can be check by calling iot_spi_ioctl.
Once the operation completes successfully, the user callback will be invoked. If the operation encounters an error, the user callback will be invoked. The callback is not invoked on paritial write, unless there is an error. And the number of bytes that have been actually written can be obtained by calling iot_spi_ioctl.
- Note
- In order to get notification when the asynchronous call is completed, iot_spi_set_callback must be called prior to this.
- Warning
- pvBuffer must be valid before callback is invoked.
-
None of other read or write functions shall be called during this function or before user callback.
- Parameters
-
[in] | pxSPIPeripheral | The SPI peripheral handle returned in open() call. |
[in] | pvBuffer | The buffer with data to transmit. |
[in] | xBytes | The number of bytes to write. |
- Returns
- IOT_SPI_SUCCESS, on success (all the requested bytes have been read)
- IOT_SPI_INVALID_VALUE, if
- pxSPIPeripheral is NULL
- pxSPIPeripheral is not opened yet
- pucBuffer is NULL
- xBytes is 0
- IOT_SPI_WRITE_ERROR, if there is some unknown driver error.
- IOT_SPI_BUSY, if the bus is busy which means there is an ongoing operation.
int32_t iot_spi_transfer_async |
( |
IotSPIHandle_t const |
pxSPIPeripheral, |
|
|
uint8_t *const |
pvTxBuffer, |
|
|
uint8_t *const |
pvRxBuffer, |
|
|
size_t |
xBytes |
|
) |
| |
The SPI master starts a asynchronous transfer between master and the slave.
This function attempts to read/write certain number of bytes from/to two pre-allocated buffers at the same time, in asynchronous way. It returns immediately when the operation is started and the status can be check by calling iot_spi_ioctl.
Once the operation completes successfully, the user callback will be invoked. If the operation encounters an error, the user callback will be invoked. The callback is not invoked on paritial read/write, unless there is an error. And the number of bytes that have been actually read/write can be obtained by calling iot_spi_ioctl.
- Parameters
-
[in] | pxSPIPeripheral | The SPI peripheral handle returned in open() call. |
[in] | pvTxBuffer | The buffer to store the received data. |
[out] | pvRxBuffer | The buffer with data to transmit. |
[in] | xBytes | The number of bytes to transfer. |
- IOT_SPI_SUCCESS, on success (all the requested bytes have been read/written)
- IOT_SPI_INVALID_VALUE, if
- pxSPIPeripheral is NULL
- pxSPIPeripheral is not opened yet
- pucBuffer is NULL
- xBytes is 0
- IOT_SPI_TRANSFER_ERROR, if there is some unknown driver error.
- IOT_SPI_BUSY, if the bus is busy which means there is an ongoing opeartion.