| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034 |
- /**
- ******************************************************************************
- * @file stm32f3xx_ll_comp.c
- * @author MCD Application Team
- * @brief COMP LL module driver
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2016 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
- #if defined(USE_FULL_LL_DRIVER)
- /* Includes ------------------------------------------------------------------*/
- #include "stm32f3xx_ll_comp.h"
- #ifdef USE_FULL_ASSERT
- #include "stm32_assert.h"
- #else
- #define assert_param(expr) ((void)0U)
- #endif
- /** @addtogroup STM32F3xx_LL_Driver
- * @{
- */
- /* Note: Devices of STM32F3 series embed 1 out of 2 different comparator IP. */
- /* - STM32F30x, STM32F31x, STM32F32x, STM32F33x, STM32F35x, STM32F39x: */
- /* COMP IP from 3 to 7 instances and other specific features */
- /* (comparator output blanking, ...) (refer to reference manual). */
- /* - STM32F37x: */
- /* COMP IP with 2 instances */
- /* This file contains the drivers of these COMP IP, located in 2 area */
- /* delimited by compilation switches. */
- #if defined(COMP_V1_3_0_0)
- #if defined (COMP1) || defined (COMP2) || defined (COMP3) || defined (COMP4) || defined (COMP5) || defined (COMP6) || defined (COMP7)
- /** @addtogroup COMP_LL COMP
- * @{
- */
- /* Private types -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- /* Private constants ---------------------------------------------------------*/
- /* Private macros ------------------------------------------------------------*/
- /** @addtogroup COMP_LL_Private_Macros
- * @{
- */
- /* Check of parameters for configuration of COMP hierarchical scope: */
- /* COMP instance. */
- #if defined(COMP_CSR_COMPxMODE)
- #define IS_LL_COMP_POWER_MODE(__POWER_MODE__) \
- ( ((__POWER_MODE__) == LL_COMP_POWERMODE_HIGHSPEED) \
- || ((__POWER_MODE__) == LL_COMP_POWERMODE_MEDIUMSPEED) \
- || ((__POWER_MODE__) == LL_COMP_POWERMODE_LOWPOWER) \
- || ((__POWER_MODE__) == LL_COMP_POWERMODE_ULTRALOWPOWER) \
- )
- #else
- #define IS_LL_COMP_POWER_MODE(__POWER_MODE__) \
- ((__POWER_MODE__) == LL_COMP_POWERMODE_HIGHSPEED)
- #endif
- /* Note: On this STM32 series, comparator input plus parameters are */
- /* the same on all COMP instances. */
- /* However, comparator instance kept as macro parameter for */
- /* compatibility with other STM32 families. */
- #if defined(COMP_CSR_COMPxNONINSEL) && defined(LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1)
- /* Note: On devices where bit COMP_CSR_COMPxNONINSEL is available, */
- /* feature LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 is also available. */
- #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \
- ( ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \
- || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO2) \
- || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1) \
- )
- #elif defined(COMP_CSR_COMPxNONINSEL) && defined(LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2)
- /* Note: On devices where bit COMP_CSR_COMPxNONINSEL is available, */
- /* feature LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 is also available. */
- #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \
- ( ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \
- || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO2) \
- || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2) \
- )
- #elif defined(COMP_CSR_COMPxNONINSEL)
- #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \
- ( ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \
- || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO2) \
- )
- #elif defined(LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2)
- /* Note: On devices where bit COMP_CSR_COMPxNONINSEL is available, */
- /* feature LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 is also available. */
- #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \
- ( ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \
- || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2) \
- )
- #else
- /* Note: Device without comparator input plus configurable: corresponds to */
- /* setting "LL_COMP_INPUT_PLUS_IO1" or "LL_COMP_INPUT_PLUS_IO2" */
- /* compared to other STM32F3 devices, depending on comparator instance */
- /* (refer to reference manual). */
- #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \
- ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1)
- #endif
- #if defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303xE) || defined(STM32F398xx)
- #define IS_LL_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) \
- ( ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_4VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_2VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_3_4VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH1) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH2) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO1) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO2) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO3) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO4) \
- )
- #elif defined(STM32F303x8) || defined(STM32F328xx) || defined(STM32F334x8)
- #define IS_LL_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) \
- ( ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_4VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_2VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_3_4VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH1) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH2) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO1) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO2) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO4) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC2_CH1) \
- )
- #elif defined(STM32F302xC) || defined(STM32F302xE)
- #define IS_LL_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) \
- ( ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_4VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_2VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_3_4VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH1) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO1) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO2) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO3) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO4) \
- )
- #else /* STM32F301x8 || STM32F318xx || STM32F302x8 */
- #define IS_LL_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) \
- ( ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_4VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_2VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_3_4VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH1) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO1) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO2) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO4) \
- )
- #endif
- #if defined(COMP_CSR_COMPxHYST)
- #define IS_LL_COMP_INPUT_HYSTERESIS(__INPUT_HYSTERESIS__) \
- ( ((__INPUT_HYSTERESIS__) == LL_COMP_HYSTERESIS_NONE) \
- || ((__INPUT_HYSTERESIS__) == LL_COMP_HYSTERESIS_LOW) \
- || ((__INPUT_HYSTERESIS__) == LL_COMP_HYSTERESIS_MEDIUM) \
- || ((__INPUT_HYSTERESIS__) == LL_COMP_HYSTERESIS_HIGH) \
- )
- #else
- #define IS_LL_COMP_INPUT_HYSTERESIS(__INPUT_HYSTERESIS__) \
- ((__INPUT_HYSTERESIS__) == LL_COMP_HYSTERESIS_NONE)
- #endif
- #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
- #define IS_LL_COMP_OUTPUT_SELECTION(__COMP_INSTANCE__, __OUTPUT_SELECTION__) \
- (( ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_NONE) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_BKIN) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_BKIN2) \
- ) \
- ? ( \
- (1U) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP2) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_IC1_COMP2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC4_COMP2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_OCCLR_COMP2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP2) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP4) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_IC2_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_OCCLR_COMP4) \
- ) \
- : \
- ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC2_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_IC1_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_OCCLR_COMP6) \
- ) \
- ) \
- ) \
- )
- #elif defined(STM32F303x8) || defined(STM32F328xx) || defined(STM32F334x8)
- #define IS_LL_COMP_OUTPUT_SELECTION(__COMP_INSTANCE__, __OUTPUT_SELECTION__) \
- (( ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_NONE) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_BKIN) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_BKIN2) \
- ) \
- ? ( \
- (1U) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP2) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP2_4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_IC1_COMP2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC4_COMP2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_OCCLR_COMP2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC1_COMP2) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP4) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP2_4)\
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC3_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_IC2_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_OCCLR_COMP4) \
- ) \
- : \
- ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC2_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_IC1_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_OCCLR_COMP6) \
- ) \
- ) \
- ) \
- )
- #elif defined(STM32F302xC) || defined(STM32F302xE)
- #define IS_LL_COMP_OUTPUT_SELECTION(__COMP_INSTANCE__, __OUTPUT_SELECTION__) \
- (( ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_NONE) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_BKIN) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_BKIN2) \
- ) \
- ? ( \
- (1U) \
- ) \
- : \
- ((((__COMP_INSTANCE__) == COMP1) || ((__COMP_INSTANCE__) == COMP2)) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_IC1_COMP1_2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC4_COMP1_2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC1_COMP1_2) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP4) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC3_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC2_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_IC2_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_OCCLR_COMP4) \
- ) \
- : \
- ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC2_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC4_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_IC1_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_OCCLR_COMP6) \
- ) \
- ) \
- ) \
- )
- #elif defined(STM32F303xC) || defined(STM32F358xx)
- #define IS_LL_COMP_OUTPUT_SELECTION(__COMP_INSTANCE__, __OUTPUT_SELECTION__) \
- (( ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_NONE) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_BKIN) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_BKIN2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_TIM8_BKIN2) \
- ) \
- ? ( \
- (1U) \
- ) \
- : \
- ((((__COMP_INSTANCE__) == COMP1) || ((__COMP_INSTANCE__) == COMP2)) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_IC1_COMP1_2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC4_COMP1_2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC1_COMP1_2) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP3) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC2_COMP3) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC1_COMP3) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_IC1_COMP3) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_BKIN) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP4) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC3_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC2_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_IC2_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_OCCLR_COMP4) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP5) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC1_COMP5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC3_COMP5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM17_IC1_COMP5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_BKIN) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP6) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC2_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC4_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_IC1_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_OCCLR_COMP6) \
- ) \
- : \
- ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_IC2_COMP7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC3_COMP7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM17_OCCLR_COMP7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM17_BKIN) \
- ) \
- ) \
- ) \
- ) \
- ) \
- ) \
- )
- #elif defined(STM32F303xE) || defined(STM32F398xx)
- #define IS_LL_COMP_OUTPUT_SELECTION(__COMP_INSTANCE__, __OUTPUT_SELECTION__) \
- (( ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_NONE) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_BKIN) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_BKIN2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_TIM8_BKIN2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM20_BKIN) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM20_BKIN2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_TIM8_TIM20_BKIN2) \
- ) \
- ? ( \
- (1U) \
- ) \
- : \
- ((((__COMP_INSTANCE__) == COMP1) || ((__COMP_INSTANCE__) == COMP2)) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_IC1_COMP1_2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC4_COMP1_2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC1_COMP1_2) \
- || (((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM20_OCCLR_COMP2) \
- && ((__COMP_INSTANCE__) == COMP2) ) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP3) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC2_COMP3) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC1_COMP3) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_IC1_COMP3) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_BKIN) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP4) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC3_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC2_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_IC2_COMP4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM15_OCCLR_COMP4) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP5) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC1_COMP5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC3_COMP5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM17_IC1_COMP5) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_BKIN) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP6) \
- ? ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC2_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC4_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_IC1_COMP6) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_OCCLR_COMP6) \
- ) \
- : \
- ( \
- ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM1_IC2_COMP7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC3_COMP7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM17_OCCLR_COMP7) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM17_BKIN) \
- ) \
- ) \
- ) \
- ) \
- ) \
- ) \
- )
- #endif
- #define IS_LL_COMP_OUTPUT_POLARITY(__POLARITY__) \
- ( ((__POLARITY__) == LL_COMP_OUTPUTPOL_NONINVERTED) \
- || ((__POLARITY__) == LL_COMP_OUTPUTPOL_INVERTED) \
- )
- #if defined(COMP_CSR_COMPxBLANKING)
- #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
- #define IS_LL_COMP_OUTPUT_BLANKING_SOURCE(__COMP_INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
- (((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_NONE) \
- ? ( \
- (1U) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP2) \
- ? ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM1_OC5_COMP2) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM2_OC3_COMP2) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM3_OC3_COMP2) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP4) \
- ? ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4) \
- ) \
- : \
- ( \
- (((__COMP_INSTANCE__) == COMP6) \
- ? ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6) \
- ) \
- : \
- ( \
- (0U) \
- ) \
- ) \
- ) \
- ) \
- ) \
- )
- #elif defined(STM32F302xE) || defined(STM32F302xC)
- #define IS_LL_COMP_OUTPUT_BLANKING_SOURCE(__COMP_INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
- (((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_NONE) \
- ? ( \
- (1U) \
- ) \
- : \
- ((((__COMP_INSTANCE__) == COMP1) || ((__COMP_INSTANCE__) == COMP2)) \
- ? ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP4) \
- ? ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4) \
- ) \
- : \
- ( \
- (((__COMP_INSTANCE__) == COMP6) \
- ? ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6) \
- ) \
- : \
- ( \
- (0U) \
- ) \
- ) \
- ) \
- ) \
- ) \
- )
- #elif defined(STM32F303xE) || defined(STM32F398xx) || defined(STM32F303xC) || defined(STM32F358xx)
- #define IS_LL_COMP_OUTPUT_BLANKING_SOURCE(__COMP_INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
- (((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_NONE) \
- ? ( \
- (1U) \
- ) \
- : \
- ((((__COMP_INSTANCE__) == COMP1) || ((__COMP_INSTANCE__) == COMP2)) \
- ? ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2_7) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP3) \
- ? ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM2_OC4_COMP3_6) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP4) \
- ? ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP5) \
- ? ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7) \
- ) \
- : \
- (((__COMP_INSTANCE__) == COMP6) \
- ? ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM2_OC4_COMP3_6) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6_7) \
- ) \
- : \
- ( \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2_7) \
- || ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6_7) \
- ) \
- ) \
- ) \
- ) \
- ) \
- ) \
- )
- #endif
- #else
- #define IS_LL_COMP_OUTPUT_BLANKING_SOURCE(__COMP_INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
- ((__OUTPUT_BLANKING_SOURCE__) == LL_COMP_BLANKINGSRC_NONE)
- #endif
- /**
- * @}
- */
- /* Private function prototypes -----------------------------------------------*/
- /* Exported functions --------------------------------------------------------*/
- /** @addtogroup COMP_LL_Exported_Functions
- * @{
- */
- /** @addtogroup COMP_LL_EF_Init
- * @{
- */
- /**
- * @brief De-initialize registers of the selected COMP instance
- * to their default reset values.
- * @note If comparator is locked, de-initialization by software is
- * not possible.
- * The only way to unlock the comparator is a device hardware reset.
- * @param COMPx COMP instance
- * @retval An ErrorStatus enumeration value:
- * - SUCCESS: COMP registers are de-initialized
- * - ERROR: COMP registers are not de-initialized
- */
- ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx)
- {
- ErrorStatus status = SUCCESS;
- /* Check the parameters */
- assert_param(IS_COMP_ALL_INSTANCE(COMPx));
- /* Note: Hardware constraint (refer to description of this function): */
- /* COMP instance must not be locked. */
- if (LL_COMP_IsLocked(COMPx) == 0U)
- {
- LL_COMP_WriteReg(COMPx, CSR, 0x00000000U);
- }
- else
- {
- /* Comparator instance is locked: de-initialization by software is */
- /* not possible. */
- /* The only way to unlock the comparator is a device hardware reset. */
- status = ERROR;
- }
- return status;
- }
- /**
- * @brief Initialize some features of COMP instance.
- * @note This function configures features of the selected COMP instance.
- * Some features are also available at scope COMP common instance
- * (common to several COMP instances).
- * Refer to functions having argument "COMPxy_COMMON" as parameter.
- * @param COMPx COMP instance
- * @param COMP_InitStruct Pointer to a @ref LL_COMP_InitTypeDef structure
- * @retval An ErrorStatus enumeration value:
- * - SUCCESS: COMP registers are initialized
- * - ERROR: COMP registers are not initialized
- */
- ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct)
- {
- ErrorStatus status = SUCCESS;
- /* Check the parameters */
- assert_param(IS_COMP_ALL_INSTANCE(COMPx));
- assert_param(IS_LL_COMP_POWER_MODE(COMP_InitStruct->PowerMode));
- assert_param(IS_LL_COMP_INPUT_PLUS(COMPx, COMP_InitStruct->InputPlus));
- assert_param(IS_LL_COMP_INPUT_MINUS(COMPx, COMP_InitStruct->InputMinus));
- assert_param(IS_LL_COMP_INPUT_HYSTERESIS(COMP_InitStruct->InputHysteresis));
- assert_param(IS_LL_COMP_OUTPUT_SELECTION(COMPx, COMP_InitStruct->OutputSelection));
- assert_param(IS_LL_COMP_OUTPUT_POLARITY(COMP_InitStruct->OutputPolarity));
- assert_param(IS_LL_COMP_OUTPUT_BLANKING_SOURCE(COMPx, COMP_InitStruct->OutputBlankingSource));
- /* Note: Hardware constraint (refer to description of this function) */
- /* COMP instance must not be locked. */
- if (LL_COMP_IsLocked(COMPx) == 0U)
- {
- /* Configuration of comparator instance : */
- /* - PowerMode */
- /* - InputPlus */
- /* - InputMinus */
- /* - InputHysteresis */
- /* - OutputSelection */
- /* - OutputPolarity */
- /* - OutputBlankingSource */
- MODIFY_REG(COMPx->CSR,
- ((uint32_t)0x00000000U)
- #if defined(COMP_CSR_COMPxMODE)
- | COMP_CSR_COMPxMODE
- #endif
- #if defined(COMP_CSR_COMPxNONINSEL)
- | COMP_CSR_COMPxNONINSEL
- #endif
- | COMP_CSR_COMPxINSEL
- #if defined(COMP_CSR_COMPxHYST)
- | COMP_CSR_COMPxHYST
- #endif
- | COMP_CSR_COMPxOUTSEL
- | COMP_CSR_COMPxPOL
- | COMP_CSR_COMPxBLANKING
- ,
- ((uint32_t)0x00000000U)
- #if defined(COMP_CSR_COMPxMODE)
- | COMP_InitStruct->PowerMode
- #endif
- #if defined(COMP_CSR_COMPxNONINSEL)
- | COMP_InitStruct->InputPlus
- #endif
- | COMP_InitStruct->InputMinus
- #if defined(COMP_CSR_COMPxHYST)
- | COMP_InitStruct->InputHysteresis
- #endif
- | COMP_InitStruct->OutputSelection
- | COMP_InitStruct->OutputPolarity
- | COMP_InitStruct->OutputBlankingSource
- );
- }
- else
- {
- /* Initialization error: COMP instance is locked. */
- status = ERROR;
- }
- return status;
- }
- /**
- * @brief Set each @ref LL_COMP_InitTypeDef field to default value.
- * @param COMP_InitStruct pointer to a @ref LL_COMP_InitTypeDef structure
- * whose fields will be set to default values.
- * @retval None
- */
- void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct)
- {
- /* Set COMP_InitStruct fields to default values */
- /* Note: Comparator power mode "high speed" is the only mode */
- /* available on all STMF3 devices. */
- COMP_InitStruct->PowerMode = LL_COMP_POWERMODE_HIGHSPEED;
- COMP_InitStruct->InputPlus = LL_COMP_INPUT_PLUS_IO1;
- COMP_InitStruct->InputMinus = LL_COMP_INPUT_MINUS_VREFINT;
- COMP_InitStruct->InputHysteresis = LL_COMP_HYSTERESIS_NONE;
- COMP_InitStruct->OutputSelection = LL_COMP_OUTPUT_NONE;
- COMP_InitStruct->OutputPolarity = LL_COMP_OUTPUTPOL_NONINVERTED;
- COMP_InitStruct->OutputBlankingSource = LL_COMP_BLANKINGSRC_NONE;
- }
- /**
- * @}
- */
- /**
- * @}
- */
- /**
- * @}
- */
- #endif /* COMP1 || COMP2 || COMP3 || COMP4 || COMP5 || COMP6 || COMP7 */
- #endif /* STM32F301x8 || STM32F302x8 || STM32F302xC || STM32F302xE || STM32F303x8 || STM32F303xC || STM32F303xE || STM32F318xx || STM32F328xx || STM32F334x8 || STM32F358xx || STM32F398xx */
- #if defined (COMP_V1_1_0_0)
- #if defined (COMP1) || defined (COMP2)
- /** @addtogroup COMP_LL COMP
- * @{
- */
- /* Private types -------------------------------------------------------------*/
- /* Private variables ---------------------------------------------------------*/
- /* Private constants ---------------------------------------------------------*/
- /* Private macros ------------------------------------------------------------*/
- /** @addtogroup COMP_LL_Private_Macros
- * @{
- */
- /* Check of parameters for configuration of COMP hierarchical scope: */
- /* COMP instance. */
- #define IS_LL_COMP_POWER_MODE(__POWER_MODE__) \
- ( ((__POWER_MODE__) == LL_COMP_POWERMODE_HIGHSPEED) \
- || ((__POWER_MODE__) == LL_COMP_POWERMODE_MEDIUMSPEED) \
- || ((__POWER_MODE__) == LL_COMP_POWERMODE_LOWPOWER) \
- || ((__POWER_MODE__) == LL_COMP_POWERMODE_ULTRALOWPOWER) \
- )
- /* Note: On this STM32 series, comparator input plus parameters are */
- /* the different depending on COMP instances. */
- #define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) \
- (((__COMP_INSTANCE__) == COMP1) \
- ? ( \
- ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \
- || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_DAC1_CH1) \
- ) \
- : \
- ( \
- ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1) \
- ) \
- )
- /* Note: On this STM32 series, comparator input minus parameters are */
- /* the same on all COMP instances. */
- /* However, comparator instance kept as macro parameter for */
- /* compatibility with other STM32 families. */
- #define IS_LL_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) \
- ( ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_4VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_2VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_3_4VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH1) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH2) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO1) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO2) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO3) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO4) \
- || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC2_CH1) \
- )
- #define IS_LL_COMP_INPUT_HYSTERESIS(__INPUT_HYSTERESIS__) \
- ( ((__INPUT_HYSTERESIS__) == LL_COMP_HYSTERESIS_NONE) \
- || ((__INPUT_HYSTERESIS__) == LL_COMP_HYSTERESIS_LOW) \
- || ((__INPUT_HYSTERESIS__) == LL_COMP_HYSTERESIS_MEDIUM) \
- || ((__INPUT_HYSTERESIS__) == LL_COMP_HYSTERESIS_HIGH) \
- )
- /* Note: Output redirection is specific to COMP instances but is checked */
- /* with literals of instance COMP2 (no differentiation possible since */
- /* literals of COMP1 and COMP2 share the same values range). */
- #define IS_LL_COMP_OUTPUT_SELECTION(__OUTPUT_SELECTION__) \
- ( ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_NONE) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM16_BKIN) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_IC1) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM4_OCCLR) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_IC4) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM2_OCCLR) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_IC1_COMP2) \
- || ((__OUTPUT_SELECTION__) == LL_COMP_OUTPUT_TIM3_OCCLR_COMP2) \
- )
- #define IS_LL_COMP_OUTPUT_POLARITY(__POLARITY__) \
- ( ((__POLARITY__) == LL_COMP_OUTPUTPOL_NONINVERTED) \
- || ((__POLARITY__) == LL_COMP_OUTPUTPOL_INVERTED) \
- )
- /**
- * @}
- */
- /* Private function prototypes -----------------------------------------------*/
- /* Exported functions --------------------------------------------------------*/
- /** @addtogroup COMP_LL_Exported_Functions
- * @{
- */
- /** @addtogroup COMP_LL_EF_Init
- * @{
- */
- /**
- * @brief De-initialize registers of the selected COMP instance
- * to their default reset values.
- * @note If comparator is locked, de-initialization by software is
- * not possible.
- * The only way to unlock the comparator is a device hardware reset.
- * @param COMPx COMP instance
- * @retval An ErrorStatus enumeration value:
- * - SUCCESS: COMP registers are de-initialized
- * - ERROR: COMP registers are not de-initialized
- */
- ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx)
- {
- ErrorStatus status = SUCCESS;
- /* Check the parameters */
- assert_param(IS_COMP_ALL_INSTANCE(COMPx));
- /* Note: Hardware constraint (refer to description of this function): */
- /* COMP instance must not be locked. */
- if (LL_COMP_IsLocked(COMPx) == 0U)
- {
- /* Note: Connection switch is applicable only to COMP instance COMP1, */
- /* therefore is COMP2 is selected the equivalent bit is */
- /* kept unmodified. */
- if (COMPx == COMP1)
- {
- CLEAR_BIT(COMP->CSR,
- ( COMP_CSR_COMP1MODE
- | COMP_CSR_COMP1INSEL
- | COMP_CSR_COMP1SW1
- | COMP_CSR_COMP1OUTSEL
- | COMP_CSR_COMP1HYST
- | COMP_CSR_COMP1POL
- | COMP_CSR_COMP1EN
- ) << __COMP_BITOFFSET_INSTANCE(COMPx)
- );
- }
- else
- {
- CLEAR_BIT(COMP->CSR,
- ( COMP_CSR_COMP1MODE
- | COMP_CSR_COMP1INSEL
- | COMP_CSR_COMP1OUTSEL
- | COMP_CSR_COMP1HYST
- | COMP_CSR_COMP1POL
- | COMP_CSR_COMP1EN
- ) << __COMP_BITOFFSET_INSTANCE(COMPx)
- );
- }
- }
- else
- {
- /* Comparator instance is locked: de-initialization by software is */
- /* not possible. */
- /* The only way to unlock the comparator is a device hardware reset. */
- status = ERROR;
- }
- return status;
- }
- /**
- * @brief Initialize some features of COMP instance.
- * @note This function configures features of the selected COMP instance.
- * Some features are also available at scope COMP common instance
- * (common to several COMP instances).
- * Refer to functions having argument "COMPxy_COMMON" as parameter.
- * @param COMPx COMP instance
- * @param COMP_InitStruct Pointer to a @ref LL_COMP_InitTypeDef structure
- * @retval An ErrorStatus enumeration value:
- * - SUCCESS: COMP registers are initialized
- * - ERROR: COMP registers are not initialized
- */
- ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct)
- {
- ErrorStatus status = SUCCESS;
- /* Check the parameters */
- assert_param(IS_COMP_ALL_INSTANCE(COMPx));
- assert_param(IS_LL_COMP_POWER_MODE(COMP_InitStruct->PowerMode));
- assert_param(IS_LL_COMP_INPUT_PLUS(COMPx, COMP_InitStruct->InputPlus));
- assert_param(IS_LL_COMP_INPUT_MINUS(COMPx, COMP_InitStruct->InputMinus));
- assert_param(IS_LL_COMP_INPUT_HYSTERESIS(COMP_InitStruct->InputHysteresis));
- assert_param(IS_LL_COMP_OUTPUT_SELECTION(COMP_InitStruct->OutputSelection));
- assert_param(IS_LL_COMP_OUTPUT_POLARITY(COMP_InitStruct->OutputPolarity));
- /* Note: Hardware constraint (refer to description of this function) */
- /* COMP instance must not be locked. */
- if (LL_COMP_IsLocked(COMPx) == 0U)
- {
- /* Configuration of comparator instance : */
- /* - PowerMode */
- /* - InputPlus */
- /* - InputMinus */
- /* - InputHysteresis */
- /* - OutputSelection */
- /* - OutputPolarity */
- /* Note: Connection switch is applicable only to COMP instance COMP1, */
- /* therefore is COMP2 is selected the equivalent bit is */
- /* kept unmodified. */
- if (COMPx == COMP1)
- {
- MODIFY_REG(COMP->CSR,
- ( COMP_CSR_COMP1MODE
- | COMP_CSR_COMP1INSEL
- | COMP_CSR_COMP1SW1
- | COMP_CSR_COMP1OUTSEL
- | COMP_CSR_COMP1HYST
- | COMP_CSR_COMP1POL
- ) << __COMP_BITOFFSET_INSTANCE(COMPx)
- ,
- ( COMP_InitStruct->PowerMode
- | COMP_InitStruct->InputPlus
- | COMP_InitStruct->InputMinus
- | COMP_InitStruct->InputHysteresis
- | COMP_InitStruct->OutputSelection
- | COMP_InitStruct->OutputPolarity
- ) << __COMP_BITOFFSET_INSTANCE(COMPx)
- );
- }
- else
- {
- MODIFY_REG(COMP->CSR,
- ( COMP_CSR_COMP1MODE
- | COMP_CSR_COMP1INSEL
- | COMP_CSR_COMP1OUTSEL
- | COMP_CSR_COMP1HYST
- | COMP_CSR_COMP1POL
- ) << __COMP_BITOFFSET_INSTANCE(COMPx)
- ,
- ( COMP_InitStruct->PowerMode
- | COMP_InitStruct->InputPlus
- | COMP_InitStruct->InputMinus
- | COMP_InitStruct->InputHysteresis
- | COMP_InitStruct->OutputSelection
- | COMP_InitStruct->OutputPolarity
- ) << __COMP_BITOFFSET_INSTANCE(COMPx)
- );
- }
- }
- else
- {
- /* Initialization error: COMP instance is locked. */
- status = ERROR;
- }
- return status;
- }
- /**
- * @brief Set each @ref LL_COMP_InitTypeDef field to default value.
- * @param COMP_InitStruct pointer to a @ref LL_COMP_InitTypeDef structure
- * whose fields will be set to default values.
- * @retval None
- */
- void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct)
- {
- /* Set COMP_InitStruct fields to default values */
- COMP_InitStruct->PowerMode = LL_COMP_POWERMODE_ULTRALOWPOWER;
- COMP_InitStruct->InputPlus = LL_COMP_INPUT_PLUS_IO1;
- COMP_InitStruct->InputMinus = LL_COMP_INPUT_MINUS_VREFINT;
- COMP_InitStruct->InputHysteresis = LL_COMP_HYSTERESIS_NONE;
- COMP_InitStruct->OutputSelection = LL_COMP_OUTPUT_NONE;
- COMP_InitStruct->OutputPolarity = LL_COMP_OUTPUTPOL_NONINVERTED;
- }
- /**
- * @}
- */
- /**
- * @}
- */
- /**
- * @}
- */
- #endif /* COMP1 || COMP2 */
- #endif /* STM32F373xC || STM32F378xx */
- /**
- * @}
- */
- #endif /* USE_FULL_LL_DRIVER */
|