hal_adc_lld.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
  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. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @file hal_adc_lld.h
  15. * @brief PLATFORM ADC subsystem low level driver header.
  16. *
  17. * @addtogroup ADC
  18. * @{
  19. */
  20. #ifndef HAL_ADC_LLD_H
  21. #define HAL_ADC_LLD_H
  22. #if (HAL_USE_ADC == TRUE) || defined(__DOXYGEN__)
  23. /*===========================================================================*/
  24. /* Driver constants. */
  25. /*===========================================================================*/
  26. /*===========================================================================*/
  27. /* Driver pre-compile time settings. */
  28. /*===========================================================================*/
  29. /**
  30. * @name PLATFORM configuration options
  31. * @{
  32. */
  33. /**
  34. * @brief ADC1 driver enable switch.
  35. * @details If set to @p TRUE the support for ADC1 is included.
  36. * @note The default is @p FALSE.
  37. */
  38. #if !defined(PLATFORM_ADC_USE_ADC1) || defined(__DOXYGEN__)
  39. #define PLATFORM_ADC_USE_ADC1 FALSE
  40. #endif
  41. /** @} */
  42. /*===========================================================================*/
  43. /* Derived constants and error checks. */
  44. /*===========================================================================*/
  45. /*===========================================================================*/
  46. /* Driver data structures and types. */
  47. /*===========================================================================*/
  48. /**
  49. * @brief ADC sample data type.
  50. */
  51. typedef uint16_t adcsample_t;
  52. /**
  53. * @brief Channels number in a conversion group.
  54. */
  55. typedef uint16_t adc_channels_num_t;
  56. /**
  57. * @brief Possible ADC failure causes.
  58. * @note Error codes are architecture dependent and should not relied
  59. * upon.
  60. */
  61. typedef enum {
  62. ADC_ERR_DMAFAILURE = 0, /**< DMA operations failure. */
  63. ADC_ERR_OVERFLOW = 1, /**< ADC overflow condition. */
  64. ADC_ERR_AWD = 2 /**< Analog watchdog triggered. */
  65. } adcerror_t;
  66. /*===========================================================================*/
  67. /* Driver macros. */
  68. /*===========================================================================*/
  69. /**
  70. * @brief Low level fields of the ADC driver structure.
  71. */
  72. #define adc_lld_driver_fields \
  73. /* Dummy field, it is not needed.*/ \
  74. uint32_t dummy
  75. /**
  76. * @brief Low level fields of the ADC configuration structure.
  77. */
  78. #define adc_lld_config_fields \
  79. /* Dummy configuration, it is not needed.*/ \
  80. uint32_t dummy
  81. /**
  82. * @brief Low level fields of the ADC configuration structure.
  83. */
  84. #define adc_lld_configuration_group_fields \
  85. /* Dummy configuration, it is not needed.*/ \
  86. uint32_t dummy
  87. /*===========================================================================*/
  88. /* External declarations. */
  89. /*===========================================================================*/
  90. #if (PLATFORM_ADC_USE_ADC1 == TRUE) && !defined(__DOXYGEN__)
  91. extern ADCDriver ADCD1;
  92. #endif
  93. #ifdef __cplusplus
  94. extern "C" {
  95. #endif
  96. void adc_lld_init(void);
  97. void adc_lld_start(ADCDriver *adcp);
  98. void adc_lld_stop(ADCDriver *adcp);
  99. void adc_lld_start_conversion(ADCDriver *adcp);
  100. void adc_lld_stop_conversion(ADCDriver *adcp);
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #endif /* HAL_USE_ADC == TRUE */
  105. #endif /* HAL_ADC_LLD_H */
  106. /** @} */