adc_arch.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Gunar Schorcht
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
27 #ifndef ADC_ARCH_H
28 #define ADC_ARCH_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include "periph/adc.h"
35 #include "periph/gpio.h"
36 
37 #include "hal/adc_types.h"
38 
39 #include "esp_idf_api/adc.h"
40 
48 typedef enum {
49  ADC_ATTENUATION_0_DB = ADC_ATTEN_DB_0,
50  ADC_ATTENUATION_3_DB = ADC_ATTEN_DB_2_5,
51  ADC_ATTENUATION_6_DB = ADC_ATTEN_DB_6,
52  ADC_ATTENUATION_11_DB = ADC_ATTEN_DB_11,
54 
85 int adc_set_attenuation(adc_t line, adc_atten_t atten);
86 
104 int adc_line_vref_to_gpio(adc_t line, gpio_t gpio);
105 
106 #if defined(CPU_FAM_ESP32)
115 static inline int adc_vref_to_gpio25 (void)
116 {
117  return esp_idf_adc_vref_to_gpio(ADC_UNIT_2, GPIO25);
118 }
119 #endif
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif /* ADC_ARCH_H */
int adc_line_vref_to_gpio(adc_t line, gpio_t gpio)
Output reference voltage of a ADC line to GPIO n.
int adc_set_attenuation(adc_t line, adc_atten_t atten)
Set the attenuation for the ADC line.
adc_attenuation_t
Attenuations that can be set for ADC lines.
Definition: adc_arch.h:48
@ ADC_ATTENUATION_0_DB
full-range is about 1.1 V (Vref)
Definition: adc_arch.h:49
@ ADC_ATTENUATION_11_DB
full-range is about 3.3 V
Definition: adc_arch.h:52
@ ADC_ATTENUATION_3_DB
full-range is about 1.5 V
Definition: adc_arch.h:50
@ ADC_ATTENUATION_6_DB
full-range is about 2.2 V
Definition: adc_arch.h:51
Interface for the ESP-IDF ADC HAL API.
Low-level ADC peripheral driver interface definitions.
Low-level GPIO peripheral driver interface definitions.
uint_fast8_t adc_t
Define default ADC type identifier.
Definition: adc.h:72