VSF Documented
adc_oneshot.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2026 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18/*
19 * Clean-room re-implementation of ESP-IDF "esp_adc/adc_oneshot.h" (v5.1).
20 *
21 * Authored from the ESP-IDF v5.1 public API only. No code copied from
22 * the ESP-IDF source tree. The VSF port bridges onto
23 *
24 * hal/driver/common/template/vsf_template_adc.h
25 *
26 * via a caller-supplied pool of vsf_adc_t * instances (see
27 * vsf_espidf_cfg_t::adc
28 * ). Pool index equals adc_unit_t (0 -> ADC_UNIT_1, 1 -> ADC_UNIT_2).
29 *
30 * Implemented subset:
31 * - adc_oneshot_new_unit / adc_oneshot_del_unit
32 * - adc_oneshot_config_channel (cached; applied on each read)
33 * - adc_oneshot_read (synchronous blocking)
34 *
35 * Continuous (DMA) mode is not implemented; callers requiring that path
36 * will receive ESP_ERR_NOT_SUPPORTED from the companion adc_continuous.h.
37 */
38
39#ifndef __VSF_ESPIDF_DRIVER_ADC_ONESHOT_H__
40#define __VSF_ESPIDF_DRIVER_ADC_ONESHOT_H__
41
42#include <stdint.h>
43
44#include "esp_err.h"
45#include "driver/adc_types.h"
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51/*============================ TYPES =========================================*/
52
55
57typedef struct {
62
64typedef struct {
68
69/*============================ PROTOTYPES ====================================*/
70
77
83
89 adc_channel_t channel,
90 const adc_oneshot_chan_cfg_t *config);
91
97 adc_channel_t channel,
98 int *out_raw);
99
100#ifdef __cplusplus
101}
102#endif
103
104#endif // __VSF_ESPIDF_DRIVER_ADC_ONESHOT_H__
esp_err_t adc_oneshot_config_channel(adc_oneshot_unit_handle_t handle, adc_channel_t channel, const adc_oneshot_chan_cfg_t *config)
Cache a channel configuration on the handle. The actual vsf_adc channel_request_once call happens in ...
Definition driver_adc_port.c:235
esp_err_t adc_oneshot_new_unit(const adc_oneshot_unit_init_cfg_t *init_config, adc_oneshot_unit_handle_t *ret_unit)
Allocate an ADC oneshot unit handle from the pool entry matching init_config->unit_id.
Definition driver_adc_port.c:166
esp_err_t adc_oneshot_read(adc_oneshot_unit_handle_t handle, adc_channel_t channel, int *out_raw)
Perform one blocking conversion on a channel and return the raw result.
Definition driver_adc_port.c:258
struct adc_oneshot_unit_ctx_t * adc_oneshot_unit_handle_t
Opaque handle for an ADC oneshot unit.
Definition adc_oneshot.h:54
esp_err_t adc_oneshot_del_unit(adc_oneshot_unit_handle_t handle)
Release an ADC oneshot unit handle allocated by adc_oneshot_new_unit().
Definition driver_adc_port.c:209
adc_oneshot_clk_src_t
ADC clock source. Accepted but ignored.
Definition adc_types.h:75
adc_atten_t
Input attenuation. Accepted but interpreted only as a hint for maximum measurable voltage – this shim...
Definition adc_types.h:66
adc_channel_t
ADC channel identifiers. Range is chip-dependent; channels beyond the target device's capability are ...
Definition adc_types.h:40
adc_ulp_mode_t
ULP mode (not modelled by this shim).
Definition adc_types.h:82
adc_unit_t
ADC peripheral unit.
Definition adc_types.h:33
adc_bitwidth_t
Effective resolution of a conversion result. Most targets support 12 or 13 bits; DEFAULT yields the c...
Definition adc_types.h:55
int esp_err_t
Definition esp_err.h:41
Per-channel configuration.
Definition adc_oneshot.h:64
adc_bitwidth_t bitwidth
Definition adc_oneshot.h:66
adc_atten_t atten
Definition adc_oneshot.h:65
Definition driver_adc_port.c:72
Unit-level init configuration.
Definition adc_oneshot.h:57
adc_oneshot_clk_src_t clk_src
Definition adc_oneshot.h:59
adc_unit_t unit_id
Definition adc_oneshot.h:58
adc_ulp_mode_t ulp_mode
Definition adc_oneshot.h:60
Generated from commit: vsfteam/vsf@015f4d1