STM32H735xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32h7xx_hal_comp.h 00004 * @author MCD Application Team 00005 * @brief Header file of COMP HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2017 STMicroelectronics. 00010 * All rights reserved. 00011 * 00012 * This software is licensed under terms that can be found in the LICENSE file 00013 * in the root directory of this software component. 00014 * If no LICENSE file comes with this software, it is provided AS-IS. 00015 * 00016 ****************************************************************************** 00017 */ 00018 00019 /* Define to prevent recursive inclusion -------------------------------------*/ 00020 #ifndef STM32H7xx_HAL_COMP_H 00021 #define STM32H7xx_HAL_COMP_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32h7xx_hal_def.h" 00029 00030 /** @addtogroup STM32H7xx_HAL_Driver 00031 * @{ 00032 */ 00033 00034 /** @addtogroup COMP 00035 * @{ 00036 */ 00037 00038 /* Exported types ------------------------------------------------------------*/ 00039 /** @defgroup COMP_Exported_Types COMP Exported Types 00040 * @{ 00041 */ 00042 00043 /** 00044 * @brief COMP Init structure definition 00045 */ 00046 typedef struct 00047 { 00048 00049 uint32_t WindowMode; /*!< Set window mode of a pair of comparators instances 00050 (2 consecutive instances odd and even COMP<x> and COMP<x+1>). 00051 Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode. 00052 This parameter can be a value of @ref COMP_WindowMode */ 00053 00054 uint32_t Mode; /*!< Set comparator operating mode to adjust power and speed. 00055 Note: For the characteritics of comparator power modes 00056 (propagation delay and power consumption), refer to device datasheet. 00057 This parameter can be a value of @ref COMP_PowerMode */ 00058 00059 uint32_t NonInvertingInput; /*!< Set comparator input plus (non-inverting input). 00060 This parameter can be a value of @ref COMP_InputPlus */ 00061 00062 uint32_t InvertingInput; /*!< Set comparator input minus (inverting input). 00063 This parameter can be a value of @ref COMP_InputMinus */ 00064 00065 uint32_t Hysteresis; /*!< Set comparator hysteresis mode of the input minus. 00066 This parameter can be a value of @ref COMP_Hysteresis */ 00067 00068 uint32_t OutputPol; /*!< Set comparator output polarity. 00069 This parameter can be a value of @ref COMP_OutputPolarity */ 00070 00071 uint32_t BlankingSrce; /*!< Set comparator blanking source. 00072 This parameter can be a value of @ref COMP_BlankingSrce */ 00073 00074 uint32_t TriggerMode; /*!< Set the comparator output triggering External Interrupt Line (EXTI). 00075 This parameter can be a value of @ref COMP_EXTI_TriggerMode */ 00076 00077 }COMP_InitTypeDef; 00078 00079 /** 00080 * @brief HAL COMP state machine: HAL COMP states definition 00081 */ 00082 #define COMP_STATE_BITFIELD_LOCK ((uint32_t)0x10) 00083 typedef enum 00084 { 00085 HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized */ 00086 HAL_COMP_STATE_RESET_LOCKED = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */ 00087 HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */ 00088 HAL_COMP_STATE_READY_LOCKED = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked */ 00089 HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */ 00090 HAL_COMP_STATE_BUSY_LOCKED = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK) /*!< COMP is running and configuration is locked */ 00091 }HAL_COMP_StateTypeDef; 00092 00093 /** 00094 * @brief COMP Handle Structure definition 00095 */ 00096 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 00097 typedef struct __COMP_HandleTypeDef 00098 #else 00099 typedef struct 00100 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 00101 { 00102 COMP_TypeDef *Instance; /*!< Register base address */ 00103 COMP_InitTypeDef Init; /*!< COMP required parameters */ 00104 HAL_LockTypeDef Lock; /*!< Locking object */ 00105 __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */ 00106 __IO uint32_t ErrorCode; /*!< COMP error code */ 00107 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 00108 void (* TriggerCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP trigger callback */ 00109 void (* MspInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp Init callback */ 00110 void (* MspDeInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp DeInit callback */ 00111 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 00112 00113 } COMP_HandleTypeDef; 00114 00115 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 00116 /** 00117 * @brief HAL COMP Callback ID enumeration definition 00118 */ 00119 typedef enum 00120 { 00121 HAL_COMP_TRIGGER_CB_ID = 0x00U, /*!< COMP trigger callback ID */ 00122 HAL_COMP_MSPINIT_CB_ID = 0x01U, /*!< COMP Msp Init callback ID */ 00123 HAL_COMP_MSPDEINIT_CB_ID = 0x02U /*!< COMP Msp DeInit callback ID */ 00124 } HAL_COMP_CallbackIDTypeDef; 00125 00126 /** 00127 * @brief HAL COMP Callback pointer definition 00128 */ 00129 typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer to a COMP callback function */ 00130 00131 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 00132 /** 00133 * @} 00134 */ 00135 00136 /* Exported constants --------------------------------------------------------*/ 00137 /** @defgroup COMP_Exported_Constants COMP Exported Constants 00138 * @{ 00139 */ 00140 00141 /** @defgroup COMP_Error_Code COMP Error Code 00142 * @{ 00143 */ 00144 #define HAL_COMP_ERROR_NONE (0x00U) /*!< No error */ 00145 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 00146 #define HAL_COMP_ERROR_INVALID_CALLBACK (0x01U) /*!< Invalid Callback error */ 00147 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 00148 /** 00149 * @} 00150 */ 00151 00152 /** @defgroup COMP_WindowMode COMP Window Mode 00153 * @{ 00154 */ 00155 #define COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000) /*!< Window mode disable: Comparators instances pair COMP1 and COMP2 are independent */ 00156 #define COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CFGRx_WINMODE) /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP1 input plus (COMP2 input plus is no more accessible). */ 00157 00158 /** 00159 * @} 00160 */ 00161 00162 /** @defgroup COMP_PowerMode COMP power mode 00163 * @{ 00164 */ 00165 /* Note: For the characteritics of comparator power modes */ 00166 /* (propagation delay and power consumption), */ 00167 /* refer to device datasheet. */ 00168 #define COMP_POWERMODE_HIGHSPEED ((uint32_t)0x00000000) /*!< High Speed */ 00169 #define COMP_POWERMODE_MEDIUMSPEED (COMP_CFGRx_PWRMODE_0) /*!< Medium Speed */ 00170 #define COMP_POWERMODE_ULTRALOWPOWER (COMP_CFGRx_PWRMODE) /*!< Ultra-low power mode */ 00171 /** 00172 * @} 00173 */ 00174 00175 /** @defgroup COMP_InputPlus COMP input plus (non-inverting input) 00176 * @{ 00177 */ 00178 #define COMP_INPUT_PLUS_IO1 ((uint32_t)0x00000000) /*!< Comparator input plus connected to IO1 (pin PB0 for COMP1, pin PE9 for COMP2) */ 00179 #define COMP_INPUT_PLUS_IO2 (COMP_CFGRx_INPSEL) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PE11 for COMP2) */ 00180 #if defined (COMP_CFGRx_INP2SEL) 00181 #define COMP_INPUT_PLUS_DAC2_CH1 (COMP_CFGRx_INP2SEL) /*!< Comparator input plus 2 connected to (DAC2_CH1 for COMP1) */ 00182 #endif 00183 /** 00184 * @} 00185 */ 00186 00187 /** @defgroup COMP_InputMinus COMP input minus (inverting input) 00188 * @{ 00189 */ 00190 #define COMP_INPUT_MINUS_1_4VREFINT ( COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN) /*!< Comparator input minus connected to 1/4 VrefInt */ 00191 #define COMP_INPUT_MINUS_1_2VREFINT ( COMP_CFGRx_INMSEL_0 | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN) /*!< Comparator input minus connected to 1/2 VrefInt */ 00192 #define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CFGRx_INMSEL_1 | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */ 00193 #define COMP_INPUT_MINUS_VREFINT ( COMP_CFGRx_INMSEL_1 | COMP_CFGRx_INMSEL_0 | COMP_CFGRx_SCALEN ) /*!< Comparator input minus connected to VrefInt */ 00194 #define COMP_INPUT_MINUS_DAC1_CH1 ( COMP_CFGRx_INMSEL_2 ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */ 00195 #define COMP_INPUT_MINUS_DAC1_CH2 ( COMP_CFGRx_INMSEL_2 | COMP_CFGRx_INMSEL_0 ) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */ 00196 #define COMP_INPUT_MINUS_IO1 ( COMP_CFGRx_INMSEL_2 | COMP_CFGRx_INMSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PB1 for COMP1, pin PE10 for COMP2) */ 00197 #define COMP_INPUT_MINUS_IO2 ( COMP_CFGRx_INMSEL_2 | COMP_CFGRx_INMSEL_1 | COMP_CFGRx_INMSEL_0 ) /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1, pin PE7 for COMP2) */ 00198 #if defined (COMP_CFGRx_INMSEL_3) 00199 #define COMP_INPUT_MINUS_TPSENS_DAC2CH1 (COMP_CFGRx_INMSEL_3 ) /*!< Comparator input minus connected to (temp sensor which is exist in ADC for COMP1, DAC2_CH1 for COMP2) */ 00200 #define COMP_INPUT_MINUS_VBAT_VDDAP (COMP_CFGRx_INMSEL_3 | COMP_CFGRx_INMSEL_0 ) /*!< Comparator input minus connected to (VBAT/4 for COMP1, VDDAP for COMP2) */ 00201 #endif 00202 /** 00203 * @} 00204 */ 00205 00206 /** @defgroup COMP_Hysteresis COMP hysteresis 00207 * @{ 00208 */ 00209 #define COMP_HYSTERESIS_NONE ((uint32_t)0x00000000) /*!< No hysteresis */ 00210 #define COMP_HYSTERESIS_LOW (COMP_CFGRx_HYST_0) /*!< Hysteresis level low */ 00211 #define COMP_HYSTERESIS_MEDIUM (COMP_CFGRx_HYST_1) /*!< Hysteresis level medium */ 00212 #define COMP_HYSTERESIS_HIGH (COMP_CFGRx_HYST) /*!< Hysteresis level high */ 00213 /** 00214 * @} 00215 */ 00216 00217 /** @defgroup COMP_OutputPolarity COMP Output Polarity 00218 * @{ 00219 */ 00220 #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output level is not inverted (comparator output is high when the input plus is at a higher voltage than the input minus) */ 00221 #define COMP_OUTPUTPOL_INVERTED (COMP_CFGRx_POLARITY) /*!< COMP output level is inverted (comparator output is low when the input plus is at a higher voltage than the input minus) */ 00222 /** 00223 * @} 00224 */ 00225 00226 00227 /** @defgroup COMP_BlankingSrce COMP Blanking Source 00228 * @{ 00229 */ 00230 /* Any blanking source can be selected for all comparators */ 00231 #define COMP_BLANKINGSRC_NONE ((uint32_t)0x00000000) /*!< No blanking source */ 00232 #define COMP_BLANKINGSRC_TIM1_OC5 (COMP_CFGRx_BLANKING_0) /*!< TIM1 OC5 selected as blanking source for comparator */ 00233 #define COMP_BLANKINGSRC_TIM2_OC3 (COMP_CFGRx_BLANKING_1) /*!< TIM2 OC3 selected as blanking source for comparator */ 00234 #define COMP_BLANKINGSRC_TIM3_OC3 (COMP_CFGRx_BLANKING_0 |COMP_CFGRx_BLANKING_1) /*!< TIM3 OC3 selected as blanking source for compartor */ 00235 #define COMP_BLANKINGSRC_TIM3_OC4 (COMP_CFGRx_BLANKING_2) /*!< TIM3 OC4 selected as blanking source for comparator */ 00236 #define COMP_BLANKINGSRC_TIM8_OC5 (COMP_CFGRx_BLANKING_2|COMP_CFGRx_BLANKING_0) /*!< TIM8 OC5 selected as blanking source for comparator */ 00237 #define COMP_BLANKINGSRC_TIM15_OC1 (COMP_CFGRx_BLANKING_2|COMP_CFGRx_BLANKING_1) /*!< TIM15 OC1 selected as blanking source for comparator */ 00238 /** 00239 * @} 00240 */ 00241 00242 00243 00244 00245 /** @defgroup COMP_OutputLevel COMP Output Level 00246 * @{ 00247 */ 00248 00249 /* Note: Comparator output level values are fixed to "0" and "1", */ 00250 /* corresponding COMP register bit is managed by HAL function to match */ 00251 /* with these values (independently of bit position in register). */ 00252 00253 /* When output polarity is not inverted, comparator output is low when 00254 the input plus is at a lower voltage than the input minus */ 00255 #define COMP_OUTPUT_LEVEL_LOW ((uint32_t)0x00000000) 00256 /* When output polarity is not inverted, comparator output is high when 00257 the input plus is at a higher voltage than the input minus */ 00258 #define COMP_OUTPUT_LEVEL_HIGH ((uint32_t)0x00000001) 00259 00260 /** 00261 * @} 00262 */ 00263 00264 /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI 00265 * @{ 00266 */ 00267 #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< Comparator output triggering no External Interrupt Line */ 00268 #define COMP_TRIGGERMODE_IT_RISING (COMP_EXTI_IT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */ 00269 #define COMP_TRIGGERMODE_IT_FALLING (COMP_EXTI_IT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */ 00270 #define COMP_TRIGGERMODE_IT_RISING_FALLING (COMP_EXTI_IT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on both rising and falling edges */ 00271 #define COMP_TRIGGERMODE_EVENT_RISING (COMP_EXTI_EVENT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */ 00272 #define COMP_TRIGGERMODE_EVENT_FALLING (COMP_EXTI_EVENT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */ 00273 #define COMP_TRIGGERMODE_EVENT_RISING_FALLING (COMP_EXTI_EVENT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on both rising and falling edges */ 00274 00275 /** 00276 * @} 00277 */ 00278 00279 /** @defgroup COMP_Flag COMP Flag 00280 * @{ 00281 */ 00282 #define COMP_FLAG_C1I COMP_SR_C1IF /*!< Comparator 1 Interrupt Flag */ 00283 #define COMP_FLAG_C2I COMP_SR_C2IF /*!< Comparator 2 Interrupt Flag */ 00284 #define COMP_FLAG_LOCK COMP_CFGRx_LOCK /*!< Lock flag */ 00285 /** 00286 * @} 00287 */ 00288 /** @defgroup COMP_IT_CLEAR_Flags COMP Interruption Clear Flags 00289 * @{ 00290 */ 00291 #define COMP_CLEAR_C1IF COMP_ICFR_C1IF /*!< Clear Comparator 1 Interrupt Flag */ 00292 #define COMP_CLEAR_C2IF COMP_ICFR_C2IF /*!< Clear Comparator 2 Interrupt Flag */ 00293 /** 00294 * @} 00295 */ 00296 /** @defgroup COMP_Interrupts_Definitions COMP Interrupts Definitions 00297 * @{ 00298 */ 00299 #define COMP_IT_EN COMP_CFGRx_ITEN 00300 00301 /** 00302 * @} 00303 */ 00304 00305 00306 /** 00307 * @} 00308 */ 00309 00310 /* Exported macros -----------------------------------------------------------*/ 00311 /** @defgroup COMP_Exported_Macros COMP Exported Macros 00312 * @{ 00313 */ 00314 /** @defgroup COMP_Handle_Management COMP Handle Management 00315 * @{ 00316 */ 00317 00318 /** @brief Reset COMP handle state. 00319 * @param __HANDLE__ COMP handle 00320 * @retval None 00321 */ 00322 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 00323 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) do{ \ 00324 (__HANDLE__)->State = HAL_COMP_STATE_RESET; \ 00325 (__HANDLE__)->MspInitCallback = NULL; \ 00326 (__HANDLE__)->MspDeInitCallback = NULL; \ 00327 } while(0) 00328 #else 00329 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET) 00330 #endif 00331 00332 /** 00333 * @brief Clear COMP error code (set it to no error code "HAL_COMP_ERROR_NONE"). 00334 * @param __HANDLE__ COMP handle 00335 * @retval None 00336 */ 00337 #define COMP_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_COMP_ERROR_NONE) 00338 00339 /** 00340 * @brief Enable the specified comparator. 00341 * @param __HANDLE__ COMP handle 00342 * @retval None 00343 */ 00344 #define __HAL_COMP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_EN) 00345 00346 /** 00347 * @brief Disable the specified comparator. 00348 * @param __HANDLE__ COMP handle 00349 * @retval None 00350 */ 00351 #define __HAL_COMP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_EN) 00352 00353 /** 00354 * @brief Lock the specified comparator configuration. 00355 * @note Using this macro induce HAL COMP handle state machine being no 00356 * more in line with COMP instance state. 00357 * To keep HAL COMP handle state machine updated, it is recommended 00358 * to use function "HAL_COMP_Lock')". 00359 * @param __HANDLE__ COMP handle 00360 * @retval None 00361 */ 00362 #define __HAL_COMP_LOCK(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_LOCK) 00363 00364 /** 00365 * @brief Check whether the specified comparator is locked. 00366 * @param __HANDLE__ COMP handle 00367 * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked 00368 */ 00369 #define __HAL_COMP_IS_LOCKED(__HANDLE__) (READ_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_LOCK) == COMP_CFGRx_LOCK) 00370 00371 /** 00372 * @} 00373 */ 00374 00375 /** @defgroup COMP_Exti_Management COMP external interrupt line management 00376 * @{ 00377 */ 00378 00379 /** 00380 * @brief Enable the COMP1 EXTI line rising edge trigger. 00381 * @retval None 00382 */ 00383 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1) 00384 00385 00386 /** 00387 * @brief Disable the COMP1 EXTI line rising edge trigger. 00388 * @retval None 00389 */ 00390 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1) 00391 00392 /** 00393 * @brief Enable the COMP1 EXTI line falling edge trigger. 00394 * @retval None 00395 */ 00396 #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1) 00397 00398 /** 00399 * @brief Disable the COMP1 EXTI line falling edge trigger. 00400 * @retval None 00401 */ 00402 #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1) 00403 00404 00405 /** 00406 * @brief Enable the COMP1 EXTI line rising & falling edge trigger. 00407 * @retval None 00408 */ 00409 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ 00410 __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE(); \ 00411 __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE(); \ 00412 } while(0) 00413 00414 00415 /** 00416 * @brief Disable the COMP1 EXTI line rising & falling edge trigger. 00417 * @retval None 00418 */ 00419 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ 00420 __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE(); \ 00421 __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE(); \ 00422 } while(0) 00423 00424 00425 /** 00426 * @brief Enable the COMP1 EXTI line in interrupt mode. 00427 * @retval None 00428 */ 00429 #define __HAL_COMP_COMP1_EXTI_ENABLE_IT() SET_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP1) 00430 00431 /** 00432 * @brief Disable the COMP1 EXTI line in interrupt mode. 00433 * @retval None 00434 */ 00435 #define __HAL_COMP_COMP1_EXTI_DISABLE_IT() CLEAR_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP1) 00436 00437 /** 00438 * @brief Enable the COMP1 EXTI Line in event mode. 00439 * @retval None 00440 */ 00441 #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() SET_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP1) 00442 00443 /** 00444 * @brief Disable the COMP1 EXTI Line in event mode. 00445 * @retval None 00446 */ 00447 #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP1) 00448 00449 /** 00450 * @brief Check whether the COMP1 EXTI line flag is set or not. 00451 * @retval RESET or SET 00452 */ 00453 #define __HAL_COMP_COMP1_EXTI_GET_FLAG() READ_BIT(EXTI_D1->PR1, COMP_EXTI_LINE_COMP1) 00454 /** 00455 * @brief Clear the COMP1 EXTI flag. 00456 * @retval None 00457 */ 00458 #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() WRITE_REG(EXTI_D1->PR1, COMP_EXTI_LINE_COMP1) 00459 00460 /** 00461 * @brief Generate a software interrupt on the COMP1 EXTI line. 00462 * @retval None 00463 */ 00464 #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP1) 00465 00466 /** 00467 * @brief Enable the COMP1 D3 EXTI Line in event mode. 00468 * @retval None 00469 */ 00470 #define __HAL_COMP_COMP1_EXTID3_ENABLE_EVENT() SET_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP1) 00471 00472 /** 00473 * @brief Disable the COMP1 D3 EXTI Line in event mode. 00474 * @retval None 00475 */ 00476 #define __HAL_COMP_COMP1_EXTID3_DISABLE_EVENT() CLEAR_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP1) 00477 00478 #if defined(DUAL_CORE) 00479 /** 00480 * @brief Enable the COMP1 D2 EXTI line in interrupt mode. 00481 * @retval None 00482 */ 00483 #define __HAL_COMP_COMP1_EXTID2_ENABLE_IT() SET_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP1) 00484 00485 /** 00486 * @brief Disable the COMP1 D2 EXTI line in interrupt mode. 00487 * @retval None 00488 */ 00489 #define __HAL_COMP_COMP1_EXTID2_DISABLE_IT() CLEAR_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP1) 00490 00491 /** 00492 * @brief Enable the COMP1 D2 EXTI Line in event mode. 00493 * @retval None 00494 */ 00495 #define __HAL_COMP_COMP1_EXTID2_ENABLE_EVENT() SET_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP1) 00496 00497 /** 00498 * @brief Disable the COMP1 D2 EXTI Line in event mode. 00499 * @retval None 00500 */ 00501 #define __HAL_COMP_COMP1_EXTID2_DISABLE_EVENT() CLEAR_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP1) 00502 00503 /** 00504 * @brief Check whether the COMP1 D2 EXTI line flag is set or not. 00505 * @retval RESET or SET 00506 */ 00507 #define __HAL_COMP_COMP1_EXTID2_GET_FLAG() READ_BIT(EXTI_D2->PR1, COMP_EXTI_LINE_COMP1) 00508 00509 /** 00510 * @brief Clear the COMP1 D2 EXTI flag. 00511 * @retval None 00512 */ 00513 #define __HAL_COMP_COMP1_EXTID2_CLEAR_FLAG() WRITE_REG(EXTI_D2->PR1, COMP_EXTI_LINE_COMP1) 00514 00515 #endif 00516 00517 /** 00518 * @brief Enable the COMP2 EXTI line rising edge trigger. 00519 * @retval None 00520 */ 00521 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2) 00522 00523 /** 00524 * @brief Disable the COMP2 EXTI line rising edge trigger. 00525 * @retval None 00526 */ 00527 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2) 00528 00529 /** 00530 * @brief Enable the COMP2 EXTI line falling edge trigger. 00531 * @retval None 00532 */ 00533 #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2) 00534 00535 /** 00536 * @brief Disable the COMP2 EXTI line falling edge trigger. 00537 * @retval None 00538 */ 00539 #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2) 00540 00541 /** 00542 * @brief Enable the COMP2 EXTI line rising & falling edge trigger. 00543 * @retval None 00544 */ 00545 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \ 00546 __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE(); \ 00547 __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE(); \ 00548 } while(0) 00549 00550 /** 00551 * @brief Disable the COMP2 EXTI line rising & falling edge trigger. 00552 * @retval None 00553 */ 00554 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \ 00555 __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE(); \ 00556 __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE(); \ 00557 } while(0) 00558 /** 00559 * @brief Enable the COMP2 EXTI line. 00560 * @retval None 00561 */ 00562 #define __HAL_COMP_COMP2_EXTI_ENABLE_IT() SET_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP2) 00563 00564 /** 00565 * @brief Disable the COMP2 EXTI line. 00566 * @retval None 00567 */ 00568 #define __HAL_COMP_COMP2_EXTI_DISABLE_IT() CLEAR_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP2) 00569 00570 /** 00571 * @brief Enable the COMP2 EXTI Line in event mode. 00572 * @retval None 00573 */ 00574 #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() SET_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP2) 00575 00576 /** 00577 * @brief Disable the COMP2 EXTI Line in event mode. 00578 * @retval None 00579 */ 00580 #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP2) 00581 00582 /** 00583 * @brief Check whether the COMP2 EXTI line flag is set or not. 00584 * @retval RESET or SET 00585 */ 00586 #define __HAL_COMP_COMP2_EXTI_GET_FLAG() READ_BIT(EXTI_D1->PR1, COMP_EXTI_LINE_COMP2) 00587 00588 /** 00589 * @brief Clear the the COMP2 EXTI flag. 00590 * @retval None 00591 */ 00592 #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() WRITE_REG(EXTI_D1->PR1, COMP_EXTI_LINE_COMP2) 00593 00594 /** 00595 * @brief Enable the COMP2 D3 EXTI Line in event mode. 00596 * @retval None 00597 */ 00598 #define __HAL_COMP_COMP2_EXTID3_ENABLE_EVENT() SET_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP2) 00599 00600 /** 00601 * @brief Disable the COMP2 D3 EXTI Line in event mode. 00602 * @retval None 00603 */ 00604 #define __HAL_COMP_COMP2_EXTID3_DISABLE_EVENT() CLEAR_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP2) 00605 00606 /** 00607 * @brief Generate a software interrupt on the COMP2 EXTI line. 00608 * @retval None 00609 */ 00610 #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP2) 00611 00612 #if defined(DUAL_CORE) 00613 /** 00614 * @brief Enable the COMP2 D2 EXTI line 00615 * @retval None 00616 */ 00617 #define __HAL_COMP_COMP2_EXTID2_ENABLE_IT() SET_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP2) 00618 00619 00620 /** 00621 * @brief Disable the COMP2 D2 EXTI line. 00622 * @retval None 00623 */ 00624 #define __HAL_COMP_COMP2_EXTID2_DISABLE_IT() CLEAR_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP2) 00625 00626 00627 00628 /** 00629 * @brief Enable the COMP2 D2 EXTI Line in event mode. 00630 * @retval None 00631 */ 00632 #define __HAL_COMP_COMP2_EXTID2_ENABLE_EVENT() SET_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP2) 00633 00634 00635 00636 /** 00637 * @brief Disable the COMP2 D2 EXTI Line in event mode. 00638 * @retval None 00639 */ 00640 #define __HAL_COMP_COMP2_EXTID2_DISABLE_EVENT() CLEAR_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP2) 00641 00642 00643 /** 00644 * @brief Check whether the COMP2 D2 EXTI line flag is set or not. 00645 * @retval RESET or SET 00646 */ 00647 #define __HAL_COMP_COMP2_EXTID2_GET_FLAG() READ_BIT(EXTI_D2->PR1, COMP_EXTI_LINE_COMP2) 00648 00649 /** 00650 * @brief Clear the the COMP2 D2 EXTI flag. 00651 * @retval None 00652 */ 00653 #define __HAL_COMP_COMP2_EXTID2_CLEAR_FLAG() WRITE_REG(EXTI_D2->PR1, COMP_EXTI_LINE_COMP2) 00654 00655 #endif 00656 /** @brief Checks if the specified COMP interrupt source is enabled or disabled. 00657 * @param __HANDLE__: specifies the COMP Handle. 00658 * This parameter can be COMP1 where x: 1 or 2 to select the COMP peripheral. 00659 * @param __INTERRUPT__: specifies the COMP interrupt source to check. 00660 * This parameter can be one of the following values: 00661 * @arg COMP_IT_EN: Comparator interrupt enable 00662 * 00663 * @retval The new state of __IT__ (TRUE or FALSE) 00664 */ 00665 #define __HAL_COMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CFGR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) 00666 00667 /** @brief Checks whether the specified COMP flag is set or not. 00668 * @param __FLAG__: specifies the flag to check. 00669 * This parameter can be one of the following values: 00670 * @arg COMP_FLAG_C1I: Comparator 1 Interrupt Flag 00671 * @arg COMP_FLAG_C2I: Comparator 2 Interrupt Flag 00672 * @retval The new state of __FLAG__ (TRUE or FALSE) 00673 */ 00674 #define __HAL_COMP_GET_FLAG(__FLAG__) ((COMP12->SR & (__FLAG__)) == (__FLAG__)) 00675 00676 /** @brief Clears the specified COMP pending flag. 00677 * @param __FLAG__: specifies the flag to check. 00678 * This parameter can be any combination of the following values: 00679 * @arg COMP_CLEAR_C1IF : Clear Comparator 1 Interrupt Flag 00680 * @arg COMP_CLEAR_C2IF : Clear Comparator 2 Interrupt Flag 00681 * @retval None 00682 */ 00683 #define __HAL_COMP_CLEAR_FLAG(__FLAG__) (COMP12->ICFR = (__FLAG__)) 00684 00685 /** @brief Clear the COMP C1I flag. 00686 * @retval None 00687 */ 00688 #define __HAL_COMP_CLEAR_C1IFLAG() __HAL_COMP_CLEAR_FLAG( COMP_CLEAR_C1IF) 00689 00690 /** @brief Clear the COMP C2I flag. 00691 * @retval None 00692 */ 00693 #define __HAL_COMP_CLEAR_C2IFLAG() __HAL_COMP_CLEAR_FLAG( COMP_CLEAR_C2IF) 00694 00695 /** @brief Enable the specified COMP interrupt. 00696 * @param __HANDLE__: specifies the COMP Handle. 00697 * @param __INTERRUPT__: specifies the COMP interrupt source to enable. 00698 * This parameter can be one of the following values: 00699 * @arg COMP_CFGRx_ITEN : Comparator interrupt 00700 * @retval None 00701 */ 00702 #define __HAL_COMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ( ((__HANDLE__)->Instance->CFGR) |= (__INTERRUPT__) ) 00703 00704 /** @brief Disable the specified COMP interrupt. 00705 * @param __HANDLE__: specifies the COMP Handle. 00706 * @param __INTERRUPT__: specifies the COMP interrupt source to enable. 00707 * This parameter can be one of the following values: 00708 * @arg COMP_CFGRx_ITEN : Comparator interrupt 00709 * @retval None 00710 */ 00711 #define __HAL_COMP_DISABLE_IT(__HANDLE__,__INTERRUPT__) (((__HANDLE__)->Instance->CFGR) &= ~(__INTERRUPT__)) 00712 00713 /** 00714 * @} 00715 */ 00716 /** @brief Enable the specified bit in the Option register. 00717 * @param __AF__: specifies the Alternate Function source selection . 00718 * This parameter can be one of the following values: 00719 * @arg COMP_OR_AFOPA6 : Alternate Function PA6 source selection 00720 * @arg COMP_OR_AFOPA8 : Alternate Function PA8 source selection 00721 * @arg COMP_OR_AFOPB12 : Alternate Function PB12 source selection 00722 * @arg COMP_OR_AFOPE6 : Alternate Function PE6 source selection 00723 * @arg COMP_OR_AFOPE15 : Alternate Function PE15 source selection 00724 * @arg COMP_OR_AFOPG2 : Alternate Function PG2 source selection 00725 * @arg COMP_OR_AFOPG3 : Alternate Function PG3 source selection 00726 * @arg COMP_OR_AFOPG4 : Alternate Function PG4 source selection 00727 * @arg COMP_OR_AFOPI1 : Alternate Function PI1 source selection 00728 * @arg COMP_OR_AFOPI4 : Alternate Function PI4 source selection 00729 * @arg COMP_OR_AFOPK2 : Alternate Function PK2 source selection 00730 * @retval None 00731 */ 00732 #define __HAL_COMP_ENABLE_OR(__AF__) SET_BIT(COMP12->OR, (__AF__)) 00733 00734 /** @brief Disable the specified bit in the Option register. 00735 * @param __AF__: specifies the Alternate Function source selection . 00736 * This parameter can be one of the following values: 00737 * @arg COMP_OR_AFOPA6 : Alternate Function PA6 source selection 00738 * @arg COMP_OR_AFOPA8 : Alternate Function PA8 source selection 00739 * @arg COMP_OR_AFOPB12 : Alternate Function PB12 source selection 00740 * @arg COMP_OR_AFOPE6 : Alternate Function PE6 source selection 00741 * @arg COMP_OR_AFOPE15 : Alternate Function PE15 source selection 00742 * @arg COMP_OR_AFOPG2 : Alternate Function PG2 source selection 00743 * @arg COMP_OR_AFOPG3 : Alternate Function PG3 source selection 00744 * @arg COMP_OR_AFOPG4 : Alternate Function PG4 source selection 00745 * @arg COMP_OR_AFOPI1 : Alternate Function PI1 source selection 00746 * @arg COMP_OR_AFOPI4 : Alternate Function PI4 source selection 00747 * @arg COMP_OR_AFOPK2 : Alternate Function PK2 source selection 00748 * @retval None 00749 */ 00750 #define __HAL_COMP_DISABLE_OR(__AF__) CLEAR_BIT(COMP12->OR, (__AF__)) 00751 /** 00752 * @} 00753 */ 00754 00755 /* Private types -------------------------------------------------------------*/ 00756 /* Private constants ---------------------------------------------------------*/ 00757 /** @defgroup COMP_Private_Constants COMP Private Constants 00758 * @{ 00759 */ 00760 /** @defgroup COMP_ExtiLine COMP EXTI Lines 00761 * @{ 00762 */ 00763 #define COMP_EXTI_LINE_COMP1 (EXTI_IMR1_IM20) /*!< EXTI line 20 connected to COMP1 output */ 00764 #define COMP_EXTI_LINE_COMP2 (EXTI_IMR1_IM21) /*!< EXTI line 21 connected to COMP2 output */ 00765 /** 00766 * @} 00767 */ 00768 /** @defgroup COMP_ExtiLine COMP EXTI Lines 00769 * @{ 00770 */ 00771 #define COMP_EXTI_IT ((uint32_t) 0x01) /*!< EXTI line event with interruption */ 00772 #define COMP_EXTI_EVENT ((uint32_t) 0x02) /*!< EXTI line event only (without interruption) */ 00773 #define COMP_EXTI_RISING ((uint32_t) 0x10) /*!< EXTI line event on rising edge */ 00774 #define COMP_EXTI_FALLING ((uint32_t) 0x20) /*!< EXTI line event on falling edge */ 00775 /** 00776 * @} 00777 */ 00778 /** 00779 * @} 00780 */ 00781 00782 /* Private macros ------------------------------------------------------------*/ 00783 /** @defgroup COMP_Private_Macros COMP Private Macros 00784 * @{ 00785 */ 00786 /** @defgroup COMP_GET_EXTI_LINE COMP Private macros to get EXTI line associated with Comparators 00787 * @{ 00788 */ 00789 /** 00790 * @brief Get the specified EXTI line for a comparator instance. 00791 * @param __INSTANCE__: specifies the COMP instance. 00792 * @retval value of @ref COMP_ExtiLine 00793 */ 00794 #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 : \ 00795 COMP_EXTI_LINE_COMP2) 00796 /** 00797 * @} 00798 */ 00799 /** @defgroup COMP_IS_COMP_Definitions COMP private macros to check input parameters 00800 * @{ 00801 */ 00802 #define IS_COMP_WINDOWMODE(__WINDOWMODE__) (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \ 00803 ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON) ) 00804 00805 #define IS_COMP_POWERMODE(__POWERMODE__) (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED) || \ 00806 ((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED) || \ 00807 ((__POWERMODE__) == COMP_POWERMODE_ULTRALOWPOWER) ) 00808 00809 #if defined (COMP_CFGRx_INP2SEL) 00810 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \ 00811 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \ 00812 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_DAC2_CH1)) 00813 #else 00814 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \ 00815 ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2)) 00816 #endif 00817 00818 00819 #if defined (COMP_CFGRx_INMSEL_3) 00820 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \ 00821 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \ 00822 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \ 00823 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \ 00824 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \ 00825 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \ 00826 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \ 00827 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \ 00828 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_TPSENS_DAC2CH1) || \ 00829 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VBAT_VDDAP)) 00830 #else 00831 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \ 00832 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \ 00833 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \ 00834 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \ 00835 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \ 00836 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \ 00837 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \ 00838 ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2)) 00839 #endif 00840 00841 #define IS_COMP_HYSTERESIS(__HYSTERESIS__) (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE) || \ 00842 ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW) || \ 00843 ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \ 00844 ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH)) 00845 00846 #define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \ 00847 ((__POL__) == COMP_OUTPUTPOL_INVERTED)) 00848 00849 #define IS_COMP_BLANKINGSRCE(__SOURCE__) (((__SOURCE__) == COMP_BLANKINGSRC_NONE) || \ 00850 ((__SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5) || \ 00851 ((__SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3) || \ 00852 ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3) || \ 00853 ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4) || \ 00854 ((__SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5) || \ 00855 ((__SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1)) 00856 00857 00858 #define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \ 00859 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \ 00860 ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \ 00861 ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \ 00862 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \ 00863 ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \ 00864 ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING)) 00865 00866 #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW) || \ 00867 ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH)) 00868 00869 /** 00870 * @} 00871 */ 00872 00873 /** 00874 * @} 00875 */ 00876 00877 /* Exported functions --------------------------------------------------------*/ 00878 /** @addtogroup COMP_Exported_Functions 00879 * @{ 00880 */ 00881 00882 /** @addtogroup COMP_Exported_Functions_Group1 00883 * @{ 00884 */ 00885 /* Initialization and de-initialization functions **********************************/ 00886 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp); 00887 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp); 00888 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp); 00889 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp); 00890 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1) 00891 /* Callbacks Register/UnRegister functions ***********************************/ 00892 HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID, pCOMP_CallbackTypeDef pCallback); 00893 HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID); 00894 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */ 00895 /** 00896 * @} 00897 */ 00898 00899 /* IO operation functions *****************************************************/ 00900 /** @addtogroup COMP_Exported_Functions_Group2 00901 * @{ 00902 */ 00903 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp); 00904 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp); 00905 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp); 00906 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp); 00907 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp); 00908 00909 /** 00910 * @} 00911 */ 00912 00913 /* Peripheral Control functions ************************************************/ 00914 /** @addtogroup COMP_Exported_Functions_Group3 00915 * @{ 00916 */ 00917 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp); 00918 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp); 00919 /* Callback in Interrupt mode */ 00920 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp); 00921 /** 00922 * @} 00923 */ 00924 00925 /* Peripheral State functions **************************************************/ 00926 /** @addtogroup COMP_Exported_Functions_Group4 00927 * @{ 00928 */ 00929 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp); 00930 uint32_t HAL_COMP_GetError(COMP_HandleTypeDef *hcomp); 00931 /** 00932 * @} 00933 */ 00934 00935 /** 00936 * @} 00937 */ 00938 00939 00940 /** 00941 * @} 00942 */ 00943 00944 /** 00945 * @} 00946 */ 00947 #ifdef __cplusplus 00948 } 00949 #endif 00950 00951 #endif /* STM32H7xx_HAL_COMP_H */ 00952 00953