mbed library sources. Supersedes mbed-src.

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

Committer:
Kojto
Date:
Tue Feb 14 14:44:10 2017 +0000
Revision:
158:b23ee177fd68
Child:
186:707f6e361f3e
This updates the lib to the mbed lib v136

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