• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2015-2016 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 #pragma once
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #include <stdint.h>
22 #include "esp_err.h"
23 #include "driver/gpio.h"
24 #include "hal/dac_types.h"
25 
26 /**
27  * @brief Get the GPIO number of a specific DAC channel.
28  *
29  * @param channel Channel to get the gpio number
30  * @param gpio_num output buffer to hold the gpio number
31  * @return
32  *   - ESP_OK if success
33  */
34 esp_err_t dac_pad_get_io_num(dac_channel_t channel, gpio_num_t *gpio_num);
35 
36 /**
37  * @brief Set DAC output voltage.
38  *        DAC output is 8-bit. Maximum (255) corresponds to VDD3P3_RTC.
39  *
40  * @note Need to configure DAC pad before calling this function.
41  *       DAC channel 1 is attached to GPIO25, DAC channel 2 is attached to GPIO26
42  * @param channel DAC channel
43  * @param dac_value DAC output value
44  *
45  * @return
46  *     - ESP_OK success
47  */
48 esp_err_t dac_output_voltage(dac_channel_t channel, uint8_t dac_value);
49 
50 /**
51  * @brief DAC pad output enable
52  *
53  * @param channel DAC channel
54  * @note DAC channel 1 is attached to GPIO25, DAC channel 2 is attached to GPIO26
55  *       I2S left channel will be mapped to DAC channel 2
56  *       I2S right channel will be mapped to DAC channel 1
57  */
58 esp_err_t dac_output_enable(dac_channel_t channel);
59 
60 /**
61  * @brief DAC pad output disable
62  *
63  * @param channel DAC channel
64  * @note DAC channel 1 is attached to GPIO25, DAC channel 2 is attached to GPIO26
65  * @return
66  *     - ESP_OK success
67  */
68 esp_err_t dac_output_disable(dac_channel_t channel);
69 
70 /**
71  * @brief Enable cosine wave generator output.
72  *
73  * @return
74  *     - ESP_OK success
75  */
76 esp_err_t dac_cw_generator_enable(void);
77 
78 /**
79  * @brief Disable cosine wave generator output.
80  *
81  * @return
82  *     - ESP_OK success
83  */
84 esp_err_t dac_cw_generator_disable(void);
85 
86 /**
87  * @brief Config the cosine wave generator function in DAC module.
88  *
89  * @param cw Configuration.
90  * @return
91  *     - ESP_OK success
92  *     - ESP_ERR_INVALID_ARG The parameter is NULL.
93  */
94 esp_err_t dac_cw_generator_config(dac_cw_config_t *cw);
95 
96 #ifdef __cplusplus
97 }
98 #endif
99