iot_adc.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. * @addtogroup IotHardware
  17. * @{
  18. *
  19. * @brief Provides APIs for operating devices,
  20. * including flash, GPIO, I2C, PWM, UART,ADC, and watchdog APIs.
  21. *
  22. *
  23. *
  24. * @since 2.2
  25. * @version 2.2
  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.1.0
  34. */
  35. #ifndef IOT_ADC_H
  36. #define IOT_ADC_H
  37. /**
  38. * @brief Enumerates analog power control modes.
  39. */
  40. typedef enum {
  41. /** Automatic control */
  42. IOT_ADC_CUR_BAIS_DEFAULT,
  43. /** Automatic control */
  44. IOT_ADC_CUR_BAIS_AUTO,
  45. /** Manual control (AVDD = 1.8 V) */
  46. IOT_ADC_CUR_BAIS_1P8V,
  47. /** Manual control (AVDD = 3.3 V) */
  48. IOT_ADC_CUR_BAIS_3P3V,
  49. /** Button value */
  50. IOT_ADC_CUR_BAIS_BUTT,
  51. } IotAdcCurBais;
  52. /**
  53. * @brief Enumerates equation models.
  54. */
  55. typedef enum {
  56. /** One-equation model */
  57. IOT_ADC_EQU_MODEL_1,
  58. /** Two-equation model */
  59. IOT_ADC_EQU_MODEL_2,
  60. /** Four-equation model */
  61. IOT_ADC_EQU_MODEL_4,
  62. /** Eight-equation model */
  63. IOT_ADC_EQU_MODEL_8,
  64. /** Button value */
  65. IOT_ADC_EQU_MODEL_BUTT,
  66. } IotAdcEquModelSel;
  67. /**
  68. * @brief Reads a piece of sampled data from a specified ADC channel based on the input parameters.
  69. *
  70. *
  71. *
  72. * @param channel Indicates the ADC channel index.
  73. * @param data Indicates the pointer to the address for storing the read data.
  74. * @param equModel Indicates the equation model.
  75. * @param curBais Indicates the analog power control mode.
  76. * @param rstCnt Indicates the count of the time from reset to conversion start.
  77. * One count is equal to 334 ns. The value must range from 0 to 0xFF0.
  78. * @return Returns {@link IOT_SUCCESS} if the PWM signal output is stopped;
  79. * returns {@link IOT_FAILURE} otherwise. For details about other return values, see the chip description.
  80. * @since 1.0
  81. * @version 1.0
  82. */
  83. unsigned int IoTAdcRead(unsigned int channel, unsigned short *data, IotAdcEquModelSel equModel,
  84. IotAdcCurBais curBais, unsigned short rstCnt);
  85. #endif
  86. /** @} */