stm32f3xx_hal_adc.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_hal_adc.h
  4. * @author MCD Application Team
  5. * @brief Header file containing functions prototypes of ADC HAL library.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F3xx_ADC_H
  37. #define __STM32F3xx_ADC_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f3xx_hal_def.h"
  43. /* Include ADC HAL Extended module */
  44. /* (include on top of file since ADC structures are defined in extended file) */
  45. #include "stm32f3xx_hal_adc_ex.h"
  46. /** @addtogroup STM32F3xx_HAL_Driver
  47. * @{
  48. */
  49. /** @addtogroup ADC
  50. * @{
  51. */
  52. /* Exported types ------------------------------------------------------------*/
  53. /** @defgroup ADC_Exported_Types ADC Exported Types
  54. * @{
  55. */
  56. /**
  57. * @brief HAL ADC state machine: ADC states definition (bitfields)
  58. * @note ADC state machine is managed by bitfields, state must be compared
  59. * with bit by bit.
  60. * For example:
  61. * " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_REG_BUSY)) "
  62. * " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_AWD1) ) "
  63. */
  64. /* States of ADC global scope */
  65. #define HAL_ADC_STATE_RESET (0x00000000U) /*!< ADC not yet initialized or disabled */
  66. #define HAL_ADC_STATE_READY (0x00000001U) /*!< ADC peripheral ready for use */
  67. #define HAL_ADC_STATE_BUSY_INTERNAL (0x00000002U) /*!< ADC is busy to internal process (initialization, calibration) */
  68. #define HAL_ADC_STATE_TIMEOUT (0x00000004U) /*!< TimeOut occurrence */
  69. /* States of ADC errors */
  70. #define HAL_ADC_STATE_ERROR_INTERNAL (0x00000010U) /*!< Internal error occurrence */
  71. #define HAL_ADC_STATE_ERROR_CONFIG (0x00000020U) /*!< Configuration error occurrence */
  72. #define HAL_ADC_STATE_ERROR_DMA (0x00000040U) /*!< DMA error occurrence */
  73. /* States of ADC group regular */
  74. #define HAL_ADC_STATE_REG_BUSY (0x00000100U) /*!< A conversion on group regular is ongoing or can occur (either by continuous mode,
  75. external trigger, low power auto power-on, multimode ADC master control) */
  76. #define HAL_ADC_STATE_REG_EOC (0x00000200U) /*!< Conversion data available on group regular */
  77. #define HAL_ADC_STATE_REG_OVR (0x00000400U) /*!< Overrun occurrence */
  78. #define HAL_ADC_STATE_REG_EOSMP (0x00000800U) /*!< End Of Sampling flag raised */
  79. /* States of ADC group injected */
  80. #define HAL_ADC_STATE_INJ_BUSY (0x00001000U) /*!< A conversion on group injected is ongoing or can occur (either by auto-injection mode,
  81. external trigger, low power auto power-on, multimode ADC master control) */
  82. #define HAL_ADC_STATE_INJ_EOC (0x00002000U) /*!< Conversion data available on group injected */
  83. #define HAL_ADC_STATE_INJ_JQOVF (0x00004000U) /*!< Injected queue overflow occurrence */
  84. /* States of ADC analog watchdogs */
  85. #define HAL_ADC_STATE_AWD1 (0x00010000U) /*!< Out-of-window occurrence of analog watchdog 1 */
  86. #define HAL_ADC_STATE_AWD2 (0x00020000U) /*!< Out-of-window occurrence of analog watchdog 2 */
  87. #define HAL_ADC_STATE_AWD3 (0x00040000U) /*!< Out-of-window occurrence of analog watchdog 3 */
  88. /* States of ADC multi-mode */
  89. #define HAL_ADC_STATE_MULTIMODE_SLAVE (0x00100000U) /*!< ADC in multimode slave state, controlled by another ADC master ( */
  90. /**
  91. * @brief ADC handle Structure definition
  92. */
  93. typedef struct __ADC_HandleTypeDef
  94. {
  95. ADC_TypeDef *Instance; /*!< Register base address */
  96. ADC_InitTypeDef Init; /*!< ADC required parameters */
  97. DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
  98. HAL_LockTypeDef Lock; /*!< ADC locking object */
  99. __IO uint32_t State; /*!< ADC communication state (bitmap of ADC states) */
  100. __IO uint32_t ErrorCode; /*!< ADC Error code */
  101. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  102. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  103. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  104. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  105. ADC_InjectionConfigTypeDef InjectionConfig ; /*!< ADC injected channel configuration build-up structure */
  106. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  107. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  108. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  109. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  110. }ADC_HandleTypeDef;
  111. /**
  112. * @}
  113. */
  114. /* Exported constants --------------------------------------------------------*/
  115. /* Exported macros -----------------------------------------------------------*/
  116. /** @defgroup ADC_Exported_Macro ADC Exported Macros
  117. * @{
  118. */
  119. /** @brief Reset ADC handle state
  120. * @param __HANDLE__ ADC handle
  121. * @retval None
  122. */
  123. #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
  124. /**
  125. * @}
  126. */
  127. /* Exported functions --------------------------------------------------------*/
  128. /** @addtogroup ADC_Exported_Functions ADC Exported Functions
  129. * @{
  130. */
  131. /** @addtogroup ADC_Exported_Functions_Group1 Initialization and de-initialization functions
  132. * @{
  133. */
  134. /* Initialization and de-initialization functions **********************************/
  135. HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
  136. HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
  137. void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
  138. void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
  139. /**
  140. * @}
  141. */
  142. /** @addtogroup ADC_Exported_Functions_Group2 Input and Output operation functions
  143. * @{
  144. */
  145. /* Blocking mode: Polling */
  146. HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
  147. HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
  148. HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
  149. HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
  150. /* Non-blocking mode: Interruption */
  151. HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
  152. HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
  153. /* Non-blocking mode: DMA */
  154. HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
  155. HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
  156. /* ADC retrieve conversion value intended to be used with polling or interruption */
  157. uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
  158. /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption and DMA) */
  159. void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
  160. void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
  161. void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
  162. void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
  163. void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
  164. /**
  165. * @}
  166. */
  167. /** @addtogroup ADC_Exported_Functions_Group3 Peripheral Control functions
  168. * @{
  169. */
  170. /* Peripheral Control functions ***********************************************/
  171. HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
  172. HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
  173. /**
  174. * @}
  175. */
  176. /** @defgroup ADC_Exported_Functions_Group4 Peripheral State functions
  177. * @brief ADC Peripheral State functions
  178. * @{
  179. */
  180. /* Peripheral State functions *************************************************/
  181. uint32_t HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
  182. uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
  183. /**
  184. * @}
  185. */
  186. /**
  187. * @}
  188. */
  189. /**
  190. * @}
  191. */
  192. /**
  193. * @}
  194. */
  195. #ifdef __cplusplus
  196. }
  197. #endif
  198. #endif /*__STM32F3xx_ADC_H */
  199. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/