dac_dma: Support DAC_DMA on esp32s2

This commit is contained in:
Cao Sen Miao
2021-05-10 15:23:45 +08:00
committed by laokaiyao
parent 8e9b1e8a7a
commit 9e4ff3d374
9 changed files with 566 additions and 194 deletions

View File

@@ -19,7 +19,7 @@ The DAC driver allows these channels to be set to arbitrary voltages.
.. only:: esp32s2
The DAC channels can also be driven with DMA-style written sample data by the digital controller, however the driver does not supported this yet.
The DAC channels can also be driven with DMA-style written sample data by the digital controller, please check the Application Example(DMA part) to get more information.
For other analog output options, see the :doc:`Sigma-delta Modulation module <sdm>` and the :doc:`LED Control module <ledc>`. Both these modules produce high frequency PDM/PWM output, which can be hardware low-pass filtered in order to generate a lower frequency analog output.
@@ -40,6 +40,35 @@ Setting DAC channel 1 ({IDF_TARGET_DAC_CH_1}) voltage to approx 0.78 of VDD_A vo
dac_output_voltage(DAC_CHANNEL_1, 200);
.. only:: esp32s2
For {IDF_TARGET_NAME}, DAC support to use DMA to send digital data to convert. Here is the example:
.. code-block:: c
#include <driver/dac.h>
const dac_digi_config_t cfg = {
.mode = mode,
.interval = 100,
.dig_clk.use_apll = false, // APB clk
.dig_clk.div_num = 79, // See comments `adc_digi_clk_t`
.dig_clk.div_b = 1,
.dig_clk.div_a = 0,
.dac_dma_cnt = 1, // The dac dma link number for your project
.dac_dma_length = 512, // The dac dam link length for your project. Should fit the buffer you prepared with dac_dma_cnt.
.dac_dma_link_type = DAC_DMA_LINK_RECURSIVE, //The link type.
};
dac_digi_initialize(&cfg);
dac_output_enable(DAC_CHANNEL_X);
dac_digi_start();
dac_digi_write_bytes((uint8_t*)buffer_you_prepared);
dac_digi_stop();
dac_digi_deinitialize();
API Reference
-------------