1 /* 2 * Copyright (c) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 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 iot 18 * @{ 19 * 20 * @brief Provides dedicated device operation interfaces on the Wi-Fi module, 21 * including ADC, AT, flash, GPIO, I2C, I2S, partition, PWM, SDIO, UART, and watchdog. 22 * 23 * @since 1.0 24 * @version 1.0 25 */ 26 27 /** 28 * @file iot_adc.h 29 * 30 * @brief Declares the ADC interface functions for you to read data. 31 * 32 * @since 1.0 33 * @version 1.0 34 */ 35 36 #ifndef IOT_ADC_H 37 #define IOT_ADC_H 38 39 /** 40 * @brief Enumerates ADC channel indexes. 41 * 42 */ 43 typedef enum { 44 /** Channel 0 */ 45 IOT_ADC_CHANNEL_0, 46 /** Channel 1 */ 47 IOT_ADC_CHANNEL_1, 48 /** Channel 2 */ 49 IOT_ADC_CHANNEL_2, 50 /** Channel 3 */ 51 IOT_ADC_CHANNEL_3, 52 /** Channel 4 */ 53 IOT_ADC_CHANNEL_4, 54 /** Channel 5 */ 55 IOT_ADC_CHANNEL_5, 56 /** Channel 6 */ 57 IOT_ADC_CHANNEL_6, 58 /** Channel 7 */ 59 IOT_ADC_CHANNEL_7, 60 /** Button value */ 61 IOT_ADC_CHANNEL_BUTT, 62 } IotAdcChannelIndex; 63 64 /** 65 * @brief Enumerates analog power control modes. 66 */ 67 typedef enum { 68 /** Automatic control */ 69 IOT_ADC_CUR_BAIS_DEFAULT, 70 /** Automatic control */ 71 IOT_ADC_CUR_BAIS_AUTO, 72 /** Manual control (AVDD = 1.8 V) */ 73 IOT_ADC_CUR_BAIS_1P8V, 74 /** Manual control (AVDD = 3.3 V) */ 75 IOT_ADC_CUR_BAIS_3P3V, 76 /** Button value */ 77 IOT_ADC_CUR_BAIS_BUTT, 78 } IotAdcCurBais; 79 80 /** 81 * @brief Enumerates equation models. 82 */ 83 typedef enum { 84 /** One-equation model */ 85 IOT_ADC_EQU_MODEL_1, 86 /** Two-equation model */ 87 IOT_ADC_EQU_MODEL_2, 88 /** Four-equation model */ 89 IOT_ADC_EQU_MODEL_4, 90 /** Eight-equation model */ 91 IOT_ADC_EQU_MODEL_8, 92 /** Button value */ 93 IOT_ADC_EQU_MODEL_BUTT, 94 } IotAdcEquModelSel; 95 96 /** 97 * @brief Reads a piece of sampled data from a specified ADC channel based on the input parameters. 98 * 99 * 100 * 101 * @param channel Indicates the ADC channel index. 102 * @param data Indicates the pointer to the address for storing the read data. 103 * @param equModel Indicates the equation model. 104 * @param curBais Indicates the analog power control mode. 105 * @param rstCnt Indicates the count of the time from reset to conversion start. 106 * One count is equal to 334 ns. The value must range from 0 to 0xFF0. 107 * @return Returns {@link WIFI_IOT_SUCCESS} if the operation is successful; 108 * returns an error code defined in {@link wifiiot_errno.h} otherwise. 109 * @since 1.0 110 * @version 1.0 111 */ 112 unsigned int AdcRead(const IotAdcChannelIndex channel, const unsigned short *data, 113 const IotAdcEquModelSel equModel, const IotAdcCurBais curBais, 114 unsigned short rstCnt); 115 116 #endif 117