2 ******************************************************************************
3 * @file stm32f3xx_hal_adc.h
4 * @author MCD Application Team
7 * @brief Header file containing functions prototypes of ADC HAL library.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F3xx_ADC_H
40 #define __STM32F3xx_ADC_H
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f3xx_hal_def.h"
48 #include "stm32f3xx_hal_adc_ex.h"
50 /** @addtogroup STM32F3xx_HAL_Driver
58 /* Exported types ------------------------------------------------------------*/
59 /** @defgroup ADC_Exported_Types ADC Exported Types
63 * @brief HAL ADC state machine: ADC States structure definition
67 HAL_ADC_STATE_RESET = 0x00, /*!< ADC not yet initialized or disabled */
68 HAL_ADC_STATE_READY = 0x01, /*!< ADC peripheral ready for use */
69 HAL_ADC_STATE_BUSY = 0x02, /*!< An internal process is ongoing */
70 HAL_ADC_STATE_BUSY_REG = 0x12, /*!< Regular conversion is ongoing */
71 HAL_ADC_STATE_BUSY_INJ = 0x22, /*!< Injected conversion is ongoing */
72 HAL_ADC_STATE_BUSY_INJ_REG = 0x32, /*!< Injected and regular conversion are ongoing */
73 HAL_ADC_STATE_TIMEOUT = 0x03, /*!< Timeout state */
74 HAL_ADC_STATE_ERROR = 0x04, /*!< ADC state error */
75 HAL_ADC_STATE_EOC = 0x05, /*!< Conversion is completed */
76 HAL_ADC_STATE_EOC_REG = 0x15, /*!< Regular conversion is completed */
77 HAL_ADC_STATE_EOC_INJ = 0x25, /*!< Injected conversion is completed */
78 HAL_ADC_STATE_EOC_INJ_REG = 0x35, /*!< Injected and regular conversion are completed */
79 HAL_ADC_STATE_AWD = 0x06, /*!< ADC state analog watchdog (main analog watchdog, present on all STM32 devices) */
80 HAL_ADC_STATE_AWD2 = 0x07, /*!< ADC state analog watchdog (additional analog watchdog, present only on STM32F3 devices) */
81 HAL_ADC_STATE_AWD3 = 0x08, /*!< ADC state analog watchdog (additional analog watchdog, present only on STM32F3 devices) */
82 }HAL_ADC_StateTypeDef;
85 * @brief ADC handle Structure definition
87 typedef struct __ADC_HandleTypeDef
89 ADC_TypeDef *Instance; /*!< Register base address */
91 ADC_InitTypeDef Init; /*!< ADC required parameters */
93 __IO uint32_t NbrOfConversionRank ; /*!< ADC conversion rank counter */
95 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
97 HAL_LockTypeDef Lock; /*!< ADC locking object */
99 __IO HAL_ADC_StateTypeDef State; /*!< ADC communication state */
101 __IO uint32_t ErrorCode; /*!< ADC Error code */
107 /* Exported constants --------------------------------------------------------*/
108 /* Exported macros -----------------------------------------------------------*/
110 /** @defgroup ADC_Exported_Macro ADC Exported Macros
113 /** @brief Reset ADC handle state
114 * @param __HANDLE__: ADC handle
117 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
124 /* Include ADC HAL Extended module */
125 #include "stm32f3xx_hal_adc_ex.h"
127 /* Exported functions --------------------------------------------------------*/
128 /** @addtogroup ADC_Exported_Functions ADC Exported Functions
132 /** @addtogroup ADC_Exported_Functions_Group1 Initialization and de-initialization functions
133 * @brief Initialization and Configuration functions
136 /* Initialization and de-initialization functions **********************************/
137 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
138 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
139 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
140 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
145 /** @addtogroup ADC_Exported_Functions_Group2 Input and Output operation functions
146 * @brief IO operation functions
149 /* Blocking mode: Polling */
150 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
151 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
152 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
153 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
155 /* Non-blocking mode: Interruption */
156 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
157 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
159 /* Non-blocking mode: DMA */
160 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
161 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
163 /* ADC retrieve conversion value intended to be used with polling or interruption */
164 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
166 /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption and DMA) */
167 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
168 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
169 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
170 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
171 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
176 /** @addtogroup ADC_Exported_Functions_Group3 Peripheral Control functions
177 * @brief Peripheral Control functions
180 /* Peripheral Control functions ***********************************************/
181 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
182 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
187 /** @defgroup ADC_Exported_Functions_Group4 Peripheral State functions
188 * @brief ADC Peripheral State functions
191 /* Peripheral State functions *************************************************/
192 HAL_ADC_StateTypeDef HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
193 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
214 #endif /*__STM32F3xx_ADC_H */
217 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/