SRA Board Components
ESP-IDF component for SRA Board
adc.h
Go to the documentation of this file.
1/*
2 * MIT License
3 *
4 * Copyright (c) 2021 Society of Robotics and Automation
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#ifndef _ADC_H
26#define _ADC_H
27
28#include <stdio.h>
29#include <stdlib.h>
30
31#include "esp_adc/adc_oneshot.h"
32#include "esp_adc/adc_cali.h"
33#include "esp_adc/adc_cali_scheme.h"
34
35#include "freertos/FreeRTOS.h"
36#include "freertos/task.h"
37#include "freertos/event_groups.h"
38
39#include "esp_log.h"
40#include "esp_err.h"
41#include "pin_defs.h"
42
43#define ADC_ATTEN ADC_ATTEN_DB_11
44#define ADC_BITWIDTH_LEN ADC_BITWIDTH_12
45
51typedef struct
52{
53 adc_oneshot_unit_handle_t adc1_handle;
54 adc_cali_handle_t adc1_cali_handle[5];
55 bool do_calib[5];
56} adc_obj_t;
57
59
65esp_err_t enable_adc1(adc_obj_t** adc_obj);
66
74int read_adc(adc_handle_t adc_handle, int gpio);
75
76#endif
adc_obj_t * adc_handle_t
Definition: adc.h:58
esp_err_t enable_adc1(adc_obj_t **adc_obj)
call function config_adc1() and characterize_adc1().
Definition: adc.c:109
int read_adc(adc_handle_t adc_handle, int gpio)
Reads the adc value from the GPIO(channel) specified.
Definition: adc.c:125
Structure representing an ADC object.
Definition: adc.h:52
adc_oneshot_unit_handle_t adc1_handle
Definition: adc.h:53