From 39cbba36851a4838c975d06a29460b43493489a1 Mon Sep 17 00:00:00 2001 From: morris Date: Wed, 28 Aug 2024 15:25:58 +0800 Subject: [PATCH] change(gdma): deprecate legacy API gdma_new_channel() is replaced by gdma_new_ahb_channel() and gdma_new_axi_channel() --- .../driver/uart/hci_driver_uart_dma.c | 4 +-- components/driver/deprecated/adc_dma_legacy.c | 2 +- components/driver/deprecated/i2s_legacy.c | 4 +-- components/esp_adc/gdma/adc_dma.c | 2 +- components/esp_driver_i2s/i2s_common.c | 4 +-- .../dma/include/esp_private/gdma.h | 34 +++++++++---------- .../main/main.c | 4 +-- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/components/bt/porting/transport/driver/uart/hci_driver_uart_dma.c b/components/bt/porting/transport/driver/uart/hci_driver_uart_dma.c index 3111a7cea3..1a12317e91 100644 --- a/components/bt/porting/transport/driver/uart/hci_driver_uart_dma.c +++ b/components/bt/porting/transport/driver/uart/hci_driver_uart_dma.c @@ -444,13 +444,13 @@ static void hci_driver_uart_dma_install(void) .direction = GDMA_CHANNEL_DIRECTION_TX, }; - ESP_ERROR_CHECK(gdma_new_channel(&tx_channel_config, &s_tx_channel)); + ESP_ERROR_CHECK(gdma_new_ahb_channel(&tx_channel_config, &s_tx_channel)); gdma_channel_alloc_config_t rx_channel_config = { .direction = GDMA_CHANNEL_DIRECTION_RX, .sibling_chan = s_tx_channel, }; - ESP_ERROR_CHECK(gdma_new_channel(&rx_channel_config, &s_rx_channel)); + ESP_ERROR_CHECK(gdma_new_ahb_channel(&rx_channel_config, &s_rx_channel)); gdma_connect(s_tx_channel, GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_UHCI, 0)); gdma_connect(s_rx_channel, GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_UHCI, 0)); gdma_strategy_config_t strategy_config = { diff --git a/components/driver/deprecated/adc_dma_legacy.c b/components/driver/deprecated/adc_dma_legacy.c index a2e2a2dc0e..0106088ed8 100644 --- a/components/driver/deprecated/adc_dma_legacy.c +++ b/components/driver/deprecated/adc_dma_legacy.c @@ -290,7 +290,7 @@ esp_err_t adc_digi_initialize(const adc_digi_init_config_t *init_config) gdma_channel_alloc_config_t rx_alloc_config = { .direction = GDMA_CHANNEL_DIRECTION_RX, }; - ret = gdma_new_channel(&rx_alloc_config, &s_adc_digi_ctx->rx_dma_channel); + ret = gdma_new_ahb_channel(&rx_alloc_config, &s_adc_digi_ctx->rx_dma_channel); if (ret != ESP_OK) { goto cleanup; } diff --git a/components/driver/deprecated/i2s_legacy.c b/components/driver/deprecated/i2s_legacy.c index 1f54c9cf06..36996697b2 100644 --- a/components/driver/deprecated/i2s_legacy.c +++ b/components/driver/deprecated/i2s_legacy.c @@ -371,7 +371,7 @@ static esp_err_t i2s_dma_intr_init(i2s_port_t i2s_num, int intr_flag) if (p_i2s[i2s_num]->dir & I2S_DIR_TX) { dma_cfg.direction = GDMA_CHANNEL_DIRECTION_TX; /* Register a new GDMA tx channel */ - ESP_RETURN_ON_ERROR(gdma_new_channel(&dma_cfg, &p_i2s[i2s_num]->tx_dma_chan), TAG, "Register tx dma channel error"); + ESP_RETURN_ON_ERROR(gdma_new_ahb_channel(&dma_cfg, &p_i2s[i2s_num]->tx_dma_chan), TAG, "Register tx dma channel error"); ESP_RETURN_ON_ERROR(gdma_connect(p_i2s[i2s_num]->tx_dma_chan, trig), TAG, "Connect tx dma channel error"); gdma_tx_event_callbacks_t cb = {.on_trans_eof = i2s_dma_tx_callback}; /* Set callback function for GDMA, the interrupt is triggered by GDMA, then the GDMA ISR will call the callback function */ @@ -380,7 +380,7 @@ static esp_err_t i2s_dma_intr_init(i2s_port_t i2s_num, int intr_flag) if (p_i2s[i2s_num]->dir & I2S_DIR_RX) { dma_cfg.direction = GDMA_CHANNEL_DIRECTION_RX; /* Register a new GDMA rx channel */ - ESP_RETURN_ON_ERROR(gdma_new_channel(&dma_cfg, &p_i2s[i2s_num]->rx_dma_chan), TAG, "Register rx dma channel error"); + ESP_RETURN_ON_ERROR(gdma_new_ahb_channel(&dma_cfg, &p_i2s[i2s_num]->rx_dma_chan), TAG, "Register rx dma channel error"); ESP_RETURN_ON_ERROR(gdma_connect(p_i2s[i2s_num]->rx_dma_chan, trig), TAG, "Connect rx dma channel error"); gdma_rx_event_callbacks_t cb = {.on_recv_eof = i2s_dma_rx_callback}; /* Set callback function for GDMA, the interrupt is triggered by GDMA, then the GDMA ISR will call the callback function */ diff --git a/components/esp_adc/gdma/adc_dma.c b/components/esp_adc/gdma/adc_dma.c index 7e5e33343d..ff5ef61933 100644 --- a/components/esp_adc/gdma/adc_dma.c +++ b/components/esp_adc/gdma/adc_dma.c @@ -31,7 +31,7 @@ esp_err_t adc_dma_init(adc_dma_t *adc_dma) gdma_channel_alloc_config_t rx_alloc_config = { .direction = GDMA_CHANNEL_DIRECTION_RX, }; - ret = gdma_new_channel(&rx_alloc_config, &(adc_dma->gdma_chan)); + ret = gdma_new_ahb_channel(&rx_alloc_config, &(adc_dma->gdma_chan)); if (ret != ESP_OK) { return ret; } diff --git a/components/esp_driver_i2s/i2s_common.c b/components/esp_driver_i2s/i2s_common.c index cae8b50708..964bbbe3e5 100644 --- a/components/esp_driver_i2s/i2s_common.c +++ b/components/esp_driver_i2s/i2s_common.c @@ -727,7 +727,7 @@ esp_err_t i2s_init_dma_intr(i2s_chan_handle_t handle, int intr_flag) if (handle->dir == I2S_DIR_TX) { dma_cfg.direction = GDMA_CHANNEL_DIRECTION_TX; /* Register a new GDMA tx channel */ - ESP_RETURN_ON_ERROR(gdma_new_channel(&dma_cfg, &handle->dma.dma_chan), TAG, "Register tx dma channel error"); + ESP_RETURN_ON_ERROR(gdma_new_ahb_channel(&dma_cfg, &handle->dma.dma_chan), TAG, "Register tx dma channel error"); ESP_GOTO_ON_ERROR(gdma_connect(handle->dma.dma_chan, trig), err1, TAG, "Connect tx dma channel error"); gdma_tx_event_callbacks_t cb = {.on_trans_eof = i2s_dma_tx_callback}; /* Set callback function for GDMA, the interrupt is triggered by GDMA, then the GDMA ISR will call the callback function */ @@ -735,7 +735,7 @@ esp_err_t i2s_init_dma_intr(i2s_chan_handle_t handle, int intr_flag) } else { dma_cfg.direction = GDMA_CHANNEL_DIRECTION_RX; /* Register a new GDMA rx channel */ - ESP_RETURN_ON_ERROR(gdma_new_channel(&dma_cfg, &handle->dma.dma_chan), TAG, "Register rx dma channel error"); + ESP_RETURN_ON_ERROR(gdma_new_ahb_channel(&dma_cfg, &handle->dma.dma_chan), TAG, "Register rx dma channel error"); ESP_GOTO_ON_ERROR(gdma_connect(handle->dma.dma_chan, trig), err1, TAG, "Connect rx dma channel error"); gdma_rx_event_callbacks_t cb = {.on_recv_eof = i2s_dma_rx_callback}; /* Set callback function for GDMA, the interrupt is triggered by GDMA, then the GDMA ISR will call the callback function */ diff --git a/components/esp_hw_support/dma/include/esp_private/gdma.h b/components/esp_hw_support/dma/include/esp_private/gdma.h index a028760340..778f87a2bb 100644 --- a/components/esp_hw_support/dma/include/esp_private/gdma.h +++ b/components/esp_hw_support/dma/include/esp_private/gdma.h @@ -109,22 +109,6 @@ typedef struct { bool eof_till_data_popped; /*!< If set / clear, DMA channel out_eof event is triggered on out / in DMA hardware fifo */ } gdma_strategy_config_t; -/** @cond */ -/** - * @brief Create GDMA channel (only create AHB GDMA channel) - * @note This API is going to be deprecated, please use `gdma_new_ahb_channel` or `gdma_new_axi_channel` instead. - * - * @param[in] config Pointer to a collection of configurations for allocating GDMA channel - * @param[out] ret_chan Returned channel handle - * @return - * - ESP_OK: Create DMA channel successfully - * - ESP_ERR_INVALID_ARG: Create DMA channel failed because of invalid argument - * - ESP_ERR_NO_MEM: Create DMA channel failed because out of memory - * - ESP_FAIL: Create DMA channel failed because of other error - */ -esp_err_t gdma_new_channel(const gdma_channel_alloc_config_t *config, gdma_channel_handle_t *ret_chan); -/** @endcond */ - /** * @brief Create AHB-GDMA channel * @note This API won't install interrupt service for the allocated channel. @@ -475,9 +459,24 @@ esp_err_t gdma_crc_get_result(gdma_channel_handle_t dma_chan, uint32_t *result); #endif // SOC_GDMA_SUPPORT_CRC /**************************************************************************************** - * Deprecated APIs + * Deprecated APIs (will be removed in esp-idf 6.0) ****************************************************************************************/ +/** @cond */ +/** + * @brief Create GDMA channel (Legacy API) + * + * @param[in] config Pointer to a collection of configurations for allocating GDMA channel + * @param[out] ret_chan Returned channel handle + * @return + * - ESP_OK: Create DMA channel successfully + * - ESP_ERR_INVALID_ARG: Create DMA channel failed because of invalid argument + * - ESP_ERR_NO_MEM: Create DMA channel failed because out of memory + * - ESP_FAIL: Create DMA channel failed because of other error + */ +esp_err_t gdma_new_channel(const gdma_channel_alloc_config_t *config, gdma_channel_handle_t *ret_chan) +__attribute__((deprecated("please use gdma_new_ahb_channel or gdma_new_axi_channel respectively"))); + /** * @brief GDMA transfer ability * @@ -503,6 +502,7 @@ typedef struct { */ esp_err_t gdma_set_transfer_ability(gdma_channel_handle_t dma_chan, const gdma_transfer_ability_t *ability) __attribute__((deprecated("please use gdma_config_transfer instead"))); +/** @endcond */ #ifdef __cplusplus } diff --git a/examples/bluetooth/hci/controller_hci_uart_esp32c3_and_esp32s3/main/main.c b/examples/bluetooth/hci/controller_hci_uart_esp32c3_and_esp32s3/main/main.c index af6df74036..f92f78299d 100644 --- a/examples/bluetooth/hci/controller_hci_uart_esp32c3_and_esp32s3/main/main.c +++ b/examples/bluetooth/hci/controller_hci_uart_esp32c3_and_esp32s3/main/main.c @@ -218,12 +218,12 @@ void uhci_uart_install(void) .flags.reserve_sibling = 1, .direction = GDMA_CHANNEL_DIRECTION_TX, }; - ESP_ERROR_CHECK(gdma_new_channel(&tx_channel_config, &s_tx_channel)); + ESP_ERROR_CHECK(gdma_new_ahb_channel(&tx_channel_config, &s_tx_channel)); gdma_channel_alloc_config_t rx_channel_config = { .direction = GDMA_CHANNEL_DIRECTION_RX, .sibling_chan = s_tx_channel, }; - ESP_ERROR_CHECK(gdma_new_channel(&rx_channel_config, &s_rx_channel)); + ESP_ERROR_CHECK(gdma_new_ahb_channel(&rx_channel_config, &s_rx_channel)); gdma_connect(s_tx_channel, GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_UHCI, 0)); gdma_connect(s_rx_channel, GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_UHCI, 0));