66 ******************************************************************************
77 * @attention
88 *
9- * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
9+ * <h2><center>© Copyright (c) 2016 STMicroelectronics.
10+ * All rights reserved.</center></h2>
1011 *
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.
12+ * This software component is licensed by ST under BSD 3-Clause license,
13+ * the "License"; You may not use this file except in compliance with the
14+ * License. You may obtain a copy of the License at:
15+ * opensource.org/licenses/BSD-3-Clause
3216 *
3317 ******************************************************************************
3418 */
@@ -127,8 +111,40 @@ typedef struct __ADC_HandleTypeDef
127111 /* STM32F302xC || STM32F303xC || STM32F358xx || */
128112 /* STM32F303x8 || STM32F334x8 || STM32F328xx || */
129113 /* STM32F301x8 || STM32F302x8 || STM32F318xx */
130-
114+
115+ #if (USE_HAL_ADC_REGISTER_CALLBACKS == 1 )
116+ void (* ConvCpltCallback )(struct __ADC_HandleTypeDef * hadc ); /*!< ADC conversion complete callback */
117+ void (* ConvHalfCpltCallback )(struct __ADC_HandleTypeDef * hadc ); /*!< ADC conversion DMA half-transfer callback */
118+ void (* LevelOutOfWindowCallback )(struct __ADC_HandleTypeDef * hadc ); /*!< ADC analog watchdog 1 callback */
119+ void (* ErrorCallback )(struct __ADC_HandleTypeDef * hadc ); /*!< ADC error callback */
120+ void (* InjectedConvCpltCallback )(struct __ADC_HandleTypeDef * hadc ); /*!< ADC group injected conversion complete callback */ /*!< ADC end of sampling callback */
121+ void (* MspInitCallback )(struct __ADC_HandleTypeDef * hadc ); /*!< ADC Msp Init callback */
122+ void (* MspDeInitCallback )(struct __ADC_HandleTypeDef * hadc ); /*!< ADC Msp DeInit callback */
123+ #endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
131124}ADC_HandleTypeDef ;
125+
126+ #if (USE_HAL_ADC_REGISTER_CALLBACKS == 1 )
127+ /**
128+ * @brief HAL ADC Callback ID enumeration definition
129+ */
130+ typedef enum
131+ {
132+ HAL_ADC_CONVERSION_COMPLETE_CB_ID = 0x00U , /*!< ADC conversion complete callback ID */
133+ HAL_ADC_CONVERSION_HALF_CB_ID = 0x01U , /*!< ADC conversion DMA half-transfer callback ID */
134+ HAL_ADC_LEVEL_OUT_OF_WINDOW_1_CB_ID = 0x02U , /*!< ADC analog watchdog 1 callback ID */
135+ HAL_ADC_ERROR_CB_ID = 0x03U , /*!< ADC error callback ID */
136+ HAL_ADC_INJ_CONVERSION_COMPLETE_CB_ID = 0x04U , /*!< ADC group injected conversion complete callback ID */
137+ HAL_ADC_MSPINIT_CB_ID = 0x09U , /*!< ADC Msp Init callback ID */
138+ HAL_ADC_MSPDEINIT_CB_ID = 0x0AU /*!< ADC Msp DeInit callback ID */
139+ } HAL_ADC_CallbackIDTypeDef ;
140+
141+ /**
142+ * @brief HAL ADC Callback pointer definition
143+ */
144+ typedef void (* pADC_CallbackTypeDef )(ADC_HandleTypeDef * hadc ); /*!< pointer to a ADC callback function */
145+
146+ #endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
147+
132148/**
133149 * @}
134150 */
@@ -143,7 +159,17 @@ typedef struct __ADC_HandleTypeDef
143159 * @param __HANDLE__ ADC handle
144160 * @retval None
145161 */
146- #define __HAL_ADC_RESET_HANDLE_STATE (__HANDLE__ ) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
162+ #if (USE_HAL_ADC_REGISTER_CALLBACKS == 1 )
163+ #define __HAL_ADC_RESET_HANDLE_STATE (__HANDLE__ ) \
164+ do{ \
165+ (__HANDLE__)->State = HAL_ADC_STATE_RESET; \
166+ (__HANDLE__)->MspInitCallback = NULL; \
167+ (__HANDLE__)->MspDeInitCallback = NULL; \
168+ } while(0)
169+ #else
170+ #define __HAL_ADC_RESET_HANDLE_STATE (__HANDLE__ ) \
171+ ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
172+ #endif
147173
148174/**
149175 * @}
@@ -164,6 +190,12 @@ HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
164190HAL_StatusTypeDef HAL_ADC_DeInit (ADC_HandleTypeDef * hadc );
165191void HAL_ADC_MspInit (ADC_HandleTypeDef * hadc );
166192void HAL_ADC_MspDeInit (ADC_HandleTypeDef * hadc );
193+
194+ #if (USE_HAL_ADC_REGISTER_CALLBACKS == 1 )
195+ /* Callbacks Register/UnRegister functions ***********************************/
196+ HAL_StatusTypeDef HAL_ADC_RegisterCallback (ADC_HandleTypeDef * hadc , HAL_ADC_CallbackIDTypeDef CallbackID , pADC_CallbackTypeDef pCallback );
197+ HAL_StatusTypeDef HAL_ADC_UnRegisterCallback (ADC_HandleTypeDef * hadc , HAL_ADC_CallbackIDTypeDef CallbackID );
198+ #endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
167199/**
168200 * @}
169201 */
0 commit comments