Back to home page

LXR

 
 

    


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

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_ll_comp.h
0004   * @author  MCD Application Team
0005   * @brief   Header file of COMP LL 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_LL_COMP_H
0021 #define __STM32H7xx_LL_COMP_H
0022 
0023 #ifdef __cplusplus
0024 extern "C" {
0025 #endif
0026 
0027 /* Includes ------------------------------------------------------------------*/
0028 #include "stm32h7xx.h"
0029 
0030 /** @addtogroup STM32H7xx_LL_Driver
0031   * @{
0032   */
0033 
0034 #if defined (COMP1) || defined (COMP2)
0035 
0036 /** @defgroup COMP_LL COMP
0037   * @ingroup RTEMSBSPsARMSTM32H7
0038   * @{
0039   */
0040 
0041 /* Private types -------------------------------------------------------------*/
0042 /* Private variables ---------------------------------------------------------*/
0043 /* Private constants ---------------------------------------------------------*/
0044 /** @defgroup COMP_LL_Private_Constants COMP Private Constants
0045   * @ingroup RTEMSBSPsARMSTM32H7
0046   * @{
0047   */
0048 
0049 /* COMP registers bits positions */
0050 #define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS (30U) /* Value equivalent to POSITION_VAL(COMP_CSR_VALUE) */
0051 
0052 /**
0053   * @}
0054   */
0055 
0056 /* Private macros ------------------------------------------------------------*/
0057 /** @defgroup COMP_LL_Private_Macros COMP Private Macros
0058   * @ingroup RTEMSBSPsARMSTM32H7
0059   * @{
0060   */
0061 /**
0062   * @}
0063   */
0064 /* Exported types ------------------------------------------------------------*/
0065 #if defined(USE_FULL_LL_DRIVER) || defined(__rtems__)
0066 /** @defgroup COMP_LL_ES_INIT COMP Exported Init structure
0067   * @ingroup RTEMSBSPsARMSTM32H7
0068   * @{
0069   */
0070 
0071 /**
0072   * @brief  Structure definition of some features of COMP instance.
0073   */
0074 typedef struct
0075 {
0076   uint32_t PowerMode;                   /*!< Set comparator operating mode to adjust power and speed.
0077                                              This parameter can be a value of @ref COMP_LL_EC_POWERMODE
0078                                              
0079                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetPowerMode(). */
0080 
0081   uint32_t InputPlus;                   /*!< Set comparator input plus (non-inverting input).
0082                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_PLUS
0083                                              
0084                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputPlus(). */
0085 
0086   uint32_t InputMinus;                  /*!< Set comparator input minus (inverting input).
0087                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_MINUS
0088                                              
0089                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputMinus(). */
0090 
0091   uint32_t InputHysteresis;             /*!< Set comparator hysteresis mode of the input minus.
0092                                              This parameter can be a value of @ref COMP_LL_EC_INPUT_HYSTERESIS
0093                                              
0094                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputHysteresis(). */
0095 
0096   uint32_t OutputPolarity;              /*!< Set comparator output polarity.
0097                                              This parameter can be a value of @ref COMP_LL_EC_OUTPUT_POLARITY
0098                                              
0099                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputPolarity(). */
0100 
0101   uint32_t OutputBlankingSource;        /*!< Set comparator blanking source.
0102                                              This parameter can be a value of @ref COMP_LL_EC_OUTPUT_BLANKING_SOURCE
0103                                              
0104                                              This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputBlankingSource(). */
0105 
0106 } LL_COMP_InitTypeDef;
0107 
0108 /**
0109   * @}
0110   */
0111 #endif /* USE_FULL_LL_DRIVER */
0112 
0113 /* Exported constants --------------------------------------------------------*/
0114 /** @defgroup COMP_LL_Exported_Constants COMP Exported Constants
0115   * @ingroup RTEMSBSPsARMSTM32H7
0116   * @{
0117   */
0118 
0119 /** @defgroup COMP_LL_EC_COMMON_WINDOWMODE Comparator common modes - Window mode
0120   * @ingroup RTEMSBSPsARMSTM32H7
0121   * @{
0122   */
0123 #define LL_COMP_WINDOWMODE_DISABLE                 (0x00000000UL)          /*!< Window mode disable: Comparators 1 and 2 are independent */
0124 #define LL_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). */
0125 /**
0126   * @}
0127   */
0128 
0129 /** @defgroup COMP_LL_EC_POWERMODE Comparator modes - Power mode
0130   * @ingroup RTEMSBSPsARMSTM32H7
0131   * @{
0132   */
0133 #define LL_COMP_POWERMODE_HIGHSPEED     (0x00000000UL)                                /*!< COMP power mode to high speed */
0134 #define LL_COMP_POWERMODE_MEDIUMSPEED   (COMP_CFGRx_PWRMODE_0)                        /*!< COMP power mode to medium speed */
0135 #define LL_COMP_POWERMODE_ULTRALOWPOWER (COMP_CFGRx_PWRMODE_1 | COMP_CFGRx_PWRMODE_0) /*!< COMP power mode to ultra-low power */
0136 /**
0137   * @}
0138   */
0139 
0140 /** @defgroup COMP_LL_EC_INPUT_PLUS Comparator inputs - Input plus (input non-inverting) selection
0141   * @ingroup RTEMSBSPsARMSTM32H7
0142   * @{
0143   */
0144 #define LL_COMP_INPUT_PLUS_IO1          (0x00000000UL)                           /*!< Comparator input plus connected to IO1 (pin PB0 for COMP1, pin PE9 for COMP2) */
0145 #define LL_COMP_INPUT_PLUS_IO2          (COMP_CFGRx_INPSEL)                      /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PE11 for COMP2) */
0146 #if defined (COMP_CFGRx_INP2SEL)
0147 #define LL_COMP_INPUT_PLUS_DAC2_CH1     (COMP_CFGRx_INP2SEL)                     /*!< Comparator input plus 2 connected to (DAC2_CH1 for COMP1)                      */
0148 #endif
0149 /**
0150   * @}
0151   */
0152 
0153 /** @defgroup COMP_LL_EC_INPUT_MINUS Comparator inputs - Input minus (input inverting) selection
0154   * @ingroup RTEMSBSPsARMSTM32H7
0155   * @{
0156   */
0157 #define LL_COMP_INPUT_MINUS_1_4VREFINT      (                                                                                        COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN)   /*!< Comparator input minus connected to 1/4 VrefInt  */
0158 #define LL_COMP_INPUT_MINUS_1_2VREFINT      (                                                                  COMP_CFGRx_INMSEL_0 | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN)   /*!< Comparator input minus connected to 1/2 VrefInt  */
0159 #define LL_COMP_INPUT_MINUS_3_4VREFINT      (                                            COMP_CFGRx_INMSEL_1                       | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN)   /*!< Comparator input minus connected to 3/4 VrefInt  */
0160 #define LL_COMP_INPUT_MINUS_VREFINT         (                                            COMP_CFGRx_INMSEL_1 | COMP_CFGRx_INMSEL_0 | COMP_CFGRx_SCALEN                   )   /*!< Comparator input minus connected to VrefInt */
0161 #define LL_COMP_INPUT_MINUS_DAC1_CH1        (                      COMP_CFGRx_INMSEL_2                                                                                   )   /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1)  */
0162 #define LL_COMP_INPUT_MINUS_DAC1_CH2        (                      COMP_CFGRx_INMSEL_2                       | COMP_CFGRx_INMSEL_0                                       )   /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2)  */
0163 #define LL_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) */
0164 #define LL_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) */
0165 #if defined (COMP_CFGRx_INMSEL_3)
0166 #define LL_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) */
0167 #define LL_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) */
0168 #endif
0169 /**
0170   * @}
0171   */
0172 
0173 /** @defgroup COMP_LL_EC_INPUT_HYSTERESIS Comparator input - Hysteresis
0174   * @ingroup RTEMSBSPsARMSTM32H7
0175   * @{
0176   */
0177 #define LL_COMP_HYSTERESIS_NONE         (0x00000000UL)                            /*!< No hysteresis */
0178 #define LL_COMP_HYSTERESIS_LOW          (                    COMP_CFGRx_HYST_0)   /*!< Hysteresis level low */
0179 #define LL_COMP_HYSTERESIS_MEDIUM       (COMP_CFGRx_HYST_1                    )   /*!< Hysteresis level medium */
0180 #define LL_COMP_HYSTERESIS_HIGH         (COMP_CFGRx_HYST_1 | COMP_CFGRx_HYST_0)   /*!< Hysteresis level high */
0181 /**
0182   * @}
0183   */
0184 
0185 /** @defgroup COMP_LL_EC_OUTPUT_POLARITY Comparator output - Output polarity
0186   * @ingroup RTEMSBSPsARMSTM32H7
0187   * @{
0188   */
0189 #define LL_COMP_OUTPUTPOL_NONINVERTED   (0x00000000UL)          /*!< COMP output polarity is not inverted: comparator output is high when the plus (non-inverting) input is at a higher voltage than the minus (inverting) input */
0190 #define LL_COMP_OUTPUTPOL_INVERTED      (COMP_CFGRx_POLARITY)   /*!< COMP output polarity is inverted: comparator output is low when the plus (non-inverting) input is at a lower voltage than the minus (inverting) input */
0191 /**
0192   * @}
0193   */
0194 
0195 /** @defgroup COMP_LL_EC_OUTPUT_BLANKING_SOURCE Comparator output - Blanking source
0196   * @ingroup RTEMSBSPsARMSTM32H7
0197   * @{
0198   */
0199 #define LL_COMP_BLANKINGSRC_NONE      (0x00000000UL)                                  /*!<Comparator output without blanking */
0200 #define LL_COMP_BLANKINGSRC_TIM1_OC5  (COMP_CFGRx_BLANKING_0)                         /*!< Comparator output blanking source TIM1 OC5 (common to all COMP instances: COMP1, COMP2) */
0201 #define LL_COMP_BLANKINGSRC_TIM2_OC3  (COMP_CFGRx_BLANKING_1)                         /*!< Comparator output blanking source TIM2 OC3 (common to all COMP instances: COMP1, COMP2) */
0202 #define LL_COMP_BLANKINGSRC_TIM3_OC3  (COMP_CFGRx_BLANKING_0 |COMP_CFGRx_BLANKING_1)  /*!< Comparator output blanking source TIM3 OC3 (common to all COMP instances: COMP1, COMP2) */
0203 #define LL_COMP_BLANKINGSRC_TIM3_OC4  (COMP_CFGRx_BLANKING_2)                         /*!< Comparator output blanking source TIM3 OC4 (common to all COMP instances: COMP1, COMP2) */
0204 #define LL_COMP_BLANKINGSRC_TIM8_OC5  (COMP_CFGRx_BLANKING_2|COMP_CFGRx_BLANKING_0)   /*!< Comparator output blanking source TIM8 OC5 (common to all COMP instances: COMP1, COMP2) */
0205 #define LL_COMP_BLANKINGSRC_TIM15_OC1 (COMP_CFGRx_BLANKING_2|COMP_CFGRx_BLANKING_1)   /*!< Comparator output blanking source TIM15 OC1 (common to all COMP instances: COMP1, COMP2) */
0206 /**
0207   * @}
0208   */
0209 
0210 /** @defgroup COMP_LL_EC_OUTPUT_LEVEL Comparator output - Output level
0211   * @ingroup RTEMSBSPsARMSTM32H7
0212   * @{
0213   */
0214 #define LL_COMP_OUTPUT_LEVEL_LOW        (0x00000000UL)           /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */
0215 #define LL_COMP_OUTPUT_LEVEL_HIGH       (0x00000001UL)           /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */
0216 /**
0217   * @}
0218   */
0219 /** @defgroup COMP_LL_EC_OUTPUT_BKIN_TIMER Comparator output - Output to BKIN timer
0220   * @ingroup RTEMSBSPsARMSTM32H7
0221   * @{
0222   */
0223 #define LL_COMP_AF_PA6          COMP_OR_AFOPA6       /*!< Comparator Alternate Function PA6 source selected to timer BKIN input  */
0224 #define LL_COMP_AF_PA8          COMP_OR_AFOPA8       /*!< Comparator Alternate Function PA8 source selected to timer BKIN input  */
0225 #define LL_COMP_AF_PB12         COMP_OR_AFOPB12      /*!< Comparator Alternate Function PB12 source selected to timer BKIN input */
0226 #define LL_COMP_AF_PE6          COMP_OR_AFOPE6       /*!< Comparator Alternate Function PE6 source selected to timer BKIN input  */
0227 #define LL_COMP_AF_PE15         COMP_OR_AFOPE15      /*!< Comparator Alternate Function PE15 source selected to timer BKIN input */
0228 #define LL_COMP_AF_PG2          COMP_OR_AFOPG2       /*!< Comparator Alternate Function PG2 source selected to timer BKIN input  */
0229 #define LL_COMP_AF_PG3          COMP_OR_AFOPG3       /*!< Comparator Alternate Function PG3 source selected to timer BKIN input  */
0230 #define LL_COMP_AF_PG4          COMP_OR_AFOPG4       /*!< Comparator Alternate Function PG4 source selected to timer BKIN input  */
0231 #define LL_COMP_AF_PI1          COMP_OR_AFOPI1       /*!< Comparator Alternate Function PI1 source selected to timer BKIN input  */
0232 #define LL_COMP_AF_PI4          COMP_OR_AFOPI4       /*!< Comparator Alternate Function PI4 source selected to timer BKIN input  */
0233 #define LL_COMP_AF_PK2          COMP_OR_AFOPK2       /*!< Comparator Alternate Function PK2 source selected to timer BKIN input  */
0234 /**
0235   * @}
0236   */
0237 
0238 /** @defgroup COMP_LL_EC_HW_DELAYS  Definitions of COMP hardware constraints delays
0239   * @ingroup RTEMSBSPsARMSTM32H7
0240   * @note   Only COMP IP HW delays are defined in COMP LL driver driver,
0241   *         not timeout values.
0242   *         For details on delays values, refer to descriptions in source code
0243   *         above each literal definition.
0244   * @{
0245   */
0246 
0247 /* Delay for comparator startup time.                                         */
0248 /* Note: Delay required to reach propagation delay specification.             */
0249 /* Literal set to maximum value (refer to device datasheet,                   */
0250 /* parameter "tSTART").                                                       */
0251 /* Unit: us                                                                   */
0252 #define LL_COMP_DELAY_STARTUP_US          ( 80UL)  /*!< Delay for COMP startup time */
0253 
0254 /* Delay for comparator voltage scaler stabilization time.                    */
0255 /* Note: Voltage scaler is used when selecting comparator input               */
0256 /*       based on VrefInt: VrefInt or subdivision of VrefInt.                 */
0257 /* Literal set to maximum value (refer to device datasheet,                   */
0258 /* parameter "tSTART_SCALER").                                                */
0259 /* Unit: us                                                                   */
0260 #define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ( 200UL)  /*!< Delay for COMP voltage scaler stabilization time */
0261 
0262 /**
0263   * @}
0264   */
0265 
0266 /**
0267   * @}
0268   */
0269 
0270 /* Exported macro ------------------------------------------------------------*/
0271 /** @defgroup COMP_LL_Exported_Macros COMP Exported Macros
0272   * @ingroup RTEMSBSPsARMSTM32H7
0273   * @{
0274   */
0275 /** @defgroup COMP_LL_EM_WRITE_READ Common write and read registers macro
0276   * @ingroup RTEMSBSPsARMSTM32H7
0277   * @{
0278   */
0279 
0280 /**
0281   * @brief  Write a value in COMP register
0282   * @param  __INSTANCE__ comparator instance
0283   * @param  __REG__ Register to be written
0284   * @param  __VALUE__ Value to be written in the register
0285   * @retval None
0286   */
0287 #define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
0288 
0289 /**
0290   * @brief  Read a value in COMP register
0291   * @param  __INSTANCE__ comparator instance
0292   * @param  __REG__ Register to be read
0293   * @retval Register value
0294   */
0295 #define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
0296 /**
0297   * @}
0298   */
0299 
0300 /** @defgroup COMP_LL_EM_HELPER_MACRO COMP helper macro
0301   * @ingroup RTEMSBSPsARMSTM32H7
0302   * @{
0303   */
0304 
0305 /**
0306   * @brief  Helper macro to select the COMP common instance
0307   *         to which is belonging the selected COMP instance.
0308   * @note   COMP common register instance can be used to
0309   *         set parameters common to several COMP instances.
0310   *         Refer to functions having argument "COMPxy_COMMON" as parameter.
0311   * @param  __COMPx__ COMP instance
0312   * @retval COMP common instance or value "0" if there is no COMP common instance.
0313   */
0314 #define __LL_COMP_COMMON_INSTANCE(__COMPx__)                                   \
0315   (COMP12_COMMON)
0316 
0317 /**
0318   * @}
0319   */
0320 
0321 /**
0322   * @}
0323   */
0324 
0325 /* Exported functions --------------------------------------------------------*/
0326 /** @defgroup COMP_LL_Exported_Functions COMP Exported Functions
0327   * @ingroup RTEMSBSPsARMSTM32H7
0328   * @{
0329   */
0330 
0331 /** @defgroup COMP_LL_EF_Configuration_comparator_common Configuration of COMP hierarchical scope: common to several COMP instances
0332   * @ingroup RTEMSBSPsARMSTM32H7
0333   * @{
0334   */
0335 
0336 /**
0337   * @brief  Set window mode of a pair of comparators instances
0338   *         (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
0339   * @rmtoll CFGRx    WINMODE        LL_COMP_SetCommonWindowMode
0340   * @param  COMPxy_COMMON Comparator common instance
0341   *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
0342   * @param  WindowMode This parameter can be one of the following values:
0343   *         @arg @ref LL_COMP_WINDOWMODE_DISABLE
0344   *         @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
0345   * @retval None
0346   */
0347 __STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode)
0348 {
0349   /* Note: On this STM32 series, window mode can be set only                   */
0350   /*       from COMP instance: COMP2.                                         */
0351   MODIFY_REG(COMPxy_COMMON->CFGR, COMP_CFGRx_WINMODE, WindowMode);
0352 }
0353 
0354 /**
0355   * @brief  Get window mode of a pair of comparators instances
0356   *         (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
0357   * @rmtoll CFGRx    WINMODE        LL_COMP_GetCommonWindowMode
0358   * @param  COMPxy_COMMON Comparator common instance
0359   *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
0360   * @retval Returned value can be one of the following values:
0361   *         @arg @ref LL_COMP_WINDOWMODE_DISABLE
0362   *         @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
0363   */
0364 __STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON)
0365 {
0366   return (uint32_t)(READ_BIT(COMPxy_COMMON->CFGR, COMP_CFGRx_WINMODE));
0367 }
0368 
0369 /**
0370   * @}
0371   */
0372 
0373 /** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes
0374   * @ingroup RTEMSBSPsARMSTM32H7
0375   * @{
0376   */
0377 
0378 /**
0379   * @brief  Set comparator instance operating mode to adjust power and speed.
0380   * @rmtoll CFGRx    PWRMODE        LL_COMP_SetPowerMode
0381   * @param  COMPx Comparator instance
0382   * @param  PowerMode This parameter can be one of the following values:
0383   *         @arg @ref LL_COMP_POWERMODE_HIGHSPEED
0384   *         @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
0385   *         @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
0386   * @retval None
0387   */
0388 __STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode)
0389 {
0390   MODIFY_REG(COMPx->CFGR, COMP_CFGRx_PWRMODE, PowerMode);
0391 }
0392 
0393 /**
0394   * @brief  Get comparator instance operating mode to adjust power and speed.
0395   * @rmtoll CFGRx    PWRMODE        LL_COMP_GetPowerMode
0396   * @param  COMPx Comparator instance
0397   * @retval Returned value can be one of the following values:
0398   *         @arg @ref LL_COMP_POWERMODE_HIGHSPEED
0399   *         @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
0400   *         @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
0401   */
0402 __STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx)
0403 {
0404   return (uint32_t)(READ_BIT(COMPx->CFGR, COMP_CFGRx_PWRMODE));
0405 }
0406 
0407 /**
0408   * @}
0409   */
0410 
0411 /** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs
0412   * @ingroup RTEMSBSPsARMSTM32H7
0413   * @{
0414   */
0415 
0416 /**
0417   * @brief  Set comparator inputs minus (inverting) and plus (non-inverting).
0418   * @note   In case of comparator input selected to be connected to IO:
0419   *         GPIO pins are specific to each comparator instance.
0420   *         Refer to description of parameters or to reference manual.
0421   * @note   On this STM32 series, scaler bridge is configurable:
0422   *         to optimize power consumption, this function enables the
0423   *         voltage scaler bridge only when required
0424   *         (when selecting comparator input based on VrefInt: VrefInt or
0425   *         subdivision of VrefInt).
0426   *         - For scaler bridge power consumption values, 
0427   *           refer to device datasheet, parameter "IDDA(SCALER)".
0428   *         - Voltage scaler requires a delay for voltage stabilization.
0429   *           Refer to device datasheet, parameter "tSTART_SCALER".
0430   *         - Scaler bridge is common for all comparator instances,
0431   *           therefore if at least one of the comparator instance
0432   *           is requiring the scaler bridge, it remains enabled.
0433   * @rmtoll CFGRx      INMSEL         LL_COMP_ConfigInputs\n
0434   *         CFGRx      INPSEL         LL_COMP_ConfigInputs\n
0435   *         CFGRx      BRGEN          LL_COMP_ConfigInputs\n
0436   *         CFGRx      SCALEN         LL_COMP_ConfigInputs
0437   * @param  COMPx Comparator instance
0438   * @param  InputMinus This parameter can be one of the following values:
0439   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
0440   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
0441   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
0442   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
0443   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
0444   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2 
0445   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
0446   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
0447   *         @arg @ref LL_COMP_INPUT_MINUS_TPSENS_DAC2CH1
0448   *         @arg @ref LL_COMP_INPUT_MINUS_VBAT_VDDAP
0449   * @param  InputPlus This parameter can be one of the following values:
0450   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
0451   *         @arg @ref LL_COMP_INPUT_PLUS_IO2
0452   *         @arg @ref LL_COMP_INPUT_PLUS_DAC2_CH1
0453   * @retval None
0454   */
0455 __STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus)
0456 {
0457 #if defined (COMP_CFGRx_INP2SEL)
0458   MODIFY_REG(COMPx->CFGR,
0459              COMP_CFGRx_INMSEL | COMP_CFGRx_INPSEL | 
0460              COMP_CFGRx_INP2SEL | 
0461              COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN,
0462              InputMinus | InputPlus);
0463 #else
0464   MODIFY_REG(COMPx->CFGR,
0465              COMP_CFGRx_INMSEL | COMP_CFGRx_INPSEL | 
0466              COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN,
0467              InputMinus | InputPlus);
0468 #endif
0469 }
0470 
0471 /**
0472   * @brief  Set comparator input plus (non-inverting).
0473   * @note   In case of comparator input selected to be connected to IO:
0474   *         GPIO pins are specific to each comparator instance.
0475   *         Refer to description of parameters or to reference manual.
0476   * @rmtoll CFGRx    INPSEL         LL_COMP_SetInputPlus
0477   * @param  COMPx Comparator instance
0478   * @param  InputPlus This parameter can be one of the following values:
0479   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
0480   *         @arg @ref LL_COMP_INPUT_PLUS_IO2
0481   *         @arg @ref LL_COMP_INPUT_PLUS_DAC2_CH1
0482   * @retval None
0483   */
0484 __STATIC_INLINE void LL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus)
0485 {
0486 #if defined (COMP_CFGRx_INP2SEL)
0487   MODIFY_REG(COMPx->CFGR, COMP_CFGRx_INPSEL | COMP_CFGRx_INP2SEL , InputPlus);
0488 #else
0489   MODIFY_REG(COMPx->CFGR, COMP_CFGRx_INPSEL , InputPlus);
0490 #endif
0491 }
0492 
0493 /**
0494   * @brief  Get comparator input plus (non-inverting).
0495   * @note   In case of comparator input selected to be connected to IO:
0496   *         GPIO pins are specific to each comparator instance.
0497   *         Refer to description of parameters or to reference manual.
0498   * @rmtoll CFGRx    INPSEL         LL_COMP_GetInputPlus
0499   * @param  COMPx Comparator instance
0500   * @retval Returned value can be one of the following values:
0501   *         @arg @ref LL_COMP_INPUT_PLUS_IO1
0502   *         @arg @ref LL_COMP_INPUT_PLUS_IO2
0503   *         @arg @ref LL_COMP_INPUT_PLUS_DAC2_CH1
0504   */
0505 __STATIC_INLINE uint32_t LL_COMP_GetInputPlus(COMP_TypeDef *COMPx)
0506 {
0507 #if defined (COMP_CFGRx_INP2SEL)
0508   return (uint32_t)(READ_BIT(COMPx->CFGR, COMP_CFGRx_INPSEL | COMP_CFGRx_INP2SEL));
0509 #else
0510   return (uint32_t)(READ_BIT(COMPx->CFGR, COMP_CFGRx_INPSEL));
0511 #endif
0512 }
0513 
0514 /**
0515   * @brief  Set comparator input minus (inverting).
0516   * @note   In case of comparator input selected to be connected to IO:
0517   *         GPIO pins are specific to each comparator instance.
0518   *         Refer to description of parameters or to reference manual.
0519   * @note   On this STM32 series, scaler bridge is configurable:
0520   *         to optimize power consumption, this function enables the
0521   *         voltage scaler bridge only when required
0522   *         (when selecting comparator input based on VrefInt: VrefInt or
0523   *         subdivision of VrefInt).
0524   *         - For scaler bridge power consumption values, 
0525   *           refer to device datasheet, parameter "IDDA(SCALER)".
0526   *         - Voltage scaler requires a delay for voltage stabilization.
0527   *           Refer to device datasheet, parameter "tSTART_SCALER".
0528   *         - Scaler bridge is common for all comparator instances,
0529   *           therefore if at least one of the comparator instance
0530   *           is requiring the scaler bridge, it remains enabled.
0531   * @rmtoll CFGRx     INMSEL         LL_COMP_SetInputMinus\n
0532   *         CFGRx     BRGEN          LL_COMP_SetInputMinus\n
0533   *         CFGRx     SCALEN         LL_COMP_SetInputMinus
0534   * @param  COMPx Comparator instance
0535   * @param  InputMinus This parameter can be one of the following values:
0536   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
0537   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
0538   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
0539   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
0540   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
0541   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
0542   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
0543   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
0544   *         @arg @ref LL_COMP_INPUT_MINUS_TPSENS_DAC2CH1
0545   *         @arg @ref LL_COMP_INPUT_MINUS_VBAT_VDDAP
0546   * @retval None
0547   */
0548 __STATIC_INLINE void LL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus)
0549 {
0550   MODIFY_REG(COMPx->CFGR, COMP_CFGRx_INMSEL | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN, InputMinus);
0551 }
0552 
0553 /**
0554   * @brief  Get comparator input minus (inverting).
0555   * @note   In case of comparator input selected to be connected to IO:
0556   *         GPIO pins are specific to each comparator instance.
0557   *         Refer to description of parameters or to reference manual.
0558   * @rmtoll CFGRx     INMSEL         LL_COMP_GetInputMinus\n
0559   *         CFGRx     BRGEN          LL_COMP_GetInputMinus\n
0560   *         CFGRx     SCALEN         LL_COMP_GetInputMinus
0561   * @param  COMPx Comparator instance
0562   * @retval Returned value can be one of the following values:
0563   *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
0564   *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
0565   *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
0566   *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
0567   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
0568   *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2  
0569   *         @arg @ref LL_COMP_INPUT_MINUS_IO1
0570   *         @arg @ref LL_COMP_INPUT_MINUS_IO2
0571   *         @arg @ref LL_COMP_INPUT_MINUS_TPSENS_DAC2CH1
0572   *         @arg @ref LL_COMP_INPUT_MINUS_VBAT_VDDAP
0573   */
0574 __STATIC_INLINE uint32_t LL_COMP_GetInputMinus(COMP_TypeDef *COMPx)
0575 {
0576   return (uint32_t)(READ_BIT(COMPx->CFGR, COMP_CFGRx_INMSEL | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN));
0577 }
0578 
0579 /**
0580   * @brief  Set comparator instance hysteresis mode of the input minus (inverting input).
0581   * @rmtoll CFGRx    HYST           LL_COMP_SetInputHysteresis
0582   * @param  COMPx Comparator instance
0583   * @param  InputHysteresis This parameter can be one of the following values:
0584   *         @arg @ref LL_COMP_HYSTERESIS_NONE
0585   *         @arg @ref LL_COMP_HYSTERESIS_LOW
0586   *         @arg @ref LL_COMP_HYSTERESIS_MEDIUM
0587   *         @arg @ref LL_COMP_HYSTERESIS_HIGH
0588   * @retval None
0589   */
0590 __STATIC_INLINE void LL_COMP_SetInputHysteresis(COMP_TypeDef *COMPx, uint32_t InputHysteresis)
0591 {
0592   MODIFY_REG(COMPx->CFGR, COMP_CFGRx_HYST, InputHysteresis);
0593 }
0594 
0595 /**
0596   * @brief  Get comparator instance hysteresis mode of the minus (inverting) input.
0597   * @rmtoll CSR      HYST           LL_COMP_GetInputHysteresis
0598   * @param  COMPx Comparator instance
0599   * @retval Returned value can be one of the following values:
0600   *         @arg @ref LL_COMP_HYSTERESIS_NONE
0601   *         @arg @ref LL_COMP_HYSTERESIS_LOW
0602   *         @arg @ref LL_COMP_HYSTERESIS_MEDIUM
0603   *         @arg @ref LL_COMP_HYSTERESIS_HIGH
0604   */
0605 __STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis(COMP_TypeDef *COMPx)
0606 {
0607   return (uint32_t)(READ_BIT(COMPx->CFGR, COMP_CFGRx_HYST));
0608 }
0609 
0610 /**
0611   * @}
0612   */
0613 
0614 /** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output
0615   * @ingroup RTEMSBSPsARMSTM32H7
0616   * @{
0617   */
0618 
0619 /**
0620   * @brief  Set comparator instance output polarity.
0621   * @rmtoll CFGRx    POLARITY       LL_COMP_SetOutputPolarity
0622   * @param  COMPx Comparator instance
0623   * @param  OutputPolarity This parameter can be one of the following values:
0624   *         @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
0625   *         @arg @ref LL_COMP_OUTPUTPOL_INVERTED
0626   * @retval None
0627   */
0628 __STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity)
0629 {
0630   MODIFY_REG(COMPx->CFGR, COMP_CFGRx_POLARITY, OutputPolarity);
0631 }
0632 
0633 /**
0634   * @brief  Get comparator instance output polarity.
0635   * @rmtoll CFGRx    POLARITY       LL_COMP_GetOutputPolarity
0636   * @param  COMPx Comparator instance
0637   * @retval Returned value can be one of the following values:
0638   *         @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
0639   *         @arg @ref LL_COMP_OUTPUTPOL_INVERTED
0640   */
0641 __STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
0642 {
0643   return (uint32_t)(READ_BIT(COMPx->CFGR, COMP_CFGRx_POLARITY));
0644 }
0645 
0646 /**
0647   * @brief  Set comparator instance blanking source.
0648   * @note   Blanking source may be specific to each comparator instance.
0649   *         Refer to description of parameters or to reference manual.
0650   * @note   Availability of parameters of blanking source from timer
0651   *         depends on timers availability on the selected device.
0652   * @rmtoll CFGR     BLANKING       LL_COMP_SetOutputBlankingSource
0653   * @param  COMPx Comparator instance
0654   * @param  BlankingSource This parameter can be one of the following values:
0655   *         @arg @ref LL_COMP_BLANKINGSRC_NONE
0656   *         @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5  
0657   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3
0658   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3
0659   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4
0660   *         @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5
0661   *         @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1 
0662   * @retval None
0663   */
0664 __STATIC_INLINE void LL_COMP_SetOutputBlankingSource(COMP_TypeDef *COMPx, uint32_t BlankingSource)
0665 {
0666   MODIFY_REG(COMPx->CFGR, COMP_CFGRx_BLANKING, BlankingSource);
0667 }
0668 
0669 /**
0670   * @brief  Get comparator instance blanking source.
0671   * @note   Availability of parameters of blanking source from timer
0672   *         depends on timers availability on the selected device.
0673   * @note   Blanking source may be specific to each comparator instance.
0674   *         Refer to description of parameters or to reference manual.
0675   * @rmtoll CFGR     BLANKING       LL_COMP_GetOutputBlankingSource
0676   * @param  COMPx Comparator instance
0677   * @retval Returned value can be one of the following values:
0678   *         @arg @ref LL_COMP_BLANKINGSRC_NONE
0679   *         @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5 
0680   *         @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3 
0681   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3
0682   *         @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4 
0683   *         @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5  
0684   *         @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1  
0685   */
0686 __STATIC_INLINE uint32_t LL_COMP_GetOutputBlankingSource(COMP_TypeDef *COMPx)
0687 {
0688   return (uint32_t)(READ_BIT(COMPx->CFGR, COMP_CFGRx_BLANKING));
0689 }
0690 
0691 /** @brief  Set the output alternate function in the Option register
0692   *         in order to be used with the alternate function
0693   *         of the timer break input.
0694   * @rmtoll OR    AFOP       COMP_LL_EC_OUTPUT_BKIN_TIMER
0695   * @param  COMPx specifies the instance.
0696   * @param  CompAFx specifies the Alternate Function source selection.
0697   *          This parameter can be one of the following values:
0698   *            @arg @ref LL_COMP_AF_PA6
0699   *            @arg @ref LL_COMP_AF_PA8
0700   *            @arg @ref LL_COMP_AF_PB12
0701   *            @arg @ref LL_COMP_AF_PE6
0702   *            @arg @ref LL_COMP_AF_PE15
0703   *            @arg @ref LL_COMP_AF_PG2
0704   *            @arg @ref LL_COMP_AF_PG3
0705   *            @arg @ref LL_COMP_AF_PG4
0706   *            @arg @ref LL_COMP_AF_PI1
0707   *            @arg @ref LL_COMP_AF_PI4
0708   *            @arg @ref LL_COMP_AF_PK2
0709   * @retval None
0710   */
0711 __STATIC_INLINE void LL_COMP_SetOutputAlternateFunction(COMP_TypeDef *COMPx, uint32_t CompAFx)
0712 {
0713   MODIFY_REG(COMP12->OR, 0x7FFUL, (COMPx == COMP1) ? ((~CompAFx) & 0x7FFUL) : CompAFx);
0714 }
0715 
0716 /** @brief  Get the output alternate function from the Option register.
0717   * @rmtoll OR     AFOP       COMP_LL_EC_OUTPUT_BKIN_TIMER
0718   * @param  COMPx specifies the Comparator instance.
0719   * @retval Returned value can be one of the following values:
0720   *            @arg @ref LL_COMP_AF_PA6
0721   *            @arg @ref LL_COMP_AF_PA8
0722   *            @arg @ref LL_COMP_AF_PB12
0723   *            @arg @ref LL_COMP_AF_PE6
0724   *            @arg @ref LL_COMP_AF_PE15
0725   *            @arg @ref LL_COMP_AF_PG2
0726   *            @arg @ref LL_COMP_AF_PG3
0727   *            @arg @ref LL_COMP_AF_PG4
0728   *            @arg @ref LL_COMP_AF_PI1
0729   *            @arg @ref LL_COMP_AF_PI4
0730   *            @arg @ref LL_COMP_AF_PK2
0731   */
0732 __STATIC_INLINE uint32_t LL_COMP_GetOutputAlternateFunction(COMP_TypeDef *COMPx )
0733 {
0734   return (uint32_t) ((COMPx == COMP1) ? ((~COMP12->OR) & 0x7FFUL) : (COMP12->OR &  0x7FFUL));
0735 }
0736 
0737 /**
0738   * @}
0739   */
0740 
0741 /** @defgroup COMP_LL_EF_Operation Operation on comparator instance
0742   * @ingroup RTEMSBSPsARMSTM32H7
0743   * @{
0744   */
0745 
0746 /**
0747   * @brief  Enable comparator instance.
0748   * @note   After enable from off state, comparator requires a delay
0749   *         to reach reach propagation delay specification.
0750   *         Refer to device datasheet, parameter "tSTART".
0751   * @rmtoll CFGR     EN             LL_COMP_Enable
0752   * @param  COMPx Comparator instance
0753   * @retval None
0754   */
0755 __STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx)
0756 {
0757   SET_BIT(COMPx->CFGR, COMP_CFGRx_EN);
0758 }
0759 
0760 /**
0761   * @brief  Disable comparator instance.
0762   * @rmtoll CFGR     EN             LL_COMP_Disable
0763   * @param  COMPx Comparator instance
0764   * @retval None
0765   */
0766 __STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx)
0767 {
0768   CLEAR_BIT(COMPx->CFGR, COMP_CFGRx_EN);
0769 }
0770 
0771 /**
0772   * @brief  Get comparator enable state
0773   *         (0: COMP is disabled, 1: COMP is enabled)
0774   * @rmtoll CFGR     EN             LL_COMP_IsEnabled
0775   * @param  COMPx Comparator instance
0776   * @retval State of bit (1 or 0).
0777   */
0778 __STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx)
0779 {
0780   return ((READ_BIT(COMPx->CFGR, COMP_CFGRx_EN) == (COMP_CFGRx_EN)) ? 1UL : 0UL);
0781 }
0782 
0783 /**
0784   * @brief  Lock comparator instance.
0785   * @note   Once locked, comparator configuration can be accessed in read-only.
0786   * @note   The only way to unlock the comparator is a device hardware reset.
0787   * @rmtoll CFGR     LOCK           LL_COMP_Lock
0788   * @param  COMPx Comparator instance
0789   * @retval None
0790   */
0791 __STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx)
0792 {
0793   SET_BIT(COMPx->CFGR, COMP_CFGRx_LOCK);
0794 }
0795 
0796 /**
0797   * @brief  Get comparator lock state
0798   *         (0: COMP is unlocked, 1: COMP is locked).
0799   * @note   Once locked, comparator configuration can be accessed in read-only.
0800   * @note   The only way to unlock the comparator is a device hardware reset.
0801   * @rmtoll CFGR     LOCK           LL_COMP_IsLocked
0802   * @param  COMPx Comparator instance
0803   * @retval State of bit (1 or 0).
0804   */
0805 __STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
0806 {
0807   return ((READ_BIT(COMPx->CFGR, COMP_CFGRx_LOCK) == (COMP_CFGRx_LOCK)) ? 1UL : 0UL);
0808 }
0809 
0810 /**
0811   * @brief  Read comparator instance output level.
0812   * @note   The comparator output level depends on the selected polarity
0813   *         (Refer to function @ref LL_COMP_SetOutputPolarity()).
0814   *         If the comparator polarity is not inverted:
0815   *          - Comparator output is low when the input plus
0816   *            is at a lower voltage than the input minus
0817   *          - Comparator output is high when the input plus
0818   *            is at a higher voltage than the input minus
0819   *         If the comparator polarity is inverted:
0820   *          - Comparator output is high when the input plus
0821   *            is at a lower voltage than the input minus
0822   *          - Comparator output is low when the input plus
0823   *            is at a higher voltage than the input minus
0824   * @rmtoll CFGR     VALUE          LL_COMP_ReadOutputLevel
0825   * @param  COMPx Comparator instance
0826   * @retval Returned value can be one of the following values:
0827   *         @arg @ref LL_COMP_OUTPUT_LEVEL_LOW
0828   *         @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH
0829   */
0830 __STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
0831 {
0832   if (COMPx == COMP1)
0833   {
0834     return (uint32_t)(READ_BIT(COMP12->SR, COMP_SR_C1VAL));
0835   }
0836   else
0837   {
0838     return (uint32_t)((READ_BIT(COMP12->SR, COMP_SR_C2VAL))>> 1); 
0839   }
0840 }
0841 
0842 /**
0843   * @}
0844   */
0845 
0846 /** @defgroup COMP_LL_EF_FLAG_Management Comparator flag Management
0847   * @ingroup RTEMSBSPsARMSTM32H7
0848   * @{
0849   */
0850 
0851 /**
0852   * @brief  Get comparator output trigger flag (latched)
0853   * @rmtoll SR       C1IF           LL_COMP_IsActiveFlag_OutputTrig
0854   * @param  COMPx Comparator instance
0855   * @retval State of bit (1 or 0).
0856   */
0857 __STATIC_INLINE uint32_t LL_COMP_IsActiveFlag_OutputTrig(COMP_TypeDef *COMPx)
0858 {
0859    if (COMPx == COMP1)
0860   {
0861     return ((READ_BIT(COMP12->SR, COMP_SR_C1IF) == (COMP_SR_C1IF)) ? 1UL : 0UL);
0862   }
0863   else
0864   {
0865     return ((READ_BIT(COMP12->SR, COMP_SR_C2IF) == (COMP_SR_C2IF)) ? 1UL : 0UL);
0866   }
0867 }
0868 
0869 /**
0870   * @brief  Clear comparator comparator output trigger flag (latched)
0871   * @rmtoll ICFR     CC1IF          LL_COMP_ClearFlag_OutputTrig
0872   * @param  COMPx Comparator instance
0873   * @retval None
0874   */
0875 __STATIC_INLINE void LL_COMP_ClearFlag_OutputTrig(COMP_TypeDef *COMPx)
0876 {
0877   if (COMPx == COMP1)
0878   {
0879     SET_BIT(COMP12->ICFR, COMP_ICFR_C1IF);
0880   }
0881   else
0882   {
0883     SET_BIT(COMP12->ICFR, COMP_ICFR_C2IF);
0884   }
0885 }
0886 
0887 /**
0888   * @}
0889   */
0890 
0891 /** @defgroup COMP_LL_EF_IT_Management Comparartor IT management
0892   * @ingroup RTEMSBSPsARMSTM32H7
0893   * @{
0894   */
0895 
0896 /**
0897   * @brief  Enable comparator output trigger interrupt
0898   * @rmtoll ICFR     ITEN           LL_COMP_EnableIT_OutputTrig
0899   * @param  COMPx Comparator instance
0900   * @retval None
0901   */
0902 __STATIC_INLINE void LL_COMP_EnableIT_OutputTrig(COMP_TypeDef *COMPx)
0903 {
0904   SET_BIT(COMPx->CFGR, COMP_CFGRx_ITEN);
0905 }
0906 
0907 /**
0908   * @brief  Disable comparator output trigger interrupt
0909   * @rmtoll ICFR     ITEN           LL_COMP_DisableIT_OutputTrig
0910   * @param  COMPx Comparator instance
0911   * @retval None
0912   */
0913 __STATIC_INLINE void LL_COMP_DisableIT_OutputTrig(COMP_TypeDef *COMPx)
0914 {
0915   CLEAR_BIT(COMPx->CFGR, COMP_CFGRx_ITEN);
0916 }
0917 
0918 /**
0919   * @brief  Get comparator output trigger interrupt state
0920   * @rmtoll ICFR     ITEN           LL_COMP_IsEnabledIT_OutputTrig
0921   * @param  COMPx Comparator instance
0922   * @retval State of bit (1 or 0).
0923   */
0924 __STATIC_INLINE uint32_t LL_COMP_IsEnabledIT_OutputTrig(COMP_TypeDef *COMPx)
0925 {
0926   return ((READ_BIT(COMPx->CFGR, COMP_CFGRx_ITEN) == (COMP_CFGRx_ITEN)) ? 1UL : 0UL);
0927 }
0928 
0929 /**
0930   * @}
0931   */
0932   
0933 #if defined(USE_FULL_LL_DRIVER) || defined(__rtems__)
0934 /** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions
0935   * @ingroup RTEMSBSPsARMSTM32H7
0936   * @{
0937   */
0938 
0939 ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx);
0940 ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct);
0941 void        LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct);
0942 
0943 /**
0944   * @}
0945   */
0946 #endif /* USE_FULL_LL_DRIVER */
0947 
0948 /**
0949   * @}
0950   */
0951 
0952 /**
0953   * @}
0954   */
0955 
0956 #endif /* COMP1 || COMP2 */
0957 
0958 /**
0959   * @}
0960   */
0961 
0962 #ifdef __cplusplus
0963 }
0964 #endif
0965 
0966 #endif /* __STM32H7xx_LL_COMP_H */
0967 
0968