Loading...
Searching...
No Matches
adc_arch.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 Gunar Schorcht
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30#include "periph/adc.h"
31#include "periph/gpio.h"
32
33#include "driver/adc.h"
34#include "driver/adc_types_legacy.h"
35
43typedef enum {
44 ADC_ATTENUATION_0_DB = ADC_ATTEN_DB_0,
45 ADC_ATTENUATION_3_DB = ADC_ATTEN_DB_2_5,
46 ADC_ATTENUATION_6_DB = ADC_ATTEN_DB_6,
47 ADC_ATTENUATION_12_DB = ADC_ATTEN_DB_12,
49
58#define ADC_ATTENUATION_11_DB ADC_ATTENUATION_12_DB
59
90int adc_set_attenuation(adc_t line, adc_atten_t atten);
91
115int adc_raw_to_voltage(adc_t line, int sample, int *voltage);
116
117#if !DOXYGEN
138__attribute__((__deprecated__))
139int adc_line_vref_to_gpio(adc_t line, gpio_t gpio);
140
141#if defined(CPU_FAM_ESP32)
153__attribute__((__deprecated__))
154static inline int adc_vref_to_gpio25(void)
155{
156 return adc_vref_to_gpio(ADC_UNIT_2, GPIO25);
157}
158#endif
159#endif /* !DOXYGEN */
160
161#ifdef __cplusplus
162}
163#endif
Low-level ADC peripheral driver interface definitions.
int adc_raw_to_voltage(adc_t line, int sample, int *voltage)
Get the voltage for a given sample value.
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:43
@ ADC_ATTENUATION_12_DB
full-range is about 3.3 V
Definition adc_arch.h:47
@ ADC_ATTENUATION_0_DB
full-range is about 1.1 V (Vref)
Definition adc_arch.h:44
@ ADC_ATTENUATION_3_DB
full-range is about 1.5 V
Definition adc_arch.h:45
@ ADC_ATTENUATION_6_DB
full-range is about 2.2 V
Definition adc_arch.h:46
Low-level GPIO peripheral driver interface definitions.
uint_fast8_t adc_t
Define default ADC type identifier.
Definition adc.h:71