stm32f3xx_ll_comp.h 147 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_ll_comp.h
  4. * @author MCD Application Team
  5. * @brief Header file of COMP LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef __STM32F3xx_LL_COMP_H
  20. #define __STM32F3xx_LL_COMP_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f3xx.h"
  26. /** @addtogroup STM32F3xx_LL_Driver
  27. * @{
  28. */
  29. /* Note: Devices of STM32F3 series embed 1 out of 2 different comparator IP. */
  30. /* - STM32F30x, STM32F31x, STM32F32x, STM32F33x, STM32F35x, STM32F39x: */
  31. /* COMP IP from 3 to 7 instances and other specific features */
  32. /* (comparator output blanking, ...) (refer to reference manual). */
  33. /* - STM32F37x: */
  34. /* COMP IP with 2 instances */
  35. /* This file contains the drivers of these COMP IP, located in 2 area */
  36. /* delimited by compilation switches. */
  37. #if defined(COMP_V1_3_0_0)
  38. #if defined (COMP1) || defined (COMP2) || defined (COMP3) || defined (COMP4) || defined (COMP5) || defined (COMP6) || defined (COMP7)
  39. /** @defgroup COMP_LL COMP
  40. * @{
  41. */
  42. /* Private types -------------------------------------------------------------*/
  43. /* Private variables ---------------------------------------------------------*/
  44. /* Private constants ---------------------------------------------------------*/
  45. /** @defgroup COMP_LL_Private_Constants COMP Private Constants
  46. * @{
  47. */
  48. /* COMP registers bits positions */
  49. #define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS ((uint32_t)30U) /* Value equivalent to POSITION_VAL(COMPxOUT) */
  50. /**
  51. * @}
  52. */
  53. /* Private macros ------------------------------------------------------------*/
  54. /* Exported types ------------------------------------------------------------*/
  55. #if defined(USE_FULL_LL_DRIVER)
  56. /** @defgroup COMP_LL_ES_INIT COMP Exported Init structure
  57. * @{
  58. */
  59. /**
  60. * @brief Structure definition of some features of COMP instance.
  61. */
  62. typedef struct
  63. {
  64. uint32_t PowerMode; /*!< Set comparator operating mode to adjust power and speed.
  65. This parameter can be a value of @ref COMP_LL_EC_POWERMODE
  66. This feature can be modified afterwards using unitary function @ref LL_COMP_SetPowerMode(). */
  67. uint32_t InputPlus; /*!< Set comparator input plus (non-inverting input).
  68. This parameter can be a value of @ref COMP_LL_EC_INPUT_PLUS
  69. This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputPlus(). */
  70. uint32_t InputMinus; /*!< Set comparator input minus (inverting input).
  71. This parameter can be a value of @ref COMP_LL_EC_INPUT_MINUS
  72. This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputMinus(). */
  73. uint32_t InputHysteresis; /*!< Set comparator hysteresis mode of the input minus.
  74. This parameter can be a value of @ref COMP_LL_EC_INPUT_HYSTERESIS
  75. This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputHysteresis(). */
  76. uint32_t OutputSelection; /*!< Set comparator output selection.
  77. This parameter can be a value of @ref COMP_LL_EC_OUTPUT_SELECTION
  78. This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputSelection(). */
  79. uint32_t OutputPolarity; /*!< Set comparator output polarity.
  80. This parameter can be a value of @ref COMP_LL_EC_OUTPUT_POLARITY
  81. This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputPolarity(). */
  82. uint32_t OutputBlankingSource; /*!< Set comparator blanking source.
  83. This parameter can be a value of @ref COMP_LL_EC_OUTPUT_BLANKING_SOURCE
  84. This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputBlankingSource(). */
  85. } LL_COMP_InitTypeDef;
  86. /**
  87. * @}
  88. */
  89. #endif /* USE_FULL_LL_DRIVER */
  90. /* Exported constants --------------------------------------------------------*/
  91. /** @defgroup COMP_LL_Exported_Constants COMP Exported Constants
  92. * @{
  93. */
  94. /** @defgroup COMP_LL_EC_COMMON_WINDOWMODE Comparator common modes - Window mode
  95. * @{
  96. */
  97. #define LL_COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000U) /*!< Window mode disable: Comparators 1 and 2 are independent */
  98. #if defined(COMP2_CSR_COMP2WNDWEN)
  99. #define LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP2_CSR_COMP2WNDWEN) /*!< 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). */
  100. #endif
  101. #if defined(COMP4_CSR_COMP4WNDWEN)
  102. #define LL_COMP_WINDOWMODE_COMP3_INPUT_PLUS_COMMON (COMP4_CSR_COMP4WNDWEN) /*!< Window mode enable: Comparators instances pair COMP3 and COMP4 have their input plus connected together. The common input is COMP3 input plus (COMP4 input plus is no more accessible). */
  103. #endif
  104. #if defined(COMP6_CSR_COMP6WNDWEN)
  105. #define LL_COMP_WINDOWMODE_COMP5_INPUT_PLUS_COMMON (COMP6_CSR_COMP6WNDWEN) /*!< Window mode enable: Comparators instances pair COMP5 and COMP6 have their input plus connected together. The common input is COMP5 input plus (COMP6 input plus is no more accessible). */
  106. #endif
  107. /**
  108. * @}
  109. */
  110. /** @defgroup COMP_LL_EC_POWERMODE Comparator modes - Power mode
  111. * @{
  112. */
  113. #define LL_COMP_POWERMODE_HIGHSPEED ((uint32_t)0x00000000U) /*!< COMP power mode to high speed */
  114. #if defined(COMP_CSR_COMPxMODE)
  115. #define LL_COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_COMPxMODE_0) /*!< COMP power mode to medium speed */
  116. #define LL_COMP_POWERMODE_LOWPOWER (COMP_CSR_COMPxMODE_1) /*!< COMP power mode to low power */
  117. #define LL_COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_COMPxMODE_1 | COMP_CSR_COMPxMODE_0) /*!< COMP power mode to ultra-low power */
  118. #endif
  119. /**
  120. * @}
  121. */
  122. /** @defgroup COMP_LL_EC_INPUT_PLUS Comparator inputs - Input plus (input non-inverting) selection
  123. * @{
  124. */
  125. #if !defined(COMP_CSR_COMPxNONINSEL)
  126. #define LL_COMP_INPUT_PLUS_IO1 ((uint32_t)0x00000000U) /*!< Comparator input plus connected to IO1 (pin PA1 for COMP1, PA3 for COMP2 (except STM32F334xx: PA7), PB14 for COMP3, PB0 for COMP4, PD12 for COMP5, PD11 for COMP6, PA0 for COMP7) (COMP instance availability depends on the selected device) */
  127. #define LL_COMP_INPUT_PLUS_IO2 ((uint32_t)0x00000000U) /*!< Comparator input plus connected to IO2: Same as IO1 */
  128. #else
  129. #define LL_COMP_INPUT_PLUS_IO1 ((uint32_t)0x00000000U) /*!< Comparator input plus connected to IO1 (pin PA7 for COMP2, PB14 for COMP3, PB0 for COMP4, PD12 for COMP5, PD11 for COMP6, PA0 for COMP7) (COMP instance availability depends on the selected device) */
  130. #define LL_COMP_INPUT_PLUS_IO2 (COMP_CSR_COMPxNONINSEL) /*!< Comparator input plus connected to IO2 (pin PA3 for COMP2, PD14 for COMP3, PE7 for COMP4, PB13 for COMP5, PB11 for COMP6, PC1 for COMP7) (COMP instance availability depends on the selected device) */
  131. #endif
  132. #if defined(STM32F302xC) || defined(STM32F302xE) || defined(STM32F303xC) || defined(STM32F303xE) || defined(STM32F358xx) || defined(STM32F398xx)
  133. #define LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 (COMP_CSR_COMPxSW1) /*!< Comparator input plus connected to DAC1 channel 1 (DAC_OUT1), through dedicated switch (Note: this switch is solely intended to redirect signals onto high impedance input, such as COMP1 input plus (highly resistive switch)) (specific to COMP instance: COMP1) */
  134. /* Note: Comparator input plus specific to COMP instances, defined with */
  135. /* generic naming not taking into account COMP instance constraints. */
  136. /* Refer to literal definitions above for COMP instance constraints. */
  137. #define LL_COMP_INPUT_PLUS_DAC1_CH1 LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 /*!< Comparator input plus connected to DAC1 channel 1 (DAC_OUT1), through dedicated switch. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  138. #elif defined(STM32F301x8) || defined(STM32F318xx) || defined(STM32F302x8)
  139. #define LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2 (COMP_CSR_COMPxSW1) /*!< Comparator input plus connected to DAC1 channel 1 (DAC_OUT1), through dedicated switch (Note: this switch is solely intended to redirect signals onto high impedance input, such as COMP2 input plus (highly resistive switch)) (specific to COMP instance: COMP2) */
  140. /* Note: Comparator input plus specific to COMP instances, defined with */
  141. /* generic naming not taking into account COMP instance constraints. */
  142. /* Refer to literal definitions above for COMP instance constraints. */
  143. #define LL_COMP_INPUT_PLUS_DAC1_CH1 LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2 /*!< Comparator input plus connected to DAC1 channel 1 (DAC_OUT1), through dedicated switch. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  144. #endif
  145. /**
  146. * @}
  147. */
  148. /** @defgroup COMP_LL_EC_INPUT_MINUS Comparator inputs - Input minus (input inverting) selection
  149. * @{
  150. */
  151. #define LL_COMP_INPUT_MINUS_1_4VREFINT ((uint32_t)0x00000000U) /*!< Comparator input minus connected to 1/4 VrefInt */
  152. #define LL_COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_COMPxINSEL_0) /*!< Comparator input minus connected to 1/2 VrefInt */
  153. #define LL_COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_COMPxINSEL_1 ) /*!< Comparator input minus connected to 3/4 VrefInt */
  154. #define LL_COMP_INPUT_MINUS_VREFINT ( COMP_CSR_COMPxINSEL_1 | COMP_CSR_COMPxINSEL_0) /*!< Comparator input minus connected to VrefInt */
  155. #define LL_COMP_INPUT_MINUS_DAC1_CH1 (COMP_CSR_COMPxINSEL_2 ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */
  156. #if defined(STM32F301x8) || defined(STM32F318xx) || defined(STM32F302x8) || defined(STM32F302xC) || defined(STM32F302xE)
  157. /* This device has no comparator input minus DAC1_CH2 */
  158. #else
  159. #define LL_COMP_INPUT_MINUS_DAC1_CH2 (COMP_CSR_COMPxINSEL_2 | COMP_CSR_COMPxINSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */
  160. #endif
  161. #if defined(STM32F301x8) || defined(STM32F318xx) || defined(STM32F334x8)
  162. #define LL_COMP_INPUT_MINUS_IO1 (COMP_CSR_COMPxINSEL_2 | COMP_CSR_COMPxINSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PA2 for COMP2) */
  163. #else
  164. #define LL_COMP_INPUT_MINUS_IO1 (COMP_CSR_COMPxINSEL_2 | COMP_CSR_COMPxINSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PA0 for COMP1, pin PA2 for COMP2, PD15 for COMP3, PE8 for COMP4, PD13 for COMP5, PD10 for COMP6, PC0 for COMP7 (COMP instance availability depends on the selected device)) */
  165. #endif
  166. #define LL_COMP_INPUT_MINUS_IO2 (COMP_CSR_COMPxINSEL_2 | COMP_CSR_COMPxINSEL_1 | COMP_CSR_COMPxINSEL_0) /*!< Comparator input minus connected to IO2 (PB12 for COMP3, PB2 for COMP4, PB10 for COMP5, PB15 for COMP6 (COMP instance availability depends on the selected device)) */
  167. #if defined(STM32F301x8) || defined(STM32F318xx) || defined(STM32F334x8) || defined(STM32F302x8) || defined(STM32F303x8) || defined(STM32F328xx)
  168. /* This device has no comparator input minus IO3 */
  169. #else
  170. #define LL_COMP_INPUT_MINUS_IO3 (COMP_CSR_COMPxINSEL_2 | COMP_CSR_COMPxINSEL_0) /*!< Comparator input minus connected to IO3 (pin PA5 for COMP1/2/3/4/5/6/7 (COMP instance availability depends on the selected device)) */
  171. #endif
  172. #define LL_COMP_INPUT_MINUS_IO4 (COMP_CSR_COMPxINSEL_2 ) /*!< Comparator input minus connected to IO4 (pin PA4 for COMP1/2/3/4/5/6/7 (COMP instance availability depends on the selected device)) */
  173. #if defined(STM32F303x8) || defined(STM32F328xx) || defined(STM32F334x8)
  174. #define LL_COMP_INPUT_MINUS_DAC2_CH1 (COMP_CSR_COMPxINSEL_3 ) /*!< Comparator input minus connected to DAC2 channel 1 (DAC2_OUT1) */
  175. #else
  176. /* This device has no comparator input minus DAC2_CH1 */
  177. #endif
  178. /**
  179. * @}
  180. */
  181. /** @defgroup COMP_LL_EC_INPUT_HYSTERESIS Comparator input - Hysteresis
  182. * @{
  183. */
  184. #define LL_COMP_HYSTERESIS_NONE ((uint32_t)0x00000000U) /*!< No hysteresis */
  185. #if defined(COMP_CSR_COMPxHYST)
  186. #define LL_COMP_HYSTERESIS_LOW ( COMP_CSR_COMPxHYST_0) /*!< Hysteresis level low (available only on devices: STM32F303xB/C, STM32F358xC) */
  187. #define LL_COMP_HYSTERESIS_MEDIUM (COMP_CSR_COMPxHYST_1 ) /*!< Hysteresis level medium (available only on devices: STM32F303xB/C, STM32F358xC) */
  188. #define LL_COMP_HYSTERESIS_HIGH (COMP_CSR_COMPxHYST_1 | COMP_CSR_COMPxHYST_0) /*!< Hysteresis level high (available only on devices: STM32F303xB/C, STM32F358xC) */
  189. #endif
  190. /**
  191. * @}
  192. */
  193. /** @defgroup COMP_LL_EC_OUTPUT_SELECTION Comparator output - Output selection
  194. * @{
  195. */
  196. #define LL_COMP_OUTPUT_NONE ((uint32_t)0x00000000) /*!< COMP output is not connected to other peripherals (except GPIO and EXTI that are always connected to COMP output) (specific to COMP instance: COMP2) */
  197. #if defined(COMP_CSR_COMPxOUT)
  198. /* Note: Output redirection common to all COMP instances, all STM32F3 series */
  199. /* devices. */
  200. #define LL_COMP_OUTPUT_TIM1_BKIN (COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM1 break input (BKIN) */
  201. #define LL_COMP_OUTPUT_TIM1_BKIN2 (COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM1 break input 2 (BKIN2) */
  202. #if defined(STM32F301x8) || defined(STM32F318xx)
  203. /* Note: Output redirection specific to COMP instance: COMP2 */
  204. #define LL_COMP_OUTPUT_TIM1_IC1_COMP2 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM1 input capture 1 (specific to COMP instance: COMP2) */
  205. #define LL_COMP_OUTPUT_TIM2_IC4_COMP2 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM1 input capture 4 (specific to COMP instance: COMP2) */
  206. #define LL_COMP_OUTPUT_TIM1_OCCLR_COMP2 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM1 OCREF clear (specific to COMP instance: COMP2) */
  207. #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP2 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP2) */
  208. /* Note: Output redirection specific to COMP instance: COMP4 */
  209. #define LL_COMP_OUTPUT_TIM15_IC2_COMP4 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM15 input capture 1 (specific to COMP instance: COMP4) */
  210. #define LL_COMP_OUTPUT_TIM15_OCCLR_COMP4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM15 OCREF clear (specific to COMP instance: COMP4) */
  211. /* Note: Output redirection specific to COMP instance: COMP6 */
  212. #define LL_COMP_OUTPUT_TIM2_IC2_COMP6 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM2 input capture 2 (specific to COMP instance: COMP6) */
  213. #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP6 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP6) */
  214. #define LL_COMP_OUTPUT_TIM16_IC1_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM16 input capture 1 (specific to COMP instance: COMP6) */
  215. #define LL_COMP_OUTPUT_TIM16_OCCLR_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM16 OCREF clear (specific to COMP instance: COMP6) */
  216. /* Note: Output redirection specific to COMP instances, defined with */
  217. /* generic naming not taking into account COMP instance constraints. */
  218. /* Refer to literal definitions above for COMP instance constraints. */
  219. /* Note: Some output redirections cannot have a generic naming, */
  220. /* due to literal value different depending on COMP instance. */
  221. /* (For example: LL_COMP_OUTPUT_TIM2_OCCLR_COMP2 and */
  222. /* LL_COMP_OUTPUT_TIM2_OCCLR_COMP6). */
  223. #define LL_COMP_OUTPUT_TIM1_IC1 LL_COMP_OUTPUT_TIM1_IC1_COMP2 /*!< COMP output connected to TIM1 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  224. #define LL_COMP_OUTPUT_TIM1_OCCLR LL_COMP_OUTPUT_TIM1_OCCLR_COMP2 /*!< COMP output connected to TIM1 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  225. #define LL_COMP_OUTPUT_TIM2_IC2 LL_COMP_OUTPUT_TIM2_IC2_COMP6 /*!< COMP output connected to TIM2 input capture 2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  226. #define LL_COMP_OUTPUT_TIM2_IC4 LL_COMP_OUTPUT_TIM2_IC4_COMP2 /*!< COMP output connected to TIM2 input capture 4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  227. #define LL_COMP_OUTPUT_TIM15_IC2 LL_COMP_OUTPUT_TIM15_IC2_COMP4 /*!< COMP output connected to TIM15 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  228. #define LL_COMP_OUTPUT_TIM15_OCCLR LL_COMP_OUTPUT_TIM15_OCCLR_COMP4 /*!< COMP output connected to TIM15 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  229. #define LL_COMP_OUTPUT_TIM16_IC1 LL_COMP_OUTPUT_TIM16_IC1_COMP6 /*!< COMP output connected to TIM16 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  230. #define LL_COMP_OUTPUT_TIM16_OCCLR LL_COMP_OUTPUT_TIM16_OCCLR_COMP6 /*!< COMP output connected to TIM16 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  231. /* Note: Output redirection specific to COMP instances, defined with */
  232. /* partially generic naming grouping COMP instance constraints. */
  233. /* Refer to literal definitions above for COMP instance constraints. */
  234. #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3 LL_COMP_OUTPUT_TIM2_OCCLR_COMP2 /*!< COMP output connected to TIM2 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  235. #elif defined(STM32F303x8) || defined(STM32F328xx) || defined(STM32F334x8)|| defined(STM32F302x8)
  236. /* Note: Output redirection specific to COMP instance: COMP2, COMP4 */
  237. #define LL_COMP_OUTPUT_TIM3_OCCLR_COMP2_4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM3 OCREF clear (specific to COMP instance: COMP2, COMP4) */
  238. /* Note: Output redirection specific to COMP instance: COMP2 */
  239. #define LL_COMP_OUTPUT_TIM1_IC1_COMP2 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM1 input capture 1 (specific to COMP instance: COMP2) */
  240. #define LL_COMP_OUTPUT_TIM2_IC4_COMP2 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM1 input capture 4 (specific to COMP instance: COMP2) */
  241. #define LL_COMP_OUTPUT_TIM1_OCCLR_COMP2 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM1 OCREF clear (specific to COMP instance: COMP2) */
  242. #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP2 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP2) */
  243. #define LL_COMP_OUTPUT_TIM3_IC1_COMP2 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM3 input capture 1 (specific to COMP instance: COMP2) */
  244. /* Note: Output redirection specific to COMP instance: COMP4 */
  245. #define LL_COMP_OUTPUT_TIM3_IC3_COMP4 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM3 input capture 3 (specific to COMP instance: COMP4) */
  246. #define LL_COMP_OUTPUT_TIM15_IC2_COMP4 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM15 input capture 1 (specific to COMP instance: COMP4) */
  247. #define LL_COMP_OUTPUT_TIM15_OCCLR_COMP4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM15 OCREF clear (specific to COMP instance: COMP4) */
  248. /* Note: Output redirection specific to COMP instance: COMP6 */
  249. #define LL_COMP_OUTPUT_TIM2_IC2_COMP6 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM2 input capture 2 (specific to COMP instance: COMP6) */
  250. #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP6 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP6) */
  251. #define LL_COMP_OUTPUT_TIM16_IC1_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM16 input capture 1 (specific to COMP instance: COMP6) */
  252. #define LL_COMP_OUTPUT_TIM16_OCCLR_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM16 OCREF clear (specific to COMP instance: COMP6) */
  253. /* Note: Output redirection specific to COMP instances, defined with */
  254. /* generic naming not taking into account COMP instance constraints. */
  255. /* Refer to literal definitions above for COMP instance constraints. */
  256. /* Note: Some output redirections cannot have a generic naming, */
  257. /* due to literal value different depending on COMP instance. */
  258. /* (For example: LL_COMP_OUTPUT_TIM2_OCCLR_COMP2 and */
  259. /* LL_COMP_OUTPUT_TIM2_OCCLR_COMP6). */
  260. #define LL_COMP_OUTPUT_TIM1_IC1 LL_COMP_OUTPUT_TIM1_IC1_COMP2 /*!< COMP output connected to TIM1 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  261. #define LL_COMP_OUTPUT_TIM1_OCCLR LL_COMP_OUTPUT_TIM1_OCCLR_COMP2 /*!< COMP output connected to TIM1 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  262. #define LL_COMP_OUTPUT_TIM2_IC2 LL_COMP_OUTPUT_TIM2_IC2_COMP6 /*!< COMP output connected to TIM2 input capture 2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  263. #define LL_COMP_OUTPUT_TIM2_IC4 LL_COMP_OUTPUT_TIM2_IC4_COMP2 /*!< COMP output connected to TIM2 input capture 4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  264. #define LL_COMP_OUTPUT_TIM3_IC1 LL_COMP_OUTPUT_TIM3_IC1_COMP2 /*!< COMP output connected to TIM3 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  265. #define LL_COMP_OUTPUT_TIM3_IC3 LL_COMP_OUTPUT_TIM3_IC3_COMP4 /*!< COMP output connected to TIM3 input capture 3. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  266. #define LL_COMP_OUTPUT_TIM3_OCCLR LL_COMP_OUTPUT_TIM3_OCCLR_COMP2_4 /*!< COMP output connected to TIM3 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  267. #define LL_COMP_OUTPUT_TIM15_IC2 LL_COMP_OUTPUT_TIM15_IC2_COMP4 /*!< COMP output connected to TIM15 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  268. #define LL_COMP_OUTPUT_TIM15_OCCLR LL_COMP_OUTPUT_TIM15_OCCLR_COMP4 /*!< COMP output connected to TIM15 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  269. #define LL_COMP_OUTPUT_TIM16_IC1 LL_COMP_OUTPUT_TIM16_IC1_COMP6 /*!< COMP output connected to TIM16 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  270. #define LL_COMP_OUTPUT_TIM16_OCCLR LL_COMP_OUTPUT_TIM16_OCCLR_COMP6 /*!< COMP output connected to TIM16 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  271. /* Note: Output redirection specific to COMP instances, defined with */
  272. /* partially generic naming grouping COMP instance constraints. */
  273. /* Refer to literal definitions above for COMP instance constraints. */
  274. #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3 LL_COMP_OUTPUT_TIM2_OCCLR_COMP2 /*!< COMP output connected to TIM2 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  275. #elif defined(STM32F302xC) || defined(STM32F302xE)
  276. /* Note: Output redirection specific to COMP instance: COMP1, COMP2, COMP4 */
  277. #define LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM3 OCREF clear (specific to COMP instance: COMP2, COMP4) */
  278. /* Note: Output redirection specific to COMP instance: COMP1, COMP2 */
  279. #define LL_COMP_OUTPUT_TIM1_IC1_COMP1_2 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM1 input capture 1 (specific to COMP instance: COMP2) */
  280. #define LL_COMP_OUTPUT_TIM2_IC4_COMP1_2 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM2 input capture 4 (specific to COMP instance: COMP2) */
  281. #define LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM1 OCREF clear (specific to COMP instance: COMP2) */
  282. #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP2) */
  283. #define LL_COMP_OUTPUT_TIM3_IC1_COMP1_2 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM3 input capture 1 (specific to COMP instance: COMP2) */
  284. /* Note: Output redirection specific to COMP instance: COMP4 */
  285. #define LL_COMP_OUTPUT_TIM3_IC3_COMP4 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM3 input capture 3 (specific to COMP instance: COMP4) */
  286. #define LL_COMP_OUTPUT_TIM4_IC2_COMP4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM4 input capture 2 (specific to COMP instance: COMP4) */
  287. #define LL_COMP_OUTPUT_TIM15_IC2_COMP4 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM15 input capture 1 (specific to COMP instance: COMP4) */
  288. #define LL_COMP_OUTPUT_TIM15_OCCLR_COMP4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM15 OCREF clear (specific to COMP instance: COMP4) */
  289. /* Note: Output redirection specific to COMP instance: COMP6 */
  290. #define LL_COMP_OUTPUT_TIM2_IC2_COMP6 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM2 input capture 2 (specific to COMP instance: COMP6) */
  291. #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP6 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP6) */
  292. #define LL_COMP_OUTPUT_TIM4_IC4_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM4 input capture 4 (specific to COMP instance: COMP6) */
  293. #define LL_COMP_OUTPUT_TIM16_IC1_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM16 input capture 1 (specific to COMP instance: COMP6) */
  294. #define LL_COMP_OUTPUT_TIM16_OCCLR_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM16 OCREF clear (specific to COMP instance: COMP6) */
  295. /* Note: Output redirection specific to COMP instances, defined with */
  296. /* generic naming not taking into account COMP instance constraints. */
  297. /* Refer to literal definitions above for COMP instance constraints. */
  298. /* Note: Some output redirections cannot have a generic naming, */
  299. /* due to literal value different depending on COMP instance. */
  300. /* (For example: LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2 and */
  301. /* LL_COMP_OUTPUT_TIM2_OCCLR_COMP6). */
  302. #define LL_COMP_OUTPUT_TIM1_IC1 LL_COMP_OUTPUT_TIM1_IC1_COMP1_2 /*!< COMP output connected to TIM1 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  303. #define LL_COMP_OUTPUT_TIM1_OCCLR LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2 /*!< COMP output connected to TIM1 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  304. #define LL_COMP_OUTPUT_TIM2_IC2 LL_COMP_OUTPUT_TIM2_IC2_COMP6 /*!< COMP output connected to TIM2 input capture 2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  305. #define LL_COMP_OUTPUT_TIM2_IC4 LL_COMP_OUTPUT_TIM2_IC4_COMP1_2 /*!< COMP output connected to TIM2 input capture 4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  306. #define LL_COMP_OUTPUT_TIM3_IC1 LL_COMP_OUTPUT_TIM3_IC1_COMP1_2 /*!< COMP output connected to TIM3 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  307. #define LL_COMP_OUTPUT_TIM3_IC3 LL_COMP_OUTPUT_TIM3_IC3_COMP4 /*!< COMP output connected to TIM3 input capture 3. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  308. #define LL_COMP_OUTPUT_TIM3_OCCLR LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4 /*!< COMP output connected to TIM3 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  309. #define LL_COMP_OUTPUT_TIM4_IC2 LL_COMP_OUTPUT_TIM4_IC2_COMP4 /*!< COMP output connected to TIM4 input capture 2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  310. #define LL_COMP_OUTPUT_TIM4_IC4 LL_COMP_OUTPUT_TIM4_IC4_COMP6 /*!< COMP output connected to TIM4 input capture 4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  311. #define LL_COMP_OUTPUT_TIM15_IC2 LL_COMP_OUTPUT_TIM15_IC2_COMP4 /*!< COMP output connected to TIM15 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  312. #define LL_COMP_OUTPUT_TIM15_OCCLR LL_COMP_OUTPUT_TIM15_OCCLR_COMP4 /*!< COMP output connected to TIM15 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  313. #define LL_COMP_OUTPUT_TIM16_IC1 LL_COMP_OUTPUT_TIM16_IC1_COMP6 /*!< COMP output connected to TIM16 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  314. #define LL_COMP_OUTPUT_TIM16_OCCLR LL_COMP_OUTPUT_TIM16_OCCLR_COMP6 /*!< COMP output connected to TIM16 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  315. /* Note: Output redirection specific to COMP instances, defined with */
  316. /* partially generic naming grouping COMP instance constraints. */
  317. /* Refer to literal definitions above for COMP instance constraints. */
  318. #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3 LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2 /*!< COMP output connected to TIM2 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  319. #elif defined(STM32F303xC) || defined(STM32F358xx) || defined(STM32F303xE) || defined(STM32F398xx)
  320. /* Note: Output redirection common to all COMP instances */
  321. #define LL_COMP_OUTPUT_TIM8_BKIN (COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM8 break input (BKIN) */
  322. #define LL_COMP_OUTPUT_TIM8_BKIN2 (COMP_CSR_COMPxOUTSEL_2) /*!< COMP output connected to TIM8 break input 2 (BKIN2) */
  323. #define LL_COMP_OUTPUT_TIM1_TIM8_BKIN2 (COMP_CSR_COMPxOUTSEL_2| COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM1 break input 2 and TIM8 break input 2 (BKIN2) */
  324. #if defined(STM32F303xE) || defined(STM32F398xx)
  325. #define LL_COMP_OUTPUT_TIM20_BKIN (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_2) /*!< COMP output connected to TIM8 break input (BKIN) */
  326. #define LL_COMP_OUTPUT_TIM20_BKIN2 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM8 break input 2 (BKIN2) */
  327. #define LL_COMP_OUTPUT_TIM1_TIM8_TIM20_BKIN2 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_2| COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM1 break input 2, TIM8 break input 2 and TIM20 break input 2 (BKIN2) */
  328. #endif
  329. /* Note: Output redirection specific to COMP instance: COMP1, COMP2, COMP3, COMP7 */
  330. #define LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM1 OCREF clear (specific to COMP instance: COMP1, COMP2, COMP3, COMP7) */
  331. /* Note: Output redirection specific to COMP instance: COMP1, COMP2, COMP3 */
  332. #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP1, COMP2, COMP3) */
  333. /* Note: Output redirection specific to COMP instance: COMP1, COMP2, COMP4, COMP5 */
  334. #define LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM3 OCREF clear (specific to COMP instance: COMP1, COMP2, COMP4, COMP5) */
  335. /* Note: Output redirection specific to COMP instance: COMP4, COMP5, COMP6, COMP7 */
  336. #define LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM8 OCREF clear (specific to COMP instance: COMP4, COMP5, COMP6, COMP7) */
  337. /* Note: Output redirection specific to COMP instance: COMP1, COMP2 */
  338. #define LL_COMP_OUTPUT_TIM1_IC1_COMP1_2 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM1 input capture 1 (specific to COMP instance: COMP2) */
  339. #define LL_COMP_OUTPUT_TIM2_IC4_COMP1_2 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM2 input capture 4 (specific to COMP instance: COMP2) */
  340. #define LL_COMP_OUTPUT_TIM3_IC1_COMP1_2 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM3 input capture 1 (specific to COMP instance: COMP2) */
  341. #if defined(STM32F303xE) || defined(STM32F398xx)
  342. #define LL_COMP_OUTPUT_TIM20_OCCLR_COMP2 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM20 OCREF clear (specific to COMP instance: COMP2) */
  343. #endif
  344. /* Note: Output redirection specific to COMP instance: COMP3 */
  345. #define LL_COMP_OUTPUT_TIM3_IC2_COMP3 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM3 input capture 2 (specific to COMP instance: COMP3) */
  346. #define LL_COMP_OUTPUT_TIM4_IC1_COMP3 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM4 input capture 1 (specific to COMP instance: COMP3) */
  347. #define LL_COMP_OUTPUT_TIM15_IC1_COMP3 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM15 input capture 1 (specific to COMP instance: COMP3) */
  348. #define LL_COMP_OUTPUT_TIM15_BKIN_COMP3 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM15 break input (BKIN) */
  349. /* Note: Output redirection specific to COMP instance: COMP4 */
  350. #define LL_COMP_OUTPUT_TIM3_IC3_COMP4 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM3 input capture 3 (specific to COMP instance: COMP4) */
  351. #define LL_COMP_OUTPUT_TIM4_IC2_COMP4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM4 input capture 2 (specific to COMP instance: COMP4) */
  352. #define LL_COMP_OUTPUT_TIM15_IC2_COMP4 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM15 input capture 1 (specific to COMP instance: COMP4) */
  353. #define LL_COMP_OUTPUT_TIM15_OCCLR_COMP4 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM15 OCREF clear (specific to COMP instance: COMP4) */
  354. /* Note: Output redirection specific to COMP instance: COMP5 */
  355. #define LL_COMP_OUTPUT_TIM2_IC1_COMP5 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM2 input capture 1 (specific to COMP instance: COMP5) */
  356. #define LL_COMP_OUTPUT_TIM4_IC3_COMP5 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM4 input capture 3 (specific to COMP instance: COMP5) */
  357. #define LL_COMP_OUTPUT_TIM17_IC1_COMP5 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM17 input capture 1 (specific to COMP instance: COMP5) */
  358. #define LL_COMP_OUTPUT_TIM16_BKIN_COMP5 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM16 break input (BKIN) */
  359. /* Note: Output redirection specific to COMP instance: COMP6 */
  360. #define LL_COMP_OUTPUT_TIM2_IC2_COMP6 (COMP_CSR_COMPxOUTSEL_2 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM2 input capture 2 (specific to COMP instance: COMP6) */
  361. #define LL_COMP_OUTPUT_TIM2_OCCLR_COMP6 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM2 OCREF clear (specific to COMP instance: COMP6) */
  362. #define LL_COMP_OUTPUT_TIM4_IC4_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM4 input capture 4 (specific to COMP instance: COMP6) */
  363. #define LL_COMP_OUTPUT_TIM16_IC1_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM16 input capture 1 (specific to COMP instance: COMP6) */
  364. #define LL_COMP_OUTPUT_TIM16_OCCLR_COMP6 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM16 OCREF clear (specific to COMP instance: COMP6) */
  365. /* Note: Output redirection specific to COMP instance: COMP7 */
  366. #define LL_COMP_OUTPUT_TIM1_IC2_COMP7 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM2 input capture 1 (specific to COMP instance: COMP7) */
  367. #define LL_COMP_OUTPUT_TIM2_IC3_COMP7 (COMP_CSR_COMPxOUTSEL_3) /*!< COMP output connected to TIM4 input capture 3 (specific to COMP instance: COMP7) */
  368. #define LL_COMP_OUTPUT_TIM17_OCCLR_COMP7 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1) /*!< COMP output connected to TIM17 OCREF clear (specific to COMP instance: COMP7) */
  369. #define LL_COMP_OUTPUT_TIM17_BKIN_COMP7 (COMP_CSR_COMPxOUTSEL_3 | COMP_CSR_COMPxOUTSEL_1 | COMP_CSR_COMPxOUTSEL_0) /*!< COMP output connected to TIM17 break input (BKIN) */
  370. /* Note: Output redirection specific to COMP instances, defined with */
  371. /* generic naming not taking into account COMP instance constraints. */
  372. /* Refer to literal definitions above for COMP instance constraints. */
  373. /* Note: Some output redirections cannot have a generic naming, */
  374. /* due to literal value different depending on COMP instance. */
  375. /* (For example: LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3 and */
  376. /* LL_COMP_OUTPUT_TIM2_OCCLR_COMP6). */
  377. #define LL_COMP_OUTPUT_TIM1_IC1 LL_COMP_OUTPUT_TIM1_IC1_COMP1_2 /*!< COMP output connected to TIM1 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  378. #define LL_COMP_OUTPUT_TIM1_IC2 LL_COMP_OUTPUT_TIM1_IC2_COMP7 /*!< COMP output connected to TIM2 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  379. #define LL_COMP_OUTPUT_TIM1_OCCLR LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7 /*!< COMP output connected to TIM1 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  380. #define LL_COMP_OUTPUT_TIM2_IC1 LL_COMP_OUTPUT_TIM2_IC1_COMP5 /*!< COMP output connected to TIM2 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  381. #define LL_COMP_OUTPUT_TIM2_IC2 LL_COMP_OUTPUT_TIM2_IC2_COMP6 /*!< COMP output connected to TIM2 input capture 2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  382. #define LL_COMP_OUTPUT_TIM2_IC3 LL_COMP_OUTPUT_TIM2_IC3_COMP7 /*!< COMP output connected to TIM4 input capture 3. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  383. #define LL_COMP_OUTPUT_TIM2_IC4 LL_COMP_OUTPUT_TIM2_IC4_COMP1_2 /*!< COMP output connected to TIM2 input capture 4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  384. #define LL_COMP_OUTPUT_TIM3_IC1 LL_COMP_OUTPUT_TIM3_IC1_COMP1_2 /*!< COMP output connected to TIM3 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  385. #define LL_COMP_OUTPUT_TIM3_IC2 LL_COMP_OUTPUT_TIM3_IC2_COMP3 /*!< COMP output connected to TIM3 input capture 2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  386. #define LL_COMP_OUTPUT_TIM3_IC3 LL_COMP_OUTPUT_TIM3_IC3_COMP4 /*!< COMP output connected to TIM3 input capture 3. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  387. #define LL_COMP_OUTPUT_TIM3_OCCLR LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5 /*!< COMP output connected to TIM3 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  388. #define LL_COMP_OUTPUT_TIM4_IC1 LL_COMP_OUTPUT_TIM4_IC1_COMP3 /*!< COMP output connected to TIM4 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  389. #define LL_COMP_OUTPUT_TIM4_IC2 LL_COMP_OUTPUT_TIM4_IC2_COMP4 /*!< COMP output connected to TIM4 input capture 2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  390. #define LL_COMP_OUTPUT_TIM4_IC3 LL_COMP_OUTPUT_TIM4_IC3_COMP5 /*!< COMP output connected to TIM4 input capture 3. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  391. #define LL_COMP_OUTPUT_TIM4_IC4 LL_COMP_OUTPUT_TIM4_IC4_COMP6 /*!< COMP output connected to TIM4 input capture 4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  392. #define LL_COMP_OUTPUT_TIM8_OCCLR LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7 /*!< COMP output connected to TIM8 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  393. #define LL_COMP_OUTPUT_TIM15_IC1 LL_COMP_OUTPUT_TIM15_IC1_COMP3 /*!< COMP output connected to TIM15 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  394. #define LL_COMP_OUTPUT_TIM15_IC2 LL_COMP_OUTPUT_TIM15_IC2_COMP4 /*!< COMP output connected to TIM15 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  395. #define LL_COMP_OUTPUT_TIM15_BKIN LL_COMP_OUTPUT_TIM15_BKIN_COMP3 /*!< COMP output connected to TIM15 break input (BKIN). Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  396. #define LL_COMP_OUTPUT_TIM15_OCCLR LL_COMP_OUTPUT_TIM15_OCCLR_COMP4 /*!< COMP output connected to TIM15 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  397. #define LL_COMP_OUTPUT_TIM16_IC1 LL_COMP_OUTPUT_TIM16_IC1_COMP6 /*!< COMP output connected to TIM16 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  398. #define LL_COMP_OUTPUT_TIM16_BKIN LL_COMP_OUTPUT_TIM16_BKIN_COMP5 /*!< COMP output connected to TIM16 break input (BKIN). Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  399. #define LL_COMP_OUTPUT_TIM16_OCCLR LL_COMP_OUTPUT_TIM16_OCCLR_COMP6 /*!< COMP output connected to TIM16 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  400. #define LL_COMP_OUTPUT_TIM17_IC1 LL_COMP_OUTPUT_TIM17_IC1_COMP5 /*!< COMP output connected to TIM17 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  401. #define LL_COMP_OUTPUT_TIM17_BKIN LL_COMP_OUTPUT_TIM17_BKIN_COMP7 /*!< COMP output connected to TIM17 break input (BKIN). Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  402. #define LL_COMP_OUTPUT_TIM17_OCCLR LL_COMP_OUTPUT_TIM17_OCCLR_COMP7 /*!< COMP output connected to TIM17 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  403. #if defined(STM32F303xE) || defined(STM32F398xx)
  404. #define LL_COMP_OUTPUT_TIM20_OCCLR LL_COMP_OUTPUT_TIM20_OCCLR_COMP2 /*!< COMP output connected to TIM20 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  405. #endif
  406. #endif
  407. #endif
  408. /**
  409. * @}
  410. */
  411. /** @defgroup COMP_LL_EC_OUTPUT_POLARITY Comparator output - Output polarity
  412. * @{
  413. */
  414. #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 */
  415. #define LL_COMP_OUTPUTPOL_INVERTED (COMP_CSR_COMPxPOL) /*!< 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 */
  416. /**
  417. * @}
  418. */
  419. /** @defgroup COMP_LL_EC_OUTPUT_BLANKING_SOURCE Comparator output - Blanking source
  420. * @{
  421. */
  422. #define LL_COMP_BLANKINGSRC_NONE ((uint32_t)0x00000000U) /*!<Comparator output without blanking */
  423. #if defined(COMP_CSR_COMPxBLANKING)
  424. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  425. /* Note: Output blanking source specific to COMP instance: COMP2 */
  426. #define LL_COMP_BLANKINGSRC_TIM1_OC5_COMP2 (COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP2) */
  427. #define LL_COMP_BLANKINGSRC_TIM2_OC3_COMP2 (COMP_CSR_COMPxBLANKING_1) /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP2) */
  428. #define LL_COMP_BLANKINGSRC_TIM3_OC3_COMP2 (COMP_CSR_COMPxBLANKING_1 | COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP2) */
  429. /* Note: Output blanking source specific to COMP instance: COMP4 */
  430. #define LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4 (COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM3 OC4 (specific to COMP instance: COMP4) */
  431. #define LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4 (COMP_CSR_COMPxBLANKING_0 | COMP_CSR_COMPxBLANKING_1) /*!< Comparator output blanking source TIM15 OC1 (specific to COMP instance: COMP4) */
  432. /* Note: Output blanking source specific to COMP instance: COMP6 */
  433. #define LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6 (COMP_CSR_COMPxBLANKING_0 | COMP_CSR_COMPxBLANKING_1) /*!< Comparator output blanking source TIM2 OC4 (specific to COMP instance: COMP6) */
  434. #define LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6 (COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM15 OC2 (specific to COMP instance: COMP6) */
  435. /* Note: Output blanking source specific to COMP instances, defined with */
  436. /* generic naming not taking into account COMP instance constraints. */
  437. /* Refer to literal definitions above for COMP instance constraints. */
  438. #define LL_COMP_BLANKINGSRC_TIM1_OC5 LL_COMP_BLANKINGSRC_TIM1_OC5_COMP2 /*!< Comparator output blanking source TIM1 OC5. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  439. #define LL_COMP_BLANKINGSRC_TIM2_OC3 LL_COMP_BLANKINGSRC_TIM2_OC3_COMP2 /*!< Comparator output blanking source TIM2 OC3. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  440. #define LL_COMP_BLANKINGSRC_TIM2_OC4 LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6 /*!< Comparator output blanking source TIM2 OC4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  441. #define LL_COMP_BLANKINGSRC_TIM3_OC3 LL_COMP_BLANKINGSRC_TIM3_OC3_COMP2 /*!< Comparator output blanking source TIM3 OC3. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  442. #define LL_COMP_BLANKINGSRC_TIM3_OC4 LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4 /*!< Comparator output blanking source TIM3 OC4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  443. #define LL_COMP_BLANKINGSRC_TIM15_OC1 LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4 /*!< Comparator output blanking source TIM15 OC1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  444. #define LL_COMP_BLANKINGSRC_TIM15_OC2 LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6 /*!< Comparator output blanking source TIM15 OC2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  445. #elif defined(STM32F302xE) || defined(STM32F302xC)
  446. /* Note: Output blanking source specific to COMP instance: COMP1, COMP2 */
  447. #define LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2 (COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP1, COMP2) */
  448. #define LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2 (COMP_CSR_COMPxBLANKING_1) /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP1, COMP2) */
  449. #define LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2 (COMP_CSR_COMPxBLANKING_1 | COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP1, COMP2) */
  450. /* Note: Output blanking source specific to COMP instance: COMP4 */
  451. #define LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4 (COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM3 OC4 (specific to COMP instance: COMP4) */
  452. #define LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4 (COMP_CSR_COMPxBLANKING_0 | COMP_CSR_COMPxBLANKING_1) /*!< Comparator output blanking source TIM15 OC1 (specific to COMP instance: COMP4) */
  453. /* Note: Output blanking source specific to COMP instance: COMP6 */
  454. #define LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6 (COMP_CSR_COMPxBLANKING_0 | COMP_CSR_COMPxBLANKING_1) /*!< Comparator output blanking source TIM2 OC4 (specific to COMP instance: COMP6) */
  455. #define LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6 (COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM15 OC2 (specific to COMP instance: COMP6) */
  456. /* Note: Output blanking source specific to COMP instances, defined with */
  457. /* generic naming not taking into account COMP instance constraints. */
  458. /* Refer to literal definitions above for COMP instance constraints. */
  459. #define LL_COMP_BLANKINGSRC_TIM1_OC5 LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2 /*!< Comparator output blanking source TIM1 OC5. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  460. #define LL_COMP_BLANKINGSRC_TIM2_OC3 LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2 /*!< Comparator output blanking source TIM2 OC3. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  461. #define LL_COMP_BLANKINGSRC_TIM2_OC4 LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6 /*!< Comparator output blanking source TIM2 OC4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  462. #define LL_COMP_BLANKINGSRC_TIM3_OC3 LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2 /*!< Comparator output blanking source TIM3 OC3. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  463. #define LL_COMP_BLANKINGSRC_TIM3_OC4 LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4 /*!< Comparator output blanking source TIM3 OC4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  464. #define LL_COMP_BLANKINGSRC_TIM15_OC1 LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4 /*!< Comparator output blanking source TIM15 OC1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  465. #define LL_COMP_BLANKINGSRC_TIM15_OC2 LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6 /*!< Comparator output blanking source TIM15 OC2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  466. #elif defined(STM32F303xE) || defined(STM32F398xx) || defined(STM32F303xC) || defined(STM32F358xx)
  467. /* Note: Output blanking source specific to COMP instance: COMP1, COMP2, COMP7 */
  468. #define LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2_7 (COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP1, COMP2, COMP7) */
  469. /* Note: Output blanking source specific to COMP instance: COMP1, COMP2 */
  470. #define LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2 (COMP_CSR_COMPxBLANKING_1) /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP1, COMP2) */
  471. #define LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2 (COMP_CSR_COMPxBLANKING_1 | COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP1, COMP2) */
  472. /* Note: Output blanking source specific to COMP instance: COMP3, COMP6 */
  473. #define LL_COMP_BLANKINGSRC_TIM2_OC4_COMP3_6 (COMP_CSR_COMPxBLANKING_1 | COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM2 OC4 (specific to COMP instance: COMP3, COMP6) */
  474. /* Note: Output blanking source specific to COMP instance: COMP4, COMP5, COMP6, COMP7 */
  475. #define LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7 (COMP_CSR_COMPxBLANKING_1) /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP4, COMP5, COMP6, COMP7) */
  476. /* Note: Output blanling source specific to COMP instance: COMP6, COMP7 */
  477. #define LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6_7 (COMP_CSR_COMPxBLANKING_2) /*!< Comparator output blanking source TIM15 OC2 (specific to COMP instance: COMP6, COMP7) */
  478. /* Note: Output blanking source specific to COMP instance: COMP4 */
  479. #define LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4 (COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM3 OC4 (specific to COMP instance: COMP4) */
  480. #define LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4 (COMP_CSR_COMPxBLANKING_1 | COMP_CSR_COMPxBLANKING_0) /*!< Comparator output blanking source TIM15 OC1 (specific to COMP instance: COMP4) */
  481. /* Note: Output blanking source specific to COMP instances, defined with */
  482. /* generic naming not taking into account COMP instance constraints. */
  483. /* Refer to literal definitions above for COMP instance constraints. */
  484. #define LL_COMP_BLANKINGSRC_TIM1_OC5 LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2_7 /*!< Comparator output blanking source TIM1 OC5. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  485. #define LL_COMP_BLANKINGSRC_TIM2_OC3 LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2 /*!< Comparator output blanking source TIM2 OC3. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  486. #define LL_COMP_BLANKINGSRC_TIM2_OC4 LL_COMP_BLANKINGSRC_TIM2_OC4_COMP3_6 /*!< Comparator output blanking source TIM2 OC4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  487. #define LL_COMP_BLANKINGSRC_TIM3_OC3 LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2 /*!< Comparator output blanking source TIM3 OC3. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  488. #define LL_COMP_BLANKINGSRC_TIM3_OC4 LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4 /*!< Comparator output blanking source TIM3 OC4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  489. #define LL_COMP_BLANKINGSRC_TIM8_OC5 LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7 /*!< Comparator output blanking source TIM8 OC5. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  490. #define LL_COMP_BLANKINGSRC_TIM15_OC1 LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4 /*!< Comparator output blanking source TIM15 OC1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  491. #define LL_COMP_BLANKINGSRC_TIM15_OC2 LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6_7 /*!< Comparator output blanking source TIM15 OC2. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  492. #endif
  493. #endif
  494. /**
  495. * @}
  496. */
  497. /** @defgroup COMP_LL_EC_OUTPUT_LEVEL Comparator output - Output level
  498. * @{
  499. */
  500. #define LL_COMP_OUTPUT_LEVEL_LOW ((uint32_t)0x00000000U) /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */
  501. #define LL_COMP_OUTPUT_LEVEL_HIGH ((uint32_t)0x00000001U) /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */
  502. /**
  503. * @}
  504. */
  505. /** @defgroup COMP_LL_EC_HW_DELAYS Definitions of COMP hardware constraints delays
  506. * @note Only COMP IP HW delays are defined in COMP LL driver driver,
  507. * not timeout values.
  508. * For details on delays values, refer to descriptions in source code
  509. * above each literal definition.
  510. * @{
  511. */
  512. /* Delay for comparator startup time. */
  513. /* Note: Delay required to reach propagation delay specification. */
  514. /* Literal set to maximum value (refer to device datasheet, */
  515. /* parameter "tSTART"). */
  516. /* Unit: us */
  517. #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
  518. #define LL_COMP_DELAY_STARTUP_US ((uint32_t) 60U) /*!< Delay for COMP startup time */
  519. #else
  520. #define LL_COMP_DELAY_STARTUP_US ((uint32_t) 10U) /*!< Delay for COMP startup time */
  521. #endif
  522. /* Delay for comparator voltage scaler stabilization time. */
  523. /* Note: Voltage scaler is used when selecting comparator input */
  524. /* based on VrefInt: VrefInt or subdivision of VrefInt. */
  525. /* Literal set to maximum value (refer to device datasheet, */
  526. /* parameter "tS_SC"). */
  527. /* Unit: us */
  528. #define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ((uint32_t) 200U) /*!< Delay for COMP voltage scaler stabilization time */
  529. /**
  530. * @}
  531. */
  532. /**
  533. * @}
  534. */
  535. /* Exported macro ------------------------------------------------------------*/
  536. /** @defgroup COMP_LL_Exported_Macros COMP Exported Macros
  537. * @{
  538. */
  539. /** @defgroup COMP_LL_EM_WRITE_READ Common write and read registers macro
  540. * @{
  541. */
  542. /**
  543. * @brief Write a value in COMP register
  544. * @param __INSTANCE__ comparator instance
  545. * @param __REG__ Register to be written
  546. * @param __VALUE__ Value to be written in the register
  547. * @retval None
  548. */
  549. #define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  550. /**
  551. * @brief Read a value in COMP register
  552. * @param __INSTANCE__ comparator instance
  553. * @param __REG__ Register to be read
  554. * @retval Register value
  555. */
  556. #define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  557. /**
  558. * @}
  559. */
  560. /** @defgroup COMP_LL_EM_HELPER_MACRO COMP helper macro
  561. * @{
  562. */
  563. /**
  564. * @brief Helper macro to select the COMP common instance
  565. * to which is belonging the selected COMP instance.
  566. * @note COMP common register instance can be used to
  567. * set parameters common to several COMP instances.
  568. * Refer to functions having argument "COMPxy_COMMON" as parameter.
  569. * @param __COMPx__ COMP instance
  570. * @retval COMP common instance or value "0" if there is no COMP common instance.
  571. */
  572. #if defined(COMP1) && defined(COMP2) && defined(COMP3) && defined(COMP4) && defined(COMP5) && defined(COMP6) && defined(COMP7)
  573. /* Note: On STM32F3 series devices with 7 comparator instances, */
  574. /* COMP instance COMP7 has no other comparator instance to work */
  575. /* in pair with: window mode is not available for COMP7. */
  576. #define __LL_COMP_COMMON_INSTANCE(__COMPx__) \
  577. ((((__COMPx__) == COMP1) || ((__COMPx__) == COMP2)) \
  578. ? ( \
  579. (COMP12_COMMON) \
  580. ) \
  581. : \
  582. ((((__COMPx__) == COMP3) || ((__COMPx__) == COMP4)) \
  583. ? ( \
  584. (COMP34_COMMON) \
  585. ) \
  586. : \
  587. ((((__COMPx__) == COMP5) || ((__COMPx__) == COMP6)) \
  588. ? ( \
  589. (COMP56_COMMON) \
  590. ) \
  591. : \
  592. ( \
  593. ((uint32_t)0U) \
  594. ) \
  595. ) \
  596. ) \
  597. )
  598. #elif defined(COMP1) && defined(COMP2) && defined(COMP4) && defined(COMP6)
  599. #define __LL_COMP_COMMON_INSTANCE(__COMPx__) \
  600. ((((__COMPx__) == COMP1) || ((__COMPx__) == COMP2)) \
  601. ? ( \
  602. (COMP12_COMMON) \
  603. ) \
  604. : \
  605. ( \
  606. ((uint32_t)0U) \
  607. ) \
  608. )
  609. #elif defined(COMP2) && defined(COMP4) && defined(COMP6)
  610. /* Note: On STM32F3 series devices with 3 comparator instances (COMP2, 4, 6) */
  611. /* COMP instances have no other comparator instance to work */
  612. /* in pair with: window mode is not available for all COMP instances. */
  613. #define __LL_COMP_COMMON_INSTANCE(__COMPx__) \
  614. ((uint32_t)0U)
  615. #endif
  616. /**
  617. * @}
  618. */
  619. /**
  620. * @}
  621. */
  622. /* Exported functions --------------------------------------------------------*/
  623. /** @defgroup COMP_LL_Exported_Functions COMP Exported Functions
  624. * @{
  625. */
  626. /** @defgroup COMP_LL_EF_Configuration_comparator_common Configuration of COMP hierarchical scope: common to several COMP instances
  627. * @{
  628. */
  629. /**
  630. * @brief Set window mode of a pair of comparators instances
  631. * (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
  632. * @rmtoll CSR COMPxWNDWEN LL_COMP_SetCommonWindowMode
  633. * @param COMPxy_COMMON Comparator common instance
  634. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
  635. * @param WindowMode This parameter can be one of the following values:
  636. * @arg @ref LL_COMP_WINDOWMODE_DISABLE
  637. * @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (1)
  638. * @arg @ref LL_COMP_WINDOWMODE_COMP3_INPUT_PLUS_COMMON (2)
  639. * @arg @ref LL_COMP_WINDOWMODE_COMP5_INPUT_PLUS_COMMON (2)
  640. *
  641. * (1) Parameter available on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
  642. * (2) Parameter available on devices: STM32F303xB/C, STM32F358xC
  643. * @retval None
  644. */
  645. __STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode)
  646. {
  647. #if defined(COMP_CSR_COMPxWNDWEN)
  648. MODIFY_REG(COMPxy_COMMON->CSR, COMP_CSR_COMPxWNDWEN, WindowMode);
  649. #else
  650. /* Device without pair of comparator working in window mode */
  651. /* No update of comparator register (corresponds to setting */
  652. /* "LL_COMP_WINDOWMODE_DISABLE"). */
  653. #endif
  654. }
  655. /**
  656. * @brief Get window mode of a pair of comparators instances
  657. * (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
  658. * @rmtoll CSR COMPxWNDWEN LL_COMP_GetCommonWindowMode
  659. * @param COMPxy_COMMON Comparator common instance
  660. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
  661. * @retval Returned value can be one of the following values:
  662. * @arg @ref LL_COMP_WINDOWMODE_DISABLE
  663. * @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (1)
  664. * @arg @ref LL_COMP_WINDOWMODE_COMP3_INPUT_PLUS_COMMON (2)
  665. * @arg @ref LL_COMP_WINDOWMODE_COMP5_INPUT_PLUS_COMMON (2)
  666. *
  667. * (1) Parameter available on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
  668. * (2) Parameter available on devices: STM32F303xB/C, STM32F358xC
  669. */
  670. __STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON)
  671. {
  672. #if defined(COMP_CSR_COMPxWNDWEN)
  673. return (uint32_t)(READ_BIT(COMPxy_COMMON->CSR, COMP_CSR_COMPxWNDWEN));
  674. #else
  675. /* Device without pair of comparator working in window mode */
  676. return (LL_COMP_WINDOWMODE_DISABLE);
  677. #endif
  678. }
  679. /**
  680. * @}
  681. */
  682. /** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes
  683. * @{
  684. */
  685. /**
  686. * @brief Set comparator instance operating mode to adjust power and speed.
  687. * @rmtoll CSR COMPxMODE LL_COMP_SetPowerMode
  688. * @param COMPx Comparator instance
  689. * @param PowerMode This parameter can be one of the following values:
  690. * @arg @ref LL_COMP_POWERMODE_HIGHSPEED
  691. * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED (1)
  692. * @arg @ref LL_COMP_POWERMODE_LOWPOWER (1)
  693. * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER (1)
  694. *
  695. * (1) Parameter available only on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
  696. * @retval None
  697. */
  698. __STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode)
  699. {
  700. #if defined(COMP_CSR_COMPxMODE)
  701. MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxMODE, PowerMode);
  702. #else
  703. /* Device without comparator power mode configurable */
  704. /* No update of comparator register (corresponds to setting */
  705. /* "LL_COMP_POWERMODE_HIGHSPEED"). */
  706. #endif
  707. }
  708. /**
  709. * @brief Get comparator instance operating mode to adjust power and speed.
  710. * @rmtoll CSR COMPxMODE LL_COMP_GetPowerMode
  711. * @param COMPx Comparator instance
  712. * @retval Returned value can be one of the following values:
  713. * @arg @ref LL_COMP_POWERMODE_HIGHSPEED
  714. * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED (1)
  715. * @arg @ref LL_COMP_POWERMODE_LOWPOWER (1)
  716. * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER (1)
  717. *
  718. * (1) Parameter available only on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
  719. */
  720. __STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx)
  721. {
  722. #if defined(COMP_CSR_COMPxMODE)
  723. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxMODE));
  724. #else
  725. /* Device without comparator power mode configurable */
  726. return (LL_COMP_POWERMODE_HIGHSPEED);
  727. #endif
  728. }
  729. /**
  730. * @}
  731. */
  732. /** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs
  733. * @{
  734. */
  735. /**
  736. * @brief Set comparator inputs minus (inverting) and plus (non-inverting).
  737. * @note In case of comparator input selected to be connected to IO:
  738. * GPIO pins are specific to each comparator instance.
  739. * Refer to description of parameters or to reference manual.
  740. * @note On this STM32 series, a voltage scaler is used
  741. * when COMP input is based on VrefInt (VrefInt or subdivision
  742. * of VrefInt):
  743. * Voltage scaler requires a delay for voltage stabilization.
  744. * Refer to device datasheet, parameter "tS_SC".
  745. * @rmtoll CSR INMSEL LL_COMP_ConfigInputs\n
  746. * CSR NONINSEL LL_COMP_ConfigInputs
  747. * @param COMPx Comparator instance
  748. * @param InputMinus This parameter can be one of the following values:
  749. * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
  750. * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
  751. * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
  752. * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
  753. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
  754. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2 (3)
  755. * @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1 (2)
  756. * @arg @ref LL_COMP_INPUT_MINUS_IO1
  757. * @arg @ref LL_COMP_INPUT_MINUS_IO2
  758. * @arg @ref LL_COMP_INPUT_MINUS_IO3 (1)
  759. * @arg @ref LL_COMP_INPUT_MINUS_IO4
  760. * (1) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302x6/8, STM32F303x6/8, STM32F328xx, STM32F334xx.\n
  761. * (2) Parameter available only on devices STM32F303x6/8, STM32F328x8, STM32F334xx.\n
  762. * (3) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302xx.\n
  763. * @param InputPlus This parameter can be one of the following values:
  764. * @arg @ref LL_COMP_INPUT_PLUS_IO1
  765. * @arg @ref LL_COMP_INPUT_PLUS_IO2 (1)
  766. * @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 (2)
  767. * @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2 (3)
  768. *
  769. * (1) Parameter available only on devices STM32F302xB/C, STM32F303xB/C, STM32F358xC.\n
  770. * (2) Parameter available on devices: STM32F302xB/C, STM32F302xD/E, STM32F303xB/C/D/E, STM32F358xC, STM32F398xE.\n
  771. * (3) Parameter available on devices: STM32F301x6/8, STM32F318xx, STM32F302x6/8.
  772. * @retval None
  773. */
  774. __STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus)
  775. {
  776. #if defined(COMP_CSR_COMPxNONINSEL) && defined(COMP_CSR_COMPxSW1)
  777. MODIFY_REG(COMPx->CSR,
  778. COMP_CSR_COMPxINSEL | COMP_CSR_COMPxNONINSEL | COMP_CSR_COMPxSW1,
  779. InputMinus | InputPlus);
  780. #elif defined(COMP_CSR_COMPxNONINSEL)
  781. MODIFY_REG(COMPx->CSR,
  782. COMP_CSR_COMPxINSEL | COMP_CSR_COMPxNONINSEL,
  783. InputMinus | InputPlus);
  784. #elif defined(COMP_CSR_COMPxSW1)
  785. MODIFY_REG(COMPx->CSR,
  786. COMP_CSR_COMPxINSEL | COMP_CSR_COMPxSW1,
  787. InputMinus | InputPlus);
  788. #else
  789. /* Device without comparator input plus configurable */
  790. /* No update of comparator register (corresponds to setting */
  791. /* "LL_COMP_INPUT_PLUS_IO1" or "LL_COMP_INPUT_PLUS_IO2" compared to */
  792. /* other STM32F3 devices, depending on comparator instance */
  793. /* (refer to reference manual)). */
  794. MODIFY_REG(COMPx->CSR,
  795. COMP_CSR_COMPxINSEL,
  796. InputMinus);
  797. #endif
  798. }
  799. /**
  800. * @brief Set comparator input plus (non-inverting).
  801. * @note In case of comparator input selected to be connected to IO:
  802. * GPIO pins are specific to each comparator instance.
  803. * Refer to description of parameters or to reference manual.
  804. * @rmtoll CSR NONINSEL LL_COMP_SetInputPlus
  805. * @param COMPx Comparator instance
  806. * @param InputPlus This parameter can be one of the following values:
  807. * @arg @ref LL_COMP_INPUT_PLUS_IO1
  808. * @arg @ref LL_COMP_INPUT_PLUS_IO2 (1)
  809. * @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 (2)
  810. * @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2 (3)
  811. *
  812. * (1) Parameter available only on devices STM32F302xB/C, STM32F303xB/C, STM32F358xC.\n
  813. * (2) Parameter available on devices: STM32F302xB/C, STM32F302xD/E, STM32F303xB/C/D/E, STM32F358xC, STM32F398xE.\n
  814. * (3) Parameter available on devices: STM32F301x6/8, STM32F318xx, STM32F302x6/8.
  815. * @retval None
  816. */
  817. __STATIC_INLINE void LL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus)
  818. {
  819. #if defined(COMP_CSR_COMPxNONINSEL) && defined(COMP_CSR_COMPxSW1)
  820. MODIFY_REG(COMPx->CSR, (COMP_CSR_COMPxNONINSEL | COMP_CSR_COMPxSW1), InputPlus);
  821. #elif defined(COMP_CSR_COMPxNONINSEL)
  822. MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxNONINSEL, InputPlus);
  823. #elif defined(COMP_CSR_COMPxSW1)
  824. MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxSW1, InputPlus);
  825. #else
  826. /* Device without comparator input plus configurable */
  827. /* No update of comparator register (corresponds to setting */
  828. /* "LL_COMP_INPUT_PLUS_IO1" or "LL_COMP_INPUT_PLUS_IO2" compared to */
  829. /* other STM32F3 devices, depending on comparator instance */
  830. /* (refer to reference manual)). */
  831. #endif
  832. }
  833. /**
  834. * @brief Get comparator input plus (non-inverting).
  835. * @note In case of comparator input selected to be connected to IO:
  836. * GPIO pins are specific to each comparator instance.
  837. * Refer to description of parameters or to reference manual.
  838. * @rmtoll CSR NONINSEL LL_COMP_GetInputPlus
  839. * @param COMPx Comparator instance
  840. * @retval Returned value can be one of the following values:
  841. * @arg @ref LL_COMP_INPUT_PLUS_IO1
  842. * @arg @ref LL_COMP_INPUT_PLUS_IO2 (1)
  843. * @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP1 (2)
  844. * @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1_COMP2 (3)
  845. *
  846. * (1) Parameter available only on devices STM32F302xB/C, STM32F303xB/C, STM32F358xC.\n
  847. * (2) Parameter available on devices: STM32F302xB/C, STM32F302xD/E, STM32F303xB/C/D/E, STM32F358xC, STM32F398xE.\n
  848. * (3) Parameter available on devices: STM32F301x6/8, STM32F318xx, STM32F302x6/8.
  849. */
  850. __STATIC_INLINE uint32_t LL_COMP_GetInputPlus(COMP_TypeDef *COMPx)
  851. {
  852. #if defined(COMP_CSR_COMPxNONINSEL) && defined(COMP_CSR_COMPxSW1)
  853. return (uint32_t)(READ_BIT(COMPx->CSR, (COMP_CSR_COMPxNONINSEL | COMP_CSR_COMPxSW1)));
  854. #elif defined(COMP_CSR_COMPxNONINSEL)
  855. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxNONINSEL));
  856. #elif defined(COMP_CSR_COMPxSW1)
  857. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxSW1));
  858. #else
  859. /* Device without comparator input plus configurable */
  860. /* No update of comparator register (corresponds to setting */
  861. /* "LL_COMP_INPUT_PLUS_IO1" or "LL_COMP_INPUT_PLUS_IO2" compared to */
  862. /* other STM32F3 devices, depending on comparator instance */
  863. /* (refer to reference manual)). */
  864. return (LL_COMP_INPUT_PLUS_IO1);
  865. #endif
  866. }
  867. /**
  868. * @brief Set comparator input minus (inverting).
  869. * @note In case of comparator input selected to be connected to IO:
  870. * GPIO pins are specific to each comparator instance.
  871. * Refer to description of parameters or to reference manual.
  872. * @note On this STM32 series, a voltage scaler is used
  873. * when COMP input is based on VrefInt (VrefInt or subdivision
  874. * of VrefInt):
  875. * Voltage scaler requires a delay for voltage stabilization.
  876. * Refer to device datasheet, parameter "tS_SC".
  877. * @rmtoll CSR INMSEL LL_COMP_SetInputMinus
  878. * @param COMPx Comparator instance
  879. * @param InputMinus This parameter can be one of the following values:
  880. * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
  881. * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
  882. * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
  883. * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
  884. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
  885. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2 (3)
  886. * @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1 (2)
  887. * @arg @ref LL_COMP_INPUT_MINUS_IO1
  888. * @arg @ref LL_COMP_INPUT_MINUS_IO2
  889. * @arg @ref LL_COMP_INPUT_MINUS_IO3 (1)
  890. * @arg @ref LL_COMP_INPUT_MINUS_IO4
  891. * (1) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302x6/8, STM32F303x6/8, STM32F328xx, STM32F334xx.\n
  892. * (2) Parameter available only on devices STM32F303x6/8, STM32F328x8, STM32F334xx.\n
  893. * (3) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302xx.\n
  894. * @retval None
  895. */
  896. __STATIC_INLINE void LL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus)
  897. {
  898. MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxINSEL, InputMinus);
  899. }
  900. /**
  901. * @brief Get comparator input minus (inverting).
  902. * @note In case of comparator input selected to be connected to IO:
  903. * GPIO pins are specific to each comparator instance.
  904. * Refer to description of parameters or to reference manual.
  905. * @rmtoll CSR INMSEL LL_COMP_GetInputMinus
  906. * @param COMPx Comparator instance
  907. * @retval Returned value can be one of the following values:
  908. * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
  909. * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
  910. * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
  911. * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
  912. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
  913. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2 (3)
  914. * @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1 (2)
  915. * @arg @ref LL_COMP_INPUT_MINUS_IO1
  916. * @arg @ref LL_COMP_INPUT_MINUS_IO2
  917. * @arg @ref LL_COMP_INPUT_MINUS_IO3 (1)
  918. * @arg @ref LL_COMP_INPUT_MINUS_IO4
  919. * (1) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302x6/8, STM32F303x6/8, STM32F328xx, STM32F334xx.\n
  920. * (2) Parameter available only on devices STM32F303x6/8, STM32F328x8, STM32F334xx.\n
  921. * (3) Parameter available on all devices except STM32F301x6/8, STM32F318x8, STM32F302xx.\n
  922. */
  923. __STATIC_INLINE uint32_t LL_COMP_GetInputMinus(COMP_TypeDef *COMPx)
  924. {
  925. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxINSEL));
  926. }
  927. /**
  928. * @brief Set comparator instance hysteresis mode of the input minus (inverting input).
  929. * @rmtoll CSR COMPxHYST LL_COMP_SetInputHysteresis
  930. * @param COMPx Comparator instance
  931. * @param InputHysteresis This parameter can be one of the following values:
  932. * @arg @ref LL_COMP_HYSTERESIS_NONE
  933. * @arg @ref LL_COMP_HYSTERESIS_LOW (1)
  934. * @arg @ref LL_COMP_HYSTERESIS_MEDIUM (1)
  935. * @arg @ref LL_COMP_HYSTERESIS_HIGH (1)
  936. *
  937. * (1) Parameter available only on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
  938. * @retval None
  939. */
  940. __STATIC_INLINE void LL_COMP_SetInputHysteresis(COMP_TypeDef *COMPx, uint32_t InputHysteresis)
  941. {
  942. #if defined(COMP_CSR_COMPxHYST)
  943. MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxHYST, InputHysteresis);
  944. #else
  945. /* Device without comparator input hysteresis */
  946. /* No update of comparator register (corresponds to setting */
  947. /* "LL_COMP_HYSTERESIS_NONE"). */
  948. #endif
  949. }
  950. /**
  951. * @brief Get comparator instance hysteresis mode of the minus (inverting) input.
  952. * @rmtoll CSR COMPxHYST LL_COMP_GetInputHysteresis
  953. * @param COMPx Comparator instance
  954. * @retval Returned value can be one of the following values:
  955. * @arg @ref LL_COMP_HYSTERESIS_NONE
  956. * @arg @ref LL_COMP_HYSTERESIS_LOW (1)
  957. * @arg @ref LL_COMP_HYSTERESIS_MEDIUM (1)
  958. * @arg @ref LL_COMP_HYSTERESIS_HIGH (1)
  959. *
  960. * (1) Parameter available only on devices: STM32F302xB/C, STM32F303xB/C, STM32F358xC
  961. */
  962. __STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis(COMP_TypeDef *COMPx)
  963. {
  964. #if defined(COMP_CSR_COMPxHYST)
  965. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxHYST));
  966. #else
  967. /* Device without comparator input hysteresis */
  968. return (LL_COMP_HYSTERESIS_NONE);
  969. #endif
  970. }
  971. /**
  972. * @}
  973. */
  974. /** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output
  975. * @{
  976. */
  977. /**
  978. * @brief Set comparator output selection.
  979. * @note Availability of parameters of output selection to timer
  980. * depends on timers availability on the selected device.
  981. * @rmtoll CSR COMPxOUTSEL LL_COMP_SetOutputSelection
  982. * @param COMPx Comparator instance
  983. * @param OutputSelection This parameter can be one of the following values:
  984. * @arg @ref LL_COMP_OUTPUT_NONE
  985. * @arg @ref LL_COMP_OUTPUT_TIM1_BKIN
  986. * @arg @ref LL_COMP_OUTPUT_TIM1_BKIN2
  987. * @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_BKIN2
  988. * @arg @ref LL_COMP_OUTPUT_TIM8_BKIN (4)
  989. * @arg @ref LL_COMP_OUTPUT_TIM8_BKIN2 (4)
  990. * @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_BKIN2 (4)
  991. * @arg @ref LL_COMP_OUTPUT_TIM20_BKIN (5)
  992. * @arg @ref LL_COMP_OUTPUT_TIM20_BKIN2 (5)
  993. * @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_TIM20_BKIN2 (5)
  994. * @arg @ref LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7 (4)
  995. * @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3 (4)
  996. * @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5 (4)
  997. * @arg @ref LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7 (4)
  998. * @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR_COMP2_4 (6)
  999. * @arg @ref LL_COMP_OUTPUT_TIM1_IC1_COMP2 (2)
  1000. * @arg @ref LL_COMP_OUTPUT_TIM2_IC4_COMP2 (2)
  1001. * @arg @ref LL_COMP_OUTPUT_TIM3_IC1_COMP2 (1)
  1002. * @arg @ref LL_COMP_OUTPUT_TIM1_IC1_COMP1_2 (3)
  1003. * @arg @ref LL_COMP_OUTPUT_TIM2_IC4_COMP1_2 (3)
  1004. * @arg @ref LL_COMP_OUTPUT_TIM3_IC1_COMP1_2 (3)
  1005. * @arg @ref LL_COMP_OUTPUT_TIM20_OCCLR_COMP2 (5)
  1006. * @arg @ref LL_COMP_OUTPUT_TIM3_IC2_COMP3 (4)
  1007. * @arg @ref LL_COMP_OUTPUT_TIM4_IC1_COMP3 (4)
  1008. * @arg @ref LL_COMP_OUTPUT_TIM15_IC1_COMP3 (4)
  1009. * @arg @ref LL_COMP_OUTPUT_TIM15_BKIN
  1010. * @arg @ref LL_COMP_OUTPUT_TIM3_IC3_COMP4 (1)
  1011. * @arg @ref LL_COMP_OUTPUT_TIM4_IC2_COMP4
  1012. * @arg @ref LL_COMP_OUTPUT_TIM15_IC2_COMP4
  1013. * @arg @ref LL_COMP_OUTPUT_TIM15_OCCLR_COMP4
  1014. * @arg @ref LL_COMP_OUTPUT_TIM2_IC1_COMP5 (4)
  1015. * @arg @ref LL_COMP_OUTPUT_TIM4_IC3_COMP5 (4)
  1016. * @arg @ref LL_COMP_OUTPUT_TIM17_IC1_COMP5 (4)
  1017. * @arg @ref LL_COMP_OUTPUT_TIM16_BKIN
  1018. * @arg @ref LL_COMP_OUTPUT_TIM2_IC2_COMP6
  1019. * @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR_COMP6
  1020. * @arg @ref LL_COMP_OUTPUT_TIM4_IC4_COMP6
  1021. * @arg @ref LL_COMP_OUTPUT_TIM16_IC1_COMP6
  1022. * @arg @ref LL_COMP_OUTPUT_TIM16_OCCLR_COMP6
  1023. * @arg @ref LL_COMP_OUTPUT_TIM1_IC2_COMP7 (4)
  1024. * @arg @ref LL_COMP_OUTPUT_TIM2_IC3_COMP7 (4)
  1025. * @arg @ref LL_COMP_OUTPUT_TIM17_OCCLR_COMP7 (4)
  1026. * @arg @ref LL_COMP_OUTPUT_TIM17_BKIN (4)
  1027. *
  1028. * (1) Parameter available on devices: STM32F302x8, STM32F318xx, STM32F303x8, STM32F328xx, STM32F334x8, STM32F302xC, STM32F302xE, STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
  1029. * (2) Parameter available on devices: STM32F301x8, STM32F302x8, STM32F318xx, STM32F303x8, STM32F328xx, STM32F334x8.\n
  1030. * (3) Parameter available on devices: STM32F302xC, STM32F302xE, STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
  1031. * (4) Parameter available on devices: STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
  1032. * (5) Parameter available on devices: STM32F303xE, STM32F398xx.\n
  1033. * (6) Parameter available on devices: STM32F303x8, STM32F328xx, STM32F334x8.
  1034. * @retval None
  1035. */
  1036. __STATIC_INLINE void LL_COMP_SetOutputSelection(COMP_TypeDef *COMPx, uint32_t OutputSelection)
  1037. {
  1038. MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxOUTSEL, OutputSelection);
  1039. }
  1040. /**
  1041. * @brief Get comparator output selection.
  1042. * @note Availability of parameters of output selection to timer
  1043. * depends on timers availability on the selected device.
  1044. * @rmtoll CSR COMPxOUTSEL LL_COMP_GetOutputSelection
  1045. * @param COMPx Comparator instance
  1046. * @retval Returned value can be one of the following values:
  1047. * @arg @ref LL_COMP_OUTPUT_NONE
  1048. * @arg @ref LL_COMP_OUTPUT_TIM1_BKIN
  1049. * @arg @ref LL_COMP_OUTPUT_TIM1_BKIN2
  1050. * @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_BKIN2
  1051. * @arg @ref LL_COMP_OUTPUT_TIM8_BKIN (4)
  1052. * @arg @ref LL_COMP_OUTPUT_TIM8_BKIN2 (4)
  1053. * @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_BKIN2 (4)
  1054. * @arg @ref LL_COMP_OUTPUT_TIM20_BKIN (5)
  1055. * @arg @ref LL_COMP_OUTPUT_TIM20_BKIN2 (5)
  1056. * @arg @ref LL_COMP_OUTPUT_TIM1_TIM8_TIM20_BKIN2 (5)
  1057. * @arg @ref LL_COMP_OUTPUT_TIM1_OCCLR_COMP1_2_3_7 (4)
  1058. * @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR_COMP1_2_3 (4)
  1059. * @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR_COMP1_2_4_5 (4)
  1060. * @arg @ref LL_COMP_OUTPUT_TIM8_OCCLR_COMP4_5_6_7 (4)
  1061. * @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR_COMP2_4 (6)
  1062. * @arg @ref LL_COMP_OUTPUT_TIM1_IC1_COMP2 (2)
  1063. * @arg @ref LL_COMP_OUTPUT_TIM2_IC4_COMP2 (2)
  1064. * @arg @ref LL_COMP_OUTPUT_TIM3_IC1_COMP2 (1)
  1065. * @arg @ref LL_COMP_OUTPUT_TIM1_IC1_COMP1_2 (3)
  1066. * @arg @ref LL_COMP_OUTPUT_TIM2_IC4_COMP1_2 (3)
  1067. * @arg @ref LL_COMP_OUTPUT_TIM3_IC1_COMP1_2 (3)
  1068. * @arg @ref LL_COMP_OUTPUT_TIM20_OCCLR_COMP2 (5)
  1069. * @arg @ref LL_COMP_OUTPUT_TIM3_IC2_COMP3 (4)
  1070. * @arg @ref LL_COMP_OUTPUT_TIM4_IC1_COMP3 (4)
  1071. * @arg @ref LL_COMP_OUTPUT_TIM15_IC1_COMP3 (4)
  1072. * @arg @ref LL_COMP_OUTPUT_TIM15_BKIN
  1073. * @arg @ref LL_COMP_OUTPUT_TIM3_IC3_COMP4 (1)
  1074. * @arg @ref LL_COMP_OUTPUT_TIM4_IC2_COMP4
  1075. * @arg @ref LL_COMP_OUTPUT_TIM15_IC2_COMP4
  1076. * @arg @ref LL_COMP_OUTPUT_TIM15_OCCLR_COMP4
  1077. * @arg @ref LL_COMP_OUTPUT_TIM2_IC1_COMP5 (4)
  1078. * @arg @ref LL_COMP_OUTPUT_TIM4_IC3_COMP5 (4)
  1079. * @arg @ref LL_COMP_OUTPUT_TIM17_IC1_COMP5 (4)
  1080. * @arg @ref LL_COMP_OUTPUT_TIM16_BKIN
  1081. * @arg @ref LL_COMP_OUTPUT_TIM2_IC2_COMP6
  1082. * @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR_COMP6
  1083. * @arg @ref LL_COMP_OUTPUT_TIM4_IC4_COMP6
  1084. * @arg @ref LL_COMP_OUTPUT_TIM16_IC1_COMP6
  1085. * @arg @ref LL_COMP_OUTPUT_TIM16_OCCLR_COMP6
  1086. * @arg @ref LL_COMP_OUTPUT_TIM1_IC2_COMP7 (4)
  1087. * @arg @ref LL_COMP_OUTPUT_TIM2_IC3_COMP7 (4)
  1088. * @arg @ref LL_COMP_OUTPUT_TIM17_OCCLR_COMP7 (4)
  1089. * @arg @ref LL_COMP_OUTPUT_TIM17_BKIN (4)
  1090. *
  1091. * (1) Parameter available on devices: STM32F302x8, STM32F318xx, STM32F303x8, STM32F328xx, STM32F334x8, STM32F302xC, STM32F302xE, STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
  1092. * (2) Parameter available on devices: STM32F301x8, STM32F302x8, STM32F318xx, STM32F303x8, STM32F328xx, STM32F334x8.\n
  1093. * (3) Parameter available on devices: STM32F302xC, STM32F302xE, STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
  1094. * (4) Parameter available on devices: STM32F303xC, STM32F358xx, STM32F303xE, STM32F398xx.\n
  1095. * (5) Parameter available on devices: STM32F303xE, STM32F398xx.\n
  1096. * (6) Parameter available on devices: STM32F303x8, STM32F328xx, STM32F334x8.
  1097. */
  1098. __STATIC_INLINE uint32_t LL_COMP_GetOutputSelection(COMP_TypeDef *COMPx)
  1099. {
  1100. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxOUTSEL));
  1101. }
  1102. /**
  1103. * @brief Set comparator instance output polarity.
  1104. * @rmtoll CSR COMPxPOL LL_COMP_SetOutputPolarity
  1105. * @param COMPx Comparator instance
  1106. * @param OutputPolarity This parameter can be one of the following values:
  1107. * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
  1108. * @arg @ref LL_COMP_OUTPUTPOL_INVERTED
  1109. * @retval None
  1110. */
  1111. __STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity)
  1112. {
  1113. MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxPOL, OutputPolarity);
  1114. }
  1115. /**
  1116. * @brief Get comparator instance output polarity.
  1117. * @rmtoll CSR COMPxPOL LL_COMP_GetOutputPolarity
  1118. * @param COMPx Comparator instance
  1119. * @retval Returned value can be one of the following values:
  1120. * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
  1121. * @arg @ref LL_COMP_OUTPUTPOL_INVERTED
  1122. */
  1123. __STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
  1124. {
  1125. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxPOL));
  1126. }
  1127. /**
  1128. * @brief Set comparator instance blanking source.
  1129. * @note Blanking source may be specific to each comparator instance.
  1130. * Refer to description of parameters or to reference manual.
  1131. * @note Availability of parameters of blanking source from timer
  1132. * depends on timers availability on the selected device.
  1133. * @rmtoll CSR COMPxBLANKING LL_COMP_SetOutputBlankingSource
  1134. * @param COMPx Comparator instance
  1135. * @param BlankingSource This parameter can be one of the following values:
  1136. * @arg @ref LL_COMP_BLANKINGSRC_NONE
  1137. * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP2 (1)
  1138. * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP2 (1)
  1139. * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP2 (1)
  1140. * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2 (2)(3)
  1141. * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2 (2)(3)
  1142. * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2 (2)(3)
  1143. * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4
  1144. * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4
  1145. * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6 (2)
  1146. * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6 (1)(2)
  1147. * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2_7 (3)
  1148. * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC4_COMP3_6 (3)
  1149. * @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7 (3)
  1150. * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6_7 (3)
  1151. *
  1152. * (1) Parameter available on devices: STM32F301x8, STM32F302x8, STM32F318xx, STM32F303x8, STM32F334x8, STM32F328xx.\n
  1153. * (2) Parameter available on devices: STM32F302xE, STM32F302xC.\n
  1154. * (3) Parameter available on devices: STM32F303xE, STM32F398xx, STM32F303xC, STM32F358xx.
  1155. * @retval None
  1156. */
  1157. __STATIC_INLINE void LL_COMP_SetOutputBlankingSource(COMP_TypeDef *COMPx, uint32_t BlankingSource)
  1158. {
  1159. MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxBLANKING, BlankingSource);
  1160. }
  1161. /**
  1162. * @brief Get comparator instance blanking source.
  1163. * @note Availability of parameters of blanking source from timer
  1164. * depends on timers availability on the selected device.
  1165. * @note Blanking source may be specific to each comparator instance.
  1166. * Refer to description of parameters or to reference manual.
  1167. * @rmtoll CSR COMPxBLANKING LL_COMP_GetOutputBlankingSource
  1168. * @param COMPx Comparator instance
  1169. * @retval Returned value can be one of the following values:
  1170. * @arg @ref LL_COMP_BLANKINGSRC_NONE
  1171. * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP2 (1)
  1172. * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP2 (1)
  1173. * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP2 (1)
  1174. * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2 (2)(3)
  1175. * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC3_COMP1_2 (2)(3)
  1176. * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC3_COMP1_2 (2)(3)
  1177. * @arg @ref LL_COMP_BLANKINGSRC_TIM3_OC4_COMP4
  1178. * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC1_COMP4
  1179. * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC4_COMP6 (2)
  1180. * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6 (1)(2)
  1181. * @arg @ref LL_COMP_BLANKINGSRC_TIM1_OC5_COMP1_2_7 (3)
  1182. * @arg @ref LL_COMP_BLANKINGSRC_TIM2_OC4_COMP3_6 (3)
  1183. * @arg @ref LL_COMP_BLANKINGSRC_TIM8_OC5_COMP4_5_6_7 (3)
  1184. * @arg @ref LL_COMP_BLANKINGSRC_TIM15_OC2_COMP6_7 (3)
  1185. *
  1186. * (1) Parameter available on devices: STM32F301x8, STM32F302x8, STM32F318xx, STM32F303x8, STM32F334x8, STM32F328xx.\n
  1187. * (2) Parameter available on devices: STM32F302xE, STM32F302xC.\n
  1188. * (3) Parameter available on devices: STM32F303xE, STM32F398xx, STM32F303xC, STM32F358xx.
  1189. */
  1190. __STATIC_INLINE uint32_t LL_COMP_GetOutputBlankingSource(COMP_TypeDef *COMPx)
  1191. {
  1192. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxBLANKING));
  1193. }
  1194. /**
  1195. * @}
  1196. */
  1197. /** @defgroup COMP_LL_EF_Operation Operation on comparator instance
  1198. * @{
  1199. */
  1200. /**
  1201. * @brief Enable comparator instance.
  1202. * @note After enable from off state, comparator requires a delay
  1203. * to reach reach propagation delay specification.
  1204. * Refer to device datasheet, parameter "tSTART".
  1205. * @rmtoll CSR COMPxEN LL_COMP_Enable
  1206. * @param COMPx Comparator instance
  1207. * @retval None
  1208. */
  1209. __STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx)
  1210. {
  1211. SET_BIT(COMPx->CSR, COMP_CSR_COMPxEN);
  1212. }
  1213. /**
  1214. * @brief Disable comparator instance.
  1215. * @rmtoll CSR COMPxEN LL_COMP_Disable
  1216. * @param COMPx Comparator instance
  1217. * @retval None
  1218. */
  1219. __STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx)
  1220. {
  1221. CLEAR_BIT(COMPx->CSR, COMP_CSR_COMPxEN);
  1222. }
  1223. /**
  1224. * @brief Get comparator enable state
  1225. * (0: COMP is disabled, 1: COMP is enabled)
  1226. * @rmtoll CSR COMPxEN LL_COMP_IsEnabled
  1227. * @param COMPx Comparator instance
  1228. * @retval State of bit (1 or 0).
  1229. */
  1230. __STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx)
  1231. {
  1232. return (READ_BIT(COMPx->CSR, COMP_CSR_COMPxEN) == (COMP_CSR_COMPxEN));
  1233. }
  1234. /**
  1235. * @brief Lock comparator instance.
  1236. * @note Once locked, comparator configuration can be accessed in read-only.
  1237. * @note The only way to unlock the comparator is a device hardware reset.
  1238. * @rmtoll CSR COMPxLOCK LL_COMP_Lock
  1239. * @param COMPx Comparator instance
  1240. * @retval None
  1241. */
  1242. __STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx)
  1243. {
  1244. SET_BIT(COMPx->CSR, COMP_CSR_COMPxLOCK);
  1245. }
  1246. /**
  1247. * @brief Get comparator lock state
  1248. * (0: COMP is unlocked, 1: COMP is locked).
  1249. * @note Once locked, comparator configuration can be accessed in read-only.
  1250. * @note The only way to unlock the comparator is a device hardware reset.
  1251. * @rmtoll CSR COMPxLOCK LL_COMP_IsLocked
  1252. * @param COMPx Comparator instance
  1253. * @retval State of bit (1 or 0).
  1254. */
  1255. __STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
  1256. {
  1257. return (READ_BIT(COMPx->CSR, COMP_CSR_COMPxLOCK) == (COMP_CSR_COMPxLOCK));
  1258. }
  1259. /**
  1260. * @brief Read comparator instance output level.
  1261. * @note The comparator output level depends on the selected polarity
  1262. * (Refer to function @ref LL_COMP_SetOutputPolarity()).
  1263. * If the comparator polarity is not inverted:
  1264. * - Comparator output is low when the input plus
  1265. * is at a lower voltage than the input minus
  1266. * - Comparator output is high when the input plus
  1267. * is at a higher voltage than the input minus
  1268. * If the comparator polarity is inverted:
  1269. * - Comparator output is high when the input plus
  1270. * is at a lower voltage than the input minus
  1271. * - Comparator output is low when the input plus
  1272. * is at a higher voltage than the input minus
  1273. * @rmtoll CSR COMPxOUT LL_COMP_ReadOutputLevel
  1274. * @param COMPx Comparator instance
  1275. * @retval Returned value can be one of the following values:
  1276. * @arg @ref LL_COMP_OUTPUT_LEVEL_LOW
  1277. * @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH
  1278. */
  1279. __STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
  1280. {
  1281. return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxOUT)
  1282. >> LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS);
  1283. }
  1284. /**
  1285. * @}
  1286. */
  1287. #if defined(USE_FULL_LL_DRIVER)
  1288. /** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions
  1289. * @{
  1290. */
  1291. ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx);
  1292. ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct);
  1293. void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct);
  1294. /**
  1295. * @}
  1296. */
  1297. #endif /* USE_FULL_LL_DRIVER */
  1298. /**
  1299. * @}
  1300. */
  1301. /**
  1302. * @}
  1303. */
  1304. #endif /* COMP1 || COMP2 || COMP3 || COMP4 || COMP5 || COMP6 || COMP7 */
  1305. #endif /* STM32F301x8 || STM32F302x8 || STM32F302xC || STM32F302xE || STM32F303x8 || STM32F303xC || STM32F303xE || STM32F318xx || STM32F328xx || STM32F334x8 || STM32F358xx || STM32F398xx */
  1306. #if defined (COMP_V1_1_0_0)
  1307. #if defined (COMP1) || defined (COMP2)
  1308. /** @defgroup COMP_LL COMP
  1309. * @{
  1310. */
  1311. /* Private types -------------------------------------------------------------*/
  1312. /* Private variables ---------------------------------------------------------*/
  1313. /* Private constants ---------------------------------------------------------*/
  1314. /** @defgroup COMP_LL_Private_Constants COMP Private Constants
  1315. * @{
  1316. */
  1317. /* Differentiation between COMP instances */
  1318. /* Note: Value not corresponding to a register offset since both */
  1319. /* COMP instances are sharing the same register) . */
  1320. #define COMPX_BASE COMP_BASE
  1321. #define COMPX (COMP1 - COMP2)
  1322. /* COMP registers bits positions */
  1323. #define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS ((uint32_t)14U) /* Value equivalent to POSITION_VAL(COMP_CSR_COMP1OUT) */
  1324. /**
  1325. * @}
  1326. */
  1327. /* Private macros ------------------------------------------------------------*/
  1328. /** @defgroup COMP_LL_Private_Macros COMP Private Macros
  1329. * @{
  1330. */
  1331. /**
  1332. * @brief Driver macro reserved for internal use: if COMP instance selected
  1333. * is odd (COMP1, COMP3, ...), return value '1', else return '0'.
  1334. * @param __COMP_INSTANCE__ COMP instance
  1335. * @retval If COMP instance is odd, value '1'. Else, value '0'.
  1336. */
  1337. #define __COMP_IS_INSTANCE_ODD(__COMP_INSTANCE__) \
  1338. ((~(((uint32_t)(__COMP_INSTANCE__) - COMP_BASE) >> 1U)) & 0x00000001)
  1339. /**
  1340. * @brief Driver macro reserved for internal use: if COMP instance selected
  1341. * is even (COMP2, COMP4, ...), return value '1', else return '0'.
  1342. * @param __COMP_INSTANCE__ COMP instance
  1343. * @retval If COMP instance is even, value '1'. Else, value '0'.
  1344. */
  1345. #define __COMP_IS_INSTANCE_EVEN(__COMP_INSTANCE__) \
  1346. (((uint32_t)(__COMP_INSTANCE__) - COMP_BASE) >> 1U)
  1347. /**
  1348. * @brief Driver macro reserved for internal use: from COMP instance
  1349. * selected, set offset of bits into COMP register.
  1350. * @note Since both COMP instances are sharing the same register
  1351. * with 2 area of bits with an offset of 16 bits, this function
  1352. * returns value "0" if COMP1 is selected and "16" if COMP2 is
  1353. * selected.
  1354. * @param __COMP_INSTANCE__ COMP instance
  1355. * @retval Bits offset in register 32 bits
  1356. */
  1357. #define __COMP_BITOFFSET_INSTANCE(__COMP_INSTANCE__) \
  1358. (((uint32_t)(__COMP_INSTANCE__) - COMP_BASE) << 3U)
  1359. /**
  1360. * @}
  1361. */
  1362. /* Exported types ------------------------------------------------------------*/
  1363. #if defined(USE_FULL_LL_DRIVER)
  1364. /** @defgroup COMP_LL_ES_INIT COMP Exported Init structure
  1365. * @{
  1366. */
  1367. /**
  1368. * @brief Structure definition of some features of COMP instance.
  1369. */
  1370. typedef struct
  1371. {
  1372. uint32_t PowerMode; /*!< Set comparator operating mode to adjust power and speed.
  1373. This parameter can be a value of @ref COMP_LL_EC_POWERMODE
  1374. This feature can be modified afterwards using unitary function @ref LL_COMP_SetPowerMode(). */
  1375. uint32_t InputPlus; /*!< Set comparator input plus (non-inverting input).
  1376. This parameter can be a value of @ref COMP_LL_EC_INPUT_PLUS
  1377. This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputPlus(). */
  1378. uint32_t InputMinus; /*!< Set comparator input minus (inverting input).
  1379. This parameter can be a value of @ref COMP_LL_EC_INPUT_MINUS
  1380. This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputMinus(). */
  1381. uint32_t InputHysteresis; /*!< Set comparator hysteresis mode of the input minus.
  1382. This parameter can be a value of @ref COMP_LL_EC_INPUT_HYSTERESIS
  1383. This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputHysteresis(). */
  1384. uint32_t OutputSelection; /*!< Set comparator output selection.
  1385. This parameter can be a value of @ref COMP_LL_EC_OUTPUT_SELECTION
  1386. This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputSelection(). */
  1387. uint32_t OutputPolarity; /*!< Set comparator output polarity.
  1388. This parameter can be a value of @ref COMP_LL_EC_OUTPUT_POLARITY
  1389. This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputPolarity(). */
  1390. } LL_COMP_InitTypeDef;
  1391. /**
  1392. * @}
  1393. */
  1394. #endif /* USE_FULL_LL_DRIVER */
  1395. /* Exported constants --------------------------------------------------------*/
  1396. /** @defgroup COMP_LL_Exported_Constants COMP Exported Constants
  1397. * @{
  1398. */
  1399. /** @defgroup COMP_LL_EC_COMMON_WINDOWMODE Comparator common modes - Window mode
  1400. * @{
  1401. */
  1402. #define LL_COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000U) /*!< Window mode disable: Comparators 1 and 2 are independent */
  1403. #define LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_WNDWEN) /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP1 input plus (COMP2 input plus is no more accessible). */
  1404. /**
  1405. * @}
  1406. */
  1407. /** @defgroup COMP_LL_EC_POWERMODE Comparator modes - Power mode
  1408. * @{
  1409. */
  1410. #define LL_COMP_POWERMODE_HIGHSPEED ((uint32_t)0x00000000U) /*!< COMP power mode to high speed */
  1411. #define LL_COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_COMP1MODE_0) /*!< COMP power mode to medium speed */
  1412. #define LL_COMP_POWERMODE_LOWPOWER (COMP_CSR_COMP1MODE_1) /*!< COMP power mode to low power */
  1413. #define LL_COMP_POWERMODE_ULTRALOWPOWER (COMP_CSR_COMP1MODE_1 | COMP_CSR_COMP1MODE_0) /*!< COMP power mode to ultra-low power */
  1414. /**
  1415. * @}
  1416. */
  1417. /** @defgroup COMP_LL_EC_INPUT_PLUS Comparator inputs - Input plus (input non-inverting) selection
  1418. * @{
  1419. */
  1420. #define LL_COMP_INPUT_PLUS_IO1 ((uint32_t)0x00000000U) /*!< Comparator input plus connected to IO1 (pin PA1 for COMP1, pin PA3 for COMP2) */
  1421. #define LL_COMP_INPUT_PLUS_DAC1_CH1 (COMP_CSR_COMP1SW1) /*!< Comparator input plus connected to DAC1 channel 1 (DAC_OUT1), through dedicated switch (Note: this switch is solely intended to redirect signals onto high impedance input, such as COMP1 input plus (highly resistive switch)) (specific to COMP instance: COMP1) */
  1422. /**
  1423. * @}
  1424. */
  1425. /** @defgroup COMP_LL_EC_INPUT_MINUS Comparator inputs - Input minus (input inverting) selection
  1426. * @{
  1427. */
  1428. #define LL_COMP_INPUT_MINUS_1_4VREFINT ((uint32_t)0x00000000U) /*!< Comparator input minus connected to 1/4 VrefInt */
  1429. #define LL_COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to 1/2 VrefInt */
  1430. #define LL_COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_COMP1INSEL_1 ) /*!< Comparator input minus connected to 3/4 VrefInt */
  1431. #define LL_COMP_INPUT_MINUS_VREFINT ( COMP_CSR_COMP1INSEL_1 | COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to VrefInt */
  1432. #define LL_COMP_INPUT_MINUS_DAC1_CH1 (COMP_CSR_COMP1INSEL_2 ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */
  1433. #define LL_COMP_INPUT_MINUS_DAC1_CH2 (COMP_CSR_COMP1INSEL_2 | COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */
  1434. #define LL_COMP_INPUT_MINUS_IO1 (COMP_CSR_COMP1INSEL_2 | COMP_CSR_COMP1INSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PA0 for COMP1, pin PA2 for COMP2) */
  1435. #define LL_COMP_INPUT_MINUS_IO2 (COMP_CSR_COMP1INSEL_2 | COMP_CSR_COMP1INSEL_1 | COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to IO2 (pin PA6 for COMP1 & COMP2) */
  1436. #define LL_COMP_INPUT_MINUS_IO3 (COMP_CSR_COMP1INSEL_2 | COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to IO3 (pin PA5 for COMP1 & COMP2) */
  1437. #define LL_COMP_INPUT_MINUS_IO4 (COMP_CSR_COMP1INSEL_2 ) /*!< Comparator input minus connected to IO4 (pin PA4 for COMP1 & COMP2) */
  1438. #define LL_COMP_INPUT_MINUS_DAC2_CH1 (COMP_CSR_COMP1INSEL_2 | COMP_CSR_COMP1INSEL_1 | COMP_CSR_COMP1INSEL_0) /*!< Comparator input minus connected to DAC2 channel 1 (DAC2_OUT1) */
  1439. /**
  1440. * @}
  1441. */
  1442. /** @defgroup COMP_LL_EC_INPUT_HYSTERESIS Comparator input - Hysteresis
  1443. * @{
  1444. */
  1445. #define LL_COMP_HYSTERESIS_NONE ((uint32_t)0x00000000U) /*!< No hysteresis */
  1446. #define LL_COMP_HYSTERESIS_LOW ( COMP_CSR_COMP1HYST_0) /*!< Hysteresis level low */
  1447. #define LL_COMP_HYSTERESIS_MEDIUM (COMP_CSR_COMP1HYST_1 ) /*!< Hysteresis level medium */
  1448. #define LL_COMP_HYSTERESIS_HIGH (COMP_CSR_COMP1HYST_1 | COMP_CSR_COMP1HYST_0) /*!< Hysteresis level high */
  1449. /**
  1450. * @}
  1451. */
  1452. /** @defgroup COMP_LL_EC_OUTPUT_SELECTION Comparator output - Output selection
  1453. * @{
  1454. */
  1455. /* Note: Output redirection is common for COMP1 and COMP2 */
  1456. #define LL_COMP_OUTPUT_NONE ((uint32_t)0x00000000U) /*!< COMP output is not connected to other peripherals (except GPIO and EXTI that are always connected to COMP output) */
  1457. #define LL_COMP_OUTPUT_TIM2_IC4 (COMP_CSR_COMP1OUTSEL_2) /*!< COMP output connected to TIM2 input capture 4 */
  1458. #define LL_COMP_OUTPUT_TIM2_OCCLR (COMP_CSR_COMP1OUTSEL_2 | COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM2 OCREF clear */
  1459. /* Note: Output redirection specific to COMP instance: COMP1 */
  1460. #define LL_COMP_OUTPUT_TIM15_BKIN_COMP1 (COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM15 break input (BKIN) (specific to COMP instance: COMP1) */
  1461. #define LL_COMP_OUTPUT_TIM3_IC1_COMP1 (COMP_CSR_COMP1OUTSEL_1) /*!< COMP output connected to TIM3 input capture 1 (specific to COMP instance: COMP1) */
  1462. #define LL_COMP_OUTPUT_TIM3_OCCLR_COMP1 (COMP_CSR_COMP1OUTSEL_1 | COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM3 OCREF clear (specific to COMP instance: COMP1) */
  1463. #define LL_COMP_OUTPUT_TIM5_IC4_COMP1 (COMP_CSR_COMP1OUTSEL_2 | COMP_CSR_COMP1OUTSEL_1) /*!< COMP output connected to TIM5 input capture 4 (specific to COMP instance: COMP1) */
  1464. #define LL_COMP_OUTPUT_TIM5_OCCLR_COMP1 (COMP_CSR_COMP1OUTSEL_2 | COMP_CSR_COMP1OUTSEL_1 | COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM5 OCREF clear (specific to COMP instance: COMP1) */
  1465. /* Note: Output redirection specific to COMP instance: COMP2 */
  1466. #define LL_COMP_OUTPUT_TIM16_BKIN_COMP2 (COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM16 break input (BKIN) (specific to COMP instance: COMP2) */
  1467. #define LL_COMP_OUTPUT_TIM4_IC1_COMP2 (COMP_CSR_COMP1OUTSEL_1) /*!< COMP output connected to TIM4 input capture 1 (specific to COMP instance: COMP2) */
  1468. #define LL_COMP_OUTPUT_TIM4_OCCLR_COMP2 (COMP_CSR_COMP1OUTSEL_1 | COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM4 OCREF clear (specific to COMP instance: COMP2) */
  1469. #define LL_COMP_OUTPUT_TIM3_IC1_COMP2 (COMP_CSR_COMP1OUTSEL_2 | COMP_CSR_COMP1OUTSEL_1) /*!< COMP output connected to TIM3 input capture 1 (specific to COMP instance: COMP2) */
  1470. #define LL_COMP_OUTPUT_TIM3_OCCLR_COMP2 (COMP_CSR_COMP1OUTSEL_2 | COMP_CSR_COMP1OUTSEL_1 | COMP_CSR_COMP1OUTSEL_0) /*!< COMP output connected to TIM3 OCREF clear (specific to COMP instance: COMP2) */
  1471. /* Note: Output redirection specific to COMP instances, defined with */
  1472. /* generic naming not taking into account COMP instance constraints. */
  1473. /* Refer to literal definitions above for COMP instance constraints. */
  1474. /* Note: Some output redirections cannot have a generic naming, */
  1475. /* due to literal value different depending on COMP instance. */
  1476. /* (For example: LL_COMP_OUTPUT_TIM3_IC1_COMP1 and */
  1477. /* LL_COMP_OUTPUT_TIM3_IC1_COMP2). */
  1478. #define LL_COMP_OUTPUT_TIM15_BKIN LL_COMP_OUTPUT_TIM15_BKIN_COMP1 /*!< COMP output connected to TIM15 break input (BKIN). Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  1479. #define LL_COMP_OUTPUT_TIM16_BKIN LL_COMP_OUTPUT_TIM16_BKIN_COMP2 /*!< COMP output connected to TIM16 break input (BKIN). Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  1480. #define LL_COMP_OUTPUT_TIM4_IC1 LL_COMP_OUTPUT_TIM4_IC1_COMP2 /*!< COMP output connected to TIM4 input capture 1. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  1481. #define LL_COMP_OUTPUT_TIM4_OCCLR LL_COMP_OUTPUT_TIM4_OCCLR_COMP2 /*!< COMP output connected to TIM4 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  1482. #define LL_COMP_OUTPUT_TIM5_IC4 LL_COMP_OUTPUT_TIM5_IC1_COMP1 /*!< COMP output connected to TIM5 input capture 4. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  1483. #define LL_COMP_OUTPUT_TIM5_OCCLR LL_COMP_OUTPUT_TIM5_OCCLR_COMP1 /*!< COMP output connected to TIM5 OCREF clear. Caution: Parameter specific to COMP instances, defined with generic naming, not taking into account COMP instance constraints. Refer to literal definitions above for COMP instance constraints. */
  1484. /**
  1485. * @}
  1486. */
  1487. /** @defgroup COMP_LL_EC_OUTPUT_POLARITY Comparator output - Output polarity
  1488. * @{
  1489. */
  1490. #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 */
  1491. #define LL_COMP_OUTPUTPOL_INVERTED (COMP_CSR_COMP1POL) /*!< COMP output polarity is inverted: comparator output is low when the plus (non-inverting) input is at a lower voltage than the minus (inverting) input */
  1492. /**
  1493. * @}
  1494. */
  1495. /** @defgroup COMP_LL_EC_OUTPUT_LEVEL Comparator output - Output level
  1496. * @{
  1497. */
  1498. #define LL_COMP_OUTPUT_LEVEL_LOW ((uint32_t)0x00000000U) /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */
  1499. #define LL_COMP_OUTPUT_LEVEL_HIGH ((uint32_t)0x00000001U) /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */
  1500. /**
  1501. * @}
  1502. */
  1503. /** @defgroup COMP_LL_EC_HW_DELAYS Definitions of COMP hardware constraints delays
  1504. * @note Only COMP IP HW delays are defined in COMP LL driver driver,
  1505. * not timeout values.
  1506. * For details on delays values, refer to descriptions in source code
  1507. * above each literal definition.
  1508. * @{
  1509. */
  1510. /* Delay for comparator startup time. */
  1511. /* Note: Delay required to reach propagation delay specification. */
  1512. /* Literal set to maximum value (refer to device datasheet, */
  1513. /* parameter "tSTART"). */
  1514. /* Unit: us */
  1515. #define LL_COMP_DELAY_STARTUP_US ((uint32_t) 60U) /*!< Delay for COMP startup time */
  1516. /* Delay for comparator voltage scaler stabilization time */
  1517. /* (voltage from VrefInt, delay based on VrefInt startup time). */
  1518. /* Literal set to maximum value (refer to device datasheet, */
  1519. /* parameter "tS_SC"). */
  1520. /* Unit: us */
  1521. #define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ((uint32_t) 200U) /*!< Delay for COMP voltage scaler stabilization time */
  1522. /**
  1523. * @}
  1524. */
  1525. /**
  1526. * @}
  1527. */
  1528. /* Exported macro ------------------------------------------------------------*/
  1529. /** @defgroup COMP_LL_Exported_Macros COMP Exported Macros
  1530. * @{
  1531. */
  1532. /** @defgroup COMP_LL_EM_WRITE_READ Common write and read registers macro
  1533. * @{
  1534. */
  1535. /**
  1536. * @brief Write a value in COMP register
  1537. * @param __INSTANCE__ comparator instance
  1538. * @param __REG__ Register to be written
  1539. * @param __VALUE__ Value to be written in the register
  1540. * @retval None
  1541. */
  1542. #define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
  1543. /**
  1544. * @brief Read a value in COMP register
  1545. * @param __INSTANCE__ comparator instance
  1546. * @param __REG__ Register to be read
  1547. * @retval Register value
  1548. */
  1549. #define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
  1550. /**
  1551. * @}
  1552. */
  1553. /** @defgroup COMP_LL_EM_HELPER_MACRO COMP helper macro
  1554. * @{
  1555. */
  1556. /**
  1557. * @brief Helper macro to select the COMP common instance
  1558. * to which is belonging the selected COMP instance.
  1559. * @note COMP common register instance can be used to
  1560. * set parameters common to several COMP instances.
  1561. * Refer to functions having argument "COMPxy_COMMON" as parameter.
  1562. * @param __COMPx__ COMP instance
  1563. * @retval COMP common instance or value "0" if there is no COMP common instance.
  1564. */
  1565. #define __LL_COMP_COMMON_INSTANCE(__COMPx__) \
  1566. (COMP12_COMMON)
  1567. /**
  1568. * @}
  1569. */
  1570. /**
  1571. * @}
  1572. */
  1573. /* Exported functions --------------------------------------------------------*/
  1574. /** @defgroup COMP_LL_Exported_Functions COMP Exported Functions
  1575. * @{
  1576. */
  1577. /** @defgroup COMP_LL_EF_Configuration_comparator_common Configuration of COMP hierarchical scope: common to several COMP instances
  1578. * @{
  1579. */
  1580. /**
  1581. * @brief Set window mode of a pair of comparators instances
  1582. * (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
  1583. * @rmtoll CSR WNDWEN LL_COMP_SetCommonWindowMode
  1584. * @param COMPxy_COMMON Comparator common instance
  1585. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
  1586. * @param WindowMode This parameter can be one of the following values:
  1587. * @arg @ref LL_COMP_WINDOWMODE_DISABLE
  1588. * @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
  1589. * @retval None
  1590. */
  1591. __STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode)
  1592. {
  1593. MODIFY_REG(COMPxy_COMMON->CSR, COMP_CSR_WNDWEN, WindowMode);
  1594. }
  1595. /**
  1596. * @brief Get window mode of a pair of comparators instances
  1597. * (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
  1598. * @rmtoll CSR WNDWEN LL_COMP_GetCommonWindowMode
  1599. * @param COMPxy_COMMON Comparator common instance
  1600. * (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
  1601. * @retval Returned value can be one of the following values:
  1602. * @arg @ref LL_COMP_WINDOWMODE_DISABLE
  1603. * @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
  1604. */
  1605. __STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON)
  1606. {
  1607. return (uint32_t)(READ_BIT(COMPxy_COMMON->CSR, COMP_CSR_WNDWEN));
  1608. }
  1609. /**
  1610. * @}
  1611. */
  1612. /** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes
  1613. * @{
  1614. */
  1615. /**
  1616. * @brief Set comparator instance operating mode to adjust power and speed.
  1617. * @rmtoll CSR COMP1MODE LL_COMP_SetPowerMode\n
  1618. * COMP2MODE LL_COMP_SetPowerMode
  1619. * @param COMPx Comparator instance
  1620. * @param PowerMode This parameter can be one of the following values:
  1621. * @arg @ref LL_COMP_POWERMODE_HIGHSPEED
  1622. * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
  1623. * @arg @ref LL_COMP_POWERMODE_LOWPOWER
  1624. * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
  1625. * @retval None
  1626. */
  1627. __STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode)
  1628. {
  1629. MODIFY_REG(COMP->CSR,
  1630. COMP_CSR_COMP1MODE << __COMP_BITOFFSET_INSTANCE(COMPx),
  1631. PowerMode << __COMP_BITOFFSET_INSTANCE(COMPx));
  1632. }
  1633. /**
  1634. * @brief Get comparator instance operating mode to adjust power and speed.
  1635. * @rmtoll CSR COMP1MODE LL_COMP_GetPowerMode\n
  1636. * COMP2MODE LL_COMP_GetPowerMode
  1637. * @param COMPx Comparator instance
  1638. * @retval Returned value can be one of the following values:
  1639. * @arg @ref LL_COMP_POWERMODE_HIGHSPEED
  1640. * @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED
  1641. * @arg @ref LL_COMP_POWERMODE_LOWPOWER
  1642. * @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER
  1643. */
  1644. __STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx)
  1645. {
  1646. return (uint32_t)(READ_BIT(COMP->CSR,
  1647. COMP_CSR_COMP1MODE << __COMP_BITOFFSET_INSTANCE(COMPx))
  1648. >> __COMP_BITOFFSET_INSTANCE(COMPx)
  1649. );
  1650. }
  1651. /**
  1652. * @}
  1653. */
  1654. /** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs
  1655. * @{
  1656. */
  1657. /**
  1658. * @brief Set comparator inputs minus (inverting) and plus (non-inverting).
  1659. * @note In case of comparator input selected to be connected to IO:
  1660. * GPIO pins are specific to each comparator instance.
  1661. * Refer to description of parameters or to reference manual.
  1662. * @rmtoll CSR COMP1INSEL LL_COMP_ConfigInputs\n
  1663. * CSR COMP2INSEL LL_COMP_ConfigInputs\n
  1664. * CSR COMP1SW1 LL_COMP_ConfigInputs
  1665. * @param COMPx Comparator instance
  1666. * @param InputMinus This parameter can be one of the following values:
  1667. * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
  1668. * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
  1669. * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
  1670. * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
  1671. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
  1672. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
  1673. * @arg @ref LL_COMP_INPUT_MINUS_IO1
  1674. * @arg @ref LL_COMP_INPUT_MINUS_IO2
  1675. * @arg @ref LL_COMP_INPUT_MINUS_IO3
  1676. * @arg @ref LL_COMP_INPUT_MINUS_IO4
  1677. * @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1
  1678. * @param InputPlus This parameter can be one of the following values:
  1679. * @arg @ref LL_COMP_INPUT_PLUS_IO1
  1680. * @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1 (1)
  1681. *
  1682. * (1) Parameter available only on COMP instance: COMP1.
  1683. * @retval None
  1684. */
  1685. __STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus)
  1686. {
  1687. /* Note: Connection switch is applicable only to COMP instance COMP1, */
  1688. /* therefore if COMP2 is selected the equivalent bit is */
  1689. /* kept unmodified. */
  1690. MODIFY_REG(COMP->CSR,
  1691. (COMP_CSR_COMP1INSEL | (COMP_CSR_COMP1SW1 * __COMP_IS_INSTANCE_ODD(COMPx))) << __COMP_BITOFFSET_INSTANCE(COMPx),
  1692. (InputMinus | InputPlus) << __COMP_BITOFFSET_INSTANCE(COMPx));
  1693. }
  1694. /**
  1695. * @brief Set comparator input plus (non-inverting).
  1696. * @note In case of comparator input selected to be connected to IO:
  1697. * GPIO pins are specific to each comparator instance.
  1698. * Refer to description of parameters or to reference manual.
  1699. * @rmtoll CSR COMP1INSEL LL_COMP_SetInputPlus\n
  1700. * CSR COMP2INSEL LL_COMP_SetInputPlus
  1701. * @param COMPx Comparator instance
  1702. * @param InputPlus This parameter can be one of the following values:
  1703. * @arg @ref LL_COMP_INPUT_PLUS_IO1
  1704. * @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1 (1)
  1705. *
  1706. * (1) Parameter available only on COMP instance: COMP1.
  1707. * @retval None
  1708. */
  1709. __STATIC_INLINE void LL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus)
  1710. {
  1711. /* Note: Connection switch is applicable only to COMP instance COMP1, */
  1712. /* therefore if COMP2 is selected the equivalent bit is */
  1713. /* kept unmodified. */
  1714. MODIFY_REG(COMP->CSR,
  1715. (COMP_CSR_COMP1SW1 * __COMP_IS_INSTANCE_ODD(COMPx)) << __COMP_BITOFFSET_INSTANCE(COMPx),
  1716. InputPlus << __COMP_BITOFFSET_INSTANCE(COMPx));
  1717. }
  1718. /**
  1719. * @brief Get comparator input plus (non-inverting).
  1720. * @note In case of comparator input selected to be connected to IO:
  1721. * GPIO pins are specific to each comparator instance.
  1722. * Refer to description of parameters or to reference manual.
  1723. * @rmtoll CSR COMP1INSEL LL_COMP_GetInputPlus\n
  1724. * CSR COMP2INSEL LL_COMP_GetInputPlus
  1725. * @param COMPx Comparator instance
  1726. * @retval Returned value can be one of the following values:
  1727. * @arg @ref LL_COMP_INPUT_PLUS_IO1
  1728. * @arg @ref LL_COMP_INPUT_PLUS_DAC1_CH1 (1)
  1729. *
  1730. * (1) Parameter available only on COMP instance: COMP1.
  1731. */
  1732. __STATIC_INLINE uint32_t LL_COMP_GetInputPlus(COMP_TypeDef *COMPx)
  1733. {
  1734. /* Note: Connection switch is applicable only to COMP instance COMP1, */
  1735. /* therefore is COMP2 is selected the returned value will be null. */
  1736. return (uint32_t)(READ_BIT(COMP->CSR,
  1737. COMP_CSR_COMP1SW1 << __COMP_BITOFFSET_INSTANCE(COMPx))
  1738. >> __COMP_BITOFFSET_INSTANCE(COMPx)
  1739. );
  1740. }
  1741. /**
  1742. * @brief Set comparator input minus (inverting).
  1743. * @note In case of comparator input selected to be connected to IO:
  1744. * GPIO pins are specific to each comparator instance.
  1745. * Refer to description of parameters or to reference manual.
  1746. * @rmtoll CSR COMP1SW1 LL_COMP_SetInputMinus
  1747. * @param COMPx Comparator instance
  1748. * @param InputMinus This parameter can be one of the following values:
  1749. * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
  1750. * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
  1751. * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
  1752. * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
  1753. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
  1754. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
  1755. * @arg @ref LL_COMP_INPUT_MINUS_IO1
  1756. * @arg @ref LL_COMP_INPUT_MINUS_IO2
  1757. * @arg @ref LL_COMP_INPUT_MINUS_IO3
  1758. * @arg @ref LL_COMP_INPUT_MINUS_IO4
  1759. * @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1
  1760. * @retval None
  1761. */
  1762. __STATIC_INLINE void LL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus)
  1763. {
  1764. MODIFY_REG(COMP->CSR,
  1765. COMP_CSR_COMP1INSEL << __COMP_BITOFFSET_INSTANCE(COMPx),
  1766. InputMinus << __COMP_BITOFFSET_INSTANCE(COMPx));
  1767. }
  1768. /**
  1769. * @brief Get comparator input minus (inverting).
  1770. * @note In case of comparator input selected to be connected to IO:
  1771. * GPIO pins are specific to each comparator instance.
  1772. * Refer to description of parameters or to reference manual.
  1773. * @rmtoll CSR COMP1SW1 LL_COMP_GetInputMinus
  1774. * @param COMPx Comparator instance
  1775. * @retval Returned value can be one of the following values:
  1776. * @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
  1777. * @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
  1778. * @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
  1779. * @arg @ref LL_COMP_INPUT_MINUS_VREFINT
  1780. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
  1781. * @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
  1782. * @arg @ref LL_COMP_INPUT_MINUS_IO1
  1783. * @arg @ref LL_COMP_INPUT_MINUS_IO2
  1784. * @arg @ref LL_COMP_INPUT_MINUS_IO3
  1785. * @arg @ref LL_COMP_INPUT_MINUS_IO4
  1786. * @arg @ref LL_COMP_INPUT_MINUS_DAC2_CH1
  1787. */
  1788. __STATIC_INLINE uint32_t LL_COMP_GetInputMinus(COMP_TypeDef *COMPx)
  1789. {
  1790. return (uint32_t)(READ_BIT(COMP->CSR,
  1791. COMP_CSR_COMP1INSEL << __COMP_BITOFFSET_INSTANCE(COMPx))
  1792. >> __COMP_BITOFFSET_INSTANCE(COMPx)
  1793. );
  1794. }
  1795. /**
  1796. * @brief Set comparator instance hysteresis mode of the input minus (inverting input).
  1797. * @rmtoll CSR COMP1HYST LL_COMP_SetInputHysteresis\n
  1798. * COMP2HYST LL_COMP_SetInputHysteresis
  1799. * @param COMPx Comparator instance
  1800. * @param InputHysteresis This parameter can be one of the following values:
  1801. * @arg @ref LL_COMP_HYSTERESIS_NONE
  1802. * @arg @ref LL_COMP_HYSTERESIS_LOW
  1803. * @arg @ref LL_COMP_HYSTERESIS_MEDIUM
  1804. * @arg @ref LL_COMP_HYSTERESIS_HIGH
  1805. * @retval None
  1806. */
  1807. __STATIC_INLINE void LL_COMP_SetInputHysteresis(COMP_TypeDef *COMPx, uint32_t InputHysteresis)
  1808. {
  1809. MODIFY_REG(COMP->CSR,
  1810. COMP_CSR_COMP1HYST << __COMP_BITOFFSET_INSTANCE(COMPx),
  1811. InputHysteresis << __COMP_BITOFFSET_INSTANCE(COMPx));
  1812. }
  1813. /**
  1814. * @brief Get comparator instance hysteresis mode of the minus (inverting) input.
  1815. * @rmtoll CSR COMP1HYST LL_COMP_GetInputHysteresis\n
  1816. * COMP2HYST LL_COMP_GetInputHysteresis
  1817. * @param COMPx Comparator instance
  1818. * @retval Returned value can be one of the following values:
  1819. * @arg @ref LL_COMP_HYSTERESIS_NONE
  1820. * @arg @ref LL_COMP_HYSTERESIS_LOW
  1821. * @arg @ref LL_COMP_HYSTERESIS_MEDIUM
  1822. * @arg @ref LL_COMP_HYSTERESIS_HIGH
  1823. */
  1824. __STATIC_INLINE uint32_t LL_COMP_GetInputHysteresis(COMP_TypeDef *COMPx)
  1825. {
  1826. return (uint32_t)(READ_BIT(COMP->CSR,
  1827. COMP_CSR_COMP1HYST << __COMP_BITOFFSET_INSTANCE(COMPx))
  1828. >> __COMP_BITOFFSET_INSTANCE(COMPx)
  1829. );
  1830. }
  1831. /**
  1832. * @}
  1833. */
  1834. /** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output
  1835. * @{
  1836. */
  1837. /**
  1838. * @brief Set comparator output selection.
  1839. * @note Availability of parameters of output selection to timer
  1840. * depends on timers availability on the selected device.
  1841. * @rmtoll CSR COMP1OUTSEL LL_COMP_SetOutputSelection\n
  1842. * COMP2OUTSEL LL_COMP_SetOutputSelection
  1843. * @param COMPx Comparator instance
  1844. * @param OutputSelection This parameter can be one of the following values:
  1845. * @arg @ref LL_COMP_OUTPUT_NONE
  1846. * @arg @ref LL_COMP_OUTPUT_TIM16_BKIN (1)
  1847. * @arg @ref LL_COMP_OUTPUT_TIM4_IC1 (1)
  1848. * @arg @ref LL_COMP_OUTPUT_TIM4_OCCLR (1)
  1849. * @arg @ref LL_COMP_OUTPUT_TIM2_IC4 (1)
  1850. * @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR (1)
  1851. * @arg @ref LL_COMP_OUTPUT_TIM3_IC1 (1)
  1852. * @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR (1)
  1853. *
  1854. * (1) Parameter availability depending on timer availability
  1855. * on the selected device.
  1856. * @retval None
  1857. */
  1858. __STATIC_INLINE void LL_COMP_SetOutputSelection(COMP_TypeDef *COMPx, uint32_t OutputSelection)
  1859. {
  1860. MODIFY_REG(COMP->CSR,
  1861. COMP_CSR_COMP1OUTSEL << __COMP_BITOFFSET_INSTANCE(COMPx),
  1862. OutputSelection << __COMP_BITOFFSET_INSTANCE(COMPx));
  1863. }
  1864. /**
  1865. * @brief Get comparator output selection.
  1866. * @note Availability of parameters of output selection to timer
  1867. * depends on timers availability on the selected device.
  1868. * @rmtoll CSR COMP1OUTSEL LL_COMP_GetOutputSelection\n
  1869. * COMP2OUTSEL LL_COMP_GetOutputSelection
  1870. * @param COMPx Comparator instance
  1871. * @retval Returned value can be one of the following values:
  1872. * @arg @ref LL_COMP_OUTPUT_NONE
  1873. * @arg @ref LL_COMP_OUTPUT_TIM16_BKIN (1)
  1874. * @arg @ref LL_COMP_OUTPUT_TIM4_IC1 (1)
  1875. * @arg @ref LL_COMP_OUTPUT_TIM4_OCCLR (1)
  1876. * @arg @ref LL_COMP_OUTPUT_TIM2_IC4 (1)
  1877. * @arg @ref LL_COMP_OUTPUT_TIM2_OCCLR (1)
  1878. * @arg @ref LL_COMP_OUTPUT_TIM3_IC1 (1)
  1879. * @arg @ref LL_COMP_OUTPUT_TIM3_OCCLR (1)
  1880. *
  1881. * (1) Parameter availability depending on timer availability
  1882. * on the selected device.
  1883. */
  1884. __STATIC_INLINE uint32_t LL_COMP_GetOutputSelection(COMP_TypeDef *COMPx)
  1885. {
  1886. return (uint32_t)(READ_BIT(COMP->CSR,
  1887. COMP_CSR_COMP1OUTSEL << __COMP_BITOFFSET_INSTANCE(COMPx))
  1888. >> __COMP_BITOFFSET_INSTANCE(COMPx)
  1889. );
  1890. }
  1891. /**
  1892. * @brief Set comparator instance output polarity.
  1893. * @rmtoll CSR COMP1POL LL_COMP_SetOutputPolarity\n
  1894. * COMP2POL LL_COMP_SetOutputPolarity
  1895. * @param COMPx Comparator instance
  1896. * @param OutputPolarity This parameter can be one of the following values:
  1897. * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
  1898. * @arg @ref LL_COMP_OUTPUTPOL_INVERTED
  1899. * @retval None
  1900. */
  1901. __STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity)
  1902. {
  1903. MODIFY_REG(COMP->CSR,
  1904. COMP_CSR_COMP1POL << __COMP_BITOFFSET_INSTANCE(COMPx),
  1905. OutputPolarity << __COMP_BITOFFSET_INSTANCE(COMPx));
  1906. }
  1907. /**
  1908. * @brief Get comparator instance output polarity.
  1909. * @rmtoll CSR COMP1POL LL_COMP_GetOutputPolarity\n
  1910. * COMP2POL LL_COMP_GetOutputPolarity
  1911. * @param COMPx Comparator instance
  1912. * @retval Returned value can be one of the following values:
  1913. * @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
  1914. * @arg @ref LL_COMP_OUTPUTPOL_INVERTED
  1915. */
  1916. __STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
  1917. {
  1918. return (uint32_t)(READ_BIT(COMP->CSR,
  1919. COMP_CSR_COMP1POL << __COMP_BITOFFSET_INSTANCE(COMPx))
  1920. >> __COMP_BITOFFSET_INSTANCE(COMPx)
  1921. );
  1922. }
  1923. /**
  1924. * @}
  1925. */
  1926. /** @defgroup COMP_LL_EF_Operation Operation on comparator instance
  1927. * @{
  1928. */
  1929. /**
  1930. * @brief Enable comparator instance.
  1931. * @note After enable from off state, comparator requires a delay
  1932. * to reach reach propagation delay specification.
  1933. * Refer to device datasheet, parameter "tSTART".
  1934. * @rmtoll CSR COMP1EN LL_COMP_Enable\n
  1935. * COMP2EN LL_COMP_Enable
  1936. * @param COMPx Comparator instance
  1937. * @retval None
  1938. */
  1939. __STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx)
  1940. {
  1941. SET_BIT(COMP->CSR, COMP_CSR_COMP1EN << __COMP_BITOFFSET_INSTANCE(COMPx));
  1942. }
  1943. /**
  1944. * @brief Disable comparator instance.
  1945. * @rmtoll CSR COMP1EN LL_COMP_Disable\n
  1946. * COMP2EN LL_COMP_Disable
  1947. * @param COMPx Comparator instance
  1948. * @retval None
  1949. */
  1950. __STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx)
  1951. {
  1952. CLEAR_BIT(COMP->CSR, COMP_CSR_COMP1EN << __COMP_BITOFFSET_INSTANCE(COMPx));
  1953. }
  1954. /**
  1955. * @brief Get comparator enable state
  1956. * (0: COMP is disabled, 1: COMP is enabled)
  1957. * @rmtoll CSR COMP1EN LL_COMP_IsEnabled\n
  1958. * COMP2EN LL_COMP_IsEnabled
  1959. * @param COMPx Comparator instance
  1960. * @retval State of bit (1 or 0).
  1961. */
  1962. __STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx)
  1963. {
  1964. return (READ_BIT(COMP->CSR, COMP_CSR_COMP1EN << __COMP_BITOFFSET_INSTANCE(COMPx)) == COMP_CSR_COMP1EN <<
  1965. __COMP_BITOFFSET_INSTANCE(COMPx));
  1966. }
  1967. /**
  1968. * @brief Lock comparator instance.
  1969. * @note Once locked, comparator configuration can be accessed in read-only.
  1970. * @note The only way to unlock the comparator is a device hardware reset.
  1971. * @rmtoll CSR COMP1LOCK LL_COMP_Lock\n
  1972. * COMP2LOCK LL_COMP_Lock
  1973. * @param COMPx Comparator instance
  1974. * @retval None
  1975. */
  1976. __STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx)
  1977. {
  1978. SET_BIT(COMP->CSR, COMP_CSR_COMP1LOCK << __COMP_BITOFFSET_INSTANCE(COMPx));
  1979. }
  1980. /**
  1981. * @brief Get comparator lock state
  1982. * (0: COMP is unlocked, 1: COMP is locked).
  1983. * @note Once locked, comparator configuration can be accessed in read-only.
  1984. * @note The only way to unlock the comparator is a device hardware reset.
  1985. * @rmtoll CSR COMP1LOCK LL_COMP_IsLocked\n
  1986. * COMP2LOCK LL_COMP_IsLocked
  1987. * @param COMPx Comparator instance
  1988. * @retval State of bit (1 or 0).
  1989. */
  1990. __STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
  1991. {
  1992. return (READ_BIT(COMP->CSR, COMP_CSR_COMP1LOCK << __COMP_BITOFFSET_INSTANCE(COMPx)) == COMP_CSR_COMP1LOCK <<
  1993. __COMP_BITOFFSET_INSTANCE(COMPx));
  1994. }
  1995. /**
  1996. * @brief Read comparator instance output level.
  1997. * @note The comparator output level depends on the selected polarity
  1998. * (Refer to function @ref LL_COMP_SetOutputPolarity()).
  1999. * If the comparator polarity is not inverted:
  2000. * - Comparator output is low when the input plus
  2001. * is at a lower voltage than the input minus
  2002. * - Comparator output is high when the input plus
  2003. * is at a higher voltage than the input minus
  2004. * If the comparator polarity is inverted:
  2005. * - Comparator output is high when the input plus
  2006. * is at a lower voltage than the input minus
  2007. * - Comparator output is low when the input plus
  2008. * is at a higher voltage than the input minus
  2009. * @rmtoll CSR COMP1OUT LL_COMP_ReadOutputLevel\n
  2010. * COMP2OUT LL_COMP_ReadOutputLevel
  2011. * @param COMPx Comparator instance
  2012. * @retval Returned value can be one of the following values:
  2013. * @arg @ref LL_COMP_OUTPUT_LEVEL_LOW
  2014. * @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH
  2015. */
  2016. __STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
  2017. {
  2018. return (uint32_t)(READ_BIT(COMP->CSR,
  2019. COMP_CSR_COMP1OUT << __COMP_BITOFFSET_INSTANCE(COMPx))
  2020. >> (__COMP_BITOFFSET_INSTANCE(COMPx) + LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS)
  2021. );
  2022. }
  2023. /**
  2024. * @}
  2025. */
  2026. #if defined(USE_FULL_LL_DRIVER)
  2027. /** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions
  2028. * @{
  2029. */
  2030. ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx);
  2031. ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct);
  2032. void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct);
  2033. /**
  2034. * @}
  2035. */
  2036. #endif /* USE_FULL_LL_DRIVER */
  2037. /**
  2038. * @}
  2039. */
  2040. /**
  2041. * @}
  2042. */
  2043. #endif /* COMP1 || COMP2 */
  2044. #endif /* STM32F373xC || STM32F378xx */
  2045. /**
  2046. * @}
  2047. */
  2048. #ifdef __cplusplus
  2049. }
  2050. #endif
  2051. #endif /* __STM32F3xx_LL_COMP_H */