1 /*
2  * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 
8 #include "freertos/FreeRTOS.h"
9 #include "hal/dac_ll.h"
10 #include "esp_err.h"
11 
12 extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished.
13 #define DAC_ENTER_CRITICAL()  portENTER_CRITICAL(&rtc_spinlock)
14 #define DAC_EXIT_CRITICAL()  portEXIT_CRITICAL(&rtc_spinlock)
15 
16 /*---------------------------------------------------------------
17                     Digital controller setting
18 ---------------------------------------------------------------*/
19 
dac_i2s_enable(void)20 esp_err_t dac_i2s_enable(void)
21 {
22     DAC_ENTER_CRITICAL();
23     dac_ll_digi_enable_dma(true);
24     DAC_EXIT_CRITICAL();
25 
26     return ESP_OK;
27 }
28 
dac_i2s_disable(void)29 esp_err_t dac_i2s_disable(void)
30 {
31     DAC_ENTER_CRITICAL();
32     dac_ll_digi_enable_dma(false);
33     DAC_EXIT_CRITICAL();
34 
35     return ESP_OK;
36 }
37