10a7ce71fSopenharmony_ci/*
20a7ce71fSopenharmony_ci * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED.
30a7ce71fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
40a7ce71fSopenharmony_ci * you may not use this file except in compliance with the License.
50a7ce71fSopenharmony_ci * You may obtain a copy of the License at
60a7ce71fSopenharmony_ci *
70a7ce71fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
80a7ce71fSopenharmony_ci *
90a7ce71fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
100a7ce71fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
110a7ce71fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120a7ce71fSopenharmony_ci * See the License for the specific language governing permissions and
130a7ce71fSopenharmony_ci * limitations under the License.
140a7ce71fSopenharmony_ci */
150a7ce71fSopenharmony_ci
160a7ce71fSopenharmony_ci/**
170a7ce71fSopenharmony_ci * @addtogroup iot
180a7ce71fSopenharmony_ci * @{
190a7ce71fSopenharmony_ci *
200a7ce71fSopenharmony_ci * @brief Provides dedicated device operation interfaces on the Wi-Fi module,
210a7ce71fSopenharmony_ci * including ADC, AT, flash, GPIO, I2C, I2S, partition, PWM, SDIO, UART, and watchdog.
220a7ce71fSopenharmony_ci *
230a7ce71fSopenharmony_ci * @since 1.0
240a7ce71fSopenharmony_ci * @version 1.0
250a7ce71fSopenharmony_ci */
260a7ce71fSopenharmony_ci
270a7ce71fSopenharmony_ci/**
280a7ce71fSopenharmony_ci * @file iot_adc.h
290a7ce71fSopenharmony_ci *
300a7ce71fSopenharmony_ci * @brief Declares the ADC interface functions for you to read data.
310a7ce71fSopenharmony_ci *
320a7ce71fSopenharmony_ci * @since 1.0
330a7ce71fSopenharmony_ci * @version 1.0
340a7ce71fSopenharmony_ci */
350a7ce71fSopenharmony_ci
360a7ce71fSopenharmony_ci#ifndef IOT_ADC_H
370a7ce71fSopenharmony_ci#define IOT_ADC_H
380a7ce71fSopenharmony_ci
390a7ce71fSopenharmony_ci/**
400a7ce71fSopenharmony_ci * @brief Enumerates ADC channel indexes.
410a7ce71fSopenharmony_ci *
420a7ce71fSopenharmony_ci */
430a7ce71fSopenharmony_citypedef enum {
440a7ce71fSopenharmony_ci    /** Channel 0 */
450a7ce71fSopenharmony_ci    IOT_ADC_CHANNEL_0,
460a7ce71fSopenharmony_ci    /** Channel 1 */
470a7ce71fSopenharmony_ci    IOT_ADC_CHANNEL_1,
480a7ce71fSopenharmony_ci    /** Channel 2 */
490a7ce71fSopenharmony_ci    IOT_ADC_CHANNEL_2,
500a7ce71fSopenharmony_ci    /** Channel 3 */
510a7ce71fSopenharmony_ci    IOT_ADC_CHANNEL_3,
520a7ce71fSopenharmony_ci    /** Channel 4 */
530a7ce71fSopenharmony_ci    IOT_ADC_CHANNEL_4,
540a7ce71fSopenharmony_ci    /** Channel 5 */
550a7ce71fSopenharmony_ci    IOT_ADC_CHANNEL_5,
560a7ce71fSopenharmony_ci    /** Channel 6 */
570a7ce71fSopenharmony_ci    IOT_ADC_CHANNEL_6,
580a7ce71fSopenharmony_ci    /** Channel 7 */
590a7ce71fSopenharmony_ci    IOT_ADC_CHANNEL_7,
600a7ce71fSopenharmony_ci    /** Button value */
610a7ce71fSopenharmony_ci    IOT_ADC_CHANNEL_BUTT,
620a7ce71fSopenharmony_ci} IotAdcChannelIndex;
630a7ce71fSopenharmony_ci
640a7ce71fSopenharmony_ci/**
650a7ce71fSopenharmony_ci * @brief Enumerates analog power control modes.
660a7ce71fSopenharmony_ci */
670a7ce71fSopenharmony_citypedef enum {
680a7ce71fSopenharmony_ci    /** Automatic control */
690a7ce71fSopenharmony_ci    IOT_ADC_CUR_BAIS_DEFAULT,
700a7ce71fSopenharmony_ci    /** Automatic control */
710a7ce71fSopenharmony_ci    IOT_ADC_CUR_BAIS_AUTO,
720a7ce71fSopenharmony_ci    /** Manual control (AVDD = 1.8 V) */
730a7ce71fSopenharmony_ci    IOT_ADC_CUR_BAIS_1P8V,
740a7ce71fSopenharmony_ci    /** Manual control (AVDD = 3.3 V) */
750a7ce71fSopenharmony_ci    IOT_ADC_CUR_BAIS_3P3V,
760a7ce71fSopenharmony_ci    /** Button value */
770a7ce71fSopenharmony_ci    IOT_ADC_CUR_BAIS_BUTT,
780a7ce71fSopenharmony_ci} IotAdcCurBais;
790a7ce71fSopenharmony_ci
800a7ce71fSopenharmony_ci/**
810a7ce71fSopenharmony_ci * @brief Enumerates equation models.
820a7ce71fSopenharmony_ci */
830a7ce71fSopenharmony_citypedef enum {
840a7ce71fSopenharmony_ci    /** One-equation model */
850a7ce71fSopenharmony_ci    IOT_ADC_EQU_MODEL_1,
860a7ce71fSopenharmony_ci    /** Two-equation model */
870a7ce71fSopenharmony_ci    IOT_ADC_EQU_MODEL_2,
880a7ce71fSopenharmony_ci    /** Four-equation model */
890a7ce71fSopenharmony_ci    IOT_ADC_EQU_MODEL_4,
900a7ce71fSopenharmony_ci    /** Eight-equation model */
910a7ce71fSopenharmony_ci    IOT_ADC_EQU_MODEL_8,
920a7ce71fSopenharmony_ci    /** Button value */
930a7ce71fSopenharmony_ci    IOT_ADC_EQU_MODEL_BUTT,
940a7ce71fSopenharmony_ci} IotAdcEquModelSel;
950a7ce71fSopenharmony_ci
960a7ce71fSopenharmony_ci/**
970a7ce71fSopenharmony_ci * @brief Reads a piece of sampled data from a specified ADC channel based on the input parameters.
980a7ce71fSopenharmony_ci *
990a7ce71fSopenharmony_ci *
1000a7ce71fSopenharmony_ci *
1010a7ce71fSopenharmony_ci * @param channel Indicates the ADC channel index.
1020a7ce71fSopenharmony_ci * @param data Indicates the pointer to the address for storing the read data.
1030a7ce71fSopenharmony_ci * @param equModel Indicates the equation model.
1040a7ce71fSopenharmony_ci * @param curBais Indicates the analog power control mode.
1050a7ce71fSopenharmony_ci * @param rstCnt Indicates the count of the time from reset to conversion start.
1060a7ce71fSopenharmony_ci *               One count is equal to 334 ns. The value must range from 0 to 0xFF0.
1070a7ce71fSopenharmony_ci * @return Returns {@link WIFI_IOT_SUCCESS} if the operation is successful;
1080a7ce71fSopenharmony_ci *         returns an error code defined in {@link wifiiot_errno.h} otherwise.
1090a7ce71fSopenharmony_ci * @since 1.0
1100a7ce71fSopenharmony_ci * @version 1.0
1110a7ce71fSopenharmony_ci */
1120a7ce71fSopenharmony_ciunsigned int AdcRead(const IotAdcChannelIndex channel, const unsigned short *data,
1130a7ce71fSopenharmony_ci    const  IotAdcEquModelSel equModel, const IotAdcCurBais curBais,
1140a7ce71fSopenharmony_ci    unsigned short rstCnt);
1150a7ce71fSopenharmony_ci
1160a7ce71fSopenharmony_ci#endif
117