From 677a0c438d2494e17443c0e5663b4bbc9dec9ceb Mon Sep 17 00:00:00 2001 From: meawoppl Date: Sun, 12 Jun 2022 13:10:42 -0700 Subject: [PATCH] spi_master: added a device flag "SPI_DEVICE_NO_RETURN_RESULT" Add this flag to select if returning done transaction descriptors from ISR. You should get the finished transaction descriptor by the callback "post_cb" if you using this flag, if not, same as the past. Close https://github.com/espressif/esp-idf/pull/9141 --- components/driver/include/driver/spi_master.h | 2 +- components/driver/spi_master.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/driver/include/driver/spi_master.h b/components/driver/include/driver/spi_master.h index 3c599ae9e0..16c9e26e79 100644 --- a/components/driver/include/driver/spi_master.h +++ b/components/driver/include/driver/spi_master.h @@ -43,7 +43,7 @@ extern "C" */ #define SPI_DEVICE_NO_DUMMY (1<<6) #define SPI_DEVICE_DDRCLK (1<<7) - +#define SPI_DEVICE_NO_RETURN_RESULT (1<<8) ///< Don't return the descriptor to the host on completion (use post_cb to notify instead) typedef struct spi_transaction_t spi_transaction_t; typedef void(*transaction_cb_t)(spi_transaction_t *trans); diff --git a/components/driver/spi_master.c b/components/driver/spi_master.c index 0a7cac3523..c6f9d5004c 100644 --- a/components/driver/spi_master.c +++ b/components/driver/spi_master.c @@ -612,9 +612,13 @@ static void SPI_MASTER_ISR_ATTR spi_intr(void *arg) //cur_cs is changed to DEV_NUM_MAX here spi_post_trans(host); + + if (!(host->device[cs]->cfg.flags & SPI_DEVICE_NO_RETURN_RESULT)) { + //Return transaction descriptor. + xQueueSendFromISR(host->device[cs]->ret_queue, &host->cur_trans_buf, &do_yield); + } + // spi_bus_lock_bg_pause(bus_attr->lock); - //Return transaction descriptor. - xQueueSendFromISR(host->device[cs]->ret_queue, &host->cur_trans_buf, &do_yield); #ifdef CONFIG_PM_ENABLE //Release APB frequency lock esp_pm_lock_release(bus_attr->pm_lock);