mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
spi_master: add check for 'post_cb' when flag 'SPI_DEVICE_NO_RETURN_RESULT' is set
There are two ways to know which transaction descriptor is finished, by either calling `spi_device_get_trans_result`, or getting it from `post_cb`. When `SPI_DEVICE_NO_RETURN_RESULT` is set, driver will not push finished transaction descriptors into the queue. So you can't get it from `spi_device_get_trans_result`. The only way to know this is via `post_cb`. update document for function `spi_bus_add_device`
This commit is contained in:
parent
677a0c438d
commit
5726f3d8cb
@ -166,7 +166,8 @@ typedef struct spi_device_t *spi_device_handle_t; ///< Handle for a device on a
|
||||
* @param dev_config SPI interface protocol config for the device
|
||||
* @param handle Pointer to variable to hold the device handle
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid
|
||||
* - ESP_ERR_INVALID_ARG if parameter is invalid or configuration combination is not supported (e.g.
|
||||
* `dev_config->post_cb` isn't set while flag `SPI_DEVICE_NO_RETURN_RESULT` is enabled)
|
||||
* - ESP_ERR_NOT_FOUND if host doesn't have any free CS slots
|
||||
* - ESP_ERR_NO_MEM if out of memory
|
||||
* - ESP_OK on success
|
||||
|
@ -329,6 +329,12 @@ esp_err_t spi_bus_add_device(spi_host_device_t host_id, const spi_device_interfa
|
||||
SPI_CHECK(dev_config->cs_ena_pretrans <= 1 || (dev_config->address_bits == 0 && dev_config->command_bits == 0) ||
|
||||
(dev_config->flags & SPI_DEVICE_HALFDUPLEX), "In full-duplex mode, only support cs pretrans delay = 1 and without address_bits and command_bits", ESP_ERR_INVALID_ARG);
|
||||
#endif
|
||||
|
||||
//Check post_cb status when `SPI_DEVICE_NO_RETURN_RESULT` flag is set.
|
||||
if (dev_config->flags & SPI_DEVICE_NO_RETURN_RESULT) {
|
||||
SPI_CHECK(dev_config->post_cb != NULL, "use feature flag 'SPI_DEVICE_NO_RETURN_RESULT' but no post callback function sets", ESP_ERR_INVALID_ARG);
|
||||
}
|
||||
|
||||
uint32_t lock_flag = ((dev_config->spics_io_num != -1)? SPI_BUS_LOCK_DEV_FLAG_CS_REQUIRED: 0);
|
||||
|
||||
spi_bus_lock_dev_config_t lock_config = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user