mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
180:96ed750bd169
mbed library release version 165

Who changed what in which revision?

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