1 // Copyright 2019-2020 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 16 #include <string.h> 17 #include "esp_log.h" 18 #include "esp_err.h" 19 #include "esp_osal/esp_osal.h" 20 #include "esp_osal/semphr.h" 21 #include "esp_osal/timers.h" 22 #include "driver/rtc_io.h" 23 #include "driver/dac.h" 24 #include "soc/dac_periph.h" 25 #include "hal/dac_hal.h" 26 27 extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished. 28 #define DAC_ENTER_CRITICAL() portENTER_CRITICAL(&rtc_spinlock) 29 #define DAC_EXIT_CRITICAL() portEXIT_CRITICAL(&rtc_spinlock) 30 31 /*--------------------------------------------------------------- 32 Digital controller setting 33 ---------------------------------------------------------------*/ 34 dac_i2s_enable(void)35esp_err_t dac_i2s_enable(void) 36 { 37 DAC_ENTER_CRITICAL(); 38 dac_hal_digi_enable_dma(true); 39 DAC_EXIT_CRITICAL(); 40 41 return ESP_OK; 42 } 43 dac_i2s_disable(void)44esp_err_t dac_i2s_disable(void) 45 { 46 DAC_ENTER_CRITICAL(); 47 dac_hal_digi_enable_dma(false); 48 DAC_EXIT_CRITICAL(); 49 50 return ESP_OK; 51 } 52