Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:35

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_hal_comp.h
0004   * @author  MCD Application Team
0005   * @brief   Header file of COMP HAL module.
0006   ******************************************************************************
0007   * @attention
0008   *
0009   * Copyright (c) 2017 STMicroelectronics.
0010   * All rights reserved.
0011   *
0012   * This software is licensed under terms that can be found in the LICENSE file
0013   * in the root directory of this software component.
0014   * If no LICENSE file comes with this software, it is provided AS-IS.
0015   *
0016   ******************************************************************************
0017   */
0018 
0019 /* Define to prevent recursive inclusion -------------------------------------*/
0020 #ifndef STM32H7xx_HAL_COMP_H
0021 #define STM32H7xx_HAL_COMP_H
0022 
0023 #ifdef __cplusplus
0024  extern "C" {
0025 #endif
0026 
0027 /* Includes ------------------------------------------------------------------*/
0028 #include "stm32h7xx_hal_def.h"
0029 
0030 /** @addtogroup STM32H7xx_HAL_Driver
0031   * @{
0032   */
0033 
0034 /** @addtogroup COMP
0035   * @{
0036   */
0037 
0038 /* Exported types ------------------------------------------------------------*/ 
0039 /** @defgroup COMP_Exported_Types COMP Exported Types
0040   * @ingroup RTEMSBSPsARMSTM32H7
0041   * @{
0042   */
0043 
0044 /** 
0045   * @brief  COMP Init structure definition  
0046   */
0047 typedef struct
0048 {
0049 
0050   uint32_t WindowMode;         /*!< Set window mode of a pair of comparators instances
0051                                     (2 consecutive instances odd and even COMP<x> and COMP<x+1>).
0052                                     Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode.
0053                                     This parameter can be a value of @ref COMP_WindowMode */
0054 
0055   uint32_t Mode;               /*!< Set comparator operating mode to adjust power and speed.
0056                                     Note: For the characteritics of comparator power modes
0057                                           (propagation delay and power consumption), refer to device datasheet.
0058                                     This parameter can be a value of @ref COMP_PowerMode */
0059 
0060   uint32_t NonInvertingInput;  /*!< Set comparator input plus (non-inverting input).
0061                                     This parameter can be a value of @ref COMP_InputPlus */
0062 
0063   uint32_t InvertingInput;     /*!< Set comparator input minus (inverting input).
0064                                     This parameter can be a value of @ref COMP_InputMinus */
0065 
0066   uint32_t Hysteresis;         /*!< Set comparator hysteresis mode of the input minus.
0067                                     This parameter can be a value of @ref COMP_Hysteresis */
0068 
0069   uint32_t OutputPol;          /*!< Set comparator output polarity.
0070                                     This parameter can be a value of @ref COMP_OutputPolarity */
0071 
0072   uint32_t BlankingSrce;       /*!< Set comparator blanking source.
0073                                     This parameter can be a value of @ref COMP_BlankingSrce */
0074 
0075   uint32_t TriggerMode;        /*!< Set the comparator output triggering External Interrupt Line (EXTI).
0076                                     This parameter can be a value of @ref COMP_EXTI_TriggerMode */
0077 
0078 }COMP_InitTypeDef;
0079 
0080 /**
0081   * @brief  HAL COMP state machine: HAL COMP states definition
0082   */
0083 #define COMP_STATE_BITFIELD_LOCK  ((uint32_t)0x10)
0084 typedef enum
0085 {
0086   HAL_COMP_STATE_RESET             = 0x00,                                              /*!< COMP not yet initialized                             */
0087   HAL_COMP_STATE_RESET_LOCKED      = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */
0088   HAL_COMP_STATE_READY             = 0x01,                                              /*!< COMP initialized and ready for use                   */
0089   HAL_COMP_STATE_READY_LOCKED      = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked         */
0090   HAL_COMP_STATE_BUSY              = 0x02,                                              /*!< COMP is running                                      */
0091   HAL_COMP_STATE_BUSY_LOCKED       = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK)   /*!< COMP is running and configuration is locked          */
0092 }HAL_COMP_StateTypeDef;
0093 
0094 /** 
0095   * @brief  COMP Handle Structure definition
0096   */
0097 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
0098 typedef struct __COMP_HandleTypeDef
0099 #else
0100 typedef struct
0101 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
0102 {
0103   COMP_TypeDef       *Instance;       /*!< Register base address    */
0104   COMP_InitTypeDef   Init;            /*!< COMP required parameters */
0105   HAL_LockTypeDef    Lock;            /*!< Locking object           */
0106   __IO HAL_COMP_StateTypeDef  State;  /*!< COMP communication state */
0107   __IO uint32_t      ErrorCode;       /*!< COMP error code */
0108 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
0109   void (* TriggerCallback)(struct __COMP_HandleTypeDef *hcomp);   /*!< COMP trigger callback */
0110   void (* MspInitCallback)(struct __COMP_HandleTypeDef *hcomp);   /*!< COMP Msp Init callback */
0111   void (* MspDeInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp DeInit callback */
0112 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
0113 
0114 } COMP_HandleTypeDef;
0115 
0116 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
0117 /**
0118   * @brief  HAL COMP Callback ID enumeration definition
0119   */
0120 typedef enum
0121 {
0122   HAL_COMP_TRIGGER_CB_ID                = 0x00U,  /*!< COMP trigger callback ID */
0123   HAL_COMP_MSPINIT_CB_ID                = 0x01U,  /*!< COMP Msp Init callback ID */
0124   HAL_COMP_MSPDEINIT_CB_ID              = 0x02U   /*!< COMP Msp DeInit callback ID */
0125 } HAL_COMP_CallbackIDTypeDef;
0126 
0127 /**
0128   * @brief  HAL COMP Callback pointer definition
0129   */
0130 typedef  void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer to a COMP callback function */
0131 
0132 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
0133 /**
0134   * @}
0135   */
0136 
0137 /* Exported constants --------------------------------------------------------*/
0138 /** @defgroup COMP_Exported_Constants COMP Exported Constants
0139   * @ingroup RTEMSBSPsARMSTM32H7
0140   * @{
0141   */
0142   
0143 /** @defgroup COMP_Error_Code COMP Error Code
0144   * @ingroup RTEMSBSPsARMSTM32H7
0145   * @{
0146   */
0147 #define HAL_COMP_ERROR_NONE             (0x00U)   /*!< No error */
0148 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
0149 #define HAL_COMP_ERROR_INVALID_CALLBACK (0x01U)   /*!< Invalid Callback error */
0150 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
0151 /**
0152   * @}
0153   */
0154   
0155 /** @defgroup COMP_WindowMode COMP Window Mode
0156   * @ingroup RTEMSBSPsARMSTM32H7
0157   * @{
0158   */
0159 #define COMP_WINDOWMODE_DISABLE                 ((uint32_t)0x00000000)   /*!< Window mode disable: Comparators instances pair COMP1 and COMP2 are independent */
0160 #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). */
0161 
0162 /**
0163   * @}
0164   */
0165 
0166 /** @defgroup COMP_PowerMode COMP power mode
0167   * @ingroup RTEMSBSPsARMSTM32H7
0168   * @{
0169   */
0170 /* Note: For the characteritics of comparator power modes                     */
0171 /*       (propagation delay and power consumption),                           */
0172 /*       refer to device datasheet.                                           */
0173 #define COMP_POWERMODE_HIGHSPEED       ((uint32_t)0x00000000)   /*!< High Speed */
0174 #define COMP_POWERMODE_MEDIUMSPEED     (COMP_CFGRx_PWRMODE_0)   /*!< Medium Speed */
0175 #define COMP_POWERMODE_ULTRALOWPOWER   (COMP_CFGRx_PWRMODE)     /*!< Ultra-low power mode */
0176 /**
0177   * @}
0178   */
0179 
0180 /** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
0181   * @ingroup RTEMSBSPsARMSTM32H7
0182   * @{
0183   */
0184 #define COMP_INPUT_PLUS_IO1            ((uint32_t)0x00000000) /*!< Comparator input plus connected to IO1 (pin PB0 for COMP1, pin PE9 for COMP2) */
0185 #define COMP_INPUT_PLUS_IO2            (COMP_CFGRx_INPSEL)    /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PE11 for COMP2) */
0186 #if defined (COMP_CFGRx_INP2SEL)
0187 #define COMP_INPUT_PLUS_DAC2_CH1       (COMP_CFGRx_INP2SEL)   /*!< Comparator input plus 2 connected to (DAC2_CH1 for COMP1) */
0188 #endif
0189 /**
0190   * @}
0191   */
0192 
0193 /** @defgroup COMP_InputMinus COMP input minus (inverting input)
0194   * @ingroup RTEMSBSPsARMSTM32H7
0195   * @{
0196   */
0197 #define COMP_INPUT_MINUS_1_4VREFINT     (                                                                                        COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN)    /*!< Comparator input minus connected to 1/4 VrefInt */
0198 #define COMP_INPUT_MINUS_1_2VREFINT     (                                                                  COMP_CFGRx_INMSEL_0 | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN)    /*!< Comparator input minus connected to 1/2 VrefInt */
0199 #define COMP_INPUT_MINUS_3_4VREFINT     (                                            COMP_CFGRx_INMSEL_1                       | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN)    /*!< Comparator input minus connected to 3/4 VrefInt */
0200 #define COMP_INPUT_MINUS_VREFINT        (                                            COMP_CFGRx_INMSEL_1 | COMP_CFGRx_INMSEL_0 | COMP_CFGRx_SCALEN                   )    /*!< Comparator input minus connected to VrefInt */
0201 #define COMP_INPUT_MINUS_DAC1_CH1       (                      COMP_CFGRx_INMSEL_2                                                                                   )    /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */
0202 #define COMP_INPUT_MINUS_DAC1_CH2       (                      COMP_CFGRx_INMSEL_2                       | COMP_CFGRx_INMSEL_0                                       )    /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */
0203 #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) */
0204 #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) */
0205 #if defined (COMP_CFGRx_INMSEL_3)
0206 #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) */
0207 #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) */
0208 #endif
0209 /**
0210   * @}
0211   */
0212 
0213 /** @defgroup COMP_Hysteresis COMP hysteresis
0214   * @ingroup RTEMSBSPsARMSTM32H7
0215   * @{
0216   */
0217 #define COMP_HYSTERESIS_NONE           ((uint32_t)0x00000000)   /*!< No hysteresis */
0218 #define COMP_HYSTERESIS_LOW            (COMP_CFGRx_HYST_0)      /*!< Hysteresis level low */
0219 #define COMP_HYSTERESIS_MEDIUM         (COMP_CFGRx_HYST_1)      /*!< Hysteresis level medium */
0220 #define COMP_HYSTERESIS_HIGH           (COMP_CFGRx_HYST)        /*!< Hysteresis level high */
0221 /**
0222   * @}
0223   */
0224 
0225 /** @defgroup COMP_OutputPolarity COMP Output Polarity
0226   * @ingroup RTEMSBSPsARMSTM32H7
0227   * @{
0228   */
0229 #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) */
0230 #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) */
0231 /**
0232   * @}
0233   */
0234 
0235 
0236 /** @defgroup COMP_BlankingSrce  COMP Blanking Source
0237   * @ingroup RTEMSBSPsARMSTM32H7
0238   * @{
0239   */
0240 /* Any blanking source can be selected for all comparators */
0241 #define COMP_BLANKINGSRC_NONE             ((uint32_t)0x00000000)                           /*!< No blanking source */
0242 #define COMP_BLANKINGSRC_TIM1_OC5         (COMP_CFGRx_BLANKING_0)                          /*!< TIM1 OC5 selected as blanking source for comparator */
0243 #define COMP_BLANKINGSRC_TIM2_OC3         (COMP_CFGRx_BLANKING_1)                          /*!< TIM2 OC3 selected as blanking source for comparator */
0244 #define COMP_BLANKINGSRC_TIM3_OC3         (COMP_CFGRx_BLANKING_0 |COMP_CFGRx_BLANKING_1)   /*!< TIM3 OC3 selected as blanking source for compartor */
0245 #define COMP_BLANKINGSRC_TIM3_OC4         (COMP_CFGRx_BLANKING_2)                          /*!< TIM3 OC4 selected as blanking source for comparator */
0246 #define COMP_BLANKINGSRC_TIM8_OC5         (COMP_CFGRx_BLANKING_2|COMP_CFGRx_BLANKING_0)    /*!< TIM8 OC5 selected as blanking source for comparator */
0247 #define COMP_BLANKINGSRC_TIM15_OC1        (COMP_CFGRx_BLANKING_2|COMP_CFGRx_BLANKING_1)    /*!< TIM15 OC1 selected as blanking source for comparator */
0248 /**
0249   * @}
0250   */
0251 
0252 
0253 
0254 
0255 /** @defgroup COMP_OutputLevel COMP Output Level
0256   * @ingroup RTEMSBSPsARMSTM32H7
0257   * @{
0258   */ 
0259 
0260 /* Note: Comparator output level values are fixed to "0" and "1",             */
0261 /* corresponding COMP register bit is managed by HAL function to match        */
0262 /* with these values (independently of bit position in register).             */
0263 
0264 /* When output polarity is not inverted, comparator output is low when
0265    the input plus is at a lower voltage than the input minus */
0266 #define COMP_OUTPUT_LEVEL_LOW              ((uint32_t)0x00000000)
0267 /* When output polarity is not inverted, comparator output is high when
0268    the input plus is at a higher voltage than the input minus */
0269 #define COMP_OUTPUT_LEVEL_HIGH             ((uint32_t)0x00000001)
0270 
0271 /**
0272   * @}
0273   */
0274 
0275 /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI
0276   * @ingroup RTEMSBSPsARMSTM32H7
0277   * @{
0278   */
0279 #define COMP_TRIGGERMODE_NONE                 ((uint32_t)0x00000000)                                    /*!< Comparator output triggering no External Interrupt Line */
0280 #define COMP_TRIGGERMODE_IT_RISING            (COMP_EXTI_IT | COMP_EXTI_RISING)                         /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */
0281 #define COMP_TRIGGERMODE_IT_FALLING           (COMP_EXTI_IT | COMP_EXTI_FALLING)                        /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */
0282 #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 */
0283 #define COMP_TRIGGERMODE_EVENT_RISING         (COMP_EXTI_EVENT | COMP_EXTI_RISING)                      /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */
0284 #define COMP_TRIGGERMODE_EVENT_FALLING        (COMP_EXTI_EVENT | COMP_EXTI_FALLING)                     /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */
0285 #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 */
0286 
0287 /**
0288   * @}
0289   */
0290 
0291 /** @defgroup COMP_Flag COMP Flag
0292   * @ingroup RTEMSBSPsARMSTM32H7
0293   * @{
0294   */
0295 #define COMP_FLAG_C1I           COMP_SR_C1IF           /*!< Comparator 1 Interrupt Flag */
0296 #define COMP_FLAG_C2I           COMP_SR_C2IF           /*!< Comparator 2 Interrupt Flag */
0297 #define COMP_FLAG_LOCK          COMP_CFGRx_LOCK        /*!< Lock flag */
0298 /**
0299   * @}
0300   */
0301 /** @defgroup COMP_IT_CLEAR_Flags  COMP Interruption Clear Flags
0302   * @ingroup RTEMSBSPsARMSTM32H7
0303   * @{
0304   */
0305 #define COMP_CLEAR_C1IF          COMP_ICFR_C1IF     /*!< Clear Comparator 1 Interrupt Flag */
0306 #define COMP_CLEAR_C2IF          COMP_ICFR_C2IF     /*!< Clear Comparator 2 Interrupt Flag */
0307 /**
0308   * @}
0309   */
0310 /** @defgroup COMP_Interrupts_Definitions COMP Interrupts Definitions
0311   * @ingroup RTEMSBSPsARMSTM32H7
0312   * @{
0313   */
0314 #define COMP_IT_EN               COMP_CFGRx_ITEN 
0315 
0316 /**
0317   * @}
0318   */
0319   
0320 
0321 /**
0322   * @}
0323   */
0324  
0325 /* Exported macros -----------------------------------------------------------*/
0326 /** @defgroup COMP_Exported_Macros COMP Exported Macros
0327   * @ingroup RTEMSBSPsARMSTM32H7
0328   * @{
0329   */
0330 /** @defgroup COMP_Handle_Management  COMP Handle Management
0331   * @ingroup RTEMSBSPsARMSTM32H7
0332  * @{
0333   */
0334 
0335 /** @brief  Reset COMP handle state.
0336   * @param  __HANDLE__  COMP handle
0337   * @retval None
0338   */
0339 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
0340 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) do{                                                 \
0341                                                      (__HANDLE__)->State = HAL_COMP_STATE_RESET;      \
0342                                                      (__HANDLE__)->MspInitCallback = NULL;            \
0343                                                      (__HANDLE__)->MspDeInitCallback = NULL;          \
0344                                                     } while(0)
0345 #else
0346 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
0347 #endif
0348 
0349 /**
0350   * @brief Clear COMP error code (set it to no error code "HAL_COMP_ERROR_NONE").
0351   * @param __HANDLE__ COMP handle
0352   * @retval None
0353   */
0354 #define COMP_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_COMP_ERROR_NONE) 
0355 
0356 /**
0357   * @brief  Enable the specified comparator.
0358   * @param  __HANDLE__ COMP handle
0359   * @retval None
0360   */
0361 #define __HAL_COMP_ENABLE(__HANDLE__)                 SET_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_EN)
0362 
0363 /**
0364   * @brief  Disable the specified comparator.
0365   * @param  __HANDLE__ COMP handle
0366   * @retval None
0367   */
0368 #define __HAL_COMP_DISABLE(__HANDLE__)                CLEAR_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_EN)
0369 
0370 /**
0371   * @brief  Lock the specified comparator configuration.
0372   * @note   Using this macro induce HAL COMP handle state machine being no
0373   *         more in line with COMP instance state.
0374   *         To keep HAL COMP handle state machine updated, it is recommended
0375   *         to use function "HAL_COMP_Lock')".
0376   * @param  __HANDLE__ COMP handle
0377   * @retval None
0378   */
0379 #define __HAL_COMP_LOCK(__HANDLE__)                   SET_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_LOCK)
0380 
0381 /**
0382   * @brief  Check whether the specified comparator is locked.
0383   * @param  __HANDLE__  COMP handle
0384   * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
0385   */
0386 #define __HAL_COMP_IS_LOCKED(__HANDLE__)           (READ_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_LOCK) == COMP_CFGRx_LOCK)
0387 
0388 /**
0389   * @}
0390   */
0391   
0392 /** @defgroup COMP_Exti_Management  COMP external interrupt line management
0393   * @ingroup RTEMSBSPsARMSTM32H7
0394   * @{
0395   */
0396 
0397 /**
0398   * @brief  Enable the COMP1 EXTI line rising edge trigger. 
0399   * @retval None
0400   */                                         
0401 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE()    SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1)
0402 
0403 
0404 /**
0405   * @brief  Disable the COMP1 EXTI line rising edge trigger. 
0406   * @retval None
0407   */                                         
0408 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE()    CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1)
0409 
0410 /**
0411   * @brief  Enable the COMP1 EXTI line falling edge trigger. 
0412   * @retval None
0413   */                                         
0414 #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE()    SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1)
0415 
0416 /**
0417   * @brief  Disable the COMP1 EXTI line falling edge trigger.
0418   * @retval None
0419   */                                         
0420 #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE()    CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1)
0421 
0422 
0423 /**
0424   * @brief  Enable the COMP1 EXTI line rising & falling edge trigger. 
0425   * @retval None
0426   */                                         
0427 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE()   do {                                           \
0428                                                                __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE();  \
0429                                                                __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE(); \
0430                                                              } while(0)
0431 
0432 
0433 /**
0434   * @brief  Disable the COMP1 EXTI line rising & falling edge trigger. 
0435   * @retval None
0436   */                                         
0437 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE()  do {                                            \
0438                                                                __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE();  \
0439                                                                __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE(); \
0440                                                              } while(0)
0441 
0442 
0443 /**
0444   * @brief  Enable the COMP1 EXTI line in interrupt mode.
0445   * @retval None
0446   */                                         
0447 #define __HAL_COMP_COMP1_EXTI_ENABLE_IT()             SET_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP1)
0448 
0449 /**
0450   * @brief  Disable the COMP1 EXTI line in interrupt mode.
0451   * @retval None
0452   */
0453 #define __HAL_COMP_COMP1_EXTI_DISABLE_IT()            CLEAR_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP1)
0454 
0455 /**
0456   * @brief  Enable the COMP1 EXTI Line in event mode.
0457   * @retval None
0458   */
0459 #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT()           SET_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP1)
0460 
0461 /**
0462   * @brief  Disable the COMP1 EXTI Line in event mode.
0463   * @retval None
0464   */
0465 #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT()          CLEAR_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP1)
0466 
0467 /**
0468   * @brief  Check whether the COMP1 EXTI line flag is set or not.
0469   * @retval RESET or SET
0470   */
0471 #define __HAL_COMP_COMP1_EXTI_GET_FLAG()              READ_BIT(EXTI_D1->PR1, COMP_EXTI_LINE_COMP1)
0472 /**
0473   * @brief  Clear the COMP1 EXTI flag.
0474   * @retval None
0475   */
0476 #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG()            WRITE_REG(EXTI_D1->PR1, COMP_EXTI_LINE_COMP1)
0477 
0478 /**
0479   * @brief  Generate a software interrupt on the COMP1 EXTI line.
0480   * @retval None
0481   */
0482 #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT()         SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP1)
0483 
0484 /**
0485   * @brief  Enable the COMP1 D3 EXTI Line in event mode.
0486   * @retval None
0487   */
0488 #define __HAL_COMP_COMP1_EXTID3_ENABLE_EVENT()        SET_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP1)
0489 
0490 /**
0491   * @brief  Disable the COMP1 D3 EXTI Line in event mode.
0492   * @retval None
0493   */
0494 #define __HAL_COMP_COMP1_EXTID3_DISABLE_EVENT()        CLEAR_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP1)
0495 
0496 #if defined(DUAL_CORE)
0497 /**
0498   * @brief  Enable the COMP1 D2 EXTI line in interrupt mode.
0499   * @retval None
0500   */                                         
0501 #define __HAL_COMP_COMP1_EXTID2_ENABLE_IT()           SET_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP1)
0502 
0503 /**
0504   * @brief  Disable the COMP1 D2 EXTI line in interrupt mode.
0505   * @retval None
0506   */
0507 #define __HAL_COMP_COMP1_EXTID2_DISABLE_IT()          CLEAR_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP1)
0508 
0509 /**
0510   * @brief  Enable the COMP1 D2 EXTI Line in event mode.
0511   * @retval None
0512   */
0513 #define __HAL_COMP_COMP1_EXTID2_ENABLE_EVENT()         SET_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP1)
0514 
0515 /**
0516   * @brief  Disable the COMP1 D2 EXTI Line in event mode.
0517   * @retval None
0518   */
0519 #define __HAL_COMP_COMP1_EXTID2_DISABLE_EVENT()        CLEAR_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP1)
0520 
0521 /**
0522   * @brief  Check whether the COMP1 D2 EXTI line flag is set or not.
0523   * @retval RESET or SET
0524   */
0525 #define __HAL_COMP_COMP1_EXTID2_GET_FLAG()              READ_BIT(EXTI_D2->PR1, COMP_EXTI_LINE_COMP1)     
0526 
0527 /**
0528   * @brief  Clear the COMP1 D2 EXTI flag.
0529   * @retval None
0530   */
0531 #define __HAL_COMP_COMP1_EXTID2_CLEAR_FLAG()            WRITE_REG(EXTI_D2->PR1, COMP_EXTI_LINE_COMP1)
0532 
0533 #endif
0534 
0535 /**
0536   * @brief  Enable the COMP2 EXTI line rising edge trigger.
0537   * @retval None
0538   */                                         
0539 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE()    SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2)
0540 
0541 /**
0542   * @brief  Disable the COMP2 EXTI line rising edge trigger.
0543   * @retval None
0544   */                                         
0545 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE()   CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2)
0546 
0547 /**
0548   * @brief  Enable the COMP2 EXTI line falling edge trigger.
0549   * @retval None
0550   */                                         
0551 #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE()   SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2)
0552 
0553 /**
0554   * @brief  Disable the COMP2 EXTI line falling edge trigger. 
0555   * @retval None
0556   */                                         
0557 #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE()  CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2)
0558 
0559 /**
0560   * @brief  Enable the COMP2 EXTI line rising & falling edge trigger.
0561   * @retval None
0562   */                                         
0563 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE()   do {                                           \
0564                                                                __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE();  \
0565                                                                __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE(); \
0566                                                              } while(0)
0567 
0568 /**
0569   * @brief  Disable the COMP2 EXTI line rising & falling edge trigger.
0570   * @retval None
0571   */                                         
0572 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE()   do {                                           \
0573                                                                __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE();  \
0574                                                                __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE(); \
0575                                                              } while(0)
0576 /**
0577   * @brief  Enable the COMP2 EXTI line.
0578   * @retval None
0579   */                                         
0580 #define __HAL_COMP_COMP2_EXTI_ENABLE_IT()             SET_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP2)
0581 
0582 /**
0583   * @brief  Disable the COMP2 EXTI line.
0584   * @retval None
0585   */
0586 #define __HAL_COMP_COMP2_EXTI_DISABLE_IT()            CLEAR_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP2)
0587 
0588 /**
0589   * @brief  Enable the COMP2 EXTI Line in event mode.
0590   * @retval None
0591   */
0592 #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT()          SET_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP2)
0593 
0594 /**
0595   * @brief  Disable the COMP2 EXTI Line in event mode.
0596   * @retval None
0597   */
0598 #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT()          CLEAR_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP2)
0599 
0600 /**
0601   * @brief  Check whether the COMP2 EXTI line flag is set or not.
0602   * @retval RESET or SET
0603   */
0604 #define __HAL_COMP_COMP2_EXTI_GET_FLAG()              READ_BIT(EXTI_D1->PR1, COMP_EXTI_LINE_COMP2)
0605 
0606 /**
0607   * @brief  Clear the the COMP2 EXTI flag.
0608   * @retval None
0609   */
0610 #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG()            WRITE_REG(EXTI_D1->PR1, COMP_EXTI_LINE_COMP2)
0611 
0612 /**
0613   * @brief  Enable the COMP2 D3 EXTI Line in event mode.
0614   * @retval None
0615   */
0616 #define __HAL_COMP_COMP2_EXTID3_ENABLE_EVENT()        SET_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP2)
0617 
0618 /**
0619   * @brief  Disable the COMP2 D3 EXTI Line in event mode.
0620   * @retval None
0621   */
0622 #define __HAL_COMP_COMP2_EXTID3_DISABLE_EVENT()       CLEAR_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP2)
0623 
0624 /**
0625   * @brief  Generate a software interrupt on the COMP2 EXTI line.
0626   * @retval None
0627   */
0628 #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT()         SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP2)
0629 
0630 #if defined(DUAL_CORE)
0631 /**
0632   * @brief  Enable the COMP2 D2 EXTI line
0633   * @retval None
0634   */                                         
0635 #define __HAL_COMP_COMP2_EXTID2_ENABLE_IT()           SET_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP2)
0636 
0637 
0638 /**
0639   * @brief  Disable the COMP2 D2 EXTI line.
0640   * @retval None
0641   */
0642 #define __HAL_COMP_COMP2_EXTID2_DISABLE_IT()          CLEAR_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP2)
0643 
0644 
0645 
0646 /**
0647   * @brief  Enable the COMP2 D2 EXTI Line in event mode.
0648   * @retval None
0649   */
0650 #define __HAL_COMP_COMP2_EXTID2_ENABLE_EVENT()         SET_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP2)
0651 
0652 
0653 
0654 /**
0655   * @brief  Disable the COMP2 D2 EXTI Line in event mode.
0656   * @retval None
0657   */
0658 #define __HAL_COMP_COMP2_EXTID2_DISABLE_EVENT()        CLEAR_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP2)
0659 
0660 
0661 /**
0662   * @brief  Check whether the COMP2 D2 EXTI line flag is set or not.
0663   * @retval RESET or SET
0664   */
0665 #define __HAL_COMP_COMP2_EXTID2_GET_FLAG()            READ_BIT(EXTI_D2->PR1, COMP_EXTI_LINE_COMP2)     
0666 
0667 /**
0668   * @brief  Clear the the COMP2 D2 EXTI flag.
0669   * @retval None
0670   */
0671 #define __HAL_COMP_COMP2_EXTID2_CLEAR_FLAG()          WRITE_REG(EXTI_D2->PR1, COMP_EXTI_LINE_COMP2)
0672 
0673 #endif
0674 /** @brief  Checks if the specified COMP interrupt source is enabled or disabled.
0675   * @param  __HANDLE__: specifies the COMP Handle.
0676   *         This parameter can be COMP1 where x: 1 or 2 to select the COMP peripheral.
0677   * @param  __INTERRUPT__: specifies the COMP interrupt source to check.
0678   *          This parameter can be one of the following values:
0679   *            @arg COMP_IT_EN: Comparator interrupt enable
0680   *   
0681   * @retval The new state of __IT__ (TRUE or FALSE)
0682   */
0683 #define __HAL_COMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CFGR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
0684 
0685 /** @brief  Checks whether the specified COMP flag is set or not.
0686   * @param  __FLAG__: specifies the flag to check.
0687   *        This parameter can be one of the following values:
0688   *            @arg COMP_FLAG_C1I:  Comparator 1 Interrupt Flag
0689   *            @arg COMP_FLAG_C2I:  Comparator 2 Interrupt Flag
0690   *            @retval The new state of __FLAG__ (TRUE or FALSE)
0691   */
0692 #define __HAL_COMP_GET_FLAG(__FLAG__)     ((COMP12->SR & (__FLAG__)) == (__FLAG__))   
0693 
0694 /** @brief  Clears the specified COMP pending flag.
0695   * @param  __FLAG__: specifies the flag to check.
0696   *          This parameter can be any combination of the following values:
0697   *            @arg COMP_CLEAR_C1IF  : Clear Comparator 1 Interrupt Flag
0698   *            @arg COMP_CLEAR_C2IF  : Clear Comparator 2 Interrupt Flag
0699   * @retval None
0700   */
0701 #define __HAL_COMP_CLEAR_FLAG(__FLAG__)   (COMP12->ICFR = (__FLAG__))
0702 
0703 /** @brief  Clear the COMP C1I  flag.
0704   * @retval None
0705   */
0706 #define __HAL_COMP_CLEAR_C1IFLAG()   __HAL_COMP_CLEAR_FLAG( COMP_CLEAR_C1IF)
0707 
0708 /** @brief  Clear the COMP C2I  flag.
0709   * @retval None
0710   */
0711 #define __HAL_COMP_CLEAR_C2IFLAG()   __HAL_COMP_CLEAR_FLAG( COMP_CLEAR_C2IF)
0712 
0713 /** @brief  Enable the specified COMP interrupt.
0714   * @param  __HANDLE__: specifies the COMP Handle.
0715   * @param  __INTERRUPT__: specifies the COMP interrupt source to enable.
0716   *          This parameter can be one of the following values:
0717   *            @arg COMP_CFGRx_ITEN :  Comparator  interrupt
0718   * @retval None
0719   */
0720 #define __HAL_COMP_ENABLE_IT(__HANDLE__, __INTERRUPT__)   ( ((__HANDLE__)->Instance->CFGR) |= (__INTERRUPT__) )
0721 
0722 /** @brief  Disable the specified COMP interrupt.
0723   * @param  __HANDLE__: specifies the COMP Handle.
0724   * @param  __INTERRUPT__: specifies the COMP interrupt source to enable.
0725   *          This parameter can be one of the following values:
0726   *            @arg COMP_CFGRx_ITEN :  Comparator  interrupt
0727   * @retval None
0728   */
0729 #define __HAL_COMP_DISABLE_IT(__HANDLE__,__INTERRUPT__) (((__HANDLE__)->Instance->CFGR) &= ~(__INTERRUPT__))
0730 
0731 /**
0732   * @}
0733   */
0734 /** @brief  Enable the specified bit in the Option register.
0735   * @param  __AF__: specifies the Alternate Function source selection .
0736   *          This parameter can be one of the following values:
0737   *            @arg COMP_OR_AFOPA6  :  Alternate Function PA6 source selection
0738   *            @arg COMP_OR_AFOPA8  :  Alternate Function PA8 source selection
0739   *            @arg COMP_OR_AFOPB12 :  Alternate Function PB12 source selection
0740   *            @arg COMP_OR_AFOPE6  :  Alternate Function PE6 source selection
0741   *            @arg COMP_OR_AFOPE15 :  Alternate Function PE15 source selection
0742   *            @arg COMP_OR_AFOPG2  :  Alternate Function PG2 source selection
0743   *            @arg COMP_OR_AFOPG3  :  Alternate Function PG3 source selection
0744   *            @arg COMP_OR_AFOPG4  :  Alternate Function PG4 source selection
0745   *            @arg COMP_OR_AFOPI1  :  Alternate Function PI1 source selection
0746   *            @arg COMP_OR_AFOPI4  :  Alternate Function PI4 source selection 
0747   *            @arg COMP_OR_AFOPK2  :  Alternate Function PK2 source selection
0748   * @retval None
0749   */
0750 #define __HAL_COMP_ENABLE_OR(__AF__) SET_BIT(COMP12->OR, (__AF__))
0751 
0752 /** @brief  Disable the specified bit in the Option register.
0753   * @param  __AF__: specifies the Alternate Function source selection .
0754   *          This parameter can be one of the following values:
0755   *            @arg COMP_OR_AFOPA6  :  Alternate Function PA6 source selection
0756   *            @arg COMP_OR_AFOPA8  :  Alternate Function PA8 source selection
0757   *            @arg COMP_OR_AFOPB12 :  Alternate Function PB12 source selection
0758   *            @arg COMP_OR_AFOPE6  :  Alternate Function PE6 source selection
0759   *            @arg COMP_OR_AFOPE15 :  Alternate Function PE15 source selection
0760   *            @arg COMP_OR_AFOPG2  :  Alternate Function PG2 source selection
0761   *            @arg COMP_OR_AFOPG3  :  Alternate Function PG3 source selection
0762   *            @arg COMP_OR_AFOPG4  :  Alternate Function PG4 source selection
0763   *            @arg COMP_OR_AFOPI1  :  Alternate Function PI1 source selection
0764   *            @arg COMP_OR_AFOPI4  :  Alternate Function PI4 source selection
0765   *            @arg COMP_OR_AFOPK2  :  Alternate Function PK2 source selection  
0766   * @retval None
0767   */
0768 #define __HAL_COMP_DISABLE_OR(__AF__) CLEAR_BIT(COMP12->OR, (__AF__))
0769 /**
0770   * @}
0771   */
0772 
0773 /* Private types -------------------------------------------------------------*/
0774 /* Private constants ---------------------------------------------------------*/
0775 /** @defgroup COMP_Private_Constants COMP Private Constants
0776   * @ingroup RTEMSBSPsARMSTM32H7
0777   * @{
0778   */
0779 /** @defgroup COMP_ExtiLine COMP EXTI Lines
0780   * @ingroup RTEMSBSPsARMSTM32H7
0781   * @{
0782   */
0783 #define COMP_EXTI_LINE_COMP1           (EXTI_IMR1_IM20)  /*!< EXTI line 20 connected to COMP1 output */
0784 #define COMP_EXTI_LINE_COMP2           (EXTI_IMR1_IM21)  /*!< EXTI line 21 connected to COMP2 output */
0785 /**
0786   * @}
0787   */
0788 /** @defgroup COMP_ExtiLine COMP EXTI Lines
0789   * @ingroup RTEMSBSPsARMSTM32H7
0790   * @{
0791   */
0792 #define COMP_EXTI_IT                        ((uint32_t) 0x01)  /*!< EXTI line event with interruption */
0793 #define COMP_EXTI_EVENT                     ((uint32_t) 0x02)  /*!< EXTI line event only (without interruption) */
0794 #define COMP_EXTI_RISING                    ((uint32_t) 0x10)  /*!< EXTI line event on rising edge */
0795 #define COMP_EXTI_FALLING                   ((uint32_t) 0x20)  /*!< EXTI line event on falling edge */
0796 /**
0797   * @}
0798   */
0799 /**
0800   * @}
0801   */
0802 
0803 /* Private macros ------------------------------------------------------------*/
0804 /** @defgroup COMP_Private_Macros COMP Private Macros
0805   * @ingroup RTEMSBSPsARMSTM32H7
0806   * @{
0807   */
0808 /** @defgroup COMP_GET_EXTI_LINE COMP Private macros to get EXTI line associated with Comparators 
0809   * @ingroup RTEMSBSPsARMSTM32H7
0810   * @{
0811   */
0812 /**
0813   * @brief  Get the specified EXTI line for a comparator instance.
0814   * @param  __INSTANCE__: specifies the COMP instance.
0815   * @retval value of @ref COMP_ExtiLine
0816   */
0817 #define COMP_GET_EXTI_LINE(__INSTANCE__)             (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 : \
0818                                                       COMP_EXTI_LINE_COMP2)
0819 /**
0820   * @}
0821   */
0822 /** @defgroup COMP_IS_COMP_Definitions COMP private macros to check input parameters
0823   * @ingroup RTEMSBSPsARMSTM32H7
0824   * @{
0825   */
0826 #define IS_COMP_WINDOWMODE(__WINDOWMODE__)  (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE)                || \
0827                                              ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON)  )
0828 
0829 #define IS_COMP_POWERMODE(__POWERMODE__)    (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED)    || \
0830                                              ((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED)  || \
0831                                              ((__POWERMODE__) == COMP_POWERMODE_ULTRALOWPOWER)  )
0832 
0833 #if defined (COMP_CFGRx_INP2SEL)
0834 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
0835                                                                ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \
0836                                                                ((__INPUT_PLUS__) == COMP_INPUT_PLUS_DAC2_CH1))
0837 #else
0838 #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
0839                                                                ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2))                                                              
0840 #endif                                                             
0841 
0842 
0843 #if defined (COMP_CFGRx_INMSEL_3)
0844 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT)     || \
0845                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT)     || \
0846                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT)     || \
0847                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT)        || \
0848                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)       || \
0849                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2)       || \
0850                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1)            || \
0851                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2)            || \
0852                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_TPSENS_DAC2CH1) || \
0853                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VBAT_VDDAP))
0854 #else                                          
0855 #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT)  || \
0856                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT)  || \
0857                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT)  || \
0858                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT)     || \
0859                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1)    || \
0860                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2)    || \
0861                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1)         || \
0862                                                                  ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2))                                                                  
0863 #endif
0864 
0865 #define IS_COMP_HYSTERESIS(__HYSTERESIS__)  (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE)   || \
0866                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW)    || \
0867                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \
0868                                              ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH))
0869 
0870 #define IS_COMP_OUTPUTPOL(__POL__)          (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
0871                                              ((__POL__) == COMP_OUTPUTPOL_INVERTED))
0872 
0873 #define IS_COMP_BLANKINGSRCE(__SOURCE__)    (((__SOURCE__) == COMP_BLANKINGSRC_NONE)      || \
0874                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5)  || \
0875                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3)  || \
0876                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3)  || \
0877                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4)  || \
0878                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5)  || \
0879                                              ((__SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1))
0880 
0881 
0882 #define IS_COMP_TRIGGERMODE(__MODE__)       (((__MODE__) == COMP_TRIGGERMODE_NONE)                 || \
0883                                              ((__MODE__) == COMP_TRIGGERMODE_IT_RISING)            || \
0884                                              ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING)           || \
0885                                              ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING)    || \
0886                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING)         || \
0887                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING)        || \
0888                                              ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
0889 
0890 #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW)     || \
0891                                                 ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH))
0892 
0893 /**
0894   * @}
0895   */
0896 
0897 /**
0898   * @}
0899   */
0900 
0901 /* Exported functions --------------------------------------------------------*/
0902 /** @addtogroup COMP_Exported_Functions
0903   * @{
0904   */
0905 
0906 /** @addtogroup COMP_Exported_Functions_Group1
0907   * @{
0908   */
0909 /* Initialization and de-initialization functions  **********************************/
0910 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
0911 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
0912 void              HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
0913 void              HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
0914 #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
0915 /* Callbacks Register/UnRegister functions  ***********************************/
0916 HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID, pCOMP_CallbackTypeDef pCallback);
0917 HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID);
0918 #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
0919 /**
0920   * @}
0921   */
0922 
0923 /* IO operation functions  *****************************************************/
0924 /** @addtogroup COMP_Exported_Functions_Group2
0925   * @{
0926   */
0927 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
0928 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
0929 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
0930 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
0931 void              HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
0932 
0933 /**
0934   * @}
0935   */
0936 
0937 /* Peripheral Control functions  ************************************************/
0938 /** @addtogroup COMP_Exported_Functions_Group3
0939   * @{
0940   */
0941 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
0942 uint32_t          HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
0943 /* Callback in Interrupt mode */
0944 void              HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
0945 /**
0946   * @}
0947   */
0948 
0949 /* Peripheral State functions  **************************************************/
0950 /** @addtogroup COMP_Exported_Functions_Group4
0951   * @{
0952   */
0953 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
0954 uint32_t              HAL_COMP_GetError(COMP_HandleTypeDef *hcomp);
0955 /**
0956   * @}
0957   */
0958 
0959 /**
0960   * @}
0961   */
0962 
0963 
0964 /**
0965   * @}
0966   */
0967 
0968 /**
0969   * @}
0970   */
0971 #ifdef __cplusplus
0972 }
0973 #endif
0974 
0975 #endif /* STM32H7xx_HAL_COMP_H */
0976 
0977