TUKS MCU Introductory course / TUKS-COURSE-THERMOMETER

Fork of TUKS-COURSE-TIMER by TUKS MCU Introductory course

Committer:
elmot
Date:
Fri Feb 24 21:13:56 2017 +0000
Revision:
1:d0dfbce63a89
Ready-to-copy

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elmot 1:d0dfbce63a89 1 /**
elmot 1:d0dfbce63a89 2 ******************************************************************************
elmot 1:d0dfbce63a89 3 * @file stm32l4xx_ll_comp.h
elmot 1:d0dfbce63a89 4 * @author MCD Application Team
elmot 1:d0dfbce63a89 5 * @version V1.5.1
elmot 1:d0dfbce63a89 6 * @date 31-May-2016
elmot 1:d0dfbce63a89 7 * @brief Header file of COMP LL module.
elmot 1:d0dfbce63a89 8 ******************************************************************************
elmot 1:d0dfbce63a89 9 * @attention
elmot 1:d0dfbce63a89 10 *
elmot 1:d0dfbce63a89 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
elmot 1:d0dfbce63a89 12 *
elmot 1:d0dfbce63a89 13 * Redistribution and use in source and binary forms, with or without modification,
elmot 1:d0dfbce63a89 14 * are permitted provided that the following conditions are met:
elmot 1:d0dfbce63a89 15 * 1. Redistributions of source code must retain the above copyright notice,
elmot 1:d0dfbce63a89 16 * this list of conditions and the following disclaimer.
elmot 1:d0dfbce63a89 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
elmot 1:d0dfbce63a89 18 * this list of conditions and the following disclaimer in the documentation
elmot 1:d0dfbce63a89 19 * and/or other materials provided with the distribution.
elmot 1:d0dfbce63a89 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
elmot 1:d0dfbce63a89 21 * may be used to endorse or promote products derived from this software
elmot 1:d0dfbce63a89 22 * without specific prior written permission.
elmot 1:d0dfbce63a89 23 *
elmot 1:d0dfbce63a89 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
elmot 1:d0dfbce63a89 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
elmot 1:d0dfbce63a89 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
elmot 1:d0dfbce63a89 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
elmot 1:d0dfbce63a89 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
elmot 1:d0dfbce63a89 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
elmot 1:d0dfbce63a89 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
elmot 1:d0dfbce63a89 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
elmot 1:d0dfbce63a89 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
elmot 1:d0dfbce63a89 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
elmot 1:d0dfbce63a89 34 *
elmot 1:d0dfbce63a89 35 ******************************************************************************
elmot 1:d0dfbce63a89 36 */
elmot 1:d0dfbce63a89 37
elmot 1:d0dfbce63a89 38 /* Define to prevent recursive inclusion -------------------------------------*/
elmot 1:d0dfbce63a89 39 #ifndef __STM32L4xx_LL_COMP_H
elmot 1:d0dfbce63a89 40 #define __STM32L4xx_LL_COMP_H
elmot 1:d0dfbce63a89 41
elmot 1:d0dfbce63a89 42 #ifdef __cplusplus
elmot 1:d0dfbce63a89 43 extern "C" {
elmot 1:d0dfbce63a89 44 #endif
elmot 1:d0dfbce63a89 45
elmot 1:d0dfbce63a89 46 /* Includes ------------------------------------------------------------------*/
elmot 1:d0dfbce63a89 47 #include "stm32l4xx.h"
elmot 1:d0dfbce63a89 48
elmot 1:d0dfbce63a89 49 /** @addtogroup STM32L4xx_LL_Driver
elmot 1:d0dfbce63a89 50 * @{
elmot 1:d0dfbce63a89 51 */
elmot 1:d0dfbce63a89 52
elmot 1:d0dfbce63a89 53 #if defined (COMP1) || defined (COMP2)
elmot 1:d0dfbce63a89 54
elmot 1:d0dfbce63a89 55 /** @defgroup COMP_LL COMP
elmot 1:d0dfbce63a89 56 * @{
elmot 1:d0dfbce63a89 57 */
elmot 1:d0dfbce63a89 58
elmot 1:d0dfbce63a89 59 /* Private types -------------------------------------------------------------*/
elmot 1:d0dfbce63a89 60 /* Private variables ---------------------------------------------------------*/
elmot 1:d0dfbce63a89 61 /* Private constants ---------------------------------------------------------*/
elmot 1:d0dfbce63a89 62 /** @defgroup COMP_LL_Private_Constants COMP Private Constants
elmot 1:d0dfbce63a89 63 * @{
elmot 1:d0dfbce63a89 64 */
elmot 1:d0dfbce63a89 65
elmot 1:d0dfbce63a89 66 /* COMP registers bits positions */
elmot 1:d0dfbce63a89 67 #define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS ((uint32_t)30U) /* Value equivalent to POSITION_VAL(COMP_CSR_VALUE) */
elmot 1:d0dfbce63a89 68
elmot 1:d0dfbce63a89 69 /**
elmot 1:d0dfbce63a89 70 * @}
elmot 1:d0dfbce63a89 71 */
elmot 1:d0dfbce63a89 72
elmot 1:d0dfbce63a89 73 /* Private macros ------------------------------------------------------------*/
elmot 1:d0dfbce63a89 74 /* Exported types ------------------------------------------------------------*/
elmot 1:d0dfbce63a89 75 #if defined(USE_FULL_LL_DRIVER)
elmot 1:d0dfbce63a89 76 /** @defgroup COMP_LL_ES_INIT COMP Exported Init structure
elmot 1:d0dfbce63a89 77 * @{
elmot 1:d0dfbce63a89 78 */
elmot 1:d0dfbce63a89 79
elmot 1:d0dfbce63a89 80 /**
elmot 1:d0dfbce63a89 81 * @brief Structure definition of some features of COMP instance.
elmot 1:d0dfbce63a89 82 */
elmot 1:d0dfbce63a89 83 typedef struct
elmot 1:d0dfbce63a89 84 {
elmot 1:d0dfbce63a89 85 uint32_t PowerMode; /*!< Set comparator operating mode to adjust power and speed.
elmot 1:d0dfbce63a89 86 This parameter can be a value of @ref COMP_LL_EC_POWERMODE
elmot 1:d0dfbce63a89 87
elmot 1:d0dfbce63a89 88 This feature can be modified afterwards using unitary function @ref LL_COMP_SetPowerMode(). */
elmot 1:d0dfbce63a89 89
elmot 1:d0dfbce63a89 90 uint32_t InputPlus; /*!< Set comparator input plus (non-inverting input).
elmot 1:d0dfbce63a89 91 This parameter can be a value of @ref COMP_LL_EC_INPUT_PLUS
elmot 1:d0dfbce63a89 92
elmot 1:d0dfbce63a89 93 This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputPlus(). */
elmot 1:d0dfbce63a89 94
elmot 1:d0dfbce63a89 95 uint32_t InputMinus; /*!< Set comparator input minus (inverting input).
elmot 1:d0dfbce63a89 96 This parameter can be a value of @ref COMP_LL_EC_INPUT_MINUS
elmot 1:d0dfbce63a89 97
elmot 1:d0dfbce63a89 98 This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputMinus(). */
elmot 1:d0dfbce63a89 99
elmot 1:d0dfbce63a89 100 uint32_t InputHysteresis; /*!< Set comparator hysteresis mode of the input minus.
elmot 1:d0dfbce63a89 101 This parameter can be a value of @ref COMP_LL_EC_INPUT_HYSTERESIS
elmot 1:d0dfbce63a89 102
elmot 1:d0dfbce63a89 103 This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputHysteresis(). */
elmot 1:d0dfbce63a89 104
elmot 1:d0dfbce63a89 105 uint32_t OutputPolarity; /*!< Set comparator output polarity.
elmot 1:d0dfbce63a89 106 This parameter can be a value of @ref COMP_LL_EC_OUTPUT_POLARITY
elmot 1:d0dfbce63a89 107
elmot 1:d0dfbce63a89 108 This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputPolarity(). */
elmot 1:d0dfbce63a89 109
elmot 1:d0dfbce63a89 110 uint32_t OutputBlankingSource; /*!< Set comparator blanking source.
elmot 1:d0dfbce63a89 111 This parameter can be a value of @ref COMP_LL_EC_OUTPUT_BLANKING_SOURCE
elmot 1:d0dfbce63a89 112
elmot 1:d0dfbce63a89 113 This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputBlankingSource(). */
elmot 1:d0dfbce63a89 114
elmot 1:d0dfbce63a89 115 } LL_COMP_InitTypeDef;
elmot 1:d0dfbce63a89 116
elmot 1:d0dfbce63a89 117 /**
elmot 1:d0dfbce63a89 118 * @}
elmot 1:d0dfbce63a89 119 */
elmot 1:d0dfbce63a89 120 #endif /* USE_FULL_LL_DRIVER */
elmot 1:d0dfbce63a89 121
elmot 1:d0dfbce63a89 122 /* Exported constants --------------------------------------------------------*/
elmot 1:d0dfbce63a89 123 /** @defgroup COMP_LL_Exported_Constants COMP Exported Constants
elmot 1:d0dfbce63a89 124 * @{
elmot 1:d0dfbce63a89 125 */
elmot 1:d0dfbce63a89 126
elmot 1:d0dfbce63a89 127 /** @defgroup COMP_LL_EC_COMMON_WINDOWMODE Comparator common modes - Window mode
elmot 1:d0dfbce63a89 128 * @{
elmot 1:d0dfbce63a89 129 */
elmot 1:d0dfbce63a89 130 #define LL_COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000U) /*!< Window mode disable: Comparators 1 and 2 are independent */
elmot 1:d0dfbce63a89 131 #define LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_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). */
elmot 1:d0dfbce63a89 132 /**
elmot 1:d0dfbce63a89 133 * @}
elmot 1:d0dfbce63a89 134 */
elmot 1:d0dfbce63a89 135
elmot 1:d0dfbce63a89 136 /** @defgroup COMP_LL_EC_POWERMODE Comparator modes - Power mode
elmot 1:d0dfbce63a89 137 * @{
elmot 1:d0dfbce63a89 138 */
elmot 1:d0dfbce63a89 139 #define LL_COMP_POWERMODE_HIGHSPEED ((uint32_t)0x00000000U) /*!< COMP power mode to high speed */
elmot 1:d0dfbce63a89 140 #define LL_COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_PWRMODE_0) /*!< COMP power mode to medium speed */
elmot 1:d0dfbce63a89 141 #define LL_COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_PWRMODE_1 | COMP_CSR_PWRMODE_0) /*!< COMP power mode to ultra-low power */
elmot 1:d0dfbce63a89 142 /**
elmot 1:d0dfbce63a89 143 * @}
elmot 1:d0dfbce63a89 144 */
elmot 1:d0dfbce63a89 145
elmot 1:d0dfbce63a89 146 /** @defgroup COMP_LL_EC_INPUT_PLUS Comparator inputs - Input plus (input non-inverting) selection
elmot 1:d0dfbce63a89 147 * @{
elmot 1:d0dfbce63a89 148 */
elmot 1:d0dfbce63a89 149 #define LL_COMP_INPUT_PLUS_IO1 ((uint32_t)0x00000000U) /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2) */
elmot 1:d0dfbce63a89 150 #define LL_COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2) */
elmot 1:d0dfbce63a89 151 #if defined(COMP_CSR_INPSEL_1)
elmot 1:d0dfbce63a89 152 #define LL_COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1 | COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2) */
elmot 1:d0dfbce63a89 153 #endif
elmot 1:d0dfbce63a89 154 /**
elmot 1:d0dfbce63a89 155 * @}
elmot 1:d0dfbce63a89 156 */
elmot 1:d0dfbce63a89 157
elmot 1:d0dfbce63a89 158 /** @defgroup COMP_LL_EC_INPUT_MINUS Comparator inputs - Input minus (input inverting) selection
elmot 1:d0dfbce63a89 159 * @{
elmot 1:d0dfbce63a89 160 */
elmot 1:d0dfbce63a89 161 #define LL_COMP_INPUT_MINUS_1_4VREFINT ( COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/4 VrefInt */
elmot 1:d0dfbce63a89 162 #define LL_COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/2 VrefInt */
elmot 1:d0dfbce63a89 163 #define LL_COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */
elmot 1:d0dfbce63a89 164 #define LL_COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< Comparator input minus connected to VrefInt */
elmot 1:d0dfbce63a89 165 #define LL_COMP_INPUT_MINUS_DAC1_CH1 (COMP_CSR_INMSEL_2 ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */
elmot 1:d0dfbce63a89 166 #define LL_COMP_INPUT_MINUS_DAC1_CH2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */
elmot 1:d0dfbce63a89 167 #define LL_COMP_INPUT_MINUS_IO1 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PB1 for COMP1, pin PB3 for COMP2) */
elmot 1:d0dfbce63a89 168 #define LL_COMP_INPUT_MINUS_IO2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1, pin PB7 for COMP2) */
elmot 1:d0dfbce63a89 169 #if defined(COMP_CSR_INMESEL_1)
elmot 1:d0dfbce63a89 170 #define LL_COMP_INPUT_MINUS_IO3 ( COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO3 (pin PA0 for COMP1, pin PA2 for COMP2) */
elmot 1:d0dfbce63a89 171 #define LL_COMP_INPUT_MINUS_IO4 (COMP_CSR_INMESEL_1 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO4 (pin PA4 for COMP1, pin PA4 for COMP2) */
elmot 1:d0dfbce63a89 172 #define LL_COMP_INPUT_MINUS_IO5 (COMP_CSR_INMESEL_1 | COMP_CSR_INMESEL_0 | COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO5 (pin PA5 for COMP1, pin PA5 for COMP2) */
elmot 1:d0dfbce63a89 173 #endif
elmot 1:d0dfbce63a89 174 /**
elmot 1:d0dfbce63a89 175 * @}
elmot 1:d0dfbce63a89 176 */
elmot 1:d0dfbce63a89 177
elmot 1:d0dfbce63a89 178 /** @defgroup COMP_LL_EC_INPUT_LEGACY Comparator inputs legacy literals name
elmot 1:d0dfbce63a89 179 * @{
elmot 1:d0dfbce63a89 180 */
elmot 1:d0dfbce63a89 181 #define LL_COMP_WINDOWMODE_ENABLE LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
elmot 1:d0dfbce63a89 182
elmot 1:d0dfbce63a89 183 #define LL_COMP_INVERTINGINPUT_1_4VREFINT LL_COMP_INPUT_MINUS_1_4VREFINT
elmot 1:d0dfbce63a89 184 #define LL_COMP_INVERTINGINPUT_1_2VREFINT LL_COMP_INPUT_MINUS_1_2VREFINT
elmot 1:d0dfbce63a89 185 #define LL_COMP_INVERTINGINPUT_3_4VREFINT LL_COMP_INPUT_MINUS_3_4VREFINT
elmot 1:d0dfbce63a89 186 #define LL_COMP_INVERTINGINPUT_VREFINT LL_COMP_INPUT_MINUS_VREFINT
elmot 1:d0dfbce63a89 187 #define LL_COMP_INVERTINGINPUT_DAC1 LL_COMP_INPUT_MINUS_DAC1_CH1
elmot 1:d0dfbce63a89 188 #define LL_COMP_INVERTINGINPUT_DAC2 LL_COMP_INPUT_MINUS_DAC1_CH2
elmot 1:d0dfbce63a89 189 #define LL_COMP_INVERTINGINPUT_IO1 LL_COMP_INPUT_MINUS_IO1
elmot 1:d0dfbce63a89 190 #define LL_COMP_INVERTINGINPUT_IO2 LL_COMP_INPUT_MINUS_IO2
elmot 1:d0dfbce63a89 191 #if defined(COMP_CSR_INMESEL_1)
elmot 1:d0dfbce63a89 192 #define LL_COMP_INVERTINGINPUT_IO3 LL_COMP_INPUT_MINUS_IO3
elmot 1:d0dfbce63a89 193 #define LL_COMP_INVERTINGINPUT_IO4 LL_COMP_INPUT_MINUS_IO4
elmot 1:d0dfbce63a89 194 #define LL_COMP_INVERTINGINPUT_IO5 LL_COMP_INPUT_MINUS_IO5
elmot 1:d0dfbce63a89 195 #endif
elmot 1:d0dfbce63a89 196
elmot 1:d0dfbce63a89 197 #define LL_COMP_NONINVERTINGINPUT_IO1 LL_COMP_INPUT_PLUS_IO1
elmot 1:d0dfbce63a89 198 #define LL_COMP_NONINVERTINGINPUT_IO2 LL_COMP_INPUT_PLUS_IO2
elmot 1:d0dfbce63a89 199 #if defined(COMP_CSR_INPSEL_1)
elmot 1:d0dfbce63a89 200 #define LL_COMP_NONINVERTINGINPUT_IO3 LL_COMP_INPUT_PLUS_IO3
elmot 1:d0dfbce63a89 201 #endif
elmot 1:d0dfbce63a89 202 /**
elmot 1:d0dfbce63a89 203 * @}
elmot 1:d0dfbce63a89 204 */
elmot 1:d0dfbce63a89 205
elmot 1:d0dfbce63a89 206 /** @defgroup COMP_LL_EC_INPUT_HYSTERESIS Comparator input - Hysteresis
elmot 1:d0dfbce63a89 207 * @{
elmot 1:d0dfbce63a89 208 */
elmot 1:d0dfbce63a89 209 #define LL_COMP_HYSTERESIS_NONE ((uint32_t)0x00000000U) /*!< No hysteresis */
elmot 1:d0dfbce63a89 210 #define LL_COMP_HYSTERESIS_LOW ( COMP_CSR_HYST_0) /*!< Hysteresis level low */
elmot 1:d0dfbce63a89 211 #define LL_COMP_HYSTERESIS_MEDIUM (COMP_CSR_HYST_1 ) /*!< Hysteresis level medium */
elmot 1:d0dfbce63a89 212 #define LL_COMP_HYSTERESIS_HIGH (COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level high */
elmot 1:d0dfbce63a89 213 /**
elmot 1:d0dfbce63a89 214 * @}
elmot 1:d0dfbce63a89 215 */
elmot 1:d0dfbce63a89 216
elmot 1:d0dfbce63a89 217 /** @defgroup COMP_LL_EC_OUTPUT_POLARITY Comparator output - Output polarity
elmot 1:d0dfbce63a89 218 * @{
elmot 1:d0dfbce63a89 219 */
elmot 1:d0dfbce63a89 220 #define LL_COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000U) /*!< 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 */
elmot 1:d0dfbce63a89 221 #define LL_COMP_OUTPUTPOL_INVERTED (COMP_CSR_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 */
elmot 1:d0dfbce63a89 222 /**
elmot 1:d0dfbce63a89 223 * @}
elmot 1:d0dfbce63a89 224 */
elmot 1:d0dfbce63a89 225
elmot 1:d0dfbce63a89 226 /** @defgroup COMP_LL_EC_OUTPUT_BLANKING_SOURCE Comparator output - Blanking source
elmot 1:d0dfbce63a89 227 * @{
elmot 1:d0dfbce63a89 228 */
elmot 1:d0dfbce63a89 229 #define LL_COMP_BLANKINGSRC_NONE ((uint32_t)0x00000000U) /*!<Comparator output without blanking */
elmot 1:d0dfbce63a89 230 #define LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1 (COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP1) */
elmot 1:d0dfbce63a89 231 #define LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1 (COMP_CSR_BLANKING_1) /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP1) */
elmot 1:d0dfbce63a89 232 #define LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1 (COMP_CSR_BLANKING_2) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP1) */
elmot 1:d0dfbce63a89 233 #define LL_COMP_BLANKINGSRC_TIM3_OC4_COMP2 (COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM3 OC4 (specific to COMP instance: COMP2) */
elmot 1:d0dfbce63a89 234 #define LL_COMP_BLANKINGSRC_TIM8_OC5_COMP2 (COMP_CSR_BLANKING_1) /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP2) */
elmot 1:d0dfbce63a89 235 #define LL_COMP_BLANKINGSRC_TIM15_OC1_COMP2 (COMP_CSR_BLANKING_2) /*!< Comparator output blanking source TIM15 OC1 (specific to COMP instance: COMP2) */
elmot 1:d0dfbce63a89 236 /**
elmot 1:d0dfbce63a89 237 * @}
elmot 1:d0dfbce63a89 238 */
elmot 1:d0dfbce63a89 239
elmot 1:d0dfbce63a89 240 /** @defgroup COMP_LL_EC_OUTPUT_BLANKING_SOURCE_LEGACY Comparator output blanking source legacy literals name
elmot 1:d0dfbce63a89 241 * @{
elmot 1:d0dfbce63a89 242 */
elmot 1:d0dfbce63a89 243 #define LL_COMP_BLANKINGSRC_TIM1_OC5 (LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1)
elmot 1:d0dfbce63a89 244 #define LL_COMP_BLANKINGSRC_TIM2_OC3 (LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1)
elmot 1:d0dfbce63a89 245 #define LL_COMP_BLANKINGSRC_TIM3_OC3 (LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1)
elmot 1:d0dfbce63a89 246
elmot 1:d0dfbce63a89 247 #define LL_COMP_BLANKINGSRC_TIM3_OC4 (LL_COMP_BLANKINGSRC_TIM3_OC4_COMP2)
elmot 1:d0dfbce63a89 248 #define LL_COMP_BLANKINGSRC_TIM8_OC5 (LL_COMP_BLANKINGSRC_TIM8_OC5_COMP2)
elmot 1:d0dfbce63a89 249 #define LL_COMP_BLANKINGSRC_TIM15_OC1 (LL_COMP_BLANKINGSRC_TIM15_OC1_COMP2)
elmot 1:d0dfbce63a89 250 /**
elmot 1:d0dfbce63a89 251 * @}
elmot 1:d0dfbce63a89 252 */
elmot 1:d0dfbce63a89 253
elmot 1:d0dfbce63a89 254 /** @defgroup COMP_LL_EC_OUTPUT_LEVEL Comparator output - Output level
elmot 1:d0dfbce63a89 255 * @{
elmot 1:d0dfbce63a89 256 */
elmot 1:d0dfbce63a89 257 #define LL_COMP_OUTPUT_LEVEL_LOW ((uint32_t)0x00000000U) /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */
elmot 1:d0dfbce63a89 258 #define LL_COMP_OUTPUT_LEVEL_HIGH ((uint32_t)0x00000001U) /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */
elmot 1:d0dfbce63a89 259 /**
elmot 1:d0dfbce63a89 260 * @}
elmot 1:d0dfbce63a89 261 */
elmot 1:d0dfbce63a89 262
elmot 1:d0dfbce63a89 263 /** @defgroup COMP_LL_EC_HW_DELAYS Definitions of COMP hardware constraints delays
elmot 1:d0dfbce63a89 264 * @note Only COMP IP HW delays are defined in COMP LL driver driver,
elmot 1:d0dfbce63a89 265 * not timeout values.
elmot 1:d0dfbce63a89 266 * For details on delays values, refer to descriptions in source code
elmot 1:d0dfbce63a89 267 * above each literal definition.
elmot 1:d0dfbce63a89 268 * @{
elmot 1:d0dfbce63a89 269 */
elmot 1:d0dfbce63a89 270
elmot 1:d0dfbce63a89 271 /* Delay for comparator startup time. */
elmot 1:d0dfbce63a89 272 /* Note: Delay required to reach propagation delay specification. */
elmot 1:d0dfbce63a89 273 /* Literal set to maximum value (refer to device datasheet, */
elmot 1:d0dfbce63a89 274 /* parameter "tSTART"). */
elmot 1:d0dfbce63a89 275 /* Unit: us */
elmot 1:d0dfbce63a89 276 #define LL_COMP_DELAY_STARTUP_US ((uint32_t) 80U) /*!< Delay for COMP startup time */
elmot 1:d0dfbce63a89 277
elmot 1:d0dfbce63a89 278 /* Delay for comparator voltage scaler stabilization time. */
elmot 1:d0dfbce63a89 279 /* Note: Voltage scaler is used when selecting comparator input */
elmot 1:d0dfbce63a89 280 /* based on VrefInt: VrefInt or subdivision of VrefInt. */
elmot 1:d0dfbce63a89 281 /* Literal set to maximum value (refer to device datasheet, */
elmot 1:d0dfbce63a89 282 /* parameter "tSTART_SCALER"). */
elmot 1:d0dfbce63a89 283 /* Unit: us */
elmot 1:d0dfbce63a89 284 #define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ((uint32_t) 200U) /*!< Delay for COMP voltage scaler stabilization time */
elmot 1:d0dfbce63a89 285
elmot 1:d0dfbce63a89 286 /**
elmot 1:d0dfbce63a89 287 * @}
elmot 1:d0dfbce63a89 288 */
elmot 1:d0dfbce63a89 289
elmot 1:d0dfbce63a89 290 /**
elmot 1:d0dfbce63a89 291 * @}
elmot 1:d0dfbce63a89 292 */
elmot 1:d0dfbce63a89 293
elmot 1:d0dfbce63a89 294 /* Exported macro ------------------------------------------------------------*/
elmot 1:d0dfbce63a89 295 /** @defgroup COMP_LL_Exported_Macros COMP Exported Macros
elmot 1:d0dfbce63a89 296 * @{
elmot 1:d0dfbce63a89 297 */
elmot 1:d0dfbce63a89 298 /** @defgroup COMP_LL_EM_WRITE_READ Common write and read registers macro
elmot 1:d0dfbce63a89 299 * @{
elmot 1:d0dfbce63a89 300 */
elmot 1:d0dfbce63a89 301
elmot 1:d0dfbce63a89 302 /**
elmot 1:d0dfbce63a89 303 * @brief Write a value in COMP register
elmot 1:d0dfbce63a89 304 * @param __INSTANCE__ comparator instance
elmot 1:d0dfbce63a89 305 * @param __REG__ Register to be written
elmot 1:d0dfbce63a89 306 * @param __VALUE__ Value to be written in the register
elmot 1:d0dfbce63a89 307 * @retval None
elmot 1:d0dfbce63a89 308 */
elmot 1:d0dfbce63a89 309 #define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
elmot 1:d0dfbce63a89 310
elmot 1:d0dfbce63a89 311 /**
elmot 1:d0dfbce63a89 312 * @brief Read a value in COMP register
elmot 1:d0dfbce63a89 313 * @param __INSTANCE__ comparator instance
elmot 1:d0dfbce63a89 314 * @param __REG__ Register to be read
elmot 1:d0dfbce63a89 315 * @retval Register value
elmot 1:d0dfbce63a89 316 */
elmot 1:d0dfbce63a89 317 #define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
elmot 1:d0dfbce63a89 318 /**
elmot 1:d0dfbce63a89 319 * @}
elmot 1:d0dfbce63a89 320 */
elmot 1:d0dfbce63a89 321
elmot 1:d0dfbce63a89 322 /** @defgroup COMP_LL_EM_HELPER_MACRO COMP helper macro
elmot 1:d0dfbce63a89 323 * @{
elmot 1:d0dfbce63a89 324 */
elmot 1:d0dfbce63a89 325
elmot 1:d0dfbce63a89 326 /**
elmot 1:d0dfbce63a89 327 * @brief Helper macro to select the COMP common instance
elmot 1:d0dfbce63a89 328 * to which is belonging the selected COMP instance.
elmot 1:d0dfbce63a89 329 * @note COMP common register instance can be used to
elmot 1:d0dfbce63a89 330 * set parameters common to several COMP instances.
elmot 1:d0dfbce63a89 331 * Refer to functions having argument "COMPxy_COMMON" as parameter.
elmot 1:d0dfbce63a89 332 * @param __COMPx__ COMP instance
elmot 1:d0dfbce63a89 333 * @retval COMP common instance or value "0" if there is no COMP common instance.
elmot 1:d0dfbce63a89 334 */
elmot 1:d0dfbce63a89 335 #define __LL_COMP_COMMON_INSTANCE(__COMPx__) \
elmot 1:d0dfbce63a89 336 (COMP12_COMMON)
elmot 1:d0dfbce63a89 337
elmot 1:d0dfbce63a89 338 /**
elmot 1:d0dfbce63a89 339 * @}
elmot 1:d0dfbce63a89 340 */
elmot 1:d0dfbce63a89 341
elmot 1:d0dfbce63a89 342 /**
elmot 1:d0dfbce63a89 343 * @}
elmot 1:d0dfbce63a89 344 */
elmot 1:d0dfbce63a89 345
elmot 1:d0dfbce63a89 346 /* Exported functions --------------------------------------------------------*/
elmot 1:d0dfbce63a89 347 /** @defgroup COMP_LL_Exported_Functions COMP Exported Functions
elmot 1:d0dfbce63a89 348 * @{
elmot 1:d0dfbce63a89 349 */
elmot 1:d0dfbce63a89 350
elmot 1:d0dfbce63a89 351 /** @defgroup COMP_LL_EF_Configuration_comparator_common Configuration of COMP hierarchical scope: common to several COMP instances
elmot 1:d0dfbce63a89 352 * @{
elmot 1:d0dfbce63a89 353 */
elmot 1:d0dfbce63a89 354
elmot 1:d0dfbce63a89 355 /**
elmot 1:d0dfbce63a89 356 * @brief Set window mode of a pair of comparators instances
elmot 1:d0dfbce63a89 357 * (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
elmot 1:d0dfbce63a89 358 * @rmtoll CSR WINMODE LL_COMP_SetCommonWindowMode
elmot 1:d0dfbce63a89 359 * @param COMPxy_COMMON Comparator common instance
elmot 1:d0dfbce63a89 360 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
elmot 1:d0dfbce63a89 361 * @param WindowMode This parameter can be one of the following values:
elmot 1:d0dfbce63a89 362 * @arg @ref LL_COMP_WINDOWMODE_DISABLE
elmot 1:d0dfbce63a89 363 * @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
elmot 1:d0dfbce63a89 364 * @retval None
elmot 1:d0dfbce63a89 365 */
elmot 1:d0dfbce63a89 366 __STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode)
elmot 1:d0dfbce63a89 367 {
elmot 1:d0dfbce63a89 368 /* Note: On this STM32 serie, window mode can be set only */
elmot 1:d0dfbce63a89 369 /* from COMP instance: COMP2. */
elmot 1:d0dfbce63a89 370 MODIFY_REG(COMPxy_COMMON->CSR, COMP_CSR_WINMODE, WindowMode);
elmot 1:d0dfbce63a89 371 }
elmot 1:d0dfbce63a89 372
elmot 1:d0dfbce63a89 373 /**
elmot 1:d0dfbce63a89 374 * @brief Get window mode of a pair of comparators instances
elmot 1:d0dfbce63a89 375 * (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
elmot 1:d0dfbce63a89 376 * @rmtoll CSR WINMODE LL_COMP_GetCommonWindowMode
elmot 1:d0dfbce63a89 377 * @param COMPxy_COMMON Comparator common instance
elmot 1:d0dfbce63a89 378 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
elmot 1:d0dfbce63a89 379 * @retval Returned value can be one of the following values:
elmot 1:d0dfbce63a89 380 * @arg @ref LL_COMP_WINDOWMODE_DISABLE
elmot 1:d0dfbce63a89 381 * @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
elmot 1:d0dfbce63a89 382 */
elmot 1:d0dfbce63a89 383 __STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON)
elmot 1:d0dfbce63a89 384 {
elmot 1:d0dfbce63a89 385 return (uint32_t)(READ_BIT(COMPxy_COMMON->CSR, COMP_CSR_WINMODE));
elmot 1:d0dfbce63a89 386 }
elmot 1:d0dfbce63a89 387
elmot 1:d0dfbce63a89 388 /**
elmot 1:d0dfbce63a89 389 * @}
elmot 1:d0dfbce63a89 390 */
elmot 1:d0dfbce63a89 391
elmot 1:d0dfbce63a89 392 /** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes
elmot 1:d0dfbce63a89 393 * @{
elmot 1:d0dfbce63a89 394 */
elmot 1:d0dfbce63a89 395
elmot 1:d0dfbce63a89 396 /**
elmot 1:d0dfbce63a89 397 * @brief Set comparator instance operating mode to adjust power and speed.
elmot 1:d0dfbce63a89 398 * @rmtoll CSR PWRMODE LL_COMP_SetPowerMode
elmot 1:d0dfbce63a89 399 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 400 * @param PowerMode This parameter can be one of the following values:
elmot 1:d0dfbce63a89 401 * @arg @ref LL_COMP_POWERMODE_HIGHSPEED
elmot 1:d0dfbce63a89 402 * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
elmot 1:d0dfbce63a89 403 * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
elmot 1:d0dfbce63a89 404 * @retval None
elmot 1:d0dfbce63a89 405 */
elmot 1:d0dfbce63a89 406 __STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode)
elmot 1:d0dfbce63a89 407 {
elmot 1:d0dfbce63a89 408 MODIFY_REG(COMPx->CSR, COMP_CSR_PWRMODE, PowerMode);
elmot 1:d0dfbce63a89 409 }
elmot 1:d0dfbce63a89 410
elmot 1:d0dfbce63a89 411 /**
elmot 1:d0dfbce63a89 412 * @brief Get comparator instance operating mode to adjust power and speed.
elmot 1:d0dfbce63a89 413 * @rmtoll CSR PWRMODE LL_COMP_GetPowerMode
elmot 1:d0dfbce63a89 414 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 415 * @retval Returned value can be one of the following values:
elmot 1:d0dfbce63a89 416 * @arg @ref LL_COMP_POWERMODE_HIGHSPEED
elmot 1:d0dfbce63a89 417 * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
elmot 1:d0dfbce63a89 418 * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
elmot 1:d0dfbce63a89 419 */
elmot 1:d0dfbce63a89 420 __STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 421 {
elmot 1:d0dfbce63a89 422 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_PWRMODE));
elmot 1:d0dfbce63a89 423 }
elmot 1:d0dfbce63a89 424
elmot 1:d0dfbce63a89 425 /**
elmot 1:d0dfbce63a89 426 * @}
elmot 1:d0dfbce63a89 427 */
elmot 1:d0dfbce63a89 428
elmot 1:d0dfbce63a89 429 /** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs
elmot 1:d0dfbce63a89 430 * @{
elmot 1:d0dfbce63a89 431 */
elmot 1:d0dfbce63a89 432
elmot 1:d0dfbce63a89 433 /**
elmot 1:d0dfbce63a89 434 * @brief Set comparator inputs minus (inverting) and plus (non-inverting).
elmot 1:d0dfbce63a89 435 * @note In case of comparator input selected to be connected to IO:
elmot 1:d0dfbce63a89 436 * GPIO pins are specific to each comparator instance.
elmot 1:d0dfbce63a89 437 * Refer to description of parameters or to reference manual.
elmot 1:d0dfbce63a89 438 * @note On this STM32 serie, scaler bridge is configurable:
elmot 1:d0dfbce63a89 439 * to optimize power consumption, this function enables the
elmot 1:d0dfbce63a89 440 * voltage scaler bridge only when required
elmot 1:d0dfbce63a89 441 * (when selecting comparator input based on VrefInt: VrefInt or
elmot 1:d0dfbce63a89 442 * subdivision of VrefInt).
elmot 1:d0dfbce63a89 443 * - For scaler bridge power consumption values,
elmot 1:d0dfbce63a89 444 * refer to device datasheet, parameter "IDDA(SCALER)".
elmot 1:d0dfbce63a89 445 * - Voltage scaler requires a delay for voltage stabilization.
elmot 1:d0dfbce63a89 446 * Refer to device datasheet, parameter "tSTART_SCALER".
elmot 1:d0dfbce63a89 447 * - Scaler bridge is common for all comparator instances,
elmot 1:d0dfbce63a89 448 * therefore if at least one of the comparator instance
elmot 1:d0dfbce63a89 449 * is requiring the scaler bridge, it remains enabled.
elmot 1:d0dfbce63a89 450 * @rmtoll CSR INMSEL LL_COMP_ConfigInputs\n
elmot 1:d0dfbce63a89 451 * CSR INPSEL LL_COMP_ConfigInputs\n
elmot 1:d0dfbce63a89 452 * CSR BRGEN LL_COMP_ConfigInputs\n
elmot 1:d0dfbce63a89 453 * CSR SCALEN LL_COMP_ConfigInputs
elmot 1:d0dfbce63a89 454 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 455 * @param InputMinus This parameter can be one of the following values:
elmot 1:d0dfbce63a89 456 * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
elmot 1:d0dfbce63a89 457 * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
elmot 1:d0dfbce63a89 458 * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
elmot 1:d0dfbce63a89 459 * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
elmot 1:d0dfbce63a89 460 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
elmot 1:d0dfbce63a89 461 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
elmot 1:d0dfbce63a89 462 * @arg @ref LL_COMP_INPUT_MINUS_IO1
elmot 1:d0dfbce63a89 463 * @arg @ref LL_COMP_INPUT_MINUS_IO2
elmot 1:d0dfbce63a89 464 * @arg @ref LL_COMP_INPUT_MINUS_IO3 (*)
elmot 1:d0dfbce63a89 465 * @arg @ref LL_COMP_INPUT_MINUS_IO4 (*)
elmot 1:d0dfbce63a89 466 * @arg @ref LL_COMP_INPUT_MINUS_IO5 (*)
elmot 1:d0dfbce63a89 467 *
elmot 1:d0dfbce63a89 468 * (*) Parameter not available on all devices.
elmot 1:d0dfbce63a89 469 * @param InputPlus This parameter can be one of the following values:
elmot 1:d0dfbce63a89 470 * @arg @ref LL_COMP_INPUT_PLUS_IO1
elmot 1:d0dfbce63a89 471 * @arg @ref LL_COMP_INPUT_PLUS_IO2
elmot 1:d0dfbce63a89 472 * @arg @ref LL_COMP_INPUT_PLUS_IO3 (*)
elmot 1:d0dfbce63a89 473 *
elmot 1:d0dfbce63a89 474 * (*) Parameter not available on all devices.
elmot 1:d0dfbce63a89 475 * @retval None
elmot 1:d0dfbce63a89 476 */
elmot 1:d0dfbce63a89 477 __STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus)
elmot 1:d0dfbce63a89 478 {
elmot 1:d0dfbce63a89 479 #if defined(COMP_CSR_INMESEL_1)
elmot 1:d0dfbce63a89 480 MODIFY_REG(COMPx->CSR,
elmot 1:d0dfbce63a89 481 COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_INPSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN,
elmot 1:d0dfbce63a89 482 InputMinus | InputPlus);
elmot 1:d0dfbce63a89 483 #else
elmot 1:d0dfbce63a89 484 MODIFY_REG(COMPx->CSR,
elmot 1:d0dfbce63a89 485 COMP_CSR_INMSEL | COMP_CSR_INPSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN,
elmot 1:d0dfbce63a89 486 InputMinus | InputPlus);
elmot 1:d0dfbce63a89 487 #endif
elmot 1:d0dfbce63a89 488 }
elmot 1:d0dfbce63a89 489
elmot 1:d0dfbce63a89 490 /**
elmot 1:d0dfbce63a89 491 * @brief Set comparator input plus (non-inverting).
elmot 1:d0dfbce63a89 492 * @note In case of comparator input selected to be connected to IO:
elmot 1:d0dfbce63a89 493 * GPIO pins are specific to each comparator instance.
elmot 1:d0dfbce63a89 494 * Refer to description of parameters or to reference manual.
elmot 1:d0dfbce63a89 495 * @rmtoll CSR INPSEL LL_COMP_SetInputPlus
elmot 1:d0dfbce63a89 496 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 497 * @param InputPlus This parameter can be one of the following values:
elmot 1:d0dfbce63a89 498 * @arg @ref LL_COMP_INPUT_PLUS_IO1
elmot 1:d0dfbce63a89 499 * @arg @ref LL_COMP_INPUT_PLUS_IO2
elmot 1:d0dfbce63a89 500 * @arg @ref LL_COMP_INPUT_PLUS_IO3 (*)
elmot 1:d0dfbce63a89 501 *
elmot 1:d0dfbce63a89 502 * (*) Parameter not available on all devices.
elmot 1:d0dfbce63a89 503 * @retval None
elmot 1:d0dfbce63a89 504 */
elmot 1:d0dfbce63a89 505 __STATIC_INLINE void LL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus)
elmot 1:d0dfbce63a89 506 {
elmot 1:d0dfbce63a89 507 MODIFY_REG(COMPx->CSR, COMP_CSR_INPSEL, InputPlus);
elmot 1:d0dfbce63a89 508 }
elmot 1:d0dfbce63a89 509
elmot 1:d0dfbce63a89 510 /**
elmot 1:d0dfbce63a89 511 * @brief Get comparator input plus (non-inverting).
elmot 1:d0dfbce63a89 512 * @note In case of comparator input selected to be connected to IO:
elmot 1:d0dfbce63a89 513 * GPIO pins are specific to each comparator instance.
elmot 1:d0dfbce63a89 514 * Refer to description of parameters or to reference manual.
elmot 1:d0dfbce63a89 515 * @rmtoll CSR INPSEL LL_COMP_GetInputPlus
elmot 1:d0dfbce63a89 516 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 517 * @retval Returned value can be one of the following values:
elmot 1:d0dfbce63a89 518 * @arg @ref LL_COMP_INPUT_PLUS_IO1
elmot 1:d0dfbce63a89 519 * @arg @ref LL_COMP_INPUT_PLUS_IO2
elmot 1:d0dfbce63a89 520 * @arg @ref LL_COMP_INPUT_PLUS_IO3 (*)
elmot 1:d0dfbce63a89 521 *
elmot 1:d0dfbce63a89 522 * (*) Parameter not available on all devices.
elmot 1:d0dfbce63a89 523 */
elmot 1:d0dfbce63a89 524 __STATIC_INLINE uint32_t LL_COMP_GetInputPlus(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 525 {
elmot 1:d0dfbce63a89 526 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INPSEL));
elmot 1:d0dfbce63a89 527 }
elmot 1:d0dfbce63a89 528
elmot 1:d0dfbce63a89 529 /**
elmot 1:d0dfbce63a89 530 * @brief Set comparator input minus (inverting).
elmot 1:d0dfbce63a89 531 * @note In case of comparator input selected to be connected to IO:
elmot 1:d0dfbce63a89 532 * GPIO pins are specific to each comparator instance.
elmot 1:d0dfbce63a89 533 * Refer to description of parameters or to reference manual.
elmot 1:d0dfbce63a89 534 * @note On this STM32 serie, scaler bridge is configurable:
elmot 1:d0dfbce63a89 535 * to optimize power consumption, this function enables the
elmot 1:d0dfbce63a89 536 * voltage scaler bridge only when required
elmot 1:d0dfbce63a89 537 * (when selecting comparator input based on VrefInt: VrefInt or
elmot 1:d0dfbce63a89 538 * subdivision of VrefInt).
elmot 1:d0dfbce63a89 539 * - For scaler bridge power consumption values,
elmot 1:d0dfbce63a89 540 * refer to device datasheet, parameter "IDDA(SCALER)".
elmot 1:d0dfbce63a89 541 * - Voltage scaler requires a delay for voltage stabilization.
elmot 1:d0dfbce63a89 542 * Refer to device datasheet, parameter "tSTART_SCALER".
elmot 1:d0dfbce63a89 543 * - Scaler bridge is common for all comparator instances,
elmot 1:d0dfbce63a89 544 * therefore if at least one of the comparator instance
elmot 1:d0dfbce63a89 545 * is requiring the scaler bridge, it remains enabled.
elmot 1:d0dfbce63a89 546 * @rmtoll CSR INMSEL LL_COMP_SetInputMinus\n
elmot 1:d0dfbce63a89 547 * CSR BRGEN LL_COMP_SetInputMinus\n
elmot 1:d0dfbce63a89 548 * CSR SCALEN LL_COMP_SetInputMinus
elmot 1:d0dfbce63a89 549 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 550 * @param InputMinus This parameter can be one of the following values:
elmot 1:d0dfbce63a89 551 * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
elmot 1:d0dfbce63a89 552 * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
elmot 1:d0dfbce63a89 553 * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
elmot 1:d0dfbce63a89 554 * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
elmot 1:d0dfbce63a89 555 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
elmot 1:d0dfbce63a89 556 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
elmot 1:d0dfbce63a89 557 * @arg @ref LL_COMP_INPUT_MINUS_IO1
elmot 1:d0dfbce63a89 558 * @arg @ref LL_COMP_INPUT_MINUS_IO2
elmot 1:d0dfbce63a89 559 * @arg @ref LL_COMP_INPUT_MINUS_IO3 (*)
elmot 1:d0dfbce63a89 560 * @arg @ref LL_COMP_INPUT_MINUS_IO4 (*)
elmot 1:d0dfbce63a89 561 * @arg @ref LL_COMP_INPUT_MINUS_IO5 (*)
elmot 1:d0dfbce63a89 562 *
elmot 1:d0dfbce63a89 563 * (*) Parameter not available on all devices.
elmot 1:d0dfbce63a89 564 * @retval None
elmot 1:d0dfbce63a89 565 */
elmot 1:d0dfbce63a89 566 __STATIC_INLINE void LL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus)
elmot 1:d0dfbce63a89 567 {
elmot 1:d0dfbce63a89 568 #if defined(COMP_CSR_INMESEL_1)
elmot 1:d0dfbce63a89 569 MODIFY_REG(COMPx->CSR, COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN, InputMinus);
elmot 1:d0dfbce63a89 570 #else
elmot 1:d0dfbce63a89 571 MODIFY_REG(COMPx->CSR, COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN, InputMinus);
elmot 1:d0dfbce63a89 572 #endif
elmot 1:d0dfbce63a89 573 }
elmot 1:d0dfbce63a89 574
elmot 1:d0dfbce63a89 575 /**
elmot 1:d0dfbce63a89 576 * @brief Get comparator input minus (inverting).
elmot 1:d0dfbce63a89 577 * @note In case of comparator input selected to be connected to IO:
elmot 1:d0dfbce63a89 578 * GPIO pins are specific to each comparator instance.
elmot 1:d0dfbce63a89 579 * Refer to description of parameters or to reference manual.
elmot 1:d0dfbce63a89 580 * @rmtoll CSR INMSEL LL_COMP_GetInputMinus\n
elmot 1:d0dfbce63a89 581 * CSR BRGEN LL_COMP_GetInputMinus\n
elmot 1:d0dfbce63a89 582 * CSR SCALEN LL_COMP_GetInputMinus
elmot 1:d0dfbce63a89 583 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 584 * @retval Returned value can be one of the following values:
elmot 1:d0dfbce63a89 585 * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
elmot 1:d0dfbce63a89 586 * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
elmot 1:d0dfbce63a89 587 * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
elmot 1:d0dfbce63a89 588 * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
elmot 1:d0dfbce63a89 589 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
elmot 1:d0dfbce63a89 590 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
elmot 1:d0dfbce63a89 591 * @arg @ref LL_COMP_INPUT_MINUS_IO1
elmot 1:d0dfbce63a89 592 * @arg @ref LL_COMP_INPUT_MINUS_IO2
elmot 1:d0dfbce63a89 593 * @arg @ref LL_COMP_INPUT_MINUS_IO3 (*)
elmot 1:d0dfbce63a89 594 * @arg @ref LL_COMP_INPUT_MINUS_IO4 (*)
elmot 1:d0dfbce63a89 595 * @arg @ref LL_COMP_INPUT_MINUS_IO5 (*)
elmot 1:d0dfbce63a89 596 *
elmot 1:d0dfbce63a89 597 * (*) Parameter not available on all devices.
elmot 1:d0dfbce63a89 598 */
elmot 1:d0dfbce63a89 599 __STATIC_INLINE uint32_t LL_COMP_GetInputMinus(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 600 {
elmot 1:d0dfbce63a89 601 #if defined(COMP_CSR_INMESEL_1)
elmot 1:d0dfbce63a89 602 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INMESEL | COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN));
elmot 1:d0dfbce63a89 603 #else
elmot 1:d0dfbce63a89 604 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN));
elmot 1:d0dfbce63a89 605 #endif
elmot 1:d0dfbce63a89 606 }
elmot 1:d0dfbce63a89 607
elmot 1:d0dfbce63a89 608 /**
elmot 1:d0dfbce63a89 609 * @brief Set comparator instance hysteresis mode of the input minus (inverting input).
elmot 1:d0dfbce63a89 610 * @rmtoll CSR HYST LL_COMP_SetInputHysteresis
elmot 1:d0dfbce63a89 611 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 612 * @param InputHysteresis This parameter can be one of the following values:
elmot 1:d0dfbce63a89 613 * @arg @ref LL_COMP_HYSTERESIS_NONE
elmot 1:d0dfbce63a89 614 * @arg @ref LL_COMP_HYSTERESIS_LOW
elmot 1:d0dfbce63a89 615 * @arg @ref LL_COMP_HYSTERESIS_MEDIUM
elmot 1:d0dfbce63a89 616 * @arg @ref LL_COMP_HYSTERESIS_HIGH
elmot 1:d0dfbce63a89 617 * @retval None
elmot 1:d0dfbce63a89 618 */
elmot 1:d0dfbce63a89 619 __STATIC_INLINE void LL_COMP_SetInputHysteresis(COMP_TypeDef *COMPx, uint32_t InputHysteresis)
elmot 1:d0dfbce63a89 620 {
elmot 1:d0dfbce63a89 621 MODIFY_REG(COMPx->CSR, COMP_CSR_HYST, InputHysteresis);
elmot 1:d0dfbce63a89 622 }
elmot 1:d0dfbce63a89 623
elmot 1:d0dfbce63a89 624 /**
elmot 1:d0dfbce63a89 625 * @brief Get comparator instance hysteresis mode of the minus (inverting) input.
elmot 1:d0dfbce63a89 626 * @rmtoll CSR HYST LL_COMP_GetInputHysteresis
elmot 1:d0dfbce63a89 627 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 628 * @retval Returned value can be one of the following values:
elmot 1:d0dfbce63a89 629 * @arg @ref LL_COMP_HYSTERESIS_NONE
elmot 1:d0dfbce63a89 630 * @arg @ref LL_COMP_HYSTERESIS_LOW
elmot 1:d0dfbce63a89 631 * @arg @ref LL_COMP_HYSTERESIS_MEDIUM
elmot 1:d0dfbce63a89 632 * @arg @ref LL_COMP_HYSTERESIS_HIGH
elmot 1:d0dfbce63a89 633 */
elmot 1:d0dfbce63a89 634 __STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 635 {
elmot 1:d0dfbce63a89 636 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_HYST));
elmot 1:d0dfbce63a89 637 }
elmot 1:d0dfbce63a89 638
elmot 1:d0dfbce63a89 639 /**
elmot 1:d0dfbce63a89 640 * @}
elmot 1:d0dfbce63a89 641 */
elmot 1:d0dfbce63a89 642
elmot 1:d0dfbce63a89 643 /** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output
elmot 1:d0dfbce63a89 644 * @{
elmot 1:d0dfbce63a89 645 */
elmot 1:d0dfbce63a89 646
elmot 1:d0dfbce63a89 647 /**
elmot 1:d0dfbce63a89 648 * @brief Set comparator instance output polarity.
elmot 1:d0dfbce63a89 649 * @rmtoll CSR POLARITY LL_COMP_SetOutputPolarity
elmot 1:d0dfbce63a89 650 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 651 * @param OutputPolarity This parameter can be one of the following values:
elmot 1:d0dfbce63a89 652 * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
elmot 1:d0dfbce63a89 653 * @arg @ref LL_COMP_OUTPUTPOL_INVERTED
elmot 1:d0dfbce63a89 654 * @retval None
elmot 1:d0dfbce63a89 655 */
elmot 1:d0dfbce63a89 656 __STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity)
elmot 1:d0dfbce63a89 657 {
elmot 1:d0dfbce63a89 658 MODIFY_REG(COMPx->CSR, COMP_CSR_POLARITY, OutputPolarity);
elmot 1:d0dfbce63a89 659 }
elmot 1:d0dfbce63a89 660
elmot 1:d0dfbce63a89 661 /**
elmot 1:d0dfbce63a89 662 * @brief Get comparator instance output polarity.
elmot 1:d0dfbce63a89 663 * @rmtoll CSR POLARITY LL_COMP_GetOutputPolarity
elmot 1:d0dfbce63a89 664 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 665 * @retval Returned value can be one of the following values:
elmot 1:d0dfbce63a89 666 * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
elmot 1:d0dfbce63a89 667 * @arg @ref LL_COMP_OUTPUTPOL_INVERTED
elmot 1:d0dfbce63a89 668 */
elmot 1:d0dfbce63a89 669 __STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 670 {
elmot 1:d0dfbce63a89 671 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_POLARITY));
elmot 1:d0dfbce63a89 672 }
elmot 1:d0dfbce63a89 673
elmot 1:d0dfbce63a89 674 /**
elmot 1:d0dfbce63a89 675 * @brief Set comparator instance blanking source.
elmot 1:d0dfbce63a89 676 * @note Blanking source may be specific to each comparator instance.
elmot 1:d0dfbce63a89 677 * Refer to description of parameters or to reference manual.
elmot 1:d0dfbce63a89 678 * @note Availability of parameters of blanking source from timer
elmot 1:d0dfbce63a89 679 * depends on timers availability on the selected device.
elmot 1:d0dfbce63a89 680 * @rmtoll CSR BLANKING LL_COMP_SetOutputBlankingSource
elmot 1:d0dfbce63a89 681 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 682 * @param BlankingSource This parameter can be one of the following values:
elmot 1:d0dfbce63a89 683 * @arg @ref LL_COMP_BLANKINGSRC_NONE
elmot 1:d0dfbce63a89 684 * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1 (1)(2)
elmot 1:d0dfbce63a89 685 * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1 (1)(2)
elmot 1:d0dfbce63a89 686 * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1 (1)(2)
elmot 1:d0dfbce63a89 687 * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4_COMP2 (1)(3)
elmot 1:d0dfbce63a89 688 * @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5_COMP2 (1)(3)
elmot 1:d0dfbce63a89 689 * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1_COMP2 (1)(3)
elmot 1:d0dfbce63a89 690 *
elmot 1:d0dfbce63a89 691 * (1) Parameter availability depending on timer availability
elmot 1:d0dfbce63a89 692 * on the selected device.
elmot 1:d0dfbce63a89 693 * (2) On STM32L4, parameter available only on comparator instance: COMP1.
elmot 1:d0dfbce63a89 694 * (3) On STM32L4, parameter available only on comparator instance: COMP2.
elmot 1:d0dfbce63a89 695 * @retval None
elmot 1:d0dfbce63a89 696 */
elmot 1:d0dfbce63a89 697 __STATIC_INLINE void LL_COMP_SetOutputBlankingSource(COMP_TypeDef *COMPx, uint32_t BlankingSource)
elmot 1:d0dfbce63a89 698 {
elmot 1:d0dfbce63a89 699 MODIFY_REG(COMPx->CSR, COMP_CSR_BLANKING, BlankingSource);
elmot 1:d0dfbce63a89 700 }
elmot 1:d0dfbce63a89 701
elmot 1:d0dfbce63a89 702 /**
elmot 1:d0dfbce63a89 703 * @brief Get comparator instance blanking source.
elmot 1:d0dfbce63a89 704 * @note Availability of parameters of blanking source from timer
elmot 1:d0dfbce63a89 705 * depends on timers availability on the selected device.
elmot 1:d0dfbce63a89 706 * @note Blanking source may be specific to each comparator instance.
elmot 1:d0dfbce63a89 707 * Refer to description of parameters or to reference manual.
elmot 1:d0dfbce63a89 708 * @rmtoll CSR BLANKING LL_COMP_GetOutputBlankingSource
elmot 1:d0dfbce63a89 709 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 710 * @retval Returned value can be one of the following values:
elmot 1:d0dfbce63a89 711 * @arg @ref LL_COMP_BLANKINGSRC_NONE
elmot 1:d0dfbce63a89 712 * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1 (1)(2)
elmot 1:d0dfbce63a89 713 * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1 (1)(2)
elmot 1:d0dfbce63a89 714 * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1 (1)(2)
elmot 1:d0dfbce63a89 715 * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4_COMP2 (1)(3)
elmot 1:d0dfbce63a89 716 * @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5_COMP2 (1)(3)
elmot 1:d0dfbce63a89 717 * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1_COMP2 (1)(3)
elmot 1:d0dfbce63a89 718 *
elmot 1:d0dfbce63a89 719 * (1) Parameter availability depending on timer availability
elmot 1:d0dfbce63a89 720 * on the selected device.
elmot 1:d0dfbce63a89 721 * (2) On STM32L4, parameter available only on comparator instance: COMP1.
elmot 1:d0dfbce63a89 722 * (3) On STM32L4, parameter available only on comparator instance: COMP2.
elmot 1:d0dfbce63a89 723 */
elmot 1:d0dfbce63a89 724 __STATIC_INLINE uint32_t LL_COMP_GetOutputBlankingSource(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 725 {
elmot 1:d0dfbce63a89 726 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_BLANKING));
elmot 1:d0dfbce63a89 727 }
elmot 1:d0dfbce63a89 728
elmot 1:d0dfbce63a89 729 /**
elmot 1:d0dfbce63a89 730 * @}
elmot 1:d0dfbce63a89 731 */
elmot 1:d0dfbce63a89 732
elmot 1:d0dfbce63a89 733 /** @defgroup COMP_LL_EF_Configuration_Legacy_Functions Configuration of COMP, legacy functions name
elmot 1:d0dfbce63a89 734 * @{
elmot 1:d0dfbce63a89 735 */
elmot 1:d0dfbce63a89 736 /* Old functions name kept for legacy purpose, to be replaced by the */
elmot 1:d0dfbce63a89 737 /* current functions name. */
elmot 1:d0dfbce63a89 738 __STATIC_INLINE void LL_COMP_SetInputNonInverting(COMP_TypeDef *COMPx, uint32_t InputNonInverting)
elmot 1:d0dfbce63a89 739 {
elmot 1:d0dfbce63a89 740 LL_COMP_SetInputPlus(COMPx, InputNonInverting);
elmot 1:d0dfbce63a89 741 }
elmot 1:d0dfbce63a89 742 __STATIC_INLINE uint32_t LL_COMP_GetInputNonInverting(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 743 {
elmot 1:d0dfbce63a89 744 return LL_COMP_GetInputPlus(COMPx);
elmot 1:d0dfbce63a89 745 }
elmot 1:d0dfbce63a89 746
elmot 1:d0dfbce63a89 747 __STATIC_INLINE void LL_COMP_SetInputInverting(COMP_TypeDef *COMPx, uint32_t InputInverting)
elmot 1:d0dfbce63a89 748 {
elmot 1:d0dfbce63a89 749 LL_COMP_SetInputMinus(COMPx, InputInverting);
elmot 1:d0dfbce63a89 750 }
elmot 1:d0dfbce63a89 751 __STATIC_INLINE uint32_t LL_COMP_GetInputInverting(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 752 {
elmot 1:d0dfbce63a89 753 return LL_COMP_GetInputMinus(COMPx);
elmot 1:d0dfbce63a89 754 }
elmot 1:d0dfbce63a89 755
elmot 1:d0dfbce63a89 756 /**
elmot 1:d0dfbce63a89 757 * @}
elmot 1:d0dfbce63a89 758 */
elmot 1:d0dfbce63a89 759
elmot 1:d0dfbce63a89 760 /** @defgroup COMP_LL_EF_Operation Operation on comparator instance
elmot 1:d0dfbce63a89 761 * @{
elmot 1:d0dfbce63a89 762 */
elmot 1:d0dfbce63a89 763
elmot 1:d0dfbce63a89 764 /**
elmot 1:d0dfbce63a89 765 * @brief Enable comparator instance.
elmot 1:d0dfbce63a89 766 * @note After enable from off state, comparator requires a delay
elmot 1:d0dfbce63a89 767 * to reach reach propagation delay specification.
elmot 1:d0dfbce63a89 768 * Refer to device datasheet, parameter "tSTART".
elmot 1:d0dfbce63a89 769 * @rmtoll CSR EN LL_COMP_Enable
elmot 1:d0dfbce63a89 770 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 771 * @retval None
elmot 1:d0dfbce63a89 772 */
elmot 1:d0dfbce63a89 773 __STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 774 {
elmot 1:d0dfbce63a89 775 SET_BIT(COMPx->CSR, COMP_CSR_EN);
elmot 1:d0dfbce63a89 776 }
elmot 1:d0dfbce63a89 777
elmot 1:d0dfbce63a89 778 /**
elmot 1:d0dfbce63a89 779 * @brief Disable comparator instance.
elmot 1:d0dfbce63a89 780 * @rmtoll CSR EN LL_COMP_Disable
elmot 1:d0dfbce63a89 781 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 782 * @retval None
elmot 1:d0dfbce63a89 783 */
elmot 1:d0dfbce63a89 784 __STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 785 {
elmot 1:d0dfbce63a89 786 CLEAR_BIT(COMPx->CSR, COMP_CSR_EN);
elmot 1:d0dfbce63a89 787 }
elmot 1:d0dfbce63a89 788
elmot 1:d0dfbce63a89 789 /**
elmot 1:d0dfbce63a89 790 * @brief Get comparator enable state
elmot 1:d0dfbce63a89 791 * (0: COMP is disabled, 1: COMP is enabled)
elmot 1:d0dfbce63a89 792 * @rmtoll CSR EN LL_COMP_IsEnabled
elmot 1:d0dfbce63a89 793 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 794 * @retval State of bit (1 or 0).
elmot 1:d0dfbce63a89 795 */
elmot 1:d0dfbce63a89 796 __STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 797 {
elmot 1:d0dfbce63a89 798 return (READ_BIT(COMPx->CSR, COMP_CSR_EN) == (COMP_CSR_EN));
elmot 1:d0dfbce63a89 799 }
elmot 1:d0dfbce63a89 800
elmot 1:d0dfbce63a89 801 /**
elmot 1:d0dfbce63a89 802 * @brief Lock comparator instance.
elmot 1:d0dfbce63a89 803 * @note Once locked, comparator configuration can be accessed in read-only.
elmot 1:d0dfbce63a89 804 * @note The only way to unlock the comparator is a device hardware reset.
elmot 1:d0dfbce63a89 805 * @rmtoll CSR LOCK LL_COMP_Lock
elmot 1:d0dfbce63a89 806 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 807 * @retval None
elmot 1:d0dfbce63a89 808 */
elmot 1:d0dfbce63a89 809 __STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 810 {
elmot 1:d0dfbce63a89 811 SET_BIT(COMPx->CSR, COMP_CSR_LOCK);
elmot 1:d0dfbce63a89 812 }
elmot 1:d0dfbce63a89 813
elmot 1:d0dfbce63a89 814 /**
elmot 1:d0dfbce63a89 815 * @brief Get comparator lock state
elmot 1:d0dfbce63a89 816 * (0: COMP is unlocked, 1: COMP is locked).
elmot 1:d0dfbce63a89 817 * @note Once locked, comparator configuration can be accessed in read-only.
elmot 1:d0dfbce63a89 818 * @note The only way to unlock the comparator is a device hardware reset.
elmot 1:d0dfbce63a89 819 * @rmtoll CSR LOCK LL_COMP_IsLocked
elmot 1:d0dfbce63a89 820 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 821 * @retval State of bit (1 or 0).
elmot 1:d0dfbce63a89 822 */
elmot 1:d0dfbce63a89 823 __STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 824 {
elmot 1:d0dfbce63a89 825 return (READ_BIT(COMPx->CSR, COMP_CSR_LOCK) == (COMP_CSR_LOCK));
elmot 1:d0dfbce63a89 826 }
elmot 1:d0dfbce63a89 827
elmot 1:d0dfbce63a89 828 /**
elmot 1:d0dfbce63a89 829 * @brief Read comparator instance output level.
elmot 1:d0dfbce63a89 830 * @note The comparator output level depends on the selected polarity
elmot 1:d0dfbce63a89 831 * (Refer to function @ref LL_COMP_SetOutputPolarity()).
elmot 1:d0dfbce63a89 832 * If the comparator polarity is not inverted:
elmot 1:d0dfbce63a89 833 * - Comparator output is low when the input plus
elmot 1:d0dfbce63a89 834 * is at a lower voltage than the input minus
elmot 1:d0dfbce63a89 835 * - Comparator output is high when the input plus
elmot 1:d0dfbce63a89 836 * is at a higher voltage than the input minus
elmot 1:d0dfbce63a89 837 * If the comparator polarity is inverted:
elmot 1:d0dfbce63a89 838 * - Comparator output is high when the input plus
elmot 1:d0dfbce63a89 839 * is at a lower voltage than the input minus
elmot 1:d0dfbce63a89 840 * - Comparator output is low when the input plus
elmot 1:d0dfbce63a89 841 * is at a higher voltage than the input minus
elmot 1:d0dfbce63a89 842 * @rmtoll CSR VALUE LL_COMP_ReadOutputLevel
elmot 1:d0dfbce63a89 843 * @param COMPx Comparator instance
elmot 1:d0dfbce63a89 844 * @retval Returned value can be one of the following values:
elmot 1:d0dfbce63a89 845 * @arg @ref LL_COMP_OUTPUT_LEVEL_LOW
elmot 1:d0dfbce63a89 846 * @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH
elmot 1:d0dfbce63a89 847 */
elmot 1:d0dfbce63a89 848 __STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
elmot 1:d0dfbce63a89 849 {
elmot 1:d0dfbce63a89 850 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_VALUE)
elmot 1:d0dfbce63a89 851 >> LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS);
elmot 1:d0dfbce63a89 852 }
elmot 1:d0dfbce63a89 853
elmot 1:d0dfbce63a89 854 /**
elmot 1:d0dfbce63a89 855 * @}
elmot 1:d0dfbce63a89 856 */
elmot 1:d0dfbce63a89 857
elmot 1:d0dfbce63a89 858 #if defined(USE_FULL_LL_DRIVER)
elmot 1:d0dfbce63a89 859 /** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions
elmot 1:d0dfbce63a89 860 * @{
elmot 1:d0dfbce63a89 861 */
elmot 1:d0dfbce63a89 862
elmot 1:d0dfbce63a89 863 ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx);
elmot 1:d0dfbce63a89 864 ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct);
elmot 1:d0dfbce63a89 865 void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct);
elmot 1:d0dfbce63a89 866
elmot 1:d0dfbce63a89 867 /**
elmot 1:d0dfbce63a89 868 * @}
elmot 1:d0dfbce63a89 869 */
elmot 1:d0dfbce63a89 870 #endif /* USE_FULL_LL_DRIVER */
elmot 1:d0dfbce63a89 871
elmot 1:d0dfbce63a89 872 /**
elmot 1:d0dfbce63a89 873 * @}
elmot 1:d0dfbce63a89 874 */
elmot 1:d0dfbce63a89 875
elmot 1:d0dfbce63a89 876 /**
elmot 1:d0dfbce63a89 877 * @}
elmot 1:d0dfbce63a89 878 */
elmot 1:d0dfbce63a89 879
elmot 1:d0dfbce63a89 880 #endif /* COMP1 || COMP2 */
elmot 1:d0dfbce63a89 881
elmot 1:d0dfbce63a89 882 /**
elmot 1:d0dfbce63a89 883 * @}
elmot 1:d0dfbce63a89 884 */
elmot 1:d0dfbce63a89 885
elmot 1:d0dfbce63a89 886 #ifdef __cplusplus
elmot 1:d0dfbce63a89 887 }
elmot 1:d0dfbce63a89 888 #endif
elmot 1:d0dfbce63a89 889
elmot 1:d0dfbce63a89 890 #endif /* __STM32L4xx_LL_COMP_H */
elmot 1:d0dfbce63a89 891
elmot 1:d0dfbce63a89 892 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/