mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
remove(legacy_dac): remove legacy dac driver in IDF v6.0
This commit is contained in:
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "esp_check.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "esp_private/gpio.h"
|
||||
#include "driver/dac_types_legacy.h"
|
||||
#include "soc/dac_periph.h"
|
||||
#include "hal/gpio_types.h"
|
||||
#include "hal/dac_ll.h"
|
||||
#include "clk_ctrl_os.h"
|
||||
|
||||
extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished.
|
||||
|
||||
static __attribute__((unused)) const char *TAG = "DAC";
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
DAC
|
||||
---------------------------------------------------------------*/
|
||||
esp_err_t dac_pad_get_io_num(dac_channel_t channel, gpio_num_t *gpio_num)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
|
||||
|
||||
*gpio_num = (gpio_num_t)dac_periph_signal.dac_channel_io_num[channel];
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t dac_rtc_pad_init(dac_channel_t channel)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
|
||||
|
||||
gpio_num_t gpio_num = 0;
|
||||
dac_pad_get_io_num(channel, &gpio_num);
|
||||
gpio_config_as_analog(gpio_num);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_output_enable(dac_channel_t channel)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
|
||||
|
||||
dac_rtc_pad_init(channel);
|
||||
portENTER_CRITICAL(&rtc_spinlock);
|
||||
dac_ll_power_on(channel);
|
||||
dac_ll_rtc_sync_by_adc(false);
|
||||
portEXIT_CRITICAL(&rtc_spinlock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_output_disable(dac_channel_t channel)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
|
||||
|
||||
portENTER_CRITICAL(&rtc_spinlock);
|
||||
dac_ll_power_down(channel);
|
||||
portEXIT_CRITICAL(&rtc_spinlock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_output_voltage(dac_channel_t channel, uint8_t dac_value)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
|
||||
|
||||
portENTER_CRITICAL(&rtc_spinlock);
|
||||
dac_ll_update_output_value(channel, dac_value);
|
||||
portEXIT_CRITICAL(&rtc_spinlock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_out_voltage(dac_channel_t channel, uint8_t dac_value)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
|
||||
|
||||
portENTER_CRITICAL(&rtc_spinlock);
|
||||
dac_ll_update_output_value(channel, dac_value);
|
||||
portEXIT_CRITICAL(&rtc_spinlock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_cw_generator_enable(void)
|
||||
{
|
||||
portENTER_CRITICAL(&rtc_spinlock);
|
||||
periph_rtc_dig_clk8m_enable();
|
||||
dac_ll_cw_generator_enable();
|
||||
portEXIT_CRITICAL(&rtc_spinlock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_cw_generator_disable(void)
|
||||
{
|
||||
portENTER_CRITICAL(&rtc_spinlock);
|
||||
dac_ll_cw_generator_disable();
|
||||
periph_rtc_dig_clk8m_disable();
|
||||
portEXIT_CRITICAL(&rtc_spinlock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_cw_generator_config(dac_cw_config_t *cw)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(cw, ESP_ERR_INVALID_ARG, TAG, "invalid clock configuration");
|
||||
portENTER_CRITICAL(&rtc_spinlock);
|
||||
/* Enable the rtc8m clock temporary to get the correct frequency */
|
||||
periph_rtc_dig_clk8m_enable();
|
||||
uint32_t rtc_freq = periph_rtc_dig_clk8m_get_freq();
|
||||
periph_rtc_dig_clk8m_disable();
|
||||
dac_ll_cw_set_freq(cw->freq, rtc_freq);
|
||||
dac_ll_cw_set_atten(cw->en_ch, (dac_cosine_atten_t)cw->scale);
|
||||
dac_ll_cw_set_phase(cw->en_ch, (dac_cosine_phase_t)cw->phase);
|
||||
dac_ll_cw_set_dc_offset(cw->en_ch, cw->offset);
|
||||
dac_ll_cw_enable_channel(cw->en_ch, true);
|
||||
portEXIT_CRITICAL(&rtc_spinlock);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if !CONFIG_DAC_SKIP_LEGACY_CONFLICT_CHECK
|
||||
/**
|
||||
* @brief This function will be called during start up, to check that this legacy DAC driver is not running along with the new driver
|
||||
*/
|
||||
__attribute__((constructor))
|
||||
static void check_dac_legacy_driver_conflict(void)
|
||||
{
|
||||
// This function was declared as weak here. The new DAC driver has one implementation.
|
||||
// So if the new DAC driver is not linked in, then `dac_priv_register_channel()` should be NULL at runtime.
|
||||
extern __attribute__((weak)) esp_err_t dac_priv_register_channel(dac_channel_t chan_id, const char *mode_name);
|
||||
if ((void *)dac_priv_register_channel != NULL) {
|
||||
ESP_EARLY_LOGE(TAG, "CONFLICT! The new DAC driver is not allowed to be used together with the legacy driver");
|
||||
abort();
|
||||
}
|
||||
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/dac_oneshot.h`, `driver/dac_cosine.h` or `driver/dac_continuous.h` instead");
|
||||
}
|
||||
#endif //CONFIG_DAC_SKIP_LEGACY_CONFLICT_CHECK
|
||||
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/dac_types_legacy.h"
|
||||
|
||||
#if !CONFIG_DAC_SUPPRESS_DEPRECATE_WARN
|
||||
#warning "The legacy DAC driver is deprecated, please use `driver/dac_oneshot.h`, `driver/dac_cosine.h` or `driver/dac_continuous.h` instead"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the GPIO number of a specific DAC channel.
|
||||
*
|
||||
* @param channel Channel to get the gpio number
|
||||
* @param gpio_num output buffer to hold the gpio number
|
||||
* @return
|
||||
* - ESP_OK if success
|
||||
*/
|
||||
esp_err_t dac_pad_get_io_num(dac_channel_t channel, gpio_num_t *gpio_num);
|
||||
|
||||
/**
|
||||
* @brief Set DAC output voltage.
|
||||
* DAC output is 8-bit. Maximum (255) corresponds to VDD3P3_RTC.
|
||||
*
|
||||
* @note Need to configure DAC pad before calling this function.
|
||||
* DAC channel 0 is attached to GPIO25, DAC channel 1 is attached to GPIO26
|
||||
* @param channel DAC channel
|
||||
* @param dac_value DAC output value
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_output_voltage(dac_channel_t channel, uint8_t dac_value);
|
||||
|
||||
/**
|
||||
* @brief DAC pad output enable
|
||||
*
|
||||
* @param channel DAC channel
|
||||
* @note DAC channel 0 is attached to GPIO25, DAC channel 1 is attached to GPIO26
|
||||
* I2S left channel will be mapped to DAC channel 1
|
||||
* I2S right channel will be mapped to DAC channel 0
|
||||
*/
|
||||
esp_err_t dac_output_enable(dac_channel_t channel);
|
||||
|
||||
/**
|
||||
* @brief DAC pad output disable
|
||||
*
|
||||
* @param channel DAC channel
|
||||
* @note DAC channel 0 is attached to GPIO25, DAC channel 1 is attached to GPIO26
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_output_disable(dac_channel_t channel);
|
||||
|
||||
/**
|
||||
* @brief Enable cosine wave generator output.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_cw_generator_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable cosine wave generator output.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_cw_generator_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Config the cosine wave generator function in DAC module.
|
||||
*
|
||||
* @param cw Configuration.
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG The parameter is NULL.
|
||||
*/
|
||||
esp_err_t dac_cw_generator_config(dac_cw_config_t *cw);
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Digital controller setting
|
||||
---------------------------------------------------------------*/
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
/**
|
||||
* @brief Enable DAC output data from I2S
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_i2s_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable DAC output data from I2S
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_i2s_disable(void);
|
||||
#endif // CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
/**
|
||||
* @brief DAC digital controller initialization.
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_digi_init(void);
|
||||
|
||||
/**
|
||||
* @brief DAC digital controller deinitialization.
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_digi_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Setting the DAC digital controller.
|
||||
*
|
||||
* @param cfg Pointer to digital controller parameter. See ``dac_digi_config_t``.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_INVALID_ARG Parameter error
|
||||
*/
|
||||
esp_err_t dac_digi_controller_config(const dac_digi_config_t *cfg);
|
||||
|
||||
/**
|
||||
* @brief DAC digital controller start output voltage.
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_digi_start(void);
|
||||
|
||||
/**
|
||||
* @brief DAC digital controller stop output voltage.
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_digi_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Reset DAC digital controller FIFO.
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_digi_fifo_reset(void);
|
||||
|
||||
/**
|
||||
* @brief Reset DAC digital controller.
|
||||
* @return
|
||||
* - ESP_OK success
|
||||
*/
|
||||
esp_err_t dac_digi_reset(void);
|
||||
#endif // CONFIG_IDF_TARGET_ESP32S2
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "hal/dac_types.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "hal/adc_types.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The multiple of the amplitude of the cosine wave generator. The max amplitude is VDD3P3_RTC.
|
||||
*/
|
||||
typedef enum {
|
||||
DAC_CW_SCALE_1 = 0x0, /*!< 1/1. Default. */
|
||||
DAC_CW_SCALE_2 = 0x1, /*!< 1/2. */
|
||||
DAC_CW_SCALE_4 = 0x2, /*!< 1/4. */
|
||||
DAC_CW_SCALE_8 = 0x3, /*!< 1/8. */
|
||||
} dac_cw_scale_t;
|
||||
|
||||
/**
|
||||
* @brief Set the phase of the cosine wave generator output.
|
||||
*/
|
||||
typedef enum {
|
||||
DAC_CW_PHASE_0 = 0x2, /*!< Phase shift +0° */
|
||||
DAC_CW_PHASE_180 = 0x3, /*!< Phase shift +180° */
|
||||
} dac_cw_phase_t;
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32S2
|
||||
/**
|
||||
* @brief DAC digital controller (DMA mode) work mode.
|
||||
*/
|
||||
typedef enum {
|
||||
DAC_CONV_NORMAL, /*!< The data in the DMA buffer is simultaneously output to the enable channel of the DAC. */
|
||||
DAC_CONV_ALTER, /*!< The data in the DMA buffer is alternately output to the enable channel of the DAC. */
|
||||
DAC_CONV_MAX
|
||||
} dac_digi_convert_mode_t;
|
||||
|
||||
/**
|
||||
* @brief DAC digital controller (DMA mode) configuration parameters.
|
||||
*/
|
||||
typedef struct {
|
||||
dac_digi_convert_mode_t mode; /*!<DAC digital controller (DMA mode) work mode. See ``dac_digi_convert_mode_t``. */
|
||||
uint32_t interval; /*!<The number of interval clock cycles for the DAC digital controller to output voltage.
|
||||
The unit is the divided clock. Range: 1 ~ 4095.
|
||||
Expression: `dac_output_freq` = `controller_clk` / interval. Refer to ``adc_digi_clk_t``.
|
||||
Note: The sampling rate of each channel is also related to the conversion mode (See ``dac_digi_convert_mode_t``) and pattern table settings. */
|
||||
adc_digi_clk_t dig_clk; /*!<DAC digital controller clock divider settings. Refer to ``adc_digi_clk_t``.
|
||||
Note: The clocks of the DAC digital controller use the ADC digital controller clock divider. */
|
||||
} dac_digi_config_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Config the cosine wave generator function in DAC module.
|
||||
*/
|
||||
typedef struct {
|
||||
dac_channel_t en_ch; /*!< Enable the cosine wave generator of DAC channel. */
|
||||
dac_cw_scale_t scale; /*!< Set the amplitude of the cosine wave generator output. */
|
||||
dac_cw_phase_t phase; /*!< Set the phase of the cosine wave generator output. */
|
||||
uint32_t freq; /*!< Set frequency of cosine wave generator output. Range: 130(130Hz) ~ 55000(100KHz). */
|
||||
int8_t offset; /*!< Set the voltage value of the DC component of the cosine wave generator output.
|
||||
Note: Unreasonable settings can cause waveform to be oversaturated. Range: -128 ~ 127. */
|
||||
} dac_cw_config_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "hal/dac_ll.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished.
|
||||
#define DAC_ENTER_CRITICAL() portENTER_CRITICAL(&rtc_spinlock)
|
||||
#define DAC_EXIT_CRITICAL() portEXIT_CRITICAL(&rtc_spinlock)
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Digital controller setting
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
esp_err_t dac_i2s_enable(void)
|
||||
{
|
||||
DAC_ENTER_CRITICAL();
|
||||
dac_ll_digi_enable_dma(true);
|
||||
DAC_EXIT_CRITICAL();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_i2s_disable(void)
|
||||
{
|
||||
DAC_ENTER_CRITICAL();
|
||||
dac_ll_digi_enable_dma(false);
|
||||
DAC_EXIT_CRITICAL();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "driver/dac_types_legacy.h"
|
||||
#include "hal/adc_ll.h"
|
||||
#include "hal/dac_ll.h"
|
||||
#include "esp_check.h"
|
||||
#include "esp_pm.h"
|
||||
|
||||
static __attribute__((unused)) const char *TAG = "DAC";
|
||||
|
||||
extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished.
|
||||
#define DAC_ENTER_CRITICAL() portENTER_CRITICAL(&rtc_spinlock)
|
||||
#define DAC_EXIT_CRITICAL() portEXIT_CRITICAL(&rtc_spinlock)
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
static esp_pm_lock_handle_t s_dac_digi_lock = NULL;
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
Digital controller setting
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
esp_err_t dac_digi_init(void)
|
||||
{
|
||||
DAC_ENTER_CRITICAL();
|
||||
dac_ll_digi_clk_inv(true);
|
||||
DAC_EXIT_CRITICAL();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_digi_deinit(void)
|
||||
{
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_dac_digi_lock) {
|
||||
esp_pm_lock_delete(s_dac_digi_lock);
|
||||
s_dac_digi_lock = NULL;
|
||||
}
|
||||
#endif
|
||||
DAC_ENTER_CRITICAL();
|
||||
dac_ll_digi_trigger_output(false);
|
||||
dac_ll_digi_enable_dma(false);
|
||||
dac_ll_digi_fifo_reset();
|
||||
dac_ll_digi_reset();
|
||||
DAC_EXIT_CRITICAL();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_digi_controller_config(const dac_digi_config_t *cfg)
|
||||
{
|
||||
ESP_RETURN_ON_FALSE(cfg->mode <= DAC_CONV_ALTER, ESP_ERR_INVALID_ARG, TAG, "DAC mode error");
|
||||
ESP_RETURN_ON_FALSE(cfg->interval > 0 && cfg->interval < 4096, ESP_ERR_INVALID_ARG, TAG, "DAC interval error");
|
||||
ESP_RETURN_ON_FALSE(cfg->dig_clk.div_num < 256, ESP_ERR_INVALID_ARG, TAG, "DAC clk div_num error");
|
||||
ESP_RETURN_ON_FALSE(cfg->dig_clk.div_b > 0 && cfg->dig_clk.div_b < 64, ESP_ERR_INVALID_ARG, TAG, "DAC clk div_b error");
|
||||
ESP_RETURN_ON_FALSE(cfg->dig_clk.div_a < 64, ESP_ERR_INVALID_ARG, TAG, "DAC clk div_a error");
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_err_t err;
|
||||
if (s_dac_digi_lock == NULL) {
|
||||
if (cfg->dig_clk.use_apll) {
|
||||
err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "dac_dma", &s_dac_digi_lock);
|
||||
} else {
|
||||
err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "dac_dma", &s_dac_digi_lock);
|
||||
}
|
||||
if (err != ESP_OK) {
|
||||
s_dac_digi_lock = NULL;
|
||||
ESP_LOGE(TAG, "DAC-DMA pm lock error");
|
||||
return err;
|
||||
}
|
||||
}
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
|
||||
DAC_ENTER_CRITICAL();
|
||||
dac_ll_digi_set_convert_mode(cfg->mode == DAC_CONV_ALTER);
|
||||
dac_ll_digi_set_trigger_interval(cfg->interval);
|
||||
adc_ll_digi_controller_clk_div(cfg->dig_clk.div_num, cfg->dig_clk.div_b, cfg->dig_clk.div_a);
|
||||
adc_ll_digi_clk_sel(cfg->dig_clk.use_apll ? ADC_DIGI_CLK_SRC_APLL : ADC_DIGI_CLK_SRC_DEFAULT);
|
||||
DAC_EXIT_CRITICAL();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_digi_start(void)
|
||||
{
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
ESP_RETURN_ON_FALSE(s_dac_digi_lock, ESP_FAIL, TAG, "Should start after call `dac_digi_controller_config`");
|
||||
esp_pm_lock_acquire(s_dac_digi_lock);
|
||||
#endif
|
||||
DAC_ENTER_CRITICAL();
|
||||
dac_ll_digi_enable_dma(true);
|
||||
dac_ll_digi_trigger_output(true);
|
||||
DAC_EXIT_CRITICAL();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_digi_stop(void)
|
||||
{
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
if (s_dac_digi_lock) {
|
||||
esp_pm_lock_release(s_dac_digi_lock);
|
||||
}
|
||||
#endif
|
||||
DAC_ENTER_CRITICAL();
|
||||
dac_ll_digi_trigger_output(false);
|
||||
dac_ll_digi_enable_dma(false);
|
||||
DAC_EXIT_CRITICAL();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_digi_fifo_reset(void)
|
||||
{
|
||||
DAC_ENTER_CRITICAL();
|
||||
dac_ll_digi_fifo_reset();
|
||||
DAC_EXIT_CRITICAL();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t dac_digi_reset(void)
|
||||
{
|
||||
DAC_ENTER_CRITICAL();
|
||||
dac_ll_digi_reset();
|
||||
DAC_EXIT_CRITICAL();
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
Reference in New Issue
Block a user