1 // Copyright 2015-2019 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 // The HAL layer for ADC (esp32s2 specific part)
16 
17 #include "hal/dac_hal.h"
18 #include "hal/adc_hal.h"
19 #include "hal/dac_types.h"
20 
21 /*---------------------------------------------------------------
22                     Digital controller setting
23 ---------------------------------------------------------------*/
24 
dac_hal_digi_init(void)25 void dac_hal_digi_init(void)
26 {
27     dac_ll_digi_clk_inv(true);
28 }
29 
dac_hal_digi_deinit(void)30 void dac_hal_digi_deinit(void)
31 {
32     dac_ll_digi_trigger_output(false);
33     dac_ll_digi_enable_dma(false);
34     dac_ll_digi_fifo_reset();
35     dac_ll_digi_reset();
36 }
37 
dac_hal_digi_controller_config(const dac_digi_config_t * cfg)38 void dac_hal_digi_controller_config(const dac_digi_config_t *cfg)
39 {
40     dac_ll_digi_set_convert_mode(cfg->mode);
41     dac_ll_digi_set_trigger_interval(cfg->interval);
42     adc_hal_digi_clk_config(&cfg->dig_clk);
43 }
44 
dac_hal_digi_start(void)45 void dac_hal_digi_start(void)
46 {
47     dac_ll_digi_enable_dma(true);
48     dac_ll_digi_trigger_output(true);
49 }
50 
dac_hal_digi_stop(void)51 void dac_hal_digi_stop(void)
52 {
53     dac_ll_digi_trigger_output(false);
54     dac_ll_digi_enable_dma(false);
55 }
56