ql_adc.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. 
  2. /*================================================================
  3. Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
  4. Quectel Wireless Solutions Proprietary and Confidential.
  5. =================================================================*/
  6. /*=================================================================
  7. EDIT HISTORY FOR MODULE
  8. This section contains comments describing changes made to the module.
  9. Notice that changes are listed in reverse chronological order.
  10. WHEN WHO WHAT, WHERE, WHY
  11. ------------ ------- -------------------------------------------------------------------------------
  12. =================================================================*/
  13. #ifndef QL_ADC_H
  14. #define QL_ADC_H
  15. #include "ql_api_common.h"
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /*===========================================================================
  20. * Macro Definition
  21. ===========================================================================*/
  22. #define QL_ADC0_CHANNEL 0
  23. #define QL_ADC1_CHANNEL 1
  24. #define QL_ADC2_CHANNEL 2
  25. #define QL_ADC3_CHANNEL 3
  26. /*========================================================================
  27. * Enumeration Definition
  28. *========================================================================*/
  29. /**************************** error code about ADC ***************************/
  30. typedef enum
  31. {
  32. QL_ADC_SUCCESS = 0,
  33. QL_ADC_INVALID_PARAM_ERR = 10 | (QL_COMPONENT_BSP_ADC << 16),
  34. QL_ADC_GET_VALUE_ERROR = 50 | (QL_COMPONENT_BSP_ADC << 16),
  35. QL_ADC_MEM_ADDR_NULL_ERROR = 60 | (QL_COMPONENT_BSP_ADC << 16),
  36. } ql_errcode_adc_e;
  37. /*===========================================================================
  38. * Struct
  39. ===========================================================================*/
  40. typedef enum
  41. {
  42. QL_ADC_SCALE_AUTO = 0xFF, //自适应
  43. QL_ADC_SCALE_0 = 0, //0.1-1V
  44. QL_ADC_SCALE_1 = 1, //0.2-1.4V
  45. QL_ADC_SCALE_2 = 2, //0.26-2.6V
  46. QL_ADC_SCALE_3 = 3, //0.406-4.06V
  47. QL_ADC_SCALE_MAX = 3,
  48. }ql_adc_aux_scale;
  49. /*===========================================================================
  50. * Functions declaration
  51. ===========================================================================*/
  52. /*****************************************************************
  53. * Function: ql_adc_get_volt
  54. *
  55. * Description: get adc value of voltage by ADC0/ADC1/ADC2/ADC3
  56. *
  57. * Parameters:
  58. * adc_id [in] input adcid
  59. * adc_value [out] adc value
  60. *
  61. * Return:
  62. * volt_value succeed
  63. * -1 failure
  64. *
  65. *****************************************************************/
  66. ql_errcode_adc_e ql_adc_get_volt(int ql_adc_channel_id, int *adc_value);
  67. /*****************************************************************
  68. * Function: ql_adc_get_volt_raw
  69. *
  70. * Description: get adc raw value of voltage by ADC0/ADC1/ADC2/ADC3
  71. * this interface obtain adc raw data in order to improve the speed
  72. * customers need to optimize the accuracy themselves
  73. *
  74. * Parameters:
  75. * adc_id [in] input adcid
  76. * aux_scale [in] input adc scale
  77. * adc_value [out] raw adc value
  78. *
  79. * Return:
  80. * volt_value succeed
  81. * -1 failure
  82. *
  83. *****************************************************************/
  84. ql_errcode_adc_e ql_adc_get_volt_raw(int ql_adc_channel_id, ql_adc_aux_scale aux_scale, int *adc_value);
  85. #ifdef __cplusplus
  86. } /*"C" */
  87. #endif
  88. #endif /* QL_ADC_H */