1 /*
2  * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /*----------------------------------------------------------------------------------
8               This file contains Deprecated ADC APIs
9 -----------------------------------------------------------------------------------*/
10 
11 #pragma once
12 #include "esp_err.h"
13 #include "hal/adc_types.h"
14 #include "driver/adc_types_deprecated.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 
21 #if CONFIG_IDF_TARGET_ESP32S2
22 /*---------------------------------------------------------------
23                     ESP32S2 Deprecated ADC APIs
24 ---------------------------------------------------------------*/
25 /**
26  * @brief Config ADC module arbiter.
27  *        The arbiter is to improve the use efficiency of ADC2. After the control right is robbed by the high priority,
28  *        the low priority controller will read the invalid ADC2 data, and the validity of the data can be judged by the flag bit in the data.
29  *
30  * @note Only ADC2 support arbiter.
31  * @note Default priority: Wi-Fi > RTC > Digital;
32  * @note In normal use, there is no need to call this interface to config arbiter.
33  *
34  * @param adc_unit ADC unit.
35  * @param config Refer to `adc_arbiter_t`.
36  *
37  * @return
38  *      - ESP_OK Success
39  *      - ESP_ERR_NOT_SUPPORTED ADC unit not support arbiter.
40  */
41 esp_err_t adc_arbiter_config(adc_unit_t adc_unit, adc_arbiter_t *config) __attribute__((deprecated));
42 
43 /**
44  * @brief Enable interrupt of adc digital controller by bitmask.
45  *
46  * @param adc_unit ADC unit.
47  * @param intr_mask Interrupt bitmask. See ``adc_digi_intr_t``.
48  *
49  * @return
50  *      - ESP_OK Success
51  */
52 esp_err_t adc_digi_intr_enable(adc_unit_t adc_unit, adc_digi_intr_t intr_mask) __attribute__((deprecated));
53 
54 /**
55  * @brief Disable interrupt of adc digital controller by bitmask.
56  *
57  * @param adc_unit ADC unit.
58  * @param intr_mask Interrupt bitmask. See ``adc_digi_intr_t``.
59  *
60  * @return
61  *      - ESP_OK Success
62  */
63 esp_err_t adc_digi_intr_disable(adc_unit_t adc_unit, adc_digi_intr_t intr_mask) __attribute__((deprecated));
64 
65 /**
66  * @brief Clear interrupt of adc digital controller by bitmask.
67  *
68  * @param adc_unit ADC unit.
69  * @param intr_mask Interrupt bitmask. See ``adc_digi_intr_t``.
70  *
71  * @return
72  *      - ESP_OK Success
73  */
74 esp_err_t adc_digi_intr_clear(adc_unit_t adc_unit, adc_digi_intr_t intr_mask) __attribute__((deprecated));
75 
76 /**
77  * @brief Get interrupt status mask of adc digital controller.
78  *
79  * @param adc_unit ADC unit.
80  * @return
81  *     - intr Interrupt bitmask, See ``adc_digi_intr_t``.
82  */
83 uint32_t adc_digi_intr_get_status(adc_unit_t adc_unit) __attribute__((deprecated));
84 
85 /**
86  * @brief Register ADC interrupt handler, the handler is an ISR.
87  *        The handler will be attached to the same CPU core that this function is running on.
88  *
89  * @param fn Interrupt handler function.
90  * @param arg Parameter for handler function
91  * @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
92  *        ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
93  *
94  * @return
95  *     - ESP_OK Success
96  *     - ESP_ERR_NOT_FOUND Can not find the interrupt that matches the flags.
97  *     - ESP_ERR_INVALID_ARG Function pointer error.
98  */
99 esp_err_t adc_digi_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags) __attribute__((deprecated));
100 
101 /**
102  * @brief Deregister ADC interrupt handler, the handler is an ISR.
103  *
104  * @return
105  *     - ESP_OK Success
106  *     - ESP_ERR_INVALID_ARG hander error.
107  *     - ESP_FAIL ISR not be registered.
108  */
109 esp_err_t adc_digi_isr_deregister(void) __attribute__((deprecated));
110 #endif  // #if CONFIG_IDF_TARGET_ESP32S2
111 
112 
113 #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
114 /*---------------------------------------------------------------
115             ESP32, ESP32S2 Deprecated ADC APIs
116 ---------------------------------------------------------------*/
117 /**
118  * @brief ADC digital controller initialization.
119  * @return
120  *      - ESP_OK Success
121  */
122 esp_err_t adc_digi_init(void) __attribute__((deprecated));
123 
124 /**
125  * @brief ADC digital controller deinitialization.
126  * @return
127  *      - ESP_OK Success
128  */
129 esp_err_t adc_digi_deinit(void) __attribute__((deprecated));
130 #endif  //#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
131 
132 
133 #if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3
134 /*---------------------------------------------------------------
135             ESP32, ESP32S2, ESP32C3 Deprecated ADC APIs
136 ---------------------------------------------------------------*/
137 /**
138  * @brief Setting the digital controller.
139  *
140  * @param config Pointer to digital controller paramter. Refer to ``adc_digi_config_t``.
141  *
142  * @return
143  *      - ESP_ERR_INVALID_STATE Driver state is invalid.
144  *      - ESP_ERR_INVALID_ARG   If the combination of arguments is invalid.
145  *      - ESP_OK                On success
146  */
147 esp_err_t adc_digi_controller_config(const adc_digi_config_t *config) __attribute__((deprecated));
148 
149 /**
150  * @brief Initialize ADC pad
151  * @param adc_unit ADC unit index
152  * @param channel ADC channel index
153  * @return
154  *     - ESP_OK success
155  *     - ESP_ERR_INVALID_ARG Parameter error
156  */
157 esp_err_t adc_gpio_init(adc_unit_t adc_unit, adc_channel_t channel) __attribute__((deprecated));;
158 #endif //#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32C3
159 
160 
161 #ifdef __cplusplus
162 }
163 #endif
164