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 "driver/adc.h"
38 #include "hal/adc_types.h"
39 
47 typedef enum {
48  ADC_ATTENUATION_0_DB = ADC_ATTEN_DB_0,
49  ADC_ATTENUATION_3_DB = ADC_ATTEN_DB_2_5,
50  ADC_ATTENUATION_6_DB = ADC_ATTEN_DB_6,
51  ADC_ATTENUATION_11_DB = ADC_ATTEN_DB_11,
53 
84 int adc_set_attenuation(adc_t line, adc_atten_t atten);
85 
103 int adc_line_vref_to_gpio(adc_t line, gpio_t gpio);
104 
105 #if defined(CPU_FAM_ESP32)
114 static inline int adc_vref_to_gpio25(void)
115 {
116  return adc_vref_to_gpio(ADC_UNIT_2, GPIO25);
117 }
118 #endif
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif /* ADC_ARCH_H */
Low-level ADC peripheral driver interface definitions.
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:47
@ ADC_ATTENUATION_0_DB
full-range is about 1.1 V (Vref)
Definition: adc_arch.h:48
@ ADC_ATTENUATION_11_DB
full-range is about 3.3 V
Definition: adc_arch.h:51
@ ADC_ATTENUATION_3_DB
full-range is about 1.5 V
Definition: adc_arch.h:49
@ ADC_ATTENUATION_6_DB
full-range is about 2.2 V
Definition: adc_arch.h:50
Low-level GPIO peripheral driver interface definitions.
uint_fast8_t adc_t
Define default ADC type identifier.
Definition: adc.h:72