stm32f3xx_hal_adc.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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 "stm32f3xx_hal_dma.h"
  44. /* Include ADC HAL Extended module */
  45. /* (include on top of file since ADC structures are defined in extended file) */
  46. #include "stm32f3xx_hal_adc_ex.h"
  47. /** @addtogroup STM32F3xx_HAL_Driver
  48. * @{
  49. */
  50. /** @addtogroup ADC
  51. * @{
  52. */
  53. /* Exported types ------------------------------------------------------------*/
  54. /** @defgroup ADC_Exported_Types ADC Exported Types
  55. * @{
  56. */
  57. /**
  58. * @brief HAL ADC state machine: ADC states definition (bitfields)
  59. * @note ADC state machine is managed by bitfields, state must be compared
  60. * with bit by bit.
  61. * For example:
  62. * " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_REG_BUSY)) "
  63. * " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_AWD1) ) "
  64. */
  65. /* States of ADC global scope */
  66. #define HAL_ADC_STATE_RESET (0x00000000U) /*!< ADC not yet initialized or disabled */
  67. #define HAL_ADC_STATE_READY (0x00000001U) /*!< ADC peripheral ready for use */
  68. #define HAL_ADC_STATE_BUSY_INTERNAL (0x00000002U) /*!< ADC is busy to internal process (initialization, calibration) */
  69. #define HAL_ADC_STATE_TIMEOUT (0x00000004U) /*!< TimeOut occurrence */
  70. /* States of ADC errors */
  71. #define HAL_ADC_STATE_ERROR_INTERNAL (0x00000010U) /*!< Internal error occurrence */
  72. #define HAL_ADC_STATE_ERROR_CONFIG (0x00000020U) /*!< Configuration error occurrence */
  73. #define HAL_ADC_STATE_ERROR_DMA (0x00000040U) /*!< DMA error occurrence */
  74. /* States of ADC group regular */
  75. #define HAL_ADC_STATE_REG_BUSY (0x00000100U) /*!< A conversion on group regular is ongoing or can occur (either by continuous mode,
  76. external trigger, low power auto power-on, multimode ADC master control) */
  77. #define HAL_ADC_STATE_REG_EOC (0x00000200U) /*!< Conversion data available on group regular */
  78. #define HAL_ADC_STATE_REG_OVR (0x00000400U) /*!< Overrun occurrence */
  79. #define HAL_ADC_STATE_REG_EOSMP (0x00000800U) /*!< End Of Sampling flag raised */
  80. /* States of ADC group injected */
  81. #define HAL_ADC_STATE_INJ_BUSY (0x00001000U) /*!< A conversion on group injected is ongoing or can occur (either by auto-injection mode,
  82. external trigger, low power auto power-on, multimode ADC master control) */
  83. #define HAL_ADC_STATE_INJ_EOC (0x00002000U) /*!< Conversion data available on group injected */
  84. #define HAL_ADC_STATE_INJ_JQOVF (0x00004000U) /*!< Injected queue overflow occurrence */
  85. /* States of ADC analog watchdogs */
  86. #define HAL_ADC_STATE_AWD1 (0x00010000U) /*!< Out-of-window occurrence of analog watchdog 1 */
  87. #define HAL_ADC_STATE_AWD2 (0x00020000U) /*!< Out-of-window occurrence of analog watchdog 2 */
  88. #define HAL_ADC_STATE_AWD3 (0x00040000U) /*!< Out-of-window occurrence of analog watchdog 3 */
  89. /* States of ADC multi-mode */
  90. #define HAL_ADC_STATE_MULTIMODE_SLAVE (0x00100000U) /*!< ADC in multimode slave state, controlled by another ADC master ( */
  91. /**
  92. * @brief ADC handle Structure definition
  93. */
  94. typedef struct __ADC_HandleTypeDef
  95. {
  96. ADC_TypeDef *Instance; /*!< Register base address */
  97. ADC_InitTypeDef Init; /*!< ADC required parameters */
  98. DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
  99. HAL_LockTypeDef Lock; /*!< ADC locking object */
  100. __IO uint32_t State; /*!< ADC communication state (bitmap of ADC states) */
  101. __IO uint32_t ErrorCode; /*!< ADC Error code */
  102. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  103. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  104. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
  105. defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  106. ADC_InjectionConfigTypeDef InjectionConfig ; /*!< ADC injected channel configuration build-up structure */
  107. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  108. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  109. /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
  110. /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  111. }ADC_HandleTypeDef;
  112. /**
  113. * @}
  114. */
  115. /* Exported constants --------------------------------------------------------*/
  116. /* Exported macros -----------------------------------------------------------*/
  117. /** @defgroup ADC_Exported_Macro ADC Exported Macros
  118. * @{
  119. */
  120. /** @brief Reset ADC handle state
  121. * @param __HANDLE__ ADC handle
  122. * @retval None
  123. */
  124. #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
  125. /**
  126. * @}
  127. */
  128. /* Exported functions --------------------------------------------------------*/
  129. /** @addtogroup ADC_Exported_Functions ADC Exported Functions
  130. * @{
  131. */
  132. /** @addtogroup ADC_Exported_Functions_Group1 Initialization and de-initialization functions
  133. * @{
  134. */
  135. /* Initialization and de-initialization functions **********************************/
  136. HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
  137. HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
  138. void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
  139. void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
  140. /**
  141. * @}
  142. */
  143. /** @addtogroup ADC_Exported_Functions_Group2 Input and Output operation functions
  144. * @{
  145. */
  146. /* Blocking mode: Polling */
  147. HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
  148. HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
  149. HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
  150. HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
  151. /* Non-blocking mode: Interruption */
  152. HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
  153. HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
  154. /* Non-blocking mode: DMA */
  155. HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
  156. HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
  157. /* ADC retrieve conversion value intended to be used with polling or interruption */
  158. uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
  159. /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption and DMA) */
  160. void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
  161. void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
  162. void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
  163. void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
  164. void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
  165. /**
  166. * @}
  167. */
  168. /** @addtogroup ADC_Exported_Functions_Group3 Peripheral Control functions
  169. * @{
  170. */
  171. /* Peripheral Control functions ***********************************************/
  172. HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
  173. HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
  174. /**
  175. * @}
  176. */
  177. /** @defgroup ADC_Exported_Functions_Group4 Peripheral State functions
  178. * @brief ADC Peripheral State functions
  179. * @{
  180. */
  181. /* Peripheral State functions *************************************************/
  182. uint32_t HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
  183. uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
  184. /**
  185. * @}
  186. */
  187. /**
  188. * @}
  189. */
  190. /**
  191. * @}
  192. */
  193. /**
  194. * @}
  195. */
  196. #ifdef __cplusplus
  197. }
  198. #endif
  199. #endif /*__STM32F3xx_ADC_H */
  200. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/