diff --git a/components/driver/CMakeLists.txt b/components/driver/CMakeLists.txt index 35630aff30..c67947fc21 100644 --- a/components/driver/CMakeLists.txt +++ b/components/driver/CMakeLists.txt @@ -10,7 +10,6 @@ set(srcs) # Always included headers set(includes "include" "deprecated" - "dac/include" "i2c/include" "ledc/include" "parlio/include" @@ -36,12 +35,7 @@ endif() # DAC related source files if(CONFIG_SOC_DAC_SUPPORTED) - list(APPEND srcs "dac/dac_oneshot.c" - "dac/dac_cosine.c" - "dac/dac_continuous.c" - "dac/dac_common.c" - "dac/${target}/dac_dma.c" - "deprecated/dac_common_legacy.c" + list(APPEND srcs "deprecated/dac_common_legacy.c" "deprecated/${target}/dac_legacy.c") endif() @@ -159,6 +153,7 @@ else() # have a public dependency on other "esp_driver_foo" components esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm esp_driver_ana_cmpr esp_driver_i2s esp_driver_sdmmc esp_driver_sdspi esp_driver_sdio + esp_driver_dac LDFRAGMENTS ${ldfragments} ) endif() diff --git a/components/driver/Kconfig b/components/driver/Kconfig index bc0eb52e2f..ba9d6b31d7 100644 --- a/components/driver/Kconfig +++ b/components/driver/Kconfig @@ -122,52 +122,6 @@ menu "Driver Configurations" orsource "./rmt/Kconfig.rmt" - menu "DAC Configuration" - depends on SOC_DAC_SUPPORTED - config DAC_CTRL_FUNC_IN_IRAM - bool "Place DAC control functions into IRAM" - default n - help - Place DAC control functions (e.g. 'dac_oneshot_output_voltage') into IRAM, - so that this function can be IRAM-safe and able to be called in the other IRAM interrupt context. - Enabling this option can improve driver performance as well. - - config DAC_ISR_IRAM_SAFE - bool "DAC ISR IRAM-Safe" - default n - help - Ensure the DAC interrupt is IRAM-Safe by allowing the interrupt handler to be - executable when the cache is disabled (e.g. SPI Flash write). - - config DAC_SUPPRESS_DEPRECATE_WARN - bool "Suppress legacy driver deprecated warning" - default n - help - Wether to suppress the deprecation warnings when using legacy DAC driver (driver/dac.h). - If you want to continue using the legacy driver, and don't want to see related deprecation warnings, - you can enable this option. - - config DAC_ENABLE_DEBUG_LOG - bool "Enable debug log" - default n - help - Wether to enable the debug log message for DAC driver. - Note that, this option only controls the DAC driver log, won't affect other drivers. - - config DAC_DMA_AUTO_16BIT_ALIGN - bool "Align the continuous data to 16 bit automatically" - depends on SOC_DAC_DMA_16BIT_ALIGN - default y - help - Whether to left shift the continuous data to align every bytes to 16 bits in the driver. - On ESP32, although the DAC resolution is only 8 bits, - the hardware requires 16 bits data in continuous mode. - By enabling this option, the driver will left shift 8 bits for the input data automatically. - Only disable this option when you decide to do this step by yourself. - Note that the driver will allocate a new piece of memory to save the converted data. - - endmenu # DAC Configuration - menu "USB Serial/JTAG Configuration" depends on SOC_USB_SERIAL_JTAG_SUPPORTED config USJ_NO_AUTO_LS_ON_CONNECTION diff --git a/components/driver/linker.lf b/components/driver/linker.lf index 490c7a89ba..728e2c34d1 100644 --- a/components/driver/linker.lf +++ b/components/driver/linker.lf @@ -3,6 +3,3 @@ archive: libdriver.a entries: if SDM_CTRL_FUNC_IN_IRAM = y: sdm: sdm_channel_set_pulse_density (noflash) - if DAC_CTRL_FUNC_IN_IRAM = y: - dac_oneshot: dac_oneshot_output_voltage (noflash) - dac_continuous: dac_continuous_write_asynchronously (noflash) diff --git a/components/driver/test_apps/.build-test-rules.yml b/components/driver/test_apps/.build-test-rules.yml index a7d41a7415..29c9e65527 100644 --- a/components/driver/test_apps/.build-test-rules.yml +++ b/components/driver/test_apps/.build-test-rules.yml @@ -1,12 +1,10 @@ # Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps -components/driver/test_apps/dac_test_apps/dac: - disable: - - if: SOC_DAC_SUPPORTED != 1 - components/driver/test_apps/dac_test_apps/legacy_dac_driver: disable: - if: SOC_DAC_SUPPORTED != 1 + depends_components: + - esp_adc components/driver/test_apps/i2c_test_apps: disable: diff --git a/components/esp_driver_dac/CMakeLists.txt b/components/esp_driver_dac/CMakeLists.txt new file mode 100644 index 0000000000..4b34f22df6 --- /dev/null +++ b/components/esp_driver_dac/CMakeLists.txt @@ -0,0 +1,32 @@ +idf_build_get_property(target IDF_TARGET) + +set(srcs) +set(priv_req esp_pm esp_driver_gpio) + +if(${target} STREQUAL "linux") + return() # This component is not supported by the POSIX/Linux simulator +elseif(${target} STREQUAL "esp32") + list(APPEND priv_req esp_driver_i2s) +elseif(${target} STREQUAL "esp32s2") + list(APPEND priv_req esp_driver_spi) +endif() + +if(CONFIG_SOC_DAC_SUPPORTED) + list(APPEND srcs "dac_oneshot.c" + "dac_cosine.c" + "dac_continuous.c" + "dac_common.c") + + if(${target} STREQUAL "esp32") + list(APPEND srcs "esp32/dac_dma.c") + elseif(${target} STREQUAL "esp32s2") + list(APPEND srcs "esp32s2/dac_dma.c") + endif() + +endif() + +idf_component_register(SRCS ${srcs} + INCLUDE_DIRS "./include" + PRIV_REQUIRES ${priv_req} + LDFRAGMENTS "linker.lf" + ) diff --git a/components/esp_driver_dac/Kconfig b/components/esp_driver_dac/Kconfig new file mode 100644 index 0000000000..a0c9c30c1d --- /dev/null +++ b/components/esp_driver_dac/Kconfig @@ -0,0 +1,45 @@ +menu "ESP-Driver:DAC Configurations" + depends on SOC_DAC_SUPPORTED + config DAC_CTRL_FUNC_IN_IRAM + bool "Place DAC control functions into IRAM" + default n + help + Place DAC control functions (e.g. 'dac_oneshot_output_voltage') into IRAM, + so that this function can be IRAM-safe and able to be called in the other IRAM interrupt context. + Enabling this option can improve driver performance as well. + + config DAC_ISR_IRAM_SAFE + bool "DAC ISR IRAM-Safe" + default n + help + Ensure the DAC interrupt is IRAM-Safe by allowing the interrupt handler to be + executable when the cache is disabled (e.g. SPI Flash write). + + config DAC_SUPPRESS_DEPRECATE_WARN + bool "Suppress legacy driver deprecated warning" + default n + help + Wether to suppress the deprecation warnings when using legacy DAC driver (driver/dac.h). + If you want to continue using the legacy driver, and don't want to see related deprecation warnings, + you can enable this option. + + config DAC_ENABLE_DEBUG_LOG + bool "Enable debug log" + default n + help + Wether to enable the debug log message for DAC driver. + Note that, this option only controls the DAC driver log, won't affect other drivers. + + config DAC_DMA_AUTO_16BIT_ALIGN + bool "Align the continuous data to 16 bit automatically" + depends on SOC_DAC_DMA_16BIT_ALIGN + default y + help + Whether to left shift the continuous data to align every bytes to 16 bits in the driver. + On ESP32, although the DAC resolution is only 8 bits, + the hardware requires 16 bits data in continuous mode. + By enabling this option, the driver will left shift 8 bits for the input data automatically. + Only disable this option when you decide to do this step by yourself. + Note that the driver will allocate a new piece of memory to save the converted data. + +endmenu # DAC Configuration diff --git a/components/driver/dac/dac_common.c b/components/esp_driver_dac/dac_common.c similarity index 100% rename from components/driver/dac/dac_common.c rename to components/esp_driver_dac/dac_common.c diff --git a/components/driver/dac/dac_continuous.c b/components/esp_driver_dac/dac_continuous.c similarity index 98% rename from components/driver/dac/dac_continuous.c rename to components/esp_driver_dac/dac_continuous.c index 98bee776ef..b3f8f9c25e 100644 --- a/components/driver/dac/dac_continuous.c +++ b/components/esp_driver_dac/dac_continuous.c @@ -194,7 +194,6 @@ static void IRAM_ATTR s_dac_default_intr_handler(void *arg) } } - esp_err_t dac_continuous_new_channels(const dac_continuous_config_t *cont_cfg, dac_continuous_handle_t *ret_handle) { #if CONFIG_DAC_ENABLE_DEBUG_LOG @@ -250,7 +249,7 @@ esp_err_t dac_continuous_new_channels(const dac_continuous_config_t *cont_cfg, d err2, TAG, "Failed to initialize DAC DMA peripheral"); /* Register DMA interrupt */ ESP_GOTO_ON_ERROR(esp_intr_alloc(dac_dma_periph_get_intr_signal(), DAC_INTR_ALLOC_FLAGS, - s_dac_default_intr_handler, handle, &(handle->intr_handle)), + s_dac_default_intr_handler, handle, &(handle->intr_handle)), err1, TAG, "Failed to register DAC DMA interrupt"); /* Connect DAC module to the DMA peripheral */ DAC_RTC_ENTER_CRITICAL(); @@ -359,7 +358,7 @@ esp_err_t dac_continuous_enable(dac_continuous_handle_t handle) esp_err_t ret = ESP_OK; /* Reset the descriptor pool */ xQueueReset(handle->desc_pool); - for ( int i = 0; i < handle->cfg.desc_num; i++) { + for (int i = 0; i < handle->cfg.desc_num; i++) { ESP_GOTO_ON_FALSE(xQueueSend(handle->desc_pool, &handle->desc[i], 0) == pdTRUE, ESP_ERR_INVALID_STATE, err, TAG, "the descriptor pool is not cleared"); } @@ -475,8 +474,8 @@ static size_t s_dac_load_data_into_buf(dac_continuous_handle_t handle, uint8_t * } esp_err_t dac_continuous_write_asynchronously(dac_continuous_handle_t handle, uint8_t *dma_buf, - size_t dma_buf_len, const uint8_t *data, - size_t data_len, size_t *bytes_loaded) + size_t dma_buf_len, const uint8_t *data, + size_t data_len, size_t *bytes_loaded) { DAC_NULL_POINTER_CHECK_ISR(handle); DAC_NULL_POINTER_CHECK_ISR(dma_buf); @@ -533,7 +532,7 @@ esp_err_t dac_continuous_write_cyclically(dac_continuous_handle_t handle, uint8_ buf += load_bytes / DAC_16BIT_ALIGN_COEFF; } /* Link the tail to the head as a ring */ - STAILQ_NEXT(handle->desc[i-1], qe) = handle->desc[0]; + STAILQ_NEXT(handle->desc[i - 1], qe) = handle->desc[0]; dac_dma_periph_dma_trans_start((uint32_t)handle->desc[0]); atomic_store(&handle->is_running, true); @@ -607,8 +606,8 @@ esp_err_t dac_continuous_write(dac_continuous_handle_t handle, uint8_t *buf, siz /* Wait for the previous DMA stop */ while (atomic_load(&handle->is_running)) {} for (int i = 0; - i < handle->cfg.desc_num && buf_size > 0; - i++, buf += w_size, buf_size -= w_size) { + i < handle->cfg.desc_num && buf_size > 0; + i++, buf += w_size, buf_size -= w_size) { ESP_GOTO_ON_ERROR(s_dac_wait_to_load_dma_data(handle, buf, buf_size, &w_size, timeout_tick), err, TAG, "Load data failed"); } dac_dma_periph_dma_trans_start((uint32_t)(STAILQ_FIRST(&handle->head))); diff --git a/components/driver/dac/dac_cosine.c b/components/esp_driver_dac/dac_cosine.c similarity index 97% rename from components/driver/dac/dac_cosine.c rename to components/esp_driver_dac/dac_cosine.c index b221465668..445cc7455b 100644 --- a/components/driver/dac/dac_cosine.c +++ b/components/esp_driver_dac/dac_cosine.c @@ -113,7 +113,7 @@ esp_err_t dac_cosine_start(dac_cosine_handle_t handle) periph_rtc_dig_clk8m_enable(); /* Enabled DAC channel */ ESP_RETURN_ON_ERROR(dac_priv_enable_channel(handle->cfg.chan_id), TAG, - "enable dac channel %d failed", handle->cfg.chan_id); + "enable dac channel %d failed", handle->cfg.chan_id); /* Enabled the cosine wave generator if no channel using it before */ DAC_RTC_ENTER_CRITICAL(); if (s_cwg_refer_cnt == 0) { @@ -136,7 +136,7 @@ esp_err_t dac_cosine_stop(dac_cosine_handle_t handle) /* Enabled DAC channel */ ESP_RETURN_ON_ERROR(dac_priv_disable_channel(handle->cfg.chan_id), TAG, - "disable dac channel %d failed", handle->cfg.chan_id); + "disable dac channel %d failed", handle->cfg.chan_id); DAC_RTC_ENTER_CRITICAL(); /* Disconnect the DAC channel from the cosine wave generator */ dac_ll_cw_enable_channel(handle->cfg.chan_id, false); diff --git a/components/driver/dac/dac_oneshot.c b/components/esp_driver_dac/dac_oneshot.c similarity index 99% rename from components/driver/dac/dac_oneshot.c rename to components/esp_driver_dac/dac_oneshot.c index b698f9cd73..5e75ea1146 100644 --- a/components/driver/dac/dac_oneshot.c +++ b/components/esp_driver_dac/dac_oneshot.c @@ -19,7 +19,7 @@ #include "esp_pm.h" #endif - struct dac_oneshot_s { +struct dac_oneshot_s { dac_oneshot_config_t cfg; /*!< Oneshot mode configurations */ }; diff --git a/components/driver/dac/dac_priv_common.h b/components/esp_driver_dac/dac_priv_common.h similarity index 100% rename from components/driver/dac/dac_priv_common.h rename to components/esp_driver_dac/dac_priv_common.h diff --git a/components/driver/dac/dac_priv_dma.h b/components/esp_driver_dac/dac_priv_dma.h similarity index 99% rename from components/driver/dac/dac_priv_dma.h rename to components/esp_driver_dac/dac_priv_dma.h index a5491f39f0..deae4f55d0 100644 --- a/components/driver/dac/dac_priv_dma.h +++ b/components/esp_driver_dac/dac_priv_dma.h @@ -9,7 +9,6 @@ #include "esp_err.h" #include "esp_intr_alloc.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/components/driver/dac/esp32/dac_dma.c b/components/esp_driver_dac/esp32/dac_dma.c similarity index 99% rename from components/driver/dac/esp32/dac_dma.c rename to components/esp_driver_dac/esp32/dac_dma.c index f1e648f16d..dc7d458195 100644 --- a/components/driver/dac/esp32/dac_dma.c +++ b/components/esp_driver_dac/esp32/dac_dma.c @@ -178,7 +178,7 @@ static void s_dac_dma_periph_reset(void) static void s_dac_dma_periph_start(void) { - i2s_ll_enable_dma(s_ddp->periph_dev,true); + i2s_ll_enable_dma(s_ddp->periph_dev, true); i2s_ll_tx_enable_intr(s_ddp->periph_dev); i2s_ll_tx_start(s_ddp->periph_dev); i2s_ll_dma_enable_eof_on_fifo_empty(s_ddp->periph_dev, true); diff --git a/components/driver/dac/esp32s2/dac_dma.c b/components/esp_driver_dac/esp32s2/dac_dma.c similarity index 99% rename from components/driver/dac/esp32s2/dac_dma.c rename to components/esp_driver_dac/esp32s2/dac_dma.c index d13c63f39b..6f40d03f22 100644 --- a/components/driver/dac/esp32s2/dac_dma.c +++ b/components/esp_driver_dac/esp32s2/dac_dma.c @@ -71,14 +71,15 @@ static uint32_t s_dac_set_apll_freq(uint32_t expt_freq) * - ESP_OK config success * - ESP_ERR_INVALID_ARG invalid frequency */ -static esp_err_t s_dac_dma_periph_set_clock(uint32_t freq_hz, bool is_apll){ +static esp_err_t s_dac_dma_periph_set_clock(uint32_t freq_hz, bool is_apll) +{ /* Step 1: Determine the digital clock source frequency */ uint32_t digi_ctrl_freq; // Digital controller clock if (is_apll) { /* Theoretical frequency range (due to the limitation of DAC, the maximum frequency may not reach): * CLK_LL_APLL_MAX_HZ: 119.24 Hz ~ 67.5 MHz * CLK_LL_APLL_MIN_HZ: 5.06 Hz ~ 2.65 MHz */ - digi_ctrl_freq = s_dac_set_apll_freq(freq_hz < 120 ? CLK_LL_APLL_MIN_HZ :CLK_LL_APLL_MAX_HZ); + digi_ctrl_freq = s_dac_set_apll_freq(freq_hz < 120 ? CLK_LL_APLL_MIN_HZ : CLK_LL_APLL_MAX_HZ); ESP_RETURN_ON_FALSE(digi_ctrl_freq, ESP_ERR_INVALID_ARG, TAG, "set APLL coefficients failed"); } else { digi_ctrl_freq = APB_CLK_FREQ; diff --git a/components/driver/dac/include/driver/dac_continuous.h b/components/esp_driver_dac/include/driver/dac_continuous.h similarity index 99% rename from components/driver/dac/include/driver/dac_continuous.h rename to components/esp_driver_dac/include/driver/dac_continuous.h index 0cb931522d..ad7668309f 100644 --- a/components/driver/dac/include/driver/dac_continuous.h +++ b/components/esp_driver_dac/include/driver/dac_continuous.h @@ -59,7 +59,6 @@ typedef struct { dac_continuous_channel_mode_t chan_mode; /*!< The channel mode of continuous mode, only take effect when multiple channels enabled, depends converting the buffer alternately or simultaneously */ } dac_continuous_config_t; - /** * @brief Event structure used in DAC event queue */ @@ -96,7 +95,6 @@ typedef struct { */ } dac_event_callbacks_t; - /** * @brief Allocate new DAC channels in continuous mode * @note The DAC channels can't be registered to continuous mode separately diff --git a/components/driver/dac/include/driver/dac_cosine.h b/components/esp_driver_dac/include/driver/dac_cosine.h similarity index 100% rename from components/driver/dac/include/driver/dac_cosine.h rename to components/esp_driver_dac/include/driver/dac_cosine.h diff --git a/components/driver/dac/include/driver/dac_oneshot.h b/components/esp_driver_dac/include/driver/dac_oneshot.h similarity index 100% rename from components/driver/dac/include/driver/dac_oneshot.h rename to components/esp_driver_dac/include/driver/dac_oneshot.h diff --git a/components/driver/dac/include/driver/dac_types.h b/components/esp_driver_dac/include/driver/dac_types.h similarity index 100% rename from components/driver/dac/include/driver/dac_types.h rename to components/esp_driver_dac/include/driver/dac_types.h diff --git a/components/esp_driver_dac/linker.lf b/components/esp_driver_dac/linker.lf new file mode 100644 index 0000000000..c58fa57831 --- /dev/null +++ b/components/esp_driver_dac/linker.lf @@ -0,0 +1,6 @@ +[mapping:dac_driver] +archive: libesp_driver_dac.a +entries: + if DAC_CTRL_FUNC_IN_IRAM = y: + dac_oneshot: dac_oneshot_output_voltage (noflash) + dac_continuous: dac_continuous_write_asynchronously (noflash) diff --git a/components/esp_driver_dac/test_apps/.build-test-rules.yml b/components/esp_driver_dac/test_apps/.build-test-rules.yml new file mode 100644 index 0000000000..33c41155f1 --- /dev/null +++ b/components/esp_driver_dac/test_apps/.build-test-rules.yml @@ -0,0 +1,9 @@ +# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps + +components/esp_driver_dac/test_apps/dac: + disable: + - if: SOC_DAC_SUPPORTED != 1 + depends_components: + - esp_driver_i2s + - esp_driver_spi + - esp_adc diff --git a/components/driver/test_apps/dac_test_apps/dac/CMakeLists.txt b/components/esp_driver_dac/test_apps/dac/CMakeLists.txt similarity index 87% rename from components/driver/test_apps/dac_test_apps/dac/CMakeLists.txt rename to components/esp_driver_dac/test_apps/dac/CMakeLists.txt index 71dad1881a..0e63a58084 100644 --- a/components/driver/test_apps/dac_test_apps/dac/CMakeLists.txt +++ b/components/esp_driver_dac/test_apps/dac/CMakeLists.txt @@ -10,7 +10,7 @@ project(dac_test) if(CONFIG_COMPILER_DUMP_RTL_FILES) add_custom_target(check_test_app_sections ALL COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py - --rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/driver/,${CMAKE_BINARY_DIR}/esp-idf/hal/ + --rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_dac/,${CMAKE_BINARY_DIR}/esp-idf/hal/ --elf-file ${CMAKE_BINARY_DIR}/dac_test.elf find-refs --from-sections=.iram0.text diff --git a/components/driver/test_apps/dac_test_apps/dac/README.md b/components/esp_driver_dac/test_apps/dac/README.md similarity index 100% rename from components/driver/test_apps/dac_test_apps/dac/README.md rename to components/esp_driver_dac/test_apps/dac/README.md diff --git a/components/driver/test_apps/dac_test_apps/dac/main/CMakeLists.txt b/components/esp_driver_dac/test_apps/dac/main/CMakeLists.txt similarity index 79% rename from components/driver/test_apps/dac_test_apps/dac/main/CMakeLists.txt rename to components/esp_driver_dac/test_apps/dac/main/CMakeLists.txt index ccfeb064b9..5a701a9196 100644 --- a/components/driver/test_apps/dac_test_apps/dac/main/CMakeLists.txt +++ b/components/esp_driver_dac/test_apps/dac/main/CMakeLists.txt @@ -9,5 +9,5 @@ endif() # the component can be registered as WHOLE_ARCHIVE idf_component_register(SRCS ${srcs} PRIV_REQUIRES unity esp_driver_pcnt esp_adc - driver # TODO: IDF-8370 remove driver when esp_driver_dac created + esp_driver_dac esp_driver_gpio esp_driver_i2s esp_driver_spi WHOLE_ARCHIVE) diff --git a/components/driver/test_apps/dac_test_apps/dac/main/test_app_main.c b/components/esp_driver_dac/test_apps/dac/main/test_app_main.c similarity index 100% rename from components/driver/test_apps/dac_test_apps/dac/main/test_app_main.c rename to components/esp_driver_dac/test_apps/dac/main/test_app_main.c diff --git a/components/driver/test_apps/dac_test_apps/dac/main/test_dac.c b/components/esp_driver_dac/test_apps/dac/main/test_dac.c similarity index 98% rename from components/driver/test_apps/dac_test_apps/dac/main/test_dac.c rename to components/esp_driver_dac/test_apps/dac/main/test_dac.c index 4a0a99f83e..79b6e08066 100644 --- a/components/driver/test_apps/dac_test_apps/dac/main/test_dac.c +++ b/components/esp_driver_dac/test_apps/dac/main/test_dac.c @@ -39,11 +39,15 @@ TEST_CASE("DAC_API_basic_logic_test", "[dac]") { /* Constant API test */ dac_oneshot_handle_t oneshot_chan0_handle; - TEST_ESP_OK(dac_oneshot_new_channel(&(dac_oneshot_config_t){.chan_id = DAC_CHAN_0}, &oneshot_chan0_handle)); + TEST_ESP_OK(dac_oneshot_new_channel(&(dac_oneshot_config_t) { + .chan_id = DAC_CHAN_0 + }, &oneshot_chan0_handle)); TEST_ESP_OK(dac_oneshot_output_voltage(oneshot_chan0_handle, 128)); TEST_ESP_OK(dac_oneshot_del_channel(oneshot_chan0_handle)); dac_oneshot_handle_t oneshot_chan1_handle; - TEST_ESP_OK(dac_oneshot_new_channel(&(dac_oneshot_config_t){.chan_id = DAC_CHAN_1}, &oneshot_chan1_handle)); + TEST_ESP_OK(dac_oneshot_new_channel(&(dac_oneshot_config_t) { + .chan_id = DAC_CHAN_1 + }, &oneshot_chan1_handle)); TEST_ESP_OK(dac_oneshot_output_voltage(oneshot_chan1_handle, 100)); TEST_ESP_OK(dac_oneshot_del_channel(oneshot_chan1_handle)); diff --git a/components/driver/test_apps/dac_test_apps/dac/main/test_dac_iram.c b/components/esp_driver_dac/test_apps/dac/main/test_dac_iram.c similarity index 96% rename from components/driver/test_apps/dac_test_apps/dac/main/test_dac_iram.c rename to components/esp_driver_dac/test_apps/dac/main/test_dac_iram.c index 7a8a1bd196..8f59b831f0 100644 --- a/components/driver/test_apps/dac_test_apps/dac/main/test_dac_iram.c +++ b/components/esp_driver_dac/test_apps/dac/main/test_dac_iram.c @@ -53,7 +53,9 @@ static bool IRAM_ATTR test_dac_on_convert_done_cb(dac_continuous_handle_t handle TEST_CASE("DAC_IRAM_safe_test", "[dac]") { dac_oneshot_handle_t oneshot_handle; - TEST_ESP_OK(dac_oneshot_new_channel(&(dac_oneshot_config_t){.chan_id = DAC_CHAN_0}, &oneshot_handle)); + TEST_ESP_OK(dac_oneshot_new_channel(&(dac_oneshot_config_t) { + .chan_id = DAC_CHAN_0 + }, &oneshot_handle)); /* Test direct voltage setting safety */ unity_utils_run_cache_disable_stub(test_dac_direct_set_safety, oneshot_handle); diff --git a/components/driver/test_apps/dac_test_apps/dac/pytest_dac.py b/components/esp_driver_dac/test_apps/dac/pytest_dac.py similarity index 100% rename from components/driver/test_apps/dac_test_apps/dac/pytest_dac.py rename to components/esp_driver_dac/test_apps/dac/pytest_dac.py diff --git a/components/driver/test_apps/dac_test_apps/dac/sdkconfig.ci.iram_safe b/components/esp_driver_dac/test_apps/dac/sdkconfig.ci.iram_safe similarity index 100% rename from components/driver/test_apps/dac_test_apps/dac/sdkconfig.ci.iram_safe rename to components/esp_driver_dac/test_apps/dac/sdkconfig.ci.iram_safe diff --git a/components/driver/test_apps/dac_test_apps/dac/sdkconfig.ci.release b/components/esp_driver_dac/test_apps/dac/sdkconfig.ci.release similarity index 100% rename from components/driver/test_apps/dac_test_apps/dac/sdkconfig.ci.release rename to components/esp_driver_dac/test_apps/dac/sdkconfig.ci.release diff --git a/components/driver/test_apps/dac_test_apps/dac/sdkconfig.defaults b/components/esp_driver_dac/test_apps/dac/sdkconfig.defaults similarity index 100% rename from components/driver/test_apps/dac_test_apps/dac/sdkconfig.defaults rename to components/esp_driver_dac/test_apps/dac/sdkconfig.defaults diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index 3945ede97c..51dbafdf6a 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -73,10 +73,6 @@ INPUT = \ $(PROJECT_PATH)/components/bt/host/bluedroid/api/include/api/esp_spp_api.h \ $(PROJECT_PATH)/components/bt/host/nimble/esp-hci/include/esp_nimble_hci.h \ $(PROJECT_PATH)/components/console/esp_console.h \ - $(PROJECT_PATH)/components/driver/dac/include/driver/dac_continuous.h \ - $(PROJECT_PATH)/components/driver/dac/include/driver/dac_cosine.h \ - $(PROJECT_PATH)/components/driver/dac/include/driver/dac_oneshot.h \ - $(PROJECT_PATH)/components/driver/dac/include/driver/dac_types.h \ $(PROJECT_PATH)/components/driver/i2c/include/driver/i2c_master.h \ $(PROJECT_PATH)/components/driver/i2c/include/driver/i2c_slave.h \ $(PROJECT_PATH)/components/driver/i2c/include/driver/i2c_types.h \ @@ -110,6 +106,10 @@ INPUT = \ $(PROJECT_PATH)/components/esp_driver_ana_cmpr/include/driver/ana_cmpr.h \ $(PROJECT_PATH)/components/esp_driver_ana_cmpr/include/driver/ana_cmpr_etm.h \ $(PROJECT_PATH)/components/esp_driver_ana_cmpr/include/driver/ana_cmpr_types.h \ + $(PROJECT_PATH)/components/esp_driver_dac/include/driver/dac_continuous.h \ + $(PROJECT_PATH)/components/esp_driver_dac/include/driver/dac_cosine.h \ + $(PROJECT_PATH)/components/esp_driver_dac/include/driver/dac_oneshot.h \ + $(PROJECT_PATH)/components/esp_driver_dac/include/driver/dac_types.h \ $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/dedic_gpio.h \ $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/gpio.h \ $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/gpio_etm.h \ diff --git a/docs/en/api-reference/peripherals/dac.rst b/docs/en/api-reference/peripherals/dac.rst index 2b7267f3d5..2d3bdc23b5 100644 --- a/docs/en/api-reference/peripherals/dac.rst +++ b/docs/en/api-reference/peripherals/dac.rst @@ -142,5 +142,5 @@ API Reference .. include-build-file:: inc/dac_oneshot.inc .. include-build-file:: inc/dac_cosine.inc .. include-build-file:: inc/dac_continuous.inc -.. include-build-file:: inc/components/driver/dac/include/driver/dac_types.inc +.. include-build-file:: inc/components/esp_driver_dac/include/driver/dac_types.inc .. include-build-file:: inc/components/hal/include/hal/dac_types.inc diff --git a/docs/en/migration-guides/release-5.x/5.3/peripherals.rst b/docs/en/migration-guides/release-5.x/5.3/peripherals.rst index db7755a7a9..f6f991246f 100644 --- a/docs/en/migration-guides/release-5.x/5.3/peripherals.rst +++ b/docs/en/migration-guides/release-5.x/5.3/peripherals.rst @@ -15,6 +15,7 @@ In order to control the dependence of other components on drivers at a smaller g - `esp_driver_sdio` - Driver for SDIO - `esp_driver_ana_cmpr` - Driver for Analog Comparator - `esp_driver_i2s` - Driver for I2S +- `esp_driver_dac` - Driver for DAC For compatibility, the original `driver`` component is still treated as an all-in-one component by registering these `esp_driver_xyz`` components as its public dependencies. In other words, you do not need to modify the CMake file of an existing project, but you now have a way to specify the specific peripheral driver that your project depends on. diff --git a/docs/zh_CN/api-reference/peripherals/dac.rst b/docs/zh_CN/api-reference/peripherals/dac.rst index 7d7da28418..6ef70b6898 100644 --- a/docs/zh_CN/api-reference/peripherals/dac.rst +++ b/docs/zh_CN/api-reference/peripherals/dac.rst @@ -142,5 +142,5 @@ API 参考 .. include-build-file:: inc/dac_oneshot.inc .. include-build-file:: inc/dac_cosine.inc .. include-build-file:: inc/dac_continuous.inc -.. include-build-file:: inc/components/driver/dac/include/driver/dac_types.inc +.. include-build-file:: inc/components/esp_driver_dac/include/driver/dac_types.inc .. include-build-file:: inc/components/hal/include/hal/dac_types.inc diff --git a/docs/zh_CN/migration-guides/release-5.x/5.3/peripherals.rst b/docs/zh_CN/migration-guides/release-5.x/5.3/peripherals.rst index 45c005b019..63cebaa68c 100644 --- a/docs/zh_CN/migration-guides/release-5.x/5.3/peripherals.rst +++ b/docs/zh_CN/migration-guides/release-5.x/5.3/peripherals.rst @@ -15,6 +15,7 @@ - `esp_driver_sdio` - SDIO 驱动 - `esp_driver_ana_cmpr` - 模拟比较器驱动 - `esp_driver_i2s` - I2S 驱动 +- `esp_driver_dac` - DAC 驱动 为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。 diff --git a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/CMakeLists.txt b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/CMakeLists.txt index 2802345426..e68a065139 100644 --- a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/CMakeLists.txt @@ -1,6 +1,5 @@ idf_component_register(SRCS "bt_app_av.c" "bt_app_core.c" "main.c" - PRIV_REQUIRES esp_driver_i2s bt nvs_flash esp_ringbuf - driver # TODO: IDF-8370 remove driver when esp_driver_dac created + PRIV_REQUIRES esp_driver_i2s bt nvs_flash esp_ringbuf esp_driver_dac INCLUDE_DIRS ".") diff --git a/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/CMakeLists.txt b/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/CMakeLists.txt index 2802345426..e68a065139 100644 --- a/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/CMakeLists.txt +++ b/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/CMakeLists.txt @@ -1,6 +1,5 @@ idf_component_register(SRCS "bt_app_av.c" "bt_app_core.c" "main.c" - PRIV_REQUIRES esp_driver_i2s bt nvs_flash esp_ringbuf - driver # TODO: IDF-8370 remove driver when esp_driver_dac created + PRIV_REQUIRES esp_driver_i2s bt nvs_flash esp_ringbuf esp_driver_dac INCLUDE_DIRS ".") diff --git a/examples/peripherals/dac/dac_continuous/dac_audio/CMakeLists.txt b/examples/peripherals/dac/dac_continuous/dac_audio/CMakeLists.txt index eefcf9cbcd..7618655484 100644 --- a/examples/peripherals/dac/dac_continuous/dac_audio/CMakeLists.txt +++ b/examples/peripherals/dac/dac_continuous/dac_audio/CMakeLists.txt @@ -2,5 +2,8 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) +# "Trim" the build. Include the minimal set of components, main, and anything it depends on. +set(COMPONENTS main) + include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(dac_audio) diff --git a/examples/peripherals/dac/dac_continuous/dac_audio/main/CMakeLists.txt b/examples/peripherals/dac/dac_continuous/dac_audio/main/CMakeLists.txt index 403d266ed2..93e667506c 100644 --- a/examples/peripherals/dac/dac_continuous/dac_audio/main/CMakeLists.txt +++ b/examples/peripherals/dac/dac_continuous/dac_audio/main/CMakeLists.txt @@ -1,2 +1,3 @@ idf_component_register(SRCS "dac_audio_example_main.c" - INCLUDE_DIRS ".") + INCLUDE_DIRS "." + PRIV_REQUIRES esp_driver_dac) diff --git a/examples/peripherals/dac/dac_continuous/signal_generator/CMakeLists.txt b/examples/peripherals/dac/dac_continuous/signal_generator/CMakeLists.txt index 99e61f9ac5..9ad91aea66 100644 --- a/examples/peripherals/dac/dac_continuous/signal_generator/CMakeLists.txt +++ b/examples/peripherals/dac/dac_continuous/signal_generator/CMakeLists.txt @@ -2,5 +2,8 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) +# "Trim" the build. Include the minimal set of components, main, and anything it depends on. +set(COMPONENTS main) + include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(signal_generator) diff --git a/examples/peripherals/dac/dac_continuous/signal_generator/main/CMakeLists.txt b/examples/peripherals/dac/dac_continuous/signal_generator/main/CMakeLists.txt index 5a747f839f..be52464f65 100644 --- a/examples/peripherals/dac/dac_continuous/signal_generator/main/CMakeLists.txt +++ b/examples/peripherals/dac/dac_continuous/signal_generator/main/CMakeLists.txt @@ -3,4 +3,5 @@ set(srcs "dac_continuous_example_main.c" "dac_continuous_example_timer.c") idf_component_register(SRCS "${srcs}" - INCLUDE_DIRS ".") + INCLUDE_DIRS "." + PRIV_REQUIRES esp_driver_dac esp_driver_gpio esp_driver_gptimer esp_adc) diff --git a/examples/peripherals/dac/dac_cosine_wave/CMakeLists.txt b/examples/peripherals/dac/dac_cosine_wave/CMakeLists.txt index 85484ad64e..531110f366 100644 --- a/examples/peripherals/dac/dac_cosine_wave/CMakeLists.txt +++ b/examples/peripherals/dac/dac_cosine_wave/CMakeLists.txt @@ -2,5 +2,8 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) +# "Trim" the build. Include the minimal set of components, main, and anything it depends on. +set(COMPONENTS main) + include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(dac_cosine_wave) diff --git a/examples/peripherals/dac/dac_cosine_wave/main/CMakeLists.txt b/examples/peripherals/dac/dac_cosine_wave/main/CMakeLists.txt index f61c2b3e9f..93a85ec415 100644 --- a/examples/peripherals/dac/dac_cosine_wave/main/CMakeLists.txt +++ b/examples/peripherals/dac/dac_cosine_wave/main/CMakeLists.txt @@ -1,2 +1,3 @@ idf_component_register(SRCS "dac_cosine_example_main.c" - INCLUDE_DIRS ".") + INCLUDE_DIRS "." + PRIV_REQUIRES esp_driver_dac esp_adc) diff --git a/examples/peripherals/dac/dac_oneshot/CMakeLists.txt b/examples/peripherals/dac/dac_oneshot/CMakeLists.txt index 66b66a84e7..0f427f4d0e 100644 --- a/examples/peripherals/dac/dac_oneshot/CMakeLists.txt +++ b/examples/peripherals/dac/dac_oneshot/CMakeLists.txt @@ -2,5 +2,8 @@ # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.16) +# "Trim" the build. Include the minimal set of components, main, and anything it depends on. +set(COMPONENTS main) + include($ENV{IDF_PATH}/tools/cmake/project.cmake) project(dac_oneshot) diff --git a/examples/peripherals/dac/dac_oneshot/main/CMakeLists.txt b/examples/peripherals/dac/dac_oneshot/main/CMakeLists.txt index 3ff1cab060..0fe75058c5 100644 --- a/examples/peripherals/dac/dac_oneshot/main/CMakeLists.txt +++ b/examples/peripherals/dac/dac_oneshot/main/CMakeLists.txt @@ -1,2 +1,3 @@ idf_component_register(SRCS "dac_oneshot_example_main.c" - INCLUDE_DIRS ".") + INCLUDE_DIRS "." + PRIV_REQUIRES esp_driver_dac esp_adc)