1 /* 2 * Copyright (c) 2020 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup IotHardware 18 * @{ 19 * 20 * @brief Provides APIs for operating devices, 21 * including flash, GPIO, I2C, PWM, UART,ADC, and watchdog APIs. 22 * 23 * 24 * 25 * @since 2.2 26 * @version 2.2 27 */ 28 29 /** 30 * @file iot_adc.h 31 * 32 * @brief Declares the ADC interface functions for you to read data. 33 * 34 * @since 1.0 35 * @version 1.1.0 36 */ 37 38 #ifndef IOT_ADC_H 39 #define IOT_ADC_H 40 41 42 /** 43 * @brief Enumerates analog power control modes. 44 */ 45 typedef enum { 46 /** Automatic control */ 47 IOT_ADC_CUR_BAIS_DEFAULT, 48 /** Automatic control */ 49 IOT_ADC_CUR_BAIS_AUTO, 50 /** Manual control (AVDD = 1.8 V) */ 51 IOT_ADC_CUR_BAIS_1P8V, 52 /** Manual control (AVDD = 3.3 V) */ 53 IOT_ADC_CUR_BAIS_3P3V, 54 /** Button value */ 55 IOT_ADC_CUR_BAIS_BUTT, 56 } IotAdcCurBais; 57 58 /** 59 * @brief Enumerates equation models. 60 */ 61 typedef enum { 62 /** One-equation model */ 63 IOT_ADC_EQU_MODEL_1, 64 /** Two-equation model */ 65 IOT_ADC_EQU_MODEL_2, 66 /** Four-equation model */ 67 IOT_ADC_EQU_MODEL_4, 68 /** Eight-equation model */ 69 IOT_ADC_EQU_MODEL_8, 70 /** Button value */ 71 IOT_ADC_EQU_MODEL_BUTT, 72 } IotAdcEquModelSel; 73 74 /** 75 * @brief Reads a piece of sampled data from a specified ADC channel based on the input parameters. 76 * 77 * 78 * 79 * @param channel Indicates the ADC channel index. 80 * @param data Indicates the pointer to the address for storing the read data. 81 * @param equModel Indicates the equation model. 82 * @param curBais Indicates the analog power control mode. 83 * @param rstCnt Indicates the count of the time from reset to conversion start. 84 * One count is equal to 334 ns. The value must range from 0 to 0xFF0. 85 * @return Returns {@link IOT_SUCCESS} if the PWM signal output is stopped; 86 * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description. 87 * @since 1.0 88 * @version 1.0 89 */ 90 unsigned int IoTAdcRead(unsigned int channel, unsigned short *data, IotAdcEquModelSel equModel, 91 IotAdcCurBais curBais, unsigned short rstCnt); 92 93 #endif 94 /** @} */