Chapter 2. API Reference
• config: Configuration for the SPI Slave HD driver
esp_err_t spi_slave_hd_deinit(spi_host_device_t host_id)
Deinitialize the SPI Slave HD driver.
Return
• ESP_OK: on success
• ESP_ERR_INVALID_ARG: if the host_id is not correct
Parameters
• host_id: The host to deinitialize the driver
esp_err_t spi_slave_hd_queue_trans(spi_host_device_t host_id, spi_slave_chan_t chan,
spi_slave_hd_data_t *trans, TickType_t timeout)
Queue transactions (segment mode)
Return
• ESP_OK: on success
• ESP_ERR_INVALID_ARG: The input argument is invalid. Can be the following reason:
– The buffer given is not DMA capable
– The length of data is invalid (not larger than 0, or exceed the max transfer length)
– The transaction direction is invalid
• ESP_ERR_TIMEOUT: Cannot queue the data before timeout. Master is still processing previous
transaction.
• ESP_ERR_INVALID_STATE: Function called in invalid state. This API should be called under
segment mode.
Parameters
• host_id: Host to queue the transaction
• chan: SPI_SLAVE_CHAN_TX or SPI_SLAVE_CHAN_RX
• trans: Transaction descriptors
• timeout: Timeout before the data is queued
esp_err_t spi_slave_hd_get_trans_res(spi_host_device_t host_id, spi_slave_chan_t chan,
spi_slave_hd_data_t **out_trans, TickType_t timeout)
Get the result of a data transaction (segment mode)
Note This API should be called successfully the same times as the spi_slave_hd_queue_trans.
Return
• ESP_OK: on success
• ESP_ERR_INVALID_ARG: Function is not valid
• ESP_ERR_TIMEOUT: There’s no transaction done before timeout
• ESP_ERR_INVALID_STATE: Function called in invalid state. This API should be called under
segment mode.
Parameters
• host_id: Host to queue the transaction
• chan: Channel to get the result, SPI_SLAVE_CHAN_TX or SPI_SLAVE_CHAN_RX
• [out] out_trans: Pointer to the transaction descriptor (spi_slave_hd_data_t) passed
to the driver before. Hardware has finished this transaction. Member trans_len indicates the
actual number of bytes of received data, it’s meaningless for TX.
• timeout: Timeout before the result is got
void spi_slave_hd_read_buffer(spi_host_device_t host_id, int addr, uint8_t *out_data, size_t len)
Read the shared registers.
Parameters
• host_id: Host to read the shared registers
• addr: Address of register to read, 0 to SOC_SPI_MAXIMUM_BUFFER_SIZE-1
• [out] out_data: Output buffer to store the read data
• len: Length to read, not larger than SOC_SPI_MAXIMUM_BUFFER_SIZE-addr
void spi_slave_hd_write_buffer(spi_host_device_t host_id, int addr, uint8_t *data, size_t len)
Write the shared registers.
Parameters
• host_id: Host to write the shared registers
Espressif Systems 391
Submit Document Feedback
Release v4.4