2 ******************************************************************************
3 * @file stm32f3xx_hal_adc.h
4 * @author MCD Application Team
5 * @brief Header file containing functions prototypes of ADC HAL library.
6 ******************************************************************************
9 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
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.
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.
33 ******************************************************************************
36 /* Define to prevent recursive inclusion -------------------------------------*/
37 #ifndef __STM32F3xx_ADC_H
38 #define __STM32F3xx_ADC_H
44 /* Includes ------------------------------------------------------------------*/
45 #include "stm32f3xx_hal_def.h"
47 /* Include ADC HAL Extended module */
48 /* (include on top of file since ADC structures are defined in extended file) */
49 #include "stm32f3xx_hal_adc_ex.h"
51 /** @addtogroup STM32F3xx_HAL_Driver
59 /* Exported types ------------------------------------------------------------*/
60 /** @defgroup ADC_Exported_Types ADC Exported Types
64 * @brief HAL ADC state machine: ADC states definition (bitfields)
65 * @note ADC state machine is managed by bitfields, state must be compared
68 * " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_REG_BUSY)) "
69 * " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_AWD1) ) "
71 /* States of ADC global scope */
72 #define HAL_ADC_STATE_RESET (0x00000000U) /*!< ADC not yet initialized or disabled */
73 #define HAL_ADC_STATE_READY (0x00000001U) /*!< ADC peripheral ready for use */
74 #define HAL_ADC_STATE_BUSY_INTERNAL (0x00000002U) /*!< ADC is busy to internal process (initialization, calibration) */
75 #define HAL_ADC_STATE_TIMEOUT (0x00000004U) /*!< TimeOut occurrence */
77 /* States of ADC errors */
78 #define HAL_ADC_STATE_ERROR_INTERNAL (0x00000010U) /*!< Internal error occurrence */
79 #define HAL_ADC_STATE_ERROR_CONFIG (0x00000020U) /*!< Configuration error occurrence */
80 #define HAL_ADC_STATE_ERROR_DMA (0x00000040U) /*!< DMA error occurrence */
82 /* States of ADC group regular */
83 #define HAL_ADC_STATE_REG_BUSY (0x00000100U) /*!< A conversion on group regular is ongoing or can occur (either by continuous mode,
84 external trigger, low power auto power-on, multimode ADC master control) */
85 #define HAL_ADC_STATE_REG_EOC (0x00000200U) /*!< Conversion data available on group regular */
86 #define HAL_ADC_STATE_REG_OVR (0x00000400U) /*!< Overrun occurrence */
87 #define HAL_ADC_STATE_REG_EOSMP (0x00000800U) /*!< End Of Sampling flag raised */
89 /* States of ADC group injected */
90 #define HAL_ADC_STATE_INJ_BUSY (0x00001000U) /*!< A conversion on group injected is ongoing or can occur (either by auto-injection mode,
91 external trigger, low power auto power-on, multimode ADC master control) */
92 #define HAL_ADC_STATE_INJ_EOC (0x00002000U) /*!< Conversion data available on group injected */
93 #define HAL_ADC_STATE_INJ_JQOVF (0x00004000U) /*!< Injected queue overflow occurrence */
95 /* States of ADC analog watchdogs */
96 #define HAL_ADC_STATE_AWD1 (0x00010000U) /*!< Out-of-window occurrence of analog watchdog 1 */
97 #define HAL_ADC_STATE_AWD2 (0x00020000U) /*!< Out-of-window occurrence of analog watchdog 2 */
98 #define HAL_ADC_STATE_AWD3 (0x00040000U) /*!< Out-of-window occurrence of analog watchdog 3 */
100 /* States of ADC multi-mode */
101 #define HAL_ADC_STATE_MULTIMODE_SLAVE (0x00100000U) /*!< ADC in multimode slave state, controlled by another ADC master ( */
105 * @brief ADC handle Structure definition
107 typedef struct __ADC_HandleTypeDef
109 ADC_TypeDef
*Instance
; /*!< Register base address */
111 ADC_InitTypeDef Init
; /*!< ADC required parameters */
113 DMA_HandleTypeDef
*DMA_Handle
; /*!< Pointer DMA Handler */
115 HAL_LockTypeDef Lock
; /*!< ADC locking object */
117 __IO
uint32_t State
; /*!< ADC communication state (bitmap of ADC states) */
119 __IO
uint32_t ErrorCode
; /*!< ADC Error code */
121 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
122 defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
123 defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx) || \
124 defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
125 ADC_InjectionConfigTypeDef InjectionConfig
; /*!< ADC injected channel configuration build-up structure */
126 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
127 /* STM32F302xC || STM32F303xC || STM32F358xx || */
128 /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
129 /* STM32F301x8 || STM32F302x8 || STM32F318xx */
136 /* Exported constants --------------------------------------------------------*/
137 /* Exported macros -----------------------------------------------------------*/
139 /** @defgroup ADC_Exported_Macro ADC Exported Macros
142 /** @brief Reset ADC handle state
143 * @param __HANDLE__ ADC handle
146 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
154 /* Exported functions --------------------------------------------------------*/
155 /** @addtogroup ADC_Exported_Functions ADC Exported Functions
159 /** @addtogroup ADC_Exported_Functions_Group1 Initialization and de-initialization functions
162 /* Initialization and de-initialization functions **********************************/
163 HAL_StatusTypeDef
HAL_ADC_Init(ADC_HandleTypeDef
* hadc
);
164 HAL_StatusTypeDef
HAL_ADC_DeInit(ADC_HandleTypeDef
*hadc
);
165 void HAL_ADC_MspInit(ADC_HandleTypeDef
* hadc
);
166 void HAL_ADC_MspDeInit(ADC_HandleTypeDef
* hadc
);
171 /** @addtogroup ADC_Exported_Functions_Group2 Input and Output operation functions
174 /* Blocking mode: Polling */
175 HAL_StatusTypeDef
HAL_ADC_Start(ADC_HandleTypeDef
* hadc
);
176 HAL_StatusTypeDef
HAL_ADC_Stop(ADC_HandleTypeDef
* hadc
);
177 HAL_StatusTypeDef
HAL_ADC_PollForConversion(ADC_HandleTypeDef
* hadc
, uint32_t Timeout
);
178 HAL_StatusTypeDef
HAL_ADC_PollForEvent(ADC_HandleTypeDef
* hadc
, uint32_t EventType
, uint32_t Timeout
);
180 /* Non-blocking mode: Interruption */
181 HAL_StatusTypeDef
HAL_ADC_Start_IT(ADC_HandleTypeDef
* hadc
);
182 HAL_StatusTypeDef
HAL_ADC_Stop_IT(ADC_HandleTypeDef
* hadc
);
184 /* Non-blocking mode: DMA */
185 HAL_StatusTypeDef
HAL_ADC_Start_DMA(ADC_HandleTypeDef
* hadc
, uint32_t* pData
, uint32_t Length
);
186 HAL_StatusTypeDef
HAL_ADC_Stop_DMA(ADC_HandleTypeDef
* hadc
);
188 /* ADC retrieve conversion value intended to be used with polling or interruption */
189 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef
* hadc
);
191 /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption and DMA) */
192 void HAL_ADC_IRQHandler(ADC_HandleTypeDef
* hadc
);
193 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef
* hadc
);
194 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef
* hadc
);
195 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef
* hadc
);
196 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef
*hadc
);
201 /** @addtogroup ADC_Exported_Functions_Group3 Peripheral Control functions
204 /* Peripheral Control functions ***********************************************/
205 HAL_StatusTypeDef
HAL_ADC_ConfigChannel(ADC_HandleTypeDef
* hadc
, ADC_ChannelConfTypeDef
* sConfig
);
206 HAL_StatusTypeDef
HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef
* hadc
, ADC_AnalogWDGConfTypeDef
* AnalogWDGConfig
);
211 /** @defgroup ADC_Exported_Functions_Group4 Peripheral State functions
212 * @brief ADC Peripheral State functions
215 /* Peripheral State functions *************************************************/
216 uint32_t HAL_ADC_GetState(ADC_HandleTypeDef
* hadc
);
217 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef
*hadc
);
238 #endif /*__STM32F3xx_ADC_H */
241 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/