stm32f3xx_ll_comp.h 151 KB

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