EasyManua.ls Logo

Espressif ESP32-S2 - Page 387

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
handle: Device handle obtained using spi_host_add_dev
trans_desc: Pointer to variable able to contain a pointer to the description of the transac-
tion that is executed. The descriptor should not be modified until the descriptor is returned by
spi_device_get_trans_result.
ticks_to_wait: Ticks to wait until theres a returned item; use portMAX_DELAY to never
time out.
esp_err_t spi_device_transmit(spi_device_handle_t handle, spi_transaction_t *trans_desc)
Send a SPI transaction, wait for it to complete, and return the result.
This function is the equivalent of calling spi_device_queue_trans() followed by spi_device_get_trans_result().
Do not use this when there is still a transaction separately queued (started) from spi_device_queue_trans() or
polling_start/transmit that hasnt been finalized.
Note This function is not thread safe when multiple tasks access the same SPI device. Normally a device
cannot start (queue) polling and interrupt transactions simutanuously.
Return
ESP_ERR_INVALID_ARG if parameter is invalid
ESP_OK on success
Parameters
handle: Device handle obtained using spi_host_add_dev
trans_desc: Description of transaction to execute
esp_err_t spi_device_polling_start(spi_device_handle_t handle, spi_transaction_t *trans_desc,
TickType_t ticks_to_wait)
Immediately start a polling transaction.
Note Normally a device cannot start (queue) polling and interrupt transactions simutanuously. Moreover, a
device cannot start a new polling transaction if another polling transaction is not finished.
Return
ESP_ERR_INVALID_ARG if parameter is invalid. This can happen if
SPI_TRANS_CS_KEEP_ACTIVE flag is specified while the bus was not acquired
(spi_device_acquire_bus() should be called first)
ESP_ERR_TIMEOUT if the device cannot get control of the bus before ticks_to_wait expired
ESP_ERR_NO_MEM if allocating DMA-capable temporary buffer failed
ESP_ERR_INVALID_STATE if previous transactions are not finished
ESP_OK on success
Parameters
handle: Device handle obtained using spi_host_add_dev
trans_desc: Description of transaction to execute
ticks_to_wait: Ticks to wait until theres room in the queue; currently only port-
MAX_DELAY is supported.
esp_err_t spi_device_polling_end(spi_device_handle_t handle, TickType_t ticks_to_wait)
Poll until the polling transaction ends.
This routine will not return until the transaction to the given device has succesfully completed. The task is not
blocked, but actively busy-spins for the transaction to be completed.
Return
ESP_ERR_INVALID_ARG if parameter is invalid
ESP_ERR_TIMEOUT if the transaction cannot finish before ticks_to_wait expired
ESP_OK on success
Parameters
handle: Device handle obtained using spi_host_add_dev
ticks_to_wait: Ticks to wait until theres a returned item; use portMAX_DELAY to never
time out.
esp_err_t spi_device_polling_transmit(spi_device_handle_t handle, spi_transaction_t
*trans_desc)
Send a polling transaction, wait for it to complete, and return the result.
This function is the equivalent of calling spi_device_polling_start() followed by spi_device_polling_end(). Do
Espressif Systems 376
Submit Document Feedback
Release v4.4

Table of Contents