Loading...
Searching...
No Matches
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
9#pragma once
10
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "periph/adc.h"
34#include "periph/gpio.h"
35
36#include "driver/adc.h"
37#include "driver/adc_types_legacy.h"
38
46typedef enum {
47 ADC_ATTENUATION_0_DB = ADC_ATTEN_DB_0,
48 ADC_ATTENUATION_3_DB = ADC_ATTEN_DB_2_5,
49 ADC_ATTENUATION_6_DB = ADC_ATTEN_DB_6,
50 ADC_ATTENUATION_12_DB = ADC_ATTEN_DB_12,
52
61#define ADC_ATTENUATION_11_DB ADC_ATTENUATION_12_DB
62
93int adc_set_attenuation(adc_t line, adc_atten_t atten);
94
118int adc_raw_to_voltage(adc_t line, int sample, int *voltage);
119
120#if !DOXYGEN
141__attribute__((__deprecated__))
142int adc_line_vref_to_gpio(adc_t line, gpio_t gpio);
143
144#if defined(CPU_FAM_ESP32)
156__attribute__((__deprecated__))
157static inline int adc_vref_to_gpio25(void)
158{
159 return adc_vref_to_gpio(ADC_UNIT_2, GPIO25);
160}
161#endif
162#endif /* !DOXYGEN */
163
164#ifdef __cplusplus
165}
166#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:46
@ ADC_ATTENUATION_12_DB
full-range is about 3.3 V
Definition adc_arch.h:50
@ ADC_ATTENUATION_0_DB
full-range is about 1.1 V (Vref)
Definition adc_arch.h:47
@ ADC_ATTENUATION_3_DB
full-range is about 1.5 V
Definition adc_arch.h:48
@ ADC_ATTENUATION_6_DB
full-range is about 2.2 V
Definition adc_arch.h:49
Low-level GPIO peripheral driver interface definitions.
uint_fast8_t adc_t
Define default ADC type identifier.
Definition adc.h:71