Hal Drivers for L4
Dependents: BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo
Fork of STM32L4xx_HAL_Driver by
stm32l4xx_ll_comp.h
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_ll_comp.h 00004 * @author MCD Application Team 00005 * @version V1.1.0 00006 * @date 16-September-2015 00007 * @brief Header file of COMP LL module. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 00038 /* Define to prevent recursive inclusion -------------------------------------*/ 00039 #ifndef __STM32L4xx_LL_COMP_H 00040 #define __STM32L4xx_LL_COMP_H 00041 00042 #ifdef __cplusplus 00043 extern "C" { 00044 #endif 00045 00046 /* Includes ------------------------------------------------------------------*/ 00047 #include "stm32l4xx.h" 00048 00049 /** @addtogroup STM32L4xx_LL_Driver 00050 * @{ 00051 */ 00052 00053 #if defined (COMP1) || defined (COMP2) 00054 00055 /** @defgroup COMP_LL COMP 00056 * @{ 00057 */ 00058 00059 /* Private types -------------------------------------------------------------*/ 00060 /* Private variables ---------------------------------------------------------*/ 00061 00062 /* Private constants ---------------------------------------------------------*/ 00063 00064 /* Private macros ------------------------------------------------------------*/ 00065 00066 /* Exported types ------------------------------------------------------------*/ 00067 /* Exported constants --------------------------------------------------------*/ 00068 00069 /** @defgroup COMP_LL_Exported_Constants COMP Exported Constants 00070 * @{ 00071 */ 00072 00073 00074 /** @defgroup COMP_LL_EC_POWERMODE POWERMODE 00075 * @{ 00076 */ 00077 #define LL_COMP_POWERMODE_HIGHSPEED ((uint32_t)0x00000000) /*!< High speed */ 00078 #define LL_COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_PWRMODE_0) /*!< Medium speed */ 00079 #define LL_COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_PWRMODE_1 | COMP_CSR_PWRMODE_0) /*!< Ultra-low power mode */ 00080 /** 00081 * @} 00082 */ 00083 00084 /** @defgroup COMP_LL_EC_WINDOWMODE WINDOWMODE 00085 * @{ 00086 */ 00087 #define LL_COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000) /*!< Window mode disable: Comparators 1 and 2 are independent (no input connection) */ 00088 #define LL_COMP_WINDOWMODE_ENABLE (COMP_CSR_WINMODE) /*!< Window mode enable: Comparators 1 and 2 have their input non-inverting connected together. The common input to be used is the one of COMP2, COMP1 non-inverting input is no more accessible. */ 00089 /** 00090 * @} 00091 */ 00092 00093 /** @defgroup COMP_LL_EC_INVERTINGINPUT INVERTINGINPUT 00094 * @{ 00095 */ 00096 #define LL_COMP_INVERTINGINPUT_1_4VREFINT ( COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< 1/4 VREFINT connected to comparator inverting input */ 00097 #define LL_COMP_INVERTINGINPUT_1_2VREFINT ( COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< 1/2 VREFINT connected to comparator inverting input */ 00098 #define LL_COMP_INVERTINGINPUT_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< 3/4 VREFINT connected to comparator inverting input */ 00099 #define LL_COMP_INVERTINGINPUT_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< VREFINT connected to comparator1 inverting input */ 00100 #define LL_COMP_INVERTINGINPUT_DAC1 (COMP_CSR_INMSEL_2 ) /*!< DAC_OUT1 connected to comparator inverting input */ 00101 #define LL_COMP_INVERTINGINPUT_DAC2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) /*!< DAC_OUT2 connected to comparator inverting input */ 00102 #define LL_COMP_INVERTINGINPUT_IO1 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 ) /*!< IO1 connected to comparator inverting input. On STM32L4: pin PB1 for COMP1, pin PB3 for COMP2. */ 00103 #define LL_COMP_INVERTINGINPUT_IO2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< IO2 connected to comparator inverting input. On STM32L4: pin PC4 for COMP1, pin PB7 for COMP2. */ 00104 /** 00105 * @} 00106 */ 00107 00108 /** @defgroup COMP_LL_EC_NONINVERTINGINPUT NONINVERTINGINPUT 00109 * @{ 00110 */ 00111 #define LL_COMP_NONINVERTINGINPUT_IO1 ((uint32_t)0x00000000) /*!< IO1 connected to comparator non inverting input. On STM32L4: pin PC5 for COMP1, pin PB4 for COMP2. */ 00112 #define LL_COMP_NONINVERTINGINPUT_IO2 (COMP_CSR_INPSEL) /*!< IO2 connected to comparator non inverting input. On STM32L4: pin PB2 for COMP1, pin PB6 for COMP2. */ 00113 /** 00114 * @} 00115 */ 00116 00117 /** @defgroup COMP_LL_EC_HYSTERESIS HYSTERESIS 00118 * @{ 00119 */ 00120 #define LL_COMP_HYSTERESIS_NONE ((uint32_t)0x00000000) /*!< No hysteresis */ 00121 #define LL_COMP_HYSTERESIS_LOW ( COMP_CSR_HYST_0) /*!< Hysteresis level low */ 00122 #define LL_COMP_HYSTERESIS_MEDIUM (COMP_CSR_HYST_1 ) /*!< Hysteresis level medium */ 00123 #define LL_COMP_HYSTERESIS_HIGH (COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level high */ 00124 /** 00125 * @} 00126 */ 00127 00128 /** @defgroup COMP_LL_EC_OUTPUTPOL OUTPUTPOL 00129 * @{ 00130 */ 00131 #define LL_COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output polarity is not inverted: comparator output is high when the non-inverting input is at a higher voltage than the inverting input */ 00132 #define LL_COMP_OUTPUTPOL_INVERTED (COMP_CSR_POLARITY) /*!< COMP output polarity is inverted: comparator output is low when the non-inverting input is at a lower voltage than the inverting input */ 00133 /** 00134 * @} 00135 */ 00136 00137 /** @defgroup COMP_LL_EC_BLANKINGSRC BLANKINGSRC 00138 * @{ 00139 */ 00140 #define LL_COMP_BLANKINGSRC_NONE ((uint32_t)0x00000000) /*!< No blanking source */ 00141 #define LL_COMP_BLANKINGSRC_TIM1_OC5 (COMP_CSR_BLANKING_0) /*!< Blanking source for COMP1: TIM1 OC5 selected as blanking source for comparator */ 00142 #define LL_COMP_BLANKINGSRC_TIM2_OC3 (COMP_CSR_BLANKING_1) /*!< Blanking source for COMP1: TIM2 OC3 selected as blanking source for comparator */ 00143 #define LL_COMP_BLANKINGSRC_TIM3_OC3 (COMP_CSR_BLANKING_2) /*!< Blanking source for COMP1: TIM3 OC3 selected as blanking source for compartor */ 00144 #define LL_COMP_BLANKINGSRC_TIM3_OC4 (COMP_CSR_BLANKING_0) /*!< Blanking source for COMP2: TIM3 OC4 selected as blanking source for comparator */ 00145 #define LL_COMP_BLANKINGSRC_TIM8_OC5 (COMP_CSR_BLANKING_1) /*!< Blanking source for COMP2: TIM8 OC5 selected as blanking source for comparator */ 00146 #define LL_COMP_BLANKINGSRC_TIM15_OC1 (COMP_CSR_BLANKING_2) /*!< Blanking source for COMP2: TIM15 OC1 selected as blanking source for comparator */ 00147 /** 00148 * @} 00149 */ 00150 00151 /** @defgroup COMP_LL_EC_OUTPUT_LEVEL OUTPUT LEVEL 00152 * @{ 00153 */ 00154 #define LL_COMP_OUTPUT_LEVEL_LOW (0x00000000) /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */ 00155 #define LL_COMP_OUTPUT_LEVEL_HIGH (COMP_CSR_VALUE) /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */ 00156 /** 00157 * @} 00158 */ 00159 00160 /** 00161 * @} 00162 */ 00163 00164 /* Exported macro ------------------------------------------------------------*/ 00165 /** @defgroup COMP_LL_Exported_Macros COMP Exported Macros 00166 * @{ 00167 */ 00168 /** @defgroup COMP_LL_EM_WRITE_READ Common Write and read registers macro 00169 * @{ 00170 */ 00171 /** 00172 * @brief Write a value in COMP register 00173 * @param __INSTANCE__ comparator instance 00174 * @param __REG__ Register to be written 00175 * @param __VALUE__ Value to be written in the register 00176 * @retval None 00177 */ 00178 #define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 00179 00180 /** 00181 * @brief Read a value in COMP register 00182 * @param __INSTANCE__ comparator instance 00183 * @param __REG__ Register to be read 00184 * @retval Register value 00185 */ 00186 #define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 00187 /** 00188 * @} 00189 */ 00190 00191 00192 /** 00193 * @} 00194 */ 00195 00196 /* Exported functions --------------------------------------------------------*/ 00197 /** @defgroup COMP_LL_Exported_Functions COMP Exported Functions 00198 * @{ 00199 */ 00200 /** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes 00201 * @{ 00202 */ 00203 /** 00204 * @brief Set comparator instance operating mode to adjust power and speed. 00205 * @rmtoll CSR PWRMODE LL_COMP_SetPowerMode 00206 * @param COMPx Comparator instance 00207 * @param PowerMode This parameter can be one of the following values: 00208 * @arg @ref LL_COMP_POWERMODE_HIGHSPEED 00209 * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED 00210 * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER 00211 * @retval None 00212 */ 00213 __STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode) 00214 { 00215 MODIFY_REG(COMPx->CSR, COMP_CSR_PWRMODE, PowerMode); 00216 } 00217 00218 /** 00219 * @brief Get comparator instance operating mode to adjust power and speed. 00220 * @rmtoll CSR PWRMODE LL_COMP_GetPowerMode 00221 * @param COMPx Comparator instance 00222 * @retval Returned value can be one of the following values: 00223 * @arg @ref LL_COMP_POWERMODE_HIGHSPEED 00224 * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED 00225 * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER 00226 */ 00227 __STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx) 00228 { 00229 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_PWRMODE)); 00230 } 00231 00232 /** 00233 * @brief Set window mode of the comparators. 00234 * @rmtoll CSR WINMODE LL_COMP_SetWindowMode 00235 * @param COMPx Comparator instance. 00236 * On this STM32 family, window mode can be set only from COMP instance: COMP2. 00237 * @param WindowMode This parameter can be one of the following values: 00238 * @arg @ref LL_COMP_WINDOWMODE_DISABLE 00239 * @arg @ref LL_COMP_WINDOWMODE_ENABLE 00240 * @retval None 00241 */ 00242 __STATIC_INLINE void LL_COMP_SetWindowMode(COMP_TypeDef *COMPx, uint32_t WindowMode) 00243 { 00244 MODIFY_REG(COMPx->CSR, COMP_CSR_WINMODE, WindowMode); 00245 } 00246 00247 /** 00248 * @brief Get window mode of the comparators. 00249 * @rmtoll CSR WINMODE LL_COMP_GetWindowMode 00250 * @param COMPx Comparator instance 00251 * On this STM32 family, window mode can be set only from COMP instance: COMP2. 00252 * @retval Returned value can be one of the following values: 00253 * @arg @ref LL_COMP_WINDOWMODE_DISABLE 00254 * @arg @ref LL_COMP_WINDOWMODE_ENABLE 00255 */ 00256 __STATIC_INLINE uint32_t LL_COMP_GetWindowMode(COMP_TypeDef *COMPx) 00257 { 00258 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_WINMODE)); 00259 } 00260 00261 /** 00262 * @} 00263 */ 00264 00265 /** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs 00266 * @{ 00267 */ 00268 /** 00269 * @brief Set COMP inputs inverting and non-inverting. 00270 * @note In case of comparator input selected to be connected to IO: 00271 * IP pins are specific to each comparator instance. 00272 * Refer to description of parameters or to reference manual. 00273 * @note On STM32L4, scaler bridge is configurable: 00274 * to optimize power consumption, this function enables the 00275 * voltage scaler bridge only when required (comparator input 00276 * based on VrefInt). 00277 * The scaler bridge is common for all comparator instances, 00278 * therefore if at least one of the comparator instance 00279 * is requiring the scaler bridge, it remains enabled. 00280 * @rmtoll CSR INMSEL LL_COMP_ConfigInputs\n 00281 * CSR INPSEL LL_COMP_ConfigInputs\n 00282 * CSR BRGEN LL_COMP_ConfigInputs\n 00283 * CSR SCALEN LL_COMP_ConfigInputs 00284 * @param COMPx Comparator instance 00285 * @param InputInverting This parameter can be one of the following values: 00286 * @arg @ref LL_COMP_INVERTINGINPUT_1_4VREFINT 00287 * @arg @ref LL_COMP_INVERTINGINPUT_1_2VREFINT 00288 * @arg @ref LL_COMP_INVERTINGINPUT_3_4VREFINT 00289 * @arg @ref LL_COMP_INVERTINGINPUT_VREFINT 00290 * @arg @ref LL_COMP_INVERTINGINPUT_DAC1 00291 * @arg @ref LL_COMP_INVERTINGINPUT_DAC2 00292 * @arg @ref LL_COMP_INVERTINGINPUT_IO1 00293 * @arg @ref LL_COMP_INVERTINGINPUT_IO2 00294 * @param InputNonInverting This parameter can be one of the following values: 00295 * @arg @ref LL_COMP_NONINVERTINGINPUT_IO1 00296 * @arg @ref LL_COMP_NONINVERTINGINPUT_IO2 00297 * @retval None 00298 */ 00299 __STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputInverting, uint32_t InputNonInverting) 00300 { 00301 MODIFY_REG(COMPx->CSR, COMP_CSR_INMSEL | COMP_CSR_INPSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN, InputInverting | InputNonInverting); 00302 } 00303 00304 /** 00305 * @brief Set COMP inputs non-inverting. 00306 * @note In case of comparator input selected to be connected to IO: 00307 * IP pins are specific to each comparator instance. 00308 * Refer to description of parameters or to reference manual. 00309 * @rmtoll CSR INMSEL LL_COMP_SetInputInverting 00310 * @param COMPx Comparator instance 00311 * @param InputNonInverting This parameter can be one of the following values: 00312 * @arg @ref LL_COMP_NONINVERTINGINPUT_IO1 00313 * @arg @ref LL_COMP_NONINVERTINGINPUT_IO2 00314 * @retval None 00315 */ 00316 __STATIC_INLINE void LL_COMP_SetInputNonInverting(COMP_TypeDef *COMPx, uint32_t InputNonInverting) 00317 { 00318 MODIFY_REG(COMPx->CSR, COMP_CSR_INPSEL, InputNonInverting); 00319 } 00320 00321 /** 00322 * @brief Get COMP input non-inverting. 00323 * @note In case of comparator input selected to be connected to IO: 00324 * IP pins are specific to each comparator instance. 00325 * Refer to description of parameters or to reference manual. 00326 * @rmtoll CSR INMSEL LL_COMP_GetInputInverting 00327 * @param COMPx Comparator instance 00328 * @retval Returned value can be one of the following values: 00329 * @arg @ref LL_COMP_NONINVERTINGINPUT_IO1 00330 * @arg @ref LL_COMP_NONINVERTINGINPUT_IO2 00331 */ 00332 __STATIC_INLINE uint32_t LL_COMP_GetInputNonInverting(COMP_TypeDef *COMPx) 00333 { 00334 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INPSEL)); 00335 } 00336 00337 /** 00338 * @brief Set COMP input inverting. 00339 * @note In case of comparator input selected to be connected to IO: 00340 * IP pins are specific to each comparator instance. 00341 * Refer to description of parameters or to reference manual. 00342 * @note On STM32L4, scaler bridge is configurable: 00343 * to optimize power consumption, this function enables the 00344 * voltage scaler bridge only when required (comparator input 00345 * based on VrefInt). 00346 * The scaler bridge is common for all comparator instances, 00347 * therefore if at least one of the comparator instance 00348 * is requiring the scaler bridge, it remains enabled. 00349 * @rmtoll CSR INPSEL LL_COMP_SetInputNonInverting\n 00350 * CSR BRGEN LL_COMP_SetInputNonInverting\n 00351 * CSR SCALEN LL_COMP_SetInputNonInverting 00352 * @param COMPx Comparator instance 00353 * @param InputInverting This parameter can be one of the following values: 00354 * @arg @ref LL_COMP_INVERTINGINPUT_1_4VREFINT 00355 * @arg @ref LL_COMP_INVERTINGINPUT_1_2VREFINT 00356 * @arg @ref LL_COMP_INVERTINGINPUT_3_4VREFINT 00357 * @arg @ref LL_COMP_INVERTINGINPUT_VREFINT 00358 * @arg @ref LL_COMP_INVERTINGINPUT_DAC1 00359 * @arg @ref LL_COMP_INVERTINGINPUT_DAC2 00360 * @arg @ref LL_COMP_INVERTINGINPUT_IO1 00361 * @arg @ref LL_COMP_INVERTINGINPUT_IO2 00362 * @retval None 00363 */ 00364 __STATIC_INLINE void LL_COMP_SetInputInverting(COMP_TypeDef *COMPx, uint32_t InputInverting) 00365 { 00366 MODIFY_REG(COMPx->CSR, COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN, InputInverting); 00367 } 00368 00369 /** 00370 * @brief Get COMP input inverting. 00371 * @note In case of comparator input selected to be connected to IO: 00372 * IP pins are specific to each comparator instance. 00373 * Refer to description of parameters or to reference manual. 00374 * @rmtoll CSR INPSEL LL_COMP_GetInputNonInverting\n 00375 * CSR BRGEN LL_COMP_GetInputNonInverting\n 00376 * CSR SCALEN LL_COMP_GetInputNonInverting 00377 * @param COMPx Comparator instance 00378 * @retval Returned value can be one of the following values: 00379 * @arg @ref LL_COMP_INVERTINGINPUT_1_4VREFINT 00380 * @arg @ref LL_COMP_INVERTINGINPUT_1_2VREFINT 00381 * @arg @ref LL_COMP_INVERTINGINPUT_3_4VREFINT 00382 * @arg @ref LL_COMP_INVERTINGINPUT_VREFINT 00383 * @arg @ref LL_COMP_INVERTINGINPUT_DAC1 00384 * @arg @ref LL_COMP_INVERTINGINPUT_DAC2 00385 * @arg @ref LL_COMP_INVERTINGINPUT_IO1 00386 * @arg @ref LL_COMP_INVERTINGINPUT_IO2 00387 */ 00388 __STATIC_INLINE uint32_t LL_COMP_GetInputInverting(COMP_TypeDef *COMPx) 00389 { 00390 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_INMSEL | COMP_CSR_SCALEN | COMP_CSR_BRGEN)); 00391 } 00392 00393 /** 00394 * @brief Set comparator instance hysteresis mode of the inverting input. 00395 * @rmtoll CSR HYST LL_COMP_SetInputHysteresis 00396 * @param COMPx Comparator instance 00397 * @param Hysteresis This parameter can be one of the following values: 00398 * @arg @ref LL_COMP_HYSTERESIS_NONE 00399 * @arg @ref LL_COMP_HYSTERESIS_LOW 00400 * @arg @ref LL_COMP_HYSTERESIS_MEDIUM 00401 * @arg @ref LL_COMP_HYSTERESIS_HIGH 00402 * @retval None 00403 */ 00404 __STATIC_INLINE void LL_COMP_SetInputHysteresis(COMP_TypeDef *COMPx, uint32_t Hysteresis) 00405 { 00406 MODIFY_REG(COMPx->CSR, COMP_CSR_HYST, Hysteresis); 00407 } 00408 00409 /** 00410 * @brief Get comparator instance hysteresis mode of the inverting input. 00411 * @rmtoll CSR HYST LL_COMP_GetInputHysteresis 00412 * @param COMPx Comparator instance 00413 * @retval Returned value can be one of the following values: 00414 * @arg @ref LL_COMP_HYSTERESIS_NONE 00415 * @arg @ref LL_COMP_HYSTERESIS_LOW 00416 * @arg @ref LL_COMP_HYSTERESIS_MEDIUM 00417 * @arg @ref LL_COMP_HYSTERESIS_HIGH 00418 */ 00419 __STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis(COMP_TypeDef *COMPx) 00420 { 00421 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_HYST)); 00422 } 00423 00424 /** 00425 * @} 00426 */ 00427 00428 /** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output 00429 * @{ 00430 */ 00431 /** 00432 * @brief Set comparator instance output polarity. 00433 * @rmtoll CSR POLARITY LL_COMP_SetOutputPolarity 00434 * @param COMPx Comparator instance 00435 * @param Polarity This parameter can be one of the following values: 00436 * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED 00437 * @arg @ref LL_COMP_OUTPUTPOL_INVERTED 00438 * @retval None 00439 */ 00440 __STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t Polarity) 00441 { 00442 MODIFY_REG(COMPx->CSR, COMP_CSR_POLARITY, Polarity); 00443 } 00444 00445 /** 00446 * @brief Get comparator instance output polarity. 00447 * @rmtoll CSR POLARITY LL_COMP_GetOutputPolarity 00448 * @param COMPx Comparator instance 00449 * @retval Returned value can be one of the following values: 00450 * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED 00451 * @arg @ref LL_COMP_OUTPUTPOL_INVERTED 00452 */ 00453 __STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx) 00454 { 00455 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_POLARITY)); 00456 } 00457 00458 /** 00459 * @brief Set comparator instance blanking source. 00460 * @note Blanking source may be specific to each comparator instance. 00461 * Refer to description of parameters or to reference manual. 00462 * @rmtoll CSR BLANKING LL_COMP_SetOutputBlankingSource 00463 * @param COMPx Comparator instance 00464 * @param BlankingSource This parameter can be one of the following values: 00465 * @arg @ref LL_COMP_BLANKINGSRC_NONE 00466 * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5 (1) 00467 * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3 (1) 00468 * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3 (1) 00469 * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4 (2) 00470 * @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5 (2) 00471 * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1 (2) 00472 * (1) On STM32L4, parameter available only on comparator instance: COMP1. 00473 * (2) On STM32L4, parameter available only on comparator instance: COMP2. 00474 * @retval None 00475 */ 00476 __STATIC_INLINE void LL_COMP_SetOutputBlankingSource(COMP_TypeDef *COMPx, uint32_t BlankingSource) 00477 { 00478 MODIFY_REG(COMPx->CSR, COMP_CSR_BLANKING, BlankingSource); 00479 } 00480 00481 /** 00482 * @brief Get comparator instance blanking source. 00483 * @note Blanking source may be specific to each comparator instance. 00484 * Refer to description of parameters or to reference manual. 00485 * @rmtoll CSR BLANKING LL_COMP_GetOutputBlankingSource 00486 * @param COMPx Comparator instance 00487 * @retval Returned value can be one of the following values: 00488 * @arg @ref LL_COMP_BLANKINGSRC_NONE 00489 * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5 (1) 00490 * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3 (1) 00491 * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3 (1) 00492 * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4 (2) 00493 * @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5 (2) 00494 * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1 (2) 00495 * (1) On STM32L4, parameter available only on comparator instance: COMP1. 00496 * (2) On STM32L4, parameter available only on comparator instance: COMP2. 00497 */ 00498 __STATIC_INLINE uint32_t LL_COMP_GetOutputBlankingSource(COMP_TypeDef *COMPx) 00499 { 00500 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_BLANKING)); 00501 } 00502 00503 /** 00504 * @} 00505 */ 00506 00507 /** @defgroup COMP_LL_EF_Operation Operation 00508 * @{ 00509 */ 00510 /** 00511 * @brief Enable comparator instance. 00512 * @rmtoll CSR EN LL_COMP_Enable 00513 * @param COMPx Comparator instance 00514 * @retval None 00515 */ 00516 __STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx) 00517 { 00518 SET_BIT(COMPx->CSR, COMP_CSR_EN); 00519 } 00520 00521 /** 00522 * @brief Disable comparator instance. 00523 * @rmtoll CSR EN LL_COMP_Disable 00524 * @param COMPx Comparator instance 00525 * @retval None 00526 */ 00527 __STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx) 00528 { 00529 CLEAR_BIT(COMPx->CSR, COMP_CSR_EN); 00530 } 00531 00532 /** 00533 * @brief Get COMP enable state 00534 * (0: COMP is disabled, 1: COMP is enabled) 00535 * @rmtoll CSR EN LL_COMP_IsEnabled 00536 * @param COMPx Comparator instance 00537 * @retval State of bit (1 or 0). 00538 */ 00539 __STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx) 00540 { 00541 return (READ_BIT(COMPx->CSR, COMP_CSR_EN) == (COMP_CSR_EN)); 00542 } 00543 00544 /** 00545 * @brief Lock comparator instance. 00546 * Once locked, comparator configuration can be accessed in read-only. 00547 * The only way to unlock the comparator is a device hardware reset. 00548 * @rmtoll CSR LOCK LL_COMP_Lock 00549 * @param COMPx Comparator instance 00550 * @retval None 00551 */ 00552 __STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx) 00553 { 00554 SET_BIT(COMPx->CSR, COMP_CSR_LOCK); 00555 } 00556 00557 /** 00558 * @brief Get COMP lock state. 00559 * (0: COMP is unlocked, 1: COMP is locked) 00560 * @rmtoll CSR LOCK LL_COMP_IsLocked 00561 * @param COMPx Comparator instance 00562 * @retval State of bit (1 or 0). 00563 */ 00564 __STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx) 00565 { 00566 return (READ_BIT(COMPx->CSR, COMP_CSR_LOCK) == (COMP_CSR_LOCK)); 00567 } 00568 00569 /** 00570 * @brief Read comparator instance output level. 00571 * The output level depends on the selected polarity. 00572 * If the polarity is not inverted: 00573 * - Comparator output is low when the non-inverting input is at a lower 00574 * voltage than the inverting input 00575 * - Comparator output is high when the non-inverting input is at a higher 00576 * voltage than the inverting input 00577 * If the polarity is inverted: 00578 * - Comparator output is high when the non-inverting input is at a lower 00579 * voltage than the inverting input 00580 * - Comparator output is low when the non-inverting input is at a higher 00581 * voltage than the inverting input 00582 * @rmtoll CSR VALUE LL_COMP_ReadOutputLevel 00583 * @param COMPx Comparator instance 00584 * @retval Returned value can be one of the following values: 00585 * @arg @ref LL_COMP_OUTPUT_LEVEL_LOW 00586 * @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH 00587 */ 00588 __STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx) 00589 { 00590 return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_VALUE)); 00591 } 00592 00593 /** 00594 * @} 00595 */ 00596 00597 00598 /** 00599 * @} 00600 */ 00601 00602 /** 00603 * @} 00604 */ 00605 00606 #endif /* COMP1 || COMP2 */ 00607 00608 /** 00609 * @} 00610 */ 00611 00612 #ifdef __cplusplus 00613 } 00614 #endif 00615 00616 #endif /* __STM32L4xx_LL_COMP_H */ 00617 00618 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00619
Generated on Tue Jul 12 2022 11:35:15 by 1.7.2