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:
186:707f6e361f3e
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 158:b23ee177fd68 1 /**
Kojto 158:b23ee177fd68 2 ******************************************************************************
Kojto 158:b23ee177fd68 3 * @file stm32l0xx_ll_comp.h
Kojto 158:b23ee177fd68 4 * @author MCD Application Team
Kojto 158:b23ee177fd68 5 * @brief Header file of COMP LL module.
Kojto 158:b23ee177fd68 6 ******************************************************************************
Kojto 158:b23ee177fd68 7 * @attention
Kojto 158:b23ee177fd68 8 *
Kojto 158:b23ee177fd68 9 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 158:b23ee177fd68 10 *
Kojto 158:b23ee177fd68 11 * Redistribution and use in source and binary forms, with or without modification,
Kojto 158:b23ee177fd68 12 * are permitted provided that the following conditions are met:
Kojto 158:b23ee177fd68 13 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 158:b23ee177fd68 14 * this list of conditions and the following disclaimer.
Kojto 158:b23ee177fd68 15 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 158:b23ee177fd68 16 * this list of conditions and the following disclaimer in the documentation
Kojto 158:b23ee177fd68 17 * and/or other materials provided with the distribution.
Kojto 158:b23ee177fd68 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 158:b23ee177fd68 19 * may be used to endorse or promote products derived from this software
Kojto 158:b23ee177fd68 20 * without specific prior written permission.
Kojto 158:b23ee177fd68 21 *
Kojto 158:b23ee177fd68 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 158:b23ee177fd68 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 158:b23ee177fd68 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 158:b23ee177fd68 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 158:b23ee177fd68 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 158:b23ee177fd68 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 158:b23ee177fd68 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 158:b23ee177fd68 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 158:b23ee177fd68 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 158:b23ee177fd68 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 158:b23ee177fd68 32 *
Kojto 158:b23ee177fd68 33 ******************************************************************************
Kojto 158:b23ee177fd68 34 */
Kojto 158:b23ee177fd68 35
Kojto 158:b23ee177fd68 36 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 158:b23ee177fd68 37 #ifndef __STM32L0xx_LL_COMP_H
Kojto 158:b23ee177fd68 38 #define __STM32L0xx_LL_COMP_H
Kojto 158:b23ee177fd68 39
Kojto 158:b23ee177fd68 40 #ifdef __cplusplus
Kojto 158:b23ee177fd68 41 extern "C" {
Kojto 158:b23ee177fd68 42 #endif
Kojto 158:b23ee177fd68 43
Kojto 158:b23ee177fd68 44 /* Includes ------------------------------------------------------------------*/
Kojto 158:b23ee177fd68 45 #include "stm32l0xx.h"
Kojto 158:b23ee177fd68 46
Kojto 158:b23ee177fd68 47 /** @addtogroup STM32L0xx_LL_Driver
Kojto 158:b23ee177fd68 48 * @{
Kojto 158:b23ee177fd68 49 */
Kojto 158:b23ee177fd68 50
Kojto 158:b23ee177fd68 51 #if defined (COMP1) || defined (COMP2)
Kojto 158:b23ee177fd68 52
Kojto 158:b23ee177fd68 53 /** @defgroup COMP_LL COMP
Kojto 158:b23ee177fd68 54 * @{
Kojto 158:b23ee177fd68 55 */
Kojto 158:b23ee177fd68 56
Kojto 158:b23ee177fd68 57 /* Private types -------------------------------------------------------------*/
Kojto 158:b23ee177fd68 58 /* Private variables ---------------------------------------------------------*/
Kojto 158:b23ee177fd68 59 /* Private constants ---------------------------------------------------------*/
Kojto 158:b23ee177fd68 60 /** @defgroup COMP_LL_Private_Constants COMP Private Constants
Kojto 158:b23ee177fd68 61 * @{
Kojto 158:b23ee177fd68 62 */
Kojto 158:b23ee177fd68 63
Kojto 158:b23ee177fd68 64 /* COMP registers bits positions */
Kojto 158:b23ee177fd68 65 #define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS ((uint32_t)30U) /* Value equivalent to POSITION_VAL(COMP_CSR_COMP1VALUE) */
Kojto 158:b23ee177fd68 66
Kojto 158:b23ee177fd68 67 /**
Kojto 158:b23ee177fd68 68 * @}
Kojto 158:b23ee177fd68 69 */
Kojto 158:b23ee177fd68 70
Kojto 158:b23ee177fd68 71 /* Private macros ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 72 /* Exported types ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 73 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 74 /** @defgroup COMP_LL_ES_INIT COMP Exported Init structure
Kojto 158:b23ee177fd68 75 * @{
Kojto 158:b23ee177fd68 76 */
Kojto 158:b23ee177fd68 77
Kojto 158:b23ee177fd68 78 /**
Kojto 158:b23ee177fd68 79 * @brief Structure definition of some features of COMP instance.
Kojto 158:b23ee177fd68 80 */
Kojto 158:b23ee177fd68 81 typedef struct
Kojto 158:b23ee177fd68 82 {
Kojto 158:b23ee177fd68 83 uint32_t PowerMode; /*!< Set comparator operating mode to adjust power and speed.
Kojto 158:b23ee177fd68 84 This parameter can be a value of @ref COMP_LL_EC_POWERMODE
Kojto 158:b23ee177fd68 85
Kojto 158:b23ee177fd68 86 This feature can be modified afterwards using unitary function @ref LL_COMP_SetPowerMode(). */
Kojto 158:b23ee177fd68 87
Kojto 158:b23ee177fd68 88 uint32_t InputPlus; /*!< Set comparator input plus (non-inverting input).
Kojto 158:b23ee177fd68 89 This parameter can be a value of @ref COMP_LL_EC_INPUT_PLUS
Kojto 158:b23ee177fd68 90
Kojto 158:b23ee177fd68 91 This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputPlus(). */
Kojto 158:b23ee177fd68 92
Kojto 158:b23ee177fd68 93 uint32_t InputMinus; /*!< Set comparator input minus (inverting input).
Kojto 158:b23ee177fd68 94 This parameter can be a value of @ref COMP_LL_EC_INPUT_MINUS
Kojto 158:b23ee177fd68 95
Kojto 158:b23ee177fd68 96 This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputMinus(). */
Kojto 158:b23ee177fd68 97
Kojto 158:b23ee177fd68 98 uint32_t OutputPolarity; /*!< Set comparator output polarity.
Kojto 158:b23ee177fd68 99 This parameter can be a value of @ref COMP_LL_EC_OUTPUT_POLARITY
Kojto 158:b23ee177fd68 100
Kojto 158:b23ee177fd68 101 This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputPolarity(). */
Kojto 158:b23ee177fd68 102
Kojto 158:b23ee177fd68 103 } LL_COMP_InitTypeDef;
Kojto 158:b23ee177fd68 104
Kojto 158:b23ee177fd68 105 /**
Kojto 158:b23ee177fd68 106 * @}
Kojto 158:b23ee177fd68 107 */
Kojto 158:b23ee177fd68 108 #endif /* USE_FULL_LL_DRIVER */
Kojto 158:b23ee177fd68 109
Kojto 158:b23ee177fd68 110 /* Exported constants --------------------------------------------------------*/
Kojto 158:b23ee177fd68 111 /** @defgroup COMP_LL_Exported_Constants COMP Exported Constants
Kojto 158:b23ee177fd68 112 * @{
Kojto 158:b23ee177fd68 113 */
Kojto 158:b23ee177fd68 114
Kojto 158:b23ee177fd68 115 /** @defgroup COMP_LL_EC_COMMON_WINDOWMODE Comparator common modes - Window mode
Kojto 158:b23ee177fd68 116 * @{
Kojto 158:b23ee177fd68 117 */
Kojto 158:b23ee177fd68 118 #define LL_COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000U) /*!< Window mode disable: Comparators 1 and 2 are independent */
Kojto 158:b23ee177fd68 119 #define LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_COMP1WM) /*!< 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). */
Kojto 158:b23ee177fd68 120 /**
Kojto 158:b23ee177fd68 121 * @}
Kojto 158:b23ee177fd68 122 */
Kojto 158:b23ee177fd68 123
Kojto 158:b23ee177fd68 124 /** @defgroup COMP_LL_EC_POWERMODE Comparator modes - Power mode
Kojto 158:b23ee177fd68 125 * @{
Kojto 158:b23ee177fd68 126 */
Kojto 158:b23ee177fd68 127 #define LL_COMP_POWERMODE_ULTRALOWPOWER ((uint32_t)0x00000000U) /*!< COMP power mode to low speed (specific to COMP instance: COMP2) */
Kojto 158:b23ee177fd68 128 #define LL_COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_COMP2SPEED) /*!< COMP power mode to fast speed (specific to COMP instance: COMP2) */
Kojto 158:b23ee177fd68 129 /**
Kojto 158:b23ee177fd68 130 * @}
Kojto 158:b23ee177fd68 131 */
Kojto 158:b23ee177fd68 132
Kojto 158:b23ee177fd68 133 /** @defgroup COMP_LL_EC_INPUT_PLUS Comparator inputs - Input plus (input non-inverting) selection
Kojto 158:b23ee177fd68 134 * @{
Kojto 158:b23ee177fd68 135 */
Kojto 158:b23ee177fd68 136 #define LL_COMP_INPUT_PLUS_IO1 ((uint32_t)0x00000000U) /*!< Comparator input plus connected to IO1 (pin PA1 for COMP1, pin PA3 for COMP2) */
Kojto 158:b23ee177fd68 137 #define LL_COMP_INPUT_PLUS_IO2 (COMP_CSR_COMP2INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB4 for COMP2) (specific to COMP instance: COMP2) */
Kojto 158:b23ee177fd68 138 #define LL_COMP_INPUT_PLUS_IO3 (COMP_CSR_COMP2INPSEL_1) /*!< Comparator input plus connected to IO3 (pin PA5 for COMP2) (specific to COMP instance: COMP2) */
Kojto 158:b23ee177fd68 139 #define LL_COMP_INPUT_PLUS_IO4 (COMP_CSR_COMP2INPSEL_0 | COMP_CSR_COMP2INPSEL_1) /*!< Comparator input plus connected to IO4 (pin PB6 for COMP2) (specific to COMP instance: COMP2) */
Kojto 158:b23ee177fd68 140 #define LL_COMP_INPUT_PLUS_IO5 (COMP_CSR_COMP2INPSEL_2) /*!< Comparator input plus connected to IO5 (pin PB7 for COMP2) (specific to COMP instance: COMP2) */
Kojto 158:b23ee177fd68 141 #if defined (STM32L011xx) || defined (STM32L021xx)
Kojto 158:b23ee177fd68 142 #define LL_COMP_INPUT_PLUS_IO6 (COMP_CSR_COMP2INPSEL_2 | COMP_CSR_COMP2INPSEL_0) /*!< Comparator input plus connected to IO6 (pin PA7 for COMP2) (specific to COMP instance: COMP2) (Available only on devices STM32L0 category 1) */
Kojto 158:b23ee177fd68 143 #endif
Kojto 158:b23ee177fd68 144 /**
Kojto 158:b23ee177fd68 145 * @}
Kojto 158:b23ee177fd68 146 */
Kojto 158:b23ee177fd68 147
Kojto 158:b23ee177fd68 148 /** @defgroup COMP_LL_EC_INPUT_MINUS Comparator inputs - Input minus (input inverting) selection
Kojto 158:b23ee177fd68 149 * @{
Kojto 158:b23ee177fd68 150 */
Kojto 158:b23ee177fd68 151 #define LL_COMP_INPUT_MINUS_1_4VREFINT (COMP_CSR_COMP2INNSEL_2 ) /*!< Comparator input minus connected to 1/4 VrefInt (specifity of COMP2 related to path to enable via SYSCFG: refer to comment in function @ref LL_COMP_SetInputMinus() ) (specific to COMP instance: COMP2) */
Kojto 158:b23ee177fd68 152 #define LL_COMP_INPUT_MINUS_1_2VREFINT (COMP_CSR_COMP2INNSEL_2 | COMP_CSR_COMP2INNSEL_0) /*!< Comparator input minus connected to 1/2 VrefInt (specifity of COMP2 related to path to enable via SYSCFG: refer to comment in function @ref LL_COMP_SetInputMinus() ) (specific to COMP instance: COMP2) */
Kojto 158:b23ee177fd68 153 #define LL_COMP_INPUT_MINUS_3_4VREFINT (COMP_CSR_COMP2INNSEL_2 | COMP_CSR_COMP2INNSEL_1 ) /*!< Comparator input minus connected to 3/4 VrefInt (specifity of COMP2 related to path to enable via SYSCFG: refer to comment in function @ref LL_COMP_SetInputMinus() ) (specific to COMP instance: COMP2) */
Kojto 158:b23ee177fd68 154 #define LL_COMP_INPUT_MINUS_VREFINT ((uint32_t)0x00000000U) /*!< Comparator input minus connected to VrefInt (specifity of COMP2 related to path to enable via SYSCFG: refer to comment in function @ref LL_COMP_SetInputMinus() ) */
Kojto 158:b23ee177fd68 155 #define LL_COMP_INPUT_MINUS_DAC1_CH1 ( COMP_CSR_COMP2INNSEL_1 ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */
Kojto 158:b23ee177fd68 156 #define LL_COMP_INPUT_MINUS_DAC1_CH2 ( COMP_CSR_COMP2INNSEL_1 | COMP_CSR_COMP2INNSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */
Kojto 158:b23ee177fd68 157 #define LL_COMP_INPUT_MINUS_IO1 ( COMP_CSR_COMP2INNSEL_0) /*!< Comparator input minus connected to IO1 (pin PA0 for COMP1, pin PA2 for COMP2) */
Kojto 158:b23ee177fd68 158 #define LL_COMP_INPUT_MINUS_IO2 (COMP_CSR_COMP2INNSEL_2 | COMP_CSR_COMP2INNSEL_1 | COMP_CSR_COMP2INNSEL_0) /*!< Comparator input minus connected to IO2 (pin PB3 for COMP2) (specific to COMP instance: COMP2) */
Kojto 158:b23ee177fd68 159 /**
Kojto 158:b23ee177fd68 160 * @}
Kojto 158:b23ee177fd68 161 */
Kojto 158:b23ee177fd68 162
Kojto 158:b23ee177fd68 163 /** @defgroup COMP_LL_EC_OUTPUT_SELECTION_LPTIM Comparator output - Output selection specific to LPTIM peripheral
Kojto 158:b23ee177fd68 164 * @{
Kojto 158:b23ee177fd68 165 */
Kojto 158:b23ee177fd68 166 #define LL_COMP_OUTPUT_LPTIM1_IN1_COMP1 (COMP_CSR_COMP1LPTIM1IN1) /*!< COMP output connected to TIM2 input capture 4 */
Kojto 158:b23ee177fd68 167 #define LL_COMP_OUTPUT_LPTIM1_IN1_COMP2 (COMP_CSR_COMP2LPTIM1IN1) /*!< COMP output connected to TIM2 input capture 4 */
Kojto 158:b23ee177fd68 168 #define LL_COMP_OUTPUT_LPTIM1_IN2_COMP2 (COMP_CSR_COMP2LPTIM1IN2) /*!< COMP output connected to TIM2 input capture 4 */
Kojto 158:b23ee177fd68 169 /**
Kojto 158:b23ee177fd68 170 * @}
Kojto 158:b23ee177fd68 171 */
Kojto 158:b23ee177fd68 172
Kojto 158:b23ee177fd68 173 /** @defgroup COMP_LL_EC_OUTPUT_POLARITY Comparator output - Output polarity
Kojto 158:b23ee177fd68 174 * @{
Kojto 158:b23ee177fd68 175 */
Kojto 158:b23ee177fd68 176 #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 */
Kojto 158:b23ee177fd68 177 #define LL_COMP_OUTPUTPOL_INVERTED (COMP_CSR_COMP1POLARITY) /*!< 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 */
Kojto 158:b23ee177fd68 178
Kojto 158:b23ee177fd68 179 /**
Kojto 158:b23ee177fd68 180 * @}
Kojto 158:b23ee177fd68 181 */
Kojto 158:b23ee177fd68 182
Kojto 158:b23ee177fd68 183 /** @defgroup COMP_LL_EC_OUTPUT_LEVEL Comparator output - Output level
Kojto 158:b23ee177fd68 184 * @{
Kojto 158:b23ee177fd68 185 */
Kojto 158:b23ee177fd68 186 #define LL_COMP_OUTPUT_LEVEL_LOW ((uint32_t)0x00000000U) /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */
Kojto 158:b23ee177fd68 187 #define LL_COMP_OUTPUT_LEVEL_HIGH ((uint32_t)0x00000001U) /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */
Kojto 158:b23ee177fd68 188 /**
Kojto 158:b23ee177fd68 189 * @}
Kojto 158:b23ee177fd68 190 */
Kojto 158:b23ee177fd68 191
Kojto 158:b23ee177fd68 192 /** @defgroup COMP_LL_EC_HW_DELAYS Definitions of COMP hardware constraints delays
Kojto 158:b23ee177fd68 193 * @note Only COMP IP HW delays are defined in COMP LL driver driver,
Kojto 158:b23ee177fd68 194 * not timeout values.
Kojto 158:b23ee177fd68 195 * For details on delays values, refer to descriptions in source code
Kojto 158:b23ee177fd68 196 * above each literal definition.
Kojto 158:b23ee177fd68 197 * @{
Kojto 158:b23ee177fd68 198 */
Kojto 158:b23ee177fd68 199
Kojto 158:b23ee177fd68 200 /* Delay for comparator startup time. */
Kojto 158:b23ee177fd68 201 /* Note: Delay required to reach propagation delay specification. */
Kojto 158:b23ee177fd68 202 /* Literal set to maximum value (refer to device datasheet, */
Kojto 158:b23ee177fd68 203 /* parameter "tSTART"). */
Kojto 158:b23ee177fd68 204 /* Unit: us */
Kojto 158:b23ee177fd68 205 #define LL_COMP_DELAY_STARTUP_US ((uint32_t) 25U) /*!< Delay for COMP startup time */
Kojto 158:b23ee177fd68 206
Kojto 158:b23ee177fd68 207 /* Delay for comparator voltage scaler stabilization time */
Kojto 158:b23ee177fd68 208 /* (voltage from VrefInt, delay based on VrefInt startup time). */
Kojto 158:b23ee177fd68 209 /* Literal set to maximum value (refer to device datasheet, */
Kojto 158:b23ee177fd68 210 /* parameter "TVREFINT"). */
Kojto 158:b23ee177fd68 211 /* Unit: us */
Kojto 158:b23ee177fd68 212 #define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ((uint32_t)3000U) /*!< Delay for COMP voltage scaler stabilization time */
Kojto 158:b23ee177fd68 213
Kojto 158:b23ee177fd68 214 /**
Kojto 158:b23ee177fd68 215 * @}
Kojto 158:b23ee177fd68 216 */
Kojto 158:b23ee177fd68 217
Kojto 158:b23ee177fd68 218 /**
Kojto 158:b23ee177fd68 219 * @}
Kojto 158:b23ee177fd68 220 */
Kojto 158:b23ee177fd68 221
Kojto 158:b23ee177fd68 222 /* Exported macro ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 223 /** @defgroup COMP_LL_Exported_Macros COMP Exported Macros
Kojto 158:b23ee177fd68 224 * @{
Kojto 158:b23ee177fd68 225 */
Kojto 158:b23ee177fd68 226 /** @defgroup COMP_LL_EM_WRITE_READ Common write and read registers macro
Kojto 158:b23ee177fd68 227 * @{
Kojto 158:b23ee177fd68 228 */
Kojto 158:b23ee177fd68 229
Kojto 158:b23ee177fd68 230 /**
Kojto 158:b23ee177fd68 231 * @brief Write a value in COMP register
Kojto 158:b23ee177fd68 232 * @param __INSTANCE__ comparator instance
Kojto 158:b23ee177fd68 233 * @param __REG__ Register to be written
Kojto 158:b23ee177fd68 234 * @param __VALUE__ Value to be written in the register
Kojto 158:b23ee177fd68 235 * @retval None
Kojto 158:b23ee177fd68 236 */
Kojto 158:b23ee177fd68 237 #define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
Kojto 158:b23ee177fd68 238
Kojto 158:b23ee177fd68 239 /**
Kojto 158:b23ee177fd68 240 * @brief Read a value in COMP register
Kojto 158:b23ee177fd68 241 * @param __INSTANCE__ comparator instance
Kojto 158:b23ee177fd68 242 * @param __REG__ Register to be read
Kojto 158:b23ee177fd68 243 * @retval Register value
Kojto 158:b23ee177fd68 244 */
Kojto 158:b23ee177fd68 245 #define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
Kojto 158:b23ee177fd68 246 /**
Kojto 158:b23ee177fd68 247 * @}
Kojto 158:b23ee177fd68 248 */
Kojto 158:b23ee177fd68 249
Kojto 158:b23ee177fd68 250 /** @defgroup COMP_LL_EM_HELPER_MACRO COMP helper macro
Kojto 158:b23ee177fd68 251 * @{
Kojto 158:b23ee177fd68 252 */
Kojto 158:b23ee177fd68 253
Kojto 158:b23ee177fd68 254 /**
Kojto 158:b23ee177fd68 255 * @brief Helper macro to select the COMP common instance
Kojto 158:b23ee177fd68 256 * to which is belonging the selected COMP instance.
Kojto 158:b23ee177fd68 257 * @note COMP common register instance can be used to
Kojto 158:b23ee177fd68 258 * set parameters common to several COMP instances.
Kojto 158:b23ee177fd68 259 * Refer to functions having argument "COMPxy_COMMON" as parameter.
Kojto 158:b23ee177fd68 260 * @param __COMPx__ COMP instance
Kojto 158:b23ee177fd68 261 * @retval COMP common instance or value "0" if there is no COMP common instance.
Kojto 158:b23ee177fd68 262 */
Kojto 158:b23ee177fd68 263 #define __LL_COMP_COMMON_INSTANCE(__COMPx__) \
Kojto 158:b23ee177fd68 264 (COMP12_COMMON)
Kojto 158:b23ee177fd68 265
Kojto 158:b23ee177fd68 266 /**
Kojto 158:b23ee177fd68 267 * @}
Kojto 158:b23ee177fd68 268 */
Kojto 158:b23ee177fd68 269
Kojto 158:b23ee177fd68 270 /**
Kojto 158:b23ee177fd68 271 * @}
Kojto 158:b23ee177fd68 272 */
Kojto 158:b23ee177fd68 273
Kojto 158:b23ee177fd68 274 /* Exported functions --------------------------------------------------------*/
Kojto 158:b23ee177fd68 275 /** @defgroup COMP_LL_Exported_Functions COMP Exported Functions
Kojto 158:b23ee177fd68 276 * @{
Kojto 158:b23ee177fd68 277 */
Kojto 158:b23ee177fd68 278
Kojto 158:b23ee177fd68 279 /** @defgroup COMP_LL_EF_Configuration_comparator_common Configuration of COMP hierarchical scope: common to several COMP instances
Kojto 158:b23ee177fd68 280 * @{
Kojto 158:b23ee177fd68 281 */
Kojto 158:b23ee177fd68 282
Kojto 158:b23ee177fd68 283 /**
Kojto 158:b23ee177fd68 284 * @brief Set window mode of a pair of comparators instances
Kojto 158:b23ee177fd68 285 * (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
Anna Bridge 186:707f6e361f3e 286 * @rmtoll COMP1_CSR COMP1WM LL_COMP_SetCommonWindowMode
Kojto 158:b23ee177fd68 287 * @param COMPxy_COMMON Comparator common instance
Kojto 158:b23ee177fd68 288 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
Kojto 158:b23ee177fd68 289 * @param WindowMode This parameter can be one of the following values:
Kojto 158:b23ee177fd68 290 * @arg @ref LL_COMP_WINDOWMODE_DISABLE
Kojto 158:b23ee177fd68 291 * @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
Kojto 158:b23ee177fd68 292 * @retval None
Kojto 158:b23ee177fd68 293 */
Kojto 158:b23ee177fd68 294 __STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode)
Kojto 158:b23ee177fd68 295 {
Kojto 158:b23ee177fd68 296 MODIFY_REG(COMPxy_COMMON->CSR, COMP_CSR_COMP1WM, WindowMode);
Kojto 158:b23ee177fd68 297 }
Kojto 158:b23ee177fd68 298
Kojto 158:b23ee177fd68 299 /**
Kojto 158:b23ee177fd68 300 * @brief Get window mode of a pair of comparators instances
Kojto 158:b23ee177fd68 301 * (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
Anna Bridge 186:707f6e361f3e 302 * @rmtoll COMP1_CSR COMP1WM LL_COMP_GetCommonWindowMode
Kojto 158:b23ee177fd68 303 * @param COMPxy_COMMON Comparator common instance
Kojto 158:b23ee177fd68 304 * (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
Kojto 158:b23ee177fd68 305 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 306 * @arg @ref LL_COMP_WINDOWMODE_DISABLE
Kojto 158:b23ee177fd68 307 * @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
Kojto 158:b23ee177fd68 308 */
Kojto 158:b23ee177fd68 309 __STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON)
Kojto 158:b23ee177fd68 310 {
Kojto 158:b23ee177fd68 311 return (uint32_t)(READ_BIT(COMPxy_COMMON->CSR, COMP_CSR_COMP1WM));
Kojto 158:b23ee177fd68 312 }
Kojto 158:b23ee177fd68 313
Kojto 158:b23ee177fd68 314 /**
Kojto 158:b23ee177fd68 315 * @}
Kojto 158:b23ee177fd68 316 */
Kojto 158:b23ee177fd68 317
Kojto 158:b23ee177fd68 318 /** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes
Kojto 158:b23ee177fd68 319 * @{
Kojto 158:b23ee177fd68 320 */
Kojto 158:b23ee177fd68 321
Kojto 158:b23ee177fd68 322 /**
Kojto 158:b23ee177fd68 323 * @brief Set comparator instance operating mode to adjust power and speed.
Anna Bridge 186:707f6e361f3e 324 * @rmtoll COMP2_CSR COMP2SPEED LL_COMP_SetPowerMode
Kojto 158:b23ee177fd68 325 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 326 * @param PowerMode This parameter can be one of the following values:
Kojto 158:b23ee177fd68 327 * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED (1)
Kojto 158:b23ee177fd68 328 * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER (1)
Kojto 158:b23ee177fd68 329 *
Kojto 158:b23ee177fd68 330 * (1) Available only on COMP instance: COMP2.
Kojto 158:b23ee177fd68 331 * @retval None
Kojto 158:b23ee177fd68 332 */
Kojto 158:b23ee177fd68 333 __STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode)
Kojto 158:b23ee177fd68 334 {
Kojto 158:b23ee177fd68 335 MODIFY_REG(COMPx->CSR, COMP_CSR_COMP2SPEED, PowerMode);
Kojto 158:b23ee177fd68 336 }
Kojto 158:b23ee177fd68 337
Kojto 158:b23ee177fd68 338 /**
Kojto 158:b23ee177fd68 339 * @brief Get comparator instance operating mode to adjust power and speed.
Kojto 158:b23ee177fd68 340 * @note Available only on COMP instance: COMP2.
Anna Bridge 186:707f6e361f3e 341 * @rmtoll COMP2_CSR COMP2SPEED LL_COMP_GetPowerMode\n
Kojto 158:b23ee177fd68 342 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 343 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 344 * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED (1)
Kojto 158:b23ee177fd68 345 * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER (1)
Kojto 158:b23ee177fd68 346 *
Kojto 158:b23ee177fd68 347 * (1) Available only on COMP instance: COMP2.
Kojto 158:b23ee177fd68 348 */
Kojto 158:b23ee177fd68 349 __STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx)
Kojto 158:b23ee177fd68 350 {
Kojto 158:b23ee177fd68 351 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMP2SPEED));
Kojto 158:b23ee177fd68 352 }
Kojto 158:b23ee177fd68 353
Kojto 158:b23ee177fd68 354 /**
Kojto 158:b23ee177fd68 355 * @}
Kojto 158:b23ee177fd68 356 */
Kojto 158:b23ee177fd68 357
Kojto 158:b23ee177fd68 358 /** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs
Kojto 158:b23ee177fd68 359 * @{
Kojto 158:b23ee177fd68 360 */
Kojto 158:b23ee177fd68 361
Kojto 158:b23ee177fd68 362 /**
Kojto 158:b23ee177fd68 363 * @brief Set comparator inputs minus (inverting) and plus (non-inverting).
Kojto 158:b23ee177fd68 364 * @note This function shall only be used for COMP2.
Kojto 158:b23ee177fd68 365 * For setting COMP1 input it is recommended to use LL_COMP_SetInputMinus()
Kojto 158:b23ee177fd68 366 * Plus (non-inverting) input is not configurable on COMP1.
Kojto 158:b23ee177fd68 367 * Using this function for COMP1 will corrupt COMP1WM register
Kojto 158:b23ee177fd68 368 * @note On this STM32 serie, specificity if using COMP instance COMP2
Kojto 158:b23ee177fd68 369 * with COMP input based on VrefInt (VrefInt or subdivision
Kojto 158:b23ee177fd68 370 * of VrefInt): scaler bridge is based on VrefInt and requires
Kojto 158:b23ee177fd68 371 * to enable path from VrefInt (refer to literal
Kojto 158:b23ee177fd68 372 * SYSCFG_CFGR3_ENBUFLP_VREFINT_COMP).
Anna Bridge 186:707f6e361f3e 373 * @rmtoll COMP2_CSR COMP2INNSEL LL_COMP_ConfigInputs\n
Anna Bridge 186:707f6e361f3e 374 * COMP2_CSR COMP2INPSEL LL_COMP_ConfigInputs
Kojto 158:b23ee177fd68 375 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 376 * @param InputMinus This parameter can be one of the following values:
Kojto 158:b23ee177fd68 377 * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
Kojto 158:b23ee177fd68 378 * @arg @ref LL_COMP_INPUT_MINUS_IO1
Kojto 158:b23ee177fd68 379 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
Kojto 158:b23ee177fd68 380 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
Kojto 158:b23ee177fd68 381 * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
Kojto 158:b23ee177fd68 382 * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
Kojto 158:b23ee177fd68 383 * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
Kojto 158:b23ee177fd68 384 * @arg @ref LL_COMP_INPUT_MINUS_IO2
Kojto 158:b23ee177fd68 385 * @param InputPlus This parameter can be one of the following values:
Kojto 158:b23ee177fd68 386 * @arg @ref LL_COMP_INPUT_PLUS_IO1 (1)
Kojto 158:b23ee177fd68 387 * @arg @ref LL_COMP_INPUT_PLUS_IO2 (1)
Kojto 158:b23ee177fd68 388 * @arg @ref LL_COMP_INPUT_PLUS_IO3 (1)
Kojto 158:b23ee177fd68 389 * @arg @ref LL_COMP_INPUT_PLUS_IO4 (1)
Kojto 158:b23ee177fd68 390 * @arg @ref LL_COMP_INPUT_PLUS_IO5 (1)
Kojto 158:b23ee177fd68 391 * @arg @ref LL_COMP_INPUT_PLUS_IO6 (1)(2)
Kojto 158:b23ee177fd68 392 *
Kojto 158:b23ee177fd68 393 * (1) Available only on COMP instance: COMP2.
Kojto 158:b23ee177fd68 394 * (2) Available only on devices STM32L0 category 1.
Kojto 158:b23ee177fd68 395 * @retval None
Kojto 158:b23ee177fd68 396 */
Kojto 158:b23ee177fd68 397 __STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus)
Kojto 158:b23ee177fd68 398 {
Kojto 158:b23ee177fd68 399 MODIFY_REG(COMPx->CSR,
Kojto 158:b23ee177fd68 400 COMP_CSR_COMP2INNSEL | COMP_CSR_COMP2INPSEL,
Kojto 158:b23ee177fd68 401 InputMinus | InputPlus);
Kojto 158:b23ee177fd68 402 }
Kojto 158:b23ee177fd68 403
Kojto 158:b23ee177fd68 404 /**
Kojto 158:b23ee177fd68 405 * @brief Set comparator input plus (non-inverting).
Kojto 158:b23ee177fd68 406 * @note Only COMP2 allows to set the input plus (non-inverting).
Kojto 158:b23ee177fd68 407 * For COMP1 it is always PA1 IO, except when Windows Mode is selected.
Anna Bridge 186:707f6e361f3e 408 * @rmtoll COMP2_CSR COMP2INPSEL LL_COMP_SetInputPlus
Kojto 158:b23ee177fd68 409 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 410 * @param InputPlus This parameter can be one of the following values:
Kojto 158:b23ee177fd68 411 * @arg @ref LL_COMP_INPUT_PLUS_IO1 (1)
Kojto 158:b23ee177fd68 412 * @arg @ref LL_COMP_INPUT_PLUS_IO2 (1)
Kojto 158:b23ee177fd68 413 * @arg @ref LL_COMP_INPUT_PLUS_IO3 (1)
Kojto 158:b23ee177fd68 414 * @arg @ref LL_COMP_INPUT_PLUS_IO4 (1)
Kojto 158:b23ee177fd68 415 * @arg @ref LL_COMP_INPUT_PLUS_IO5 (1)
Kojto 158:b23ee177fd68 416 * @arg @ref LL_COMP_INPUT_PLUS_IO6 (1)(2)
Kojto 158:b23ee177fd68 417 *
Kojto 158:b23ee177fd68 418 * (1) Available only on COMP instance: COMP2.
Kojto 158:b23ee177fd68 419 * (2) Available only on devices STM32L0 category 1.
Kojto 158:b23ee177fd68 420 * @retval None
Kojto 158:b23ee177fd68 421 */
Kojto 158:b23ee177fd68 422 __STATIC_INLINE void LL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus)
Kojto 158:b23ee177fd68 423 {
Kojto 158:b23ee177fd68 424 MODIFY_REG(COMPx->CSR, COMP_CSR_COMP2INPSEL, InputPlus);
Kojto 158:b23ee177fd68 425 }
Kojto 158:b23ee177fd68 426
Kojto 158:b23ee177fd68 427 /**
Kojto 158:b23ee177fd68 428 * @brief Get comparator input plus (non-inverting).
Kojto 158:b23ee177fd68 429 * @note Only COMP2 allows to set the input plus (non-inverting).
Kojto 158:b23ee177fd68 430 * For COMP1 it is always PA1 IO, except when Windows Mode is selected.
Anna Bridge 186:707f6e361f3e 431 * @rmtoll COMP2_CSR COMP2INPSEL LL_COMP_GetInputPlus
Kojto 158:b23ee177fd68 432 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 433 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 434 * @arg @ref LL_COMP_INPUT_PLUS_IO1 (1)
Kojto 158:b23ee177fd68 435 * @arg @ref LL_COMP_INPUT_PLUS_IO2 (1)
Kojto 158:b23ee177fd68 436 * @arg @ref LL_COMP_INPUT_PLUS_IO3 (1)
Kojto 158:b23ee177fd68 437 * @arg @ref LL_COMP_INPUT_PLUS_IO4 (1)
Kojto 158:b23ee177fd68 438 * @arg @ref LL_COMP_INPUT_PLUS_IO5 (1)
Kojto 158:b23ee177fd68 439 * @arg @ref LL_COMP_INPUT_PLUS_IO6 (1)(2)
Kojto 158:b23ee177fd68 440 *
Kojto 158:b23ee177fd68 441 * (1) Available only on COMP instance: COMP2.
Kojto 158:b23ee177fd68 442 * (2) Available only on devices STM32L0 category 1.
Kojto 158:b23ee177fd68 443 */
Kojto 158:b23ee177fd68 444 __STATIC_INLINE uint32_t LL_COMP_GetInputPlus(COMP_TypeDef *COMPx)
Kojto 158:b23ee177fd68 445 {
Kojto 158:b23ee177fd68 446 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMP2INPSEL));
Kojto 158:b23ee177fd68 447 }
Kojto 158:b23ee177fd68 448
Kojto 158:b23ee177fd68 449 /**
Kojto 158:b23ee177fd68 450 * @brief Set comparator input minus (inverting).
Kojto 158:b23ee177fd68 451 * @note In case of comparator input selected to be connected to IO:
Kojto 158:b23ee177fd68 452 * GPIO pins are specific to each comparator instance.
Kojto 158:b23ee177fd68 453 * Refer to description of parameters or to reference manual.
Kojto 158:b23ee177fd68 454 * @note On this STM32 serie, specificity if using COMP instance COMP2
Kojto 158:b23ee177fd68 455 * with COMP input based on VrefInt (VrefInt or subdivision
Kojto 158:b23ee177fd68 456 * of VrefInt): scaler bridge is based on VrefInt and requires
Kojto 158:b23ee177fd68 457 * to enable path from VrefInt (refer to literal
Kojto 158:b23ee177fd68 458 * SYSCFG_CFGR3_ENBUFLP_VREFINT_COMP).
Anna Bridge 186:707f6e361f3e 459 * @rmtoll COMP1_CSR COMP1INNSEL LL_COMP_SetInputMinus\n
Anna Bridge 186:707f6e361f3e 460 * COMP2_CSR COMP2INNSEL LL_COMP_SetInputMinus
Kojto 158:b23ee177fd68 461 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 462 * @param InputMinus This parameter can be one of the following values:
Kojto 158:b23ee177fd68 463 * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
Kojto 158:b23ee177fd68 464 * @arg @ref LL_COMP_INPUT_MINUS_IO1
Kojto 158:b23ee177fd68 465 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
Kojto 158:b23ee177fd68 466 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
Kojto 158:b23ee177fd68 467 * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT (*)
Kojto 158:b23ee177fd68 468 * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT (*)
Kojto 158:b23ee177fd68 469 * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT (*)
Kojto 158:b23ee177fd68 470 * @arg @ref LL_COMP_INPUT_MINUS_IO2 (*)
Kojto 158:b23ee177fd68 471 *
Kojto 158:b23ee177fd68 472 * (*) Available only on COMP instance: COMP2.
Kojto 158:b23ee177fd68 473 * @retval None
Kojto 158:b23ee177fd68 474 */
Kojto 158:b23ee177fd68 475 __STATIC_INLINE void LL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus)
Kojto 158:b23ee177fd68 476 {
Kojto 158:b23ee177fd68 477 MODIFY_REG(COMPx->CSR, COMP_CSR_COMP2INNSEL, InputMinus);
Kojto 158:b23ee177fd68 478 }
Kojto 158:b23ee177fd68 479
Kojto 158:b23ee177fd68 480 /**
Kojto 158:b23ee177fd68 481 * @brief Get comparator input minus (inverting).
Kojto 158:b23ee177fd68 482 * @note In case of comparator input selected to be connected to IO:
Kojto 158:b23ee177fd68 483 * GPIO pins are specific to each comparator instance.
Kojto 158:b23ee177fd68 484 * Refer to description of parameters or to reference manual.
Anna Bridge 186:707f6e361f3e 485 * @rmtoll COMP1_CSR COMP1INNSEL LL_COMP_GetInputMinus\n
Anna Bridge 186:707f6e361f3e 486 * COMP2_CSR COMP2INNSEL LL_COMP_GetInputMinus
Kojto 158:b23ee177fd68 487 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 488 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 489 * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
Kojto 158:b23ee177fd68 490 * @arg @ref LL_COMP_INPUT_MINUS_IO1
Kojto 158:b23ee177fd68 491 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
Kojto 158:b23ee177fd68 492 * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
Kojto 158:b23ee177fd68 493 * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT (*)
Kojto 158:b23ee177fd68 494 * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT (*)
Kojto 158:b23ee177fd68 495 * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT (*)
Kojto 158:b23ee177fd68 496 * @arg @ref LL_COMP_INPUT_MINUS_IO2 (*)
Kojto 158:b23ee177fd68 497 *
Kojto 158:b23ee177fd68 498 * (*) Available only on COMP instance: COMP2.
Kojto 158:b23ee177fd68 499 */
Kojto 158:b23ee177fd68 500 __STATIC_INLINE uint32_t LL_COMP_GetInputMinus(COMP_TypeDef *COMPx)
Kojto 158:b23ee177fd68 501 {
Kojto 158:b23ee177fd68 502 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMP2INNSEL));
Kojto 158:b23ee177fd68 503 }
Kojto 158:b23ee177fd68 504
Kojto 158:b23ee177fd68 505 /**
Kojto 158:b23ee177fd68 506 * @}
Kojto 158:b23ee177fd68 507 */
Kojto 158:b23ee177fd68 508
Kojto 158:b23ee177fd68 509 /** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output
Kojto 158:b23ee177fd68 510 * @{
Kojto 158:b23ee177fd68 511 */
Kojto 158:b23ee177fd68 512
Kojto 158:b23ee177fd68 513 /**
Kojto 158:b23ee177fd68 514 * @brief Set comparator output LPTIM.
Anna Bridge 186:707f6e361f3e 515 * @rmtoll COMP1_CSR COMP1LPTIMIN1 LL_COMP_SetOutputLPTIM\n
Anna Bridge 186:707f6e361f3e 516 * COMP2_CSR COMP2LPTIMIN1 LL_COMP_SetOutputLPTIM\n
Anna Bridge 186:707f6e361f3e 517 * COMP2_CSR COMP2LPTIMIN2 LL_COMP_SetOutputLPTIM
Kojto 158:b23ee177fd68 518 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 519 * @param OutputLptim This parameter can be one of the following values:
Kojto 158:b23ee177fd68 520 * @arg @ref LL_COMP_OUTPUT_LPTIM1_IN1_COMP1 (*)
Kojto 158:b23ee177fd68 521 * @arg @ref LL_COMP_OUTPUT_LPTIM1_IN1_COMP2 (**)
Kojto 158:b23ee177fd68 522 * @arg @ref LL_COMP_OUTPUT_LPTIM1_IN2_COMP2 (**)
Kojto 158:b23ee177fd68 523 *
Kojto 158:b23ee177fd68 524 * (*) Available only on COMP instance: COMP1.\n
Kojto 158:b23ee177fd68 525 * (**) Available only on COMP instance: COMP2.
Kojto 158:b23ee177fd68 526 * @retval None
Kojto 158:b23ee177fd68 527 */
Kojto 158:b23ee177fd68 528 __STATIC_INLINE void LL_COMP_SetOutputLPTIM(COMP_TypeDef *COMPx, uint32_t OutputLptim)
Kojto 158:b23ee177fd68 529 {
Kojto 158:b23ee177fd68 530 MODIFY_REG(COMPx->CSR, (COMP_CSR_COMP1LPTIM1IN1 | COMP_CSR_COMP2LPTIM1IN1 | COMP_CSR_COMP2LPTIM1IN2), OutputLptim);
Kojto 158:b23ee177fd68 531 }
Kojto 158:b23ee177fd68 532
Kojto 158:b23ee177fd68 533 /**
Kojto 158:b23ee177fd68 534 * @brief Get comparator output LPTIM.
Anna Bridge 186:707f6e361f3e 535 * @rmtoll COMP1_CSR COMP1LPTIMIN1 LL_COMP_GetOutputLPTIM\n
Anna Bridge 186:707f6e361f3e 536 * COMP2_CSR COMP2LPTIMIN1 LL_COMP_GetOutputLPTIM\n
Anna Bridge 186:707f6e361f3e 537 * COMP2_CSR COMP2LPTIMIN2 LL_COMP_GetOutputLPTIM
Kojto 158:b23ee177fd68 538 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 539 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 540 * @arg @ref LL_COMP_OUTPUT_LPTIM1_IN1_COMP1 (*)
Kojto 158:b23ee177fd68 541 * @arg @ref LL_COMP_OUTPUT_LPTIM1_IN1_COMP2 (**)
Kojto 158:b23ee177fd68 542 * @arg @ref LL_COMP_OUTPUT_LPTIM1_IN2_COMP2 (**)
Kojto 158:b23ee177fd68 543 *
Kojto 158:b23ee177fd68 544 * (*) Available only on COMP instance: COMP1.\n
Kojto 158:b23ee177fd68 545 * (**) Available only on COMP instance: COMP2.
Kojto 158:b23ee177fd68 546 */
Kojto 158:b23ee177fd68 547 __STATIC_INLINE uint32_t LL_COMP_GetOutputLPTIM(COMP_TypeDef *COMPx)
Kojto 158:b23ee177fd68 548 {
Kojto 158:b23ee177fd68 549 return (uint32_t)(READ_BIT(COMPx->CSR, (COMP_CSR_COMP1LPTIM1IN1 | COMP_CSR_COMP2LPTIM1IN1 | COMP_CSR_COMP2LPTIM1IN2)));
Kojto 158:b23ee177fd68 550 }
Kojto 158:b23ee177fd68 551
Kojto 158:b23ee177fd68 552 /**
Kojto 158:b23ee177fd68 553 * @brief Set comparator instance output polarity.
Kojto 158:b23ee177fd68 554 * @rmtoll COMP COMP1POLARITY LL_COMP_SetOutputPolarity
Kojto 158:b23ee177fd68 555 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 556 * @param OutputPolarity This parameter can be one of the following values:
Kojto 158:b23ee177fd68 557 * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
Kojto 158:b23ee177fd68 558 * @arg @ref LL_COMP_OUTPUTPOL_INVERTED
Kojto 158:b23ee177fd68 559 * @retval None
Kojto 158:b23ee177fd68 560 */
Kojto 158:b23ee177fd68 561 __STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity)
Kojto 158:b23ee177fd68 562 {
Kojto 158:b23ee177fd68 563 MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxPOLARITY, OutputPolarity);
Kojto 158:b23ee177fd68 564 }
Kojto 158:b23ee177fd68 565
Kojto 158:b23ee177fd68 566 /**
Kojto 158:b23ee177fd68 567 * @brief Get comparator instance output polarity.
Kojto 158:b23ee177fd68 568 * @rmtoll COMP COMP1POLARITY LL_COMP_GetOutputPolarity
Kojto 158:b23ee177fd68 569 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 570 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 571 * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
Kojto 158:b23ee177fd68 572 * @arg @ref LL_COMP_OUTPUTPOL_INVERTED
Kojto 158:b23ee177fd68 573 */
Kojto 158:b23ee177fd68 574 __STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
Kojto 158:b23ee177fd68 575 {
Kojto 158:b23ee177fd68 576 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxPOLARITY));
Kojto 158:b23ee177fd68 577 }
Kojto 158:b23ee177fd68 578
Kojto 158:b23ee177fd68 579 /**
Kojto 158:b23ee177fd68 580 * @}
Kojto 158:b23ee177fd68 581 */
Kojto 158:b23ee177fd68 582
Kojto 158:b23ee177fd68 583 /** @defgroup COMP_LL_EF_Operation Operation on comparator instance
Kojto 158:b23ee177fd68 584 * @{
Kojto 158:b23ee177fd68 585 */
Kojto 158:b23ee177fd68 586
Kojto 158:b23ee177fd68 587 /**
Kojto 158:b23ee177fd68 588 * @brief Enable comparator instance.
Kojto 158:b23ee177fd68 589 * @note After enable from off state, comparator requires a delay
Kojto 158:b23ee177fd68 590 * to reach reach propagation delay specification.
Kojto 158:b23ee177fd68 591 * Refer to device datasheet, parameter "tSTART".
Anna Bridge 186:707f6e361f3e 592 * @rmtoll COMP1_CSR COMP1EN LL_COMP_Enable\n
Anna Bridge 186:707f6e361f3e 593 * COMP2_CSR COMP2EN LL_COMP_Enable
Kojto 158:b23ee177fd68 594 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 595 * @retval None
Kojto 158:b23ee177fd68 596 */
Kojto 158:b23ee177fd68 597 __STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx)
Kojto 158:b23ee177fd68 598 {
Kojto 158:b23ee177fd68 599 SET_BIT(COMPx->CSR, COMP_CSR_COMPxEN);
Kojto 158:b23ee177fd68 600 }
Kojto 158:b23ee177fd68 601
Kojto 158:b23ee177fd68 602 /**
Kojto 158:b23ee177fd68 603 * @brief Disable comparator instance.
Anna Bridge 186:707f6e361f3e 604 * @rmtoll COMP1_CSR COMP1EN LL_COMP_Disable\n
Anna Bridge 186:707f6e361f3e 605 * COMP2_CSR COMP2EN LL_COMP_Disable
Kojto 158:b23ee177fd68 606 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 607 * @retval None
Kojto 158:b23ee177fd68 608 */
Kojto 158:b23ee177fd68 609 __STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx)
Kojto 158:b23ee177fd68 610 {
Kojto 158:b23ee177fd68 611 CLEAR_BIT(COMPx->CSR, COMP_CSR_COMPxEN);
Kojto 158:b23ee177fd68 612 }
Kojto 158:b23ee177fd68 613
Kojto 158:b23ee177fd68 614 /**
Kojto 158:b23ee177fd68 615 * @brief Get comparator enable state
Kojto 158:b23ee177fd68 616 * (0: COMP is disabled, 1: COMP is enabled)
Anna Bridge 186:707f6e361f3e 617 * @rmtoll COMP1_CSR COMP1EN LL_COMP_IsEnabled\n
Anna Bridge 186:707f6e361f3e 618 * COMP2_CSR COMP2EN LL_COMP_IsEnabled
Kojto 158:b23ee177fd68 619 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 620 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 621 */
Kojto 158:b23ee177fd68 622 __STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx)
Kojto 158:b23ee177fd68 623 {
Kojto 158:b23ee177fd68 624 return (READ_BIT(COMPx->CSR, COMP_CSR_COMPxEN) == (COMP_CSR_COMPxEN));
Kojto 158:b23ee177fd68 625 }
Kojto 158:b23ee177fd68 626
Kojto 158:b23ee177fd68 627 /**
Kojto 158:b23ee177fd68 628 * @brief Lock comparator instance.
Kojto 158:b23ee177fd68 629 * @note Once locked, comparator configuration can be accessed in read-only.
Kojto 158:b23ee177fd68 630 * @note The only way to unlock the comparator is a device hardware reset.
Anna Bridge 186:707f6e361f3e 631 * @rmtoll COMP1_CSR COMP1LOCK LL_COMP_Lock\n
Anna Bridge 186:707f6e361f3e 632 * COMP2_CSR COMP2LOCK LL_COMP_Lock
Kojto 158:b23ee177fd68 633 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 634 * @retval None
Kojto 158:b23ee177fd68 635 */
Kojto 158:b23ee177fd68 636 __STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx)
Kojto 158:b23ee177fd68 637 {
Kojto 158:b23ee177fd68 638 SET_BIT(COMPx->CSR, COMP_CSR_COMPxLOCK);
Kojto 158:b23ee177fd68 639 }
Kojto 158:b23ee177fd68 640
Kojto 158:b23ee177fd68 641 /**
Kojto 158:b23ee177fd68 642 * @brief Get comparator lock state
Kojto 158:b23ee177fd68 643 * (0: COMP is unlocked, 1: COMP is locked).
Kojto 158:b23ee177fd68 644 * @note Once locked, comparator configuration can be accessed in read-only.
Kojto 158:b23ee177fd68 645 * @note The only way to unlock the comparator is a device hardware reset.
Anna Bridge 186:707f6e361f3e 646 * @rmtoll COMP1_CSR COMP1LOCK LL_COMP_IsLocked\n
Anna Bridge 186:707f6e361f3e 647 * COMP2_CSR COMP2LOCK LL_COMP_IsLocked
Kojto 158:b23ee177fd68 648 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 649 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 650 */
Kojto 158:b23ee177fd68 651 __STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
Kojto 158:b23ee177fd68 652 {
Kojto 158:b23ee177fd68 653 return (READ_BIT(COMPx->CSR, COMP_CSR_COMPxLOCK) == (COMP_CSR_COMPxLOCK));
Kojto 158:b23ee177fd68 654 }
Kojto 158:b23ee177fd68 655
Kojto 158:b23ee177fd68 656 /**
Kojto 158:b23ee177fd68 657 * @brief Read comparator instance output level.
Kojto 158:b23ee177fd68 658 * @note The comparator output level depends on the selected polarity
Kojto 158:b23ee177fd68 659 * (Refer to function @ref LL_COMP_SetOutputPolarity()).
Kojto 158:b23ee177fd68 660 * If the comparator polarity is not inverted:
Kojto 158:b23ee177fd68 661 * - Comparator output is low when the input plus
Kojto 158:b23ee177fd68 662 * is at a lower voltage than the input minus
Kojto 158:b23ee177fd68 663 * - Comparator output is high when the input plus
Kojto 158:b23ee177fd68 664 * is at a higher voltage than the input minus
Kojto 158:b23ee177fd68 665 * If the comparator polarity is inverted:
Kojto 158:b23ee177fd68 666 * - Comparator output is high when the input plus
Kojto 158:b23ee177fd68 667 * is at a lower voltage than the input minus
Kojto 158:b23ee177fd68 668 * - Comparator output is low when the input plus
Kojto 158:b23ee177fd68 669 * is at a higher voltage than the input minus
Anna Bridge 186:707f6e361f3e 670 * @rmtoll COMP1_CSR COMP1VALUE LL_COMP_ReadOutputLevel\n
Anna Bridge 186:707f6e361f3e 671 * COMP2_CSR COMP2VALUE LL_COMP_ReadOutputLevel
Kojto 158:b23ee177fd68 672 * @param COMPx Comparator instance
Kojto 158:b23ee177fd68 673 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 674 * @arg @ref LL_COMP_OUTPUT_LEVEL_LOW
Kojto 158:b23ee177fd68 675 * @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH
Kojto 158:b23ee177fd68 676 */
Kojto 158:b23ee177fd68 677 __STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
Kojto 158:b23ee177fd68 678 {
Kojto 158:b23ee177fd68 679 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxOUTVALUE)
Kojto 158:b23ee177fd68 680 >> LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS);
Kojto 158:b23ee177fd68 681 }
Kojto 158:b23ee177fd68 682
Kojto 158:b23ee177fd68 683 /**
Kojto 158:b23ee177fd68 684 * @}
Kojto 158:b23ee177fd68 685 */
Kojto 158:b23ee177fd68 686
Kojto 158:b23ee177fd68 687 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 688 /** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions
Kojto 158:b23ee177fd68 689 * @{
Kojto 158:b23ee177fd68 690 */
Kojto 158:b23ee177fd68 691
Kojto 158:b23ee177fd68 692 ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx);
Kojto 158:b23ee177fd68 693 ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct);
Kojto 158:b23ee177fd68 694 void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct);
Kojto 158:b23ee177fd68 695
Kojto 158:b23ee177fd68 696 /**
Kojto 158:b23ee177fd68 697 * @}
Kojto 158:b23ee177fd68 698 */
Kojto 158:b23ee177fd68 699 #endif /* USE_FULL_LL_DRIVER */
Kojto 158:b23ee177fd68 700
Kojto 158:b23ee177fd68 701 /**
Kojto 158:b23ee177fd68 702 * @}
Kojto 158:b23ee177fd68 703 */
Kojto 158:b23ee177fd68 704
Kojto 158:b23ee177fd68 705 /**
Kojto 158:b23ee177fd68 706 * @}
Kojto 158:b23ee177fd68 707 */
Kojto 158:b23ee177fd68 708
Kojto 158:b23ee177fd68 709 #endif /* COMP1 || COMP2 */
Kojto 158:b23ee177fd68 710
Kojto 158:b23ee177fd68 711 /**
Kojto 158:b23ee177fd68 712 * @}
Kojto 158:b23ee177fd68 713 */
Kojto 158:b23ee177fd68 714
Kojto 158:b23ee177fd68 715 #ifdef __cplusplus
Kojto 158:b23ee177fd68 716 }
Kojto 158:b23ee177fd68 717 #endif
Kojto 158:b23ee177fd68 718
Kojto 158:b23ee177fd68 719 #endif /* __STM32L0xx_LL_COMP_H */
Kojto 158:b23ee177fd68 720
Kojto 158:b23ee177fd68 721 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/