stm32f3xx_hal_comp_ex.h 149 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788
  1. /**
  2. ******************************************************************************
  3. * @file stm32f3xx_hal_comp_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of COMP HAL Extended module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef __STM32F3xx_HAL_COMP_EX_H
  20. #define __STM32F3xx_HAL_COMP_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f3xx_hal_def.h"
  26. /** @addtogroup STM32F3xx_HAL_Driver
  27. * @{
  28. */
  29. /** @defgroup COMPEx COMPEx
  30. * @{
  31. */
  32. /* Exported types ------------------------------------------------------------*/
  33. /* Exported constants --------------------------------------------------------*/
  34. /** @defgroup COMPEx_Exported_Constants COMP Extended Exported Constants
  35. * @{
  36. */
  37. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  38. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
  39. /** @defgroup COMPEx_InvertingInput COMP Extended InvertingInput (STM32F302xE/STM32F303xE/STM32F398xx/STM32F302xC/STM32F303xC/STM32F358xx Product devices)
  40. * @{
  41. */
  42. #define COMP_INVERTINGINPUT_1_4VREFINT (0x00000000U) /*!< 1U/4 VREFINT connected to comparator inverting input */
  43. #define COMP_INVERTINGINPUT_1_2VREFINT COMP_CSR_COMPxINSEL_0 /*!< 1U/2 VREFINT connected to comparator inverting input */
  44. #define COMP_INVERTINGINPUT_3_4VREFINT COMP_CSR_COMPxINSEL_1 /*!< 3U/4 VREFINT connected to comparator inverting input */
  45. #define COMP_INVERTINGINPUT_VREFINT (COMP_CSR_COMPxINSEL_1|COMP_CSR_COMPxINSEL_0) /*!< VREFINT connected to comparator inverting input */
  46. #define COMP_INVERTINGINPUT_DAC1_CH1 COMP_CSR_COMPxINSEL_2 /*!< DAC1_CH1_OUT (PA4) connected to comparator inverting input */
  47. #define COMP_INVERTINGINPUT_DAC1_CH2 (COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_0) /*!< DAC1_CH2_OUT (PA5) connected to comparator inverting input */
  48. #define COMP_INVERTINGINPUT_IO1 (COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_1) /*!< IO1 (PA0 for COMP1, PA2 for COMP2, PD15 for COMP3,
  49. PE8 for COMP4, PD13 for COMP5, PD10 for COMP6,
  50. PC0 for COMP7) connected to comparator inverting input */
  51. #define COMP_INVERTINGINPUT_IO2 COMP_CSR_COMPxINSEL /*!< IO2 (PB12 for COMP3, PB2 for COMP4, PB10 for COMP5,
  52. PB15 for COMP6) connected to comparator inverting input */
  53. /* Aliases for compatibility */
  54. #define COMP_INVERTINGINPUT_DAC1 COMP_INVERTINGINPUT_DAC1_CH1
  55. #define COMP_INVERTINGINPUT_DAC2 COMP_INVERTINGINPUT_DAC1_CH2
  56. /**
  57. * @}
  58. */
  59. #elif defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  60. /** @defgroup COMPEx_InvertingInput COMP Extended InvertingInput (STM32F301x8/STM32F302x8/STM32F318xx Product devices)
  61. * @{
  62. */
  63. #define COMP_INVERTINGINPUT_1_4VREFINT (0x00000000U) /*!< 1U/4 VREFINT connected to comparator inverting input */
  64. #define COMP_INVERTINGINPUT_1_2VREFINT COMP_CSR_COMPxINSEL_0 /*!< 1U/2 VREFINT connected to comparator inverting input */
  65. #define COMP_INVERTINGINPUT_3_4VREFINT COMP_CSR_COMPxINSEL_1 /*!< 3U/4 VREFINT connected to comparator inverting input */
  66. #define COMP_INVERTINGINPUT_VREFINT (COMP_CSR_COMPxINSEL_1|COMP_CSR_COMPxINSEL_0) /*!< VREFINT connected to comparator inverting input */
  67. #define COMP_INVERTINGINPUT_DAC1_CH1 COMP_CSR_COMPxINSEL_2 /*!< DAC1_CH1_OUT (PA4) connected to comparator inverting input */
  68. #define COMP_INVERTINGINPUT_IO1 (COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_1) /*!< IO1 (PA2 for COMP2),
  69. connected to comparator inverting input */
  70. #define COMP_INVERTINGINPUT_IO2 COMP_CSR_COMPxINSEL /*!< IO2 (PB2 for COMP4, PB15 for COMP6)
  71. connected to comparator inverting input */
  72. /* Aliases for compatibility */
  73. #define COMP_INVERTINGINPUT_DAC1 COMP_INVERTINGINPUT_DAC1_CH1
  74. /**
  75. * @}
  76. */
  77. #elif defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  78. /** @defgroup COMPEx_InvertingInput COMP Extended InvertingInput (STM32F303x8/STM32F334x8/STM32F328xx Product devices)
  79. * @{
  80. */
  81. /* Note: On these STM32 devices, there is only 1 comparator inverting input */
  82. /* connected to a GPIO. */
  83. /* It must be chosen among the 2 literals COMP_INVERTINGINPUT_IOx */
  84. /* depending on comparator instance COMPx. */
  85. #define COMP_INVERTINGINPUT_1_4VREFINT (0x00000000U) /*!< 1U/4 VREFINT connected to comparator inverting input */
  86. #define COMP_INVERTINGINPUT_1_2VREFINT COMP_CSR_COMPxINSEL_0 /*!< 1U/2 VREFINT connected to comparator inverting input */
  87. #define COMP_INVERTINGINPUT_3_4VREFINT COMP_CSR_COMPxINSEL_1 /*!< 3U/4 VREFINT connected to comparator inverting input */
  88. #define COMP_INVERTINGINPUT_VREFINT (COMP_CSR_COMPxINSEL_1|COMP_CSR_COMPxINSEL_0) /*!< VREFINT connected to comparator inverting input */
  89. #define COMP_INVERTINGINPUT_DAC1_CH1 COMP_CSR_COMPxINSEL_2 /*!< DAC1_CH1_OUT (PA4) connected to comparator inverting input */
  90. #define COMP_INVERTINGINPUT_DAC1_CH2 (COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_0) /*!< DAC1_CH2_OUT (PA5) connected to comparator inverting input */
  91. #define COMP_INVERTINGINPUT_IO1 (COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_1) /*!< IO1 (PA2 for COMP2),
  92. connected to comparator inverting input */
  93. #define COMP_INVERTINGINPUT_IO2 COMP_CSR_COMPxINSEL /*!< IO2 (PB2 for COMP4, PB15 for COMP6)
  94. connected to comparator inverting input */
  95. #define COMP_INVERTINGINPUT_DAC2_CH1 COMP_CSR_COMPxINSEL_3 /*!< DAC2_CH1_OUT connected to comparator inverting input */
  96. /* Aliases for compatibility */
  97. #define COMP_INVERTINGINPUT_DAC1 COMP_INVERTINGINPUT_DAC1_CH1
  98. #define COMP_INVERTINGINPUT_DAC2 COMP_INVERTINGINPUT_DAC1_CH2
  99. /**
  100. * @}
  101. */
  102. #elif defined(STM32F373xC) || defined(STM32F378xx)
  103. /** @defgroup COMPEx_InvertingInput COMP Extended InvertingInput (STM32F373xC/STM32F378xx Product devices)
  104. * @{
  105. */
  106. #define COMP_INVERTINGINPUT_1_4VREFINT (0x00000000U) /*!< 1U/4 VREFINT connected to comparator inverting input */
  107. #define COMP_INVERTINGINPUT_1_2VREFINT ((uint32_t)COMP_CSR_COMPxINSEL_0) /*!< 1U/2 VREFINT connected to comparator inverting input */
  108. #define COMP_INVERTINGINPUT_3_4VREFINT ((uint32_t)COMP_CSR_COMPxINSEL_1) /*!< 3U/4 VREFINT connected to comparator inverting input */
  109. #define COMP_INVERTINGINPUT_VREFINT ((uint32_t)(COMP_CSR_COMPxINSEL_1|COMP_CSR_COMPxINSEL_0)) /*!< VREFINT connected to comparator inverting input */
  110. #define COMP_INVERTINGINPUT_DAC1_CH1 ((uint32_t)COMP_CSR_COMPxINSEL_2) /*!< DAC1_CH1_OUT (PA4) connected to comparator inverting input */
  111. #define COMP_INVERTINGINPUT_DAC1_CH2 ((uint32_t)(COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_0)) /*!< DAC1_CH2_OUT (PA5) connected to comparator inverting input */
  112. #define COMP_INVERTINGINPUT_IO1 ((uint32_t)(COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_1)) /*!< IO1 (PA0 for COMP1, PA2 for COMP2) connected to comparator inverting input */
  113. #define COMP_INVERTINGINPUT_DAC2_CH1 ((uint32_t)COMP_CSR_COMPxINSEL) /*!< DAC2_CH1_OUT connected to comparator inverting input */
  114. /* Aliases for compatibility */
  115. #define COMP_INVERTINGINPUT_DAC1 COMP_INVERTINGINPUT_DAC1_CH1
  116. #define COMP_INVERTINGINPUT_DAC2 COMP_INVERTINGINPUT_DAC1_CH2
  117. /**
  118. * @}
  119. */
  120. #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
  121. /* STM32F302xC || STM32F303xC || STM32F358xx */
  122. #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
  123. /** @defgroup COMPEx_NonInvertingInput COMP Extended NonInvertingInput (STM32F302xC/STM32F303xC/STM32F358xx Product devices)
  124. * @{
  125. */
  126. #define COMP_NONINVERTINGINPUT_IO1 (0x00000000U) /*!< IO1 (PA1 for COMP1, PA7 for COMP2, PB14 for COMP3,
  127. PB0 for COMP4, PD12 for COMP5, PD11 for COMP6,
  128. PA0 for COMP7) connected to comparator non inverting input */
  129. #define COMP_NONINVERTINGINPUT_IO2 COMP_CSR_COMPxNONINSEL /*!< IO2 (PA3 for COMP2, PD14 for COMP3, PE7 for COMP4, PB13 for COMP5,
  130. PB11 for COMP6, PC1 for COMP7) connected to comparator non inverting input */
  131. #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED COMP1_CSR_COMP1SW1 /*!< DAC output connected to comparator COMP1 non inverting input */
  132. /**
  133. * @}
  134. */
  135. #elif defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  136. /** @defgroup COMPEx_NonInvertingInput COMP Extended NonInvertingInput (STM32F301x8/STM32F302x8/STM32F318xx Product devices)
  137. * @{
  138. */
  139. #define COMP_NONINVERTINGINPUT_IO1 (0x00000000U) /*!< IO1 (PA7 for COMP2, PB0 for COMP4, PB11 for COMP6)
  140. connected to comparator non inverting input */
  141. #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED COMP2_CSR_COMP2INPDAC /*!< DAC output connected to comparator COMP2 non inverting input */
  142. /**
  143. * @}
  144. */
  145. #elif defined(STM32F373xC) || defined(STM32F378xx)
  146. /** @defgroup COMPEx_NonInvertingInput COMP Extended NonInvertingInput (STM32F373xC/STM32F378xx Product devices)
  147. * @{
  148. */
  149. #define COMP_NONINVERTINGINPUT_IO1 (0x00000000U) /*!< IO1 (PA1 for COMP1, PA3 for COMP2)
  150. connected to comparator non inverting input */
  151. #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED COMP_CSR_COMP1SW1 /*!< DAC output connected to comparator COMP1 non inverting input */
  152. /**
  153. * @}
  154. */
  155. #elif defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx)
  156. /** @defgroup COMPEx_NonInvertingInput COMP Extended NonInvertingInput (STM32F302xE/STM32F303xE/STM32F398xx Product devices)
  157. * @{
  158. */
  159. #define COMP_NONINVERTINGINPUT_IO1 (0x00000000U) /*!< IO1 (PA1 for COMP1, PA7 for COMP2, PB14 for COMP3,
  160. PB0 for COMP4, PD12 for COMP5, PD11 for COMP6,
  161. PA0 for COMP7) connected to comparator non inverting input */
  162. #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED COMP1_CSR_COMP1SW1 /*!< DAC output connected to comparator COMP1 non inverting input */
  163. /**
  164. * @}
  165. */
  166. #else
  167. /** @defgroup COMPEx_NonInvertingInput COMP Extended NonInvertingInput (Other Product devices)
  168. * @{
  169. */
  170. #define COMP_NONINVERTINGINPUT_IO1 (0x00000000U) /*!< IO1 (PA7 for COMP2, PB0 for COMP4, PB11 for COMP6)
  171. connected to comparator non inverting input */
  172. /**
  173. * @}
  174. */
  175. #endif /* STM32F302xC || STM32F303xC || STM32F358xx */
  176. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  177. /** @defgroup COMPEx_Output COMP Extended Output (STM32F301x8/STM32F302x8/STM32F318xx Product devices)
  178. * Elements value convention on 16 LSB: 00XXXX0000YYYYYYb
  179. * - YYYYYY : Applicable comparator instance number (bitmap format: 000010 for COMP2, 100000 for COMP6)
  180. * - XXXX : COMPxOUTSEL value
  181. * @{
  182. */
  183. /* Output Redirection values common to all comparators COMP2, COMP4 and COMP6 */
  184. #define COMP_OUTPUT_NONE (0x0000002AU) /*!< COMP2, COMP4 or COMP6 output isn't connected to other peripherals */
  185. #define COMP_OUTPUT_TIM1BKIN (0x0000042AU) /*!< COMP2, COMP4 or COMP6 output connected to TIM1 Break Input (BKIN) */
  186. #define COMP_OUTPUT_TIM1BKIN2_BRK2 (0x0000082AU) /*!< COMP2, COMP4 or COMP6 output connected to TIM1 Break Input 2 (BRK2) */
  187. #define COMP_OUTPUT_TIM1BKIN2 (0x0000142AU) /*!< COMP2, COMP4 or COMP6 output connected to TIM1 Break Input 2 (BKIN2) */
  188. /* Output Redirection specific to COMP2 */
  189. #define COMP_OUTPUT_TIM1OCREFCLR (0x00001802U) /*!< COMP2 output connected to TIM1 OCREF Clear */
  190. #define COMP_OUTPUT_TIM1IC1 (0x00001C02U) /*!< COMP2 output connected to TIM1 Input Capture 1U */
  191. #define COMP_OUTPUT_TIM2IC4 (0x00002002U) /*!< COMP2 output connected to TIM2 Input Capture 4U */
  192. #define COMP_OUTPUT_TIM2OCREFCLR (0x00002402U) /*!< COMP2 output connected to TIM2 OCREF Clear */
  193. /* Output Redirection specific to COMP4 */
  194. #define COMP_OUTPUT_TIM15IC2 (0x00002008U) /*!< COMP4 output connected to TIM15 Input Capture 2U */
  195. #define COMP_OUTPUT_TIM15OCREFCLR (0x00002808U) /*!< COMP4 output connected to TIM15 OCREF Clear */
  196. /* Output Redirection specific to COMP6 */
  197. #define COMP_OUTPUT_TIM2IC2 (0x00001820U) /*!< COMP6 output connected to TIM2 Input Capture 2U */
  198. #define COMP_OUTPUT_COMP6_TIM2OCREFCLR (0x00002020U) /*!< COMP6 output connected to TIM2 OCREF Clear */
  199. #define COMP_OUTPUT_TIM16OCREFCLR (0x00002420U) /*!< COMP6 output connected to TIM16 OCREF Clear */
  200. #define COMP_OUTPUT_TIM16IC1 (0x00002820U) /*!< COMP6 output connected to TIM16 Input Capture 1U */
  201. /**
  202. * @}
  203. */
  204. #elif defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  205. /** @defgroup COMPEx_Output COMP Extended Output (STM32F303x8/STM32F334x8/STM32F328xx Product devices)
  206. * Elements value convention on 16 LSB: 00XXXX0000YYYYYYb
  207. * - YYYYYY : Applicable comparator instance number (bitmap format: 000010 for COMP2, 100000 for COMP6)
  208. * - XXXX : COMPxOUTSEL value
  209. * @{
  210. */
  211. /* Output Redirection values common to all comparators COMP2, COMP4 and COMP6 */
  212. #define COMP_OUTPUT_NONE (0x0000002AU) /*!< COMP2, COMP4 or COMP6 output isn't connected to other peripherals */
  213. #define COMP_OUTPUT_TIM1BKIN (0x0000042AU) /*!< COMP2, COMP4 or COMP6 output connected to TIM1 Break Input (BKIN) */
  214. #define COMP_OUTPUT_TIM1BKIN2 (0x0000082AU) /*!< COMP2, COMP4 or COMP6 output connected to TIM1 Break Input 2 (BKIN2) */
  215. /* Output Redirection common to COMP2 and COMP4 */
  216. #define COMP_OUTPUT_TIM3OCREFCLR (0x00002C0AU) /*!< COMP2 or COMP4 output connected to TIM3 OCREF Clear */
  217. /* Output Redirection specific to COMP2 */
  218. #define COMP_OUTPUT_TIM1OCREFCLR (0x00001802U) /*!< COMP2 output connected to TIM1 OCREF Clear */
  219. #define COMP_OUTPUT_TIM1IC1 (0x00001C02U) /*!< COMP2 output connected to TIM1 Input Capture 1U */
  220. #define COMP_OUTPUT_TIM2IC4 (0x00002002U) /*!< COMP2 output connected to TIM2 Input Capture 4U */
  221. #define COMP_OUTPUT_TIM2OCREFCLR (0x00002402U) /*!< COMP2 output connected to TIM2 OCREF Clear */
  222. #define COMP_OUTPUT_TIM3IC1 (0x00002802U) /*!< COMP2 output connected to TIM3 Input Capture 1U */
  223. /* Output Redirection specific to COMP4 */
  224. #define COMP_OUTPUT_TIM3IC3 (0x00001808U) /*!< COMP4 output connected to TIM3 Input Capture 3U */
  225. #define COMP_OUTPUT_TIM15IC2 (0x00002008U) /*!< COMP4 output connected to TIM15 Input Capture 2U */
  226. #define COMP_OUTPUT_TIM15OCREFCLR (0x00002808U) /*!< COMP4 output connected to TIM15 OCREF Clear */
  227. /* Output Redirection specific to COMP6 */
  228. #define COMP_OUTPUT_TIM2IC2 (0x00001820U) /*!< COMP6 output connected to TIM2 Input Capture 2U */
  229. #define COMP_OUTPUT_COMP6_TIM2OCREFCLR (0x00002020U) /*!< COMP6 output connected to TIM2 OCREF Clear */
  230. #define COMP_OUTPUT_TIM16OCREFCLR (0x00002420U) /*!< COMP6 output connected to TIM16 OCREF Clear */
  231. #define COMP_OUTPUT_TIM16IC1 (0x00002820U) /*!< COMP6 output connected to TIM16 Input Capture 1U */
  232. /**
  233. * @}
  234. */
  235. #elif defined(STM32F302xC) || defined(STM32F302xE)
  236. /** @defgroup COMPEx_Output COMP Extended Output (STM32F302xC/STM32F302xE Product devices)
  237. * Elements value convention on 16 LSB: 00XXXX0000YYYYYYb
  238. * - YYYYYY : Applicable comparator instance number (bitmap format: 000001 for COMP1, 100000 for COMP6)
  239. * - XXXX : COMPxOUTSEL value
  240. * @{
  241. */
  242. /* Output Redirection values common to all comparators COMP1, COMP2, COMP4, COMP6 */
  243. #define COMP_OUTPUT_NONE (0x0000002BU) /*!< COMP1, COMP2, COMP4 or COMP6 output isn't connected to other peripherals */
  244. #define COMP_OUTPUT_TIM1BKIN (0x0000042BU) /*!< COMP1, COMP2, COMP4 or COMP6 output connected to TIM1 Break Input (BKIN) */
  245. #define COMP_OUTPUT_TIM1BKIN2_BRK2 (0x0000082BU) /*!< COMP1, COMP2, COMP4 or COMP6 output connected to TIM1 Break Input 2 (BRK2) */
  246. #define COMP_OUTPUT_TIM1BKIN2 (0x0000142BU) /*!< COMP1, COMP2, COMP4 or COMP6 output connected to TIM1 Break Input 2 (BKIN2) */
  247. /* Output Redirection common to COMP1 and COMP2 */
  248. #define COMP_OUTPUT_TIM1OCREFCLR (0x00001803U) /*!< COMP1 or COMP2 output connected to TIM1 OCREF Clear */
  249. #define COMP_OUTPUT_TIM1IC1 (0x00001C03U) /*!< COMP1 or COMP2 output connected to TIM1 Input Capture 1U */
  250. #define COMP_OUTPUT_TIM2IC4 (0x00002003U) /*!< COMP1 or COMP2 output connected to TIM2 Input Capture 4U */
  251. #define COMP_OUTPUT_TIM2OCREFCLR (0x00002403U) /*!< COMP1 or COMP2 output connected to TIM2 OCREF Clear */
  252. #define COMP_OUTPUT_TIM3IC1 (0x00002803U) /*!< COMP1 or COMP2 output connected to TIM3 Input Capture 1U */
  253. /* Output Redirection common to COMP1,COMP2 and COMP4 */
  254. #define COMP_OUTPUT_TIM3OCREFCLR (0x00002C0BU) /*!< COMP1, COMP2 or COMP4 output connected to TIM3 OCREF Clear */
  255. /* Output Redirection specific to COMP4 */
  256. #define COMP_OUTPUT_TIM3IC3 (0x00001808U) /*!< COMP4 output connected to TIM3 Input Capture 3U */
  257. #define COMP_OUTPUT_TIM15IC2 (0x00002008U) /*!< COMP4 output connected to TIM15 Input Capture 2U */
  258. #define COMP_OUTPUT_TIM4IC2 (0x00002408U) /*!< COMP4 output connected to TIM4 Input Capture 2U */
  259. #define COMP_OUTPUT_TIM15OCREFCLR (0x00002808U) /*!< COMP4 output connected to TIM15 OCREF Clear */
  260. /* Output Redirection specific to COMP6 */
  261. #define COMP_OUTPUT_TIM2IC2 (0x00001820U) /*!< COMP6 output connected to TIM2 Input Capture 2U */
  262. #define COMP_OUTPUT_COMP6_TIM2OCREFCLR (0x00002020U) /*!< COMP6 output connected to TIM2 OCREF Clear */
  263. #define COMP_OUTPUT_TIM16OCREFCLR (0x00002420U) /*!< COMP6 output connected to TIM16 OCREF Clear */
  264. #define COMP_OUTPUT_TIM16IC1 (0x00002820U) /*!< COMP6 output connected to TIM16 Input Capture 1U */
  265. #define COMP_OUTPUT_TIM4IC4 (0x00002C20U) /*!< COMP6 output connected to TIM4 Input Capture 4U */
  266. /**
  267. * @}
  268. */
  269. #elif defined(STM32F303xC) || defined(STM32F358xx)
  270. /** @defgroup COMPEx_Output COMP Extended Output (STM32F303xC/STM32F358xx Product devices)
  271. * Elements value convention on 16 LSB: 00XXXX000YYYYYYYb
  272. * - YYYYYYY : Applicable comparator instance number (bitmap format: 0000001 for COMP1, 1000000 for COMP7)
  273. * - XXXX : COMPxOUTSEL value
  274. * @{
  275. */
  276. /* Output Redirection values common to all comparators COMP1...COMP7 */
  277. #define COMP_OUTPUT_NONE (0x0000007FU) /*!< COMP1, COMP2... or COMP7 output isn't connected to other peripherals */
  278. #define COMP_OUTPUT_TIM1BKIN (0x0000047FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM1 Break Input (BKIN) */
  279. #define COMP_OUTPUT_TIM1BKIN2 (0x0000087FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM1 Break Input 2 (BKIN2) */
  280. #define COMP_OUTPUT_TIM8BKIN (0x00000C7FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM8 Break Input (BKIN) */
  281. #define COMP_OUTPUT_TIM8BKIN2 (0x0000107FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM8 Break Input 2 (BKIN2) */
  282. #define COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2 (0x0000147FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM1 Break Input 2 and TIM8 Break Input 2U */
  283. /* Output Redirection common to COMP1, COMP2, COMP3 and COMP7 */
  284. #define COMP_OUTPUT_TIM1OCREFCLR (0x00001847U) /*!< COMP1, COMP2, COMP3 or COMP7 output connected to TIM1 OCREF Clear */
  285. /* Output Redirection common to COMP1, COMP2 and COMP3 */
  286. #define COMP_OUTPUT_TIM2OCREFCLR (0x00002407U) /*!< COMP1, COMP2 or COMP3 output connected to TIM2 OCREF Clear */
  287. /* Output Redirection common to COMP1, COMP2, COMP4 and COMP5 */
  288. #define COMP_OUTPUT_TIM3OCREFCLR (0x00002C1BU) /*!< COMP1, COMP2, COMP4 or COMP5 output connected to TIM3 OCREF Clear */
  289. /* Output Redirection common to COMP4, COMP5, COMP6 and COMP7 */
  290. #define COMP_OUTPUT_TIM8OCREFCLR (0x00001C78U) /*!< COMP4, COMP5, COMP6 or COMP7 output connected to TIM8 OCREF Clear */
  291. /* Output Redirection common to COMP1 and COMP2 */
  292. #define COMP_OUTPUT_TIM1IC1 (0x00001C03U) /*!< COMP1 or COMP2 output connected to TIM1 Input Capture 1U */
  293. #define COMP_OUTPUT_TIM2IC4 (0x00002003U) /*!< COMP1 or COMP2 output connected to TIM2 Input Capture 4U */
  294. #define COMP_OUTPUT_TIM3IC1 (0x00002803U) /*!< COMP1 or COMP2 output connected to TIM3 Input Capture 1U */
  295. /* Output Redirection specific to COMP3 */
  296. #define COMP_OUTPUT_TIM4IC1 (0x00001C04U) /*!< COMP3 output connected to TIM4 Input Capture 1U */
  297. #define COMP_OUTPUT_TIM3IC2 (0x00002004U) /*!< COMP3 output connected to TIM3 Input Capture 2U */
  298. #define COMP_OUTPUT_TIM15IC1 (0x00002804U) /*!< COMP3 output connected to TIM15 Input Capture 1U */
  299. #define COMP_OUTPUT_TIM15BKIN (0x00002C04U) /*!< COMP3 output connected to TIM15 Break Input (BKIN) */
  300. /* Output Redirection specific to COMP4 */
  301. #define COMP_OUTPUT_TIM3IC3 (0x00001808U) /*!< COMP4 output connected to TIM3 Input Capture 3U */
  302. #define COMP_OUTPUT_TIM15IC2 (0x00002008U) /*!< COMP4 output connected to TIM15 Input Capture 2U */
  303. #define COMP_OUTPUT_TIM4IC2 (0x00002408U) /*!< COMP4 output connected to TIM4 Input Capture 2U */
  304. #define COMP_OUTPUT_TIM15OCREFCLR (0x00002808U) /*!< COMP4 output connected to TIM15 OCREF Clear */
  305. /* Output Redirection specific to COMP5 */
  306. #define COMP_OUTPUT_TIM2IC1 (0x00001810U) /*!< COMP5 output connected to TIM2 Input Capture 1U */
  307. #define COMP_OUTPUT_TIM17IC1 (0x00002010U) /*!< COMP5 output connected to TIM17 Input Capture 1U */
  308. #define COMP_OUTPUT_TIM4IC3 (0x00002410U) /*!< COMP5 output connected to TIM4 Input Capture 3U */
  309. #define COMP_OUTPUT_TIM16BKIN (0x00002810U) /*!< COMP5 output connected to TIM16 Break Input (BKIN) */
  310. /* Output Redirection specific to COMP6 */
  311. #define COMP_OUTPUT_TIM2IC2 (0x00001820U) /*!< COMP6 output connected to TIM2 Input Capture 2U */
  312. #define COMP_OUTPUT_COMP6_TIM2OCREFCLR (0x00002020U) /*!< COMP6 output connected to TIM2 OCREF Clear */
  313. #define COMP_OUTPUT_TIM16OCREFCLR (0x00002420U) /*!< COMP6 output connected to TIM16 OCREF Clear */
  314. #define COMP_OUTPUT_TIM16IC1 (0x00002820U) /*!< COMP6 output connected to TIM16 Input Capture 1U */
  315. #define COMP_OUTPUT_TIM4IC4 (0x00002C20U) /*!< COMP6 output connected to TIM4 Input Capture 4U */
  316. /* Output Redirection specific to COMP7 */
  317. #define COMP_OUTPUT_TIM2IC3 (0x00002040U) /*!< COMP7 output connected to TIM2 Input Capture 3U */
  318. #define COMP_OUTPUT_TIM1IC2 (0x00002440U) /*!< COMP7 output connected to TIM1 Input Capture 2U */
  319. #define COMP_OUTPUT_TIM17OCREFCLR (0x00002840U) /*!< COMP7 output connected to TIM17 OCREF Clear */
  320. #define COMP_OUTPUT_TIM17BKIN (0x00002C40U) /*!< COMP7 output connected to TIM17 Break Input (BKIN) */
  321. /**
  322. * @}
  323. */
  324. #elif defined(STM32F303xE) || defined(STM32F398xx)
  325. /** @defgroup COMPEx_Output COMP Extended Output (STM32F303xE/STM32F398xx Product devices)
  326. * Elements value convention on 16 LSB: 00XXXX000YYYYYYYb
  327. * - YYYYYYY : Applicable comparator instance number (bitmap format: 0000001 for COMP1, 1000000 for COMP7)
  328. * - XXXX : COMPxOUTSEL value
  329. * @{
  330. */
  331. /* Output Redirection values common to all comparators COMP1...COMP7 */
  332. #define COMP_OUTPUT_NONE (0x0000007FU) /*!< COMP1, COMP2... or COMP7 output isn't connected to other peripherals */
  333. #define COMP_OUTPUT_TIM1BKIN (0x0000047FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM1 Break Input (BKIN) */
  334. #define COMP_OUTPUT_TIM1BKIN2 (0x0000087FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM1 Break Input 2 (BKIN2) */
  335. #define COMP_OUTPUT_TIM8BKIN (0x00000C7FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM8 Break Input (BKIN) */
  336. #define COMP_OUTPUT_TIM8BKIN2 (0x0000107FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM8 Break Input 2 (BKIN2) */
  337. #define COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2 (0x0000147FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM1 Break Input 2 and TIM8 Break Input 2U */
  338. #define COMP_OUTPUT_TIM20BKIN (0x0000307FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM20 Break Input (BKIN) */
  339. #define COMP_OUTPUT_TIM20BKIN2 (0x0000347FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM20 Break Input 2 (BKIN2) */
  340. #define COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2 (0x0000387FU) /*!< COMP1, COMP2... or COMP7 output connected to TIM1 Break Input 2U, TIM8 Break Input 2 and TIM20 Break Input 2 */
  341. /* Output Redirection common to COMP1, COMP2, COMP3 and COMP7 */
  342. #define COMP_OUTPUT_TIM1OCREFCLR (0x00001847U) /*!< COMP1, COMP2, COMP3 or COMP7 output connected to TIM1 OCREF Clear */
  343. /* Output Redirection common to COMP1, COMP2 and COMP3 */
  344. #define COMP_OUTPUT_TIM2OCREFCLR (0x00002407U) /*!< COMP1, COMP2 or COMP3 output connected to TIM2 OCREF Clear */
  345. /* Output Redirection common to COMP1, COMP2, COMP4 and COMP5 */
  346. #define COMP_OUTPUT_TIM3OCREFCLR (0x00002C1BU) /*!< COMP1, COMP2, COMP4 or COMP5 output connected to TIM3 OCREF Clear */
  347. /* Output Redirection common to COMP4, COMP5, COMP6 and COMP7 */
  348. #define COMP_OUTPUT_TIM8OCREFCLR (0x00001C78U) /*!< COMP4, COMP5, COMP6 or COMP7 output connected to TIM8 OCREF Clear */
  349. /* Output Redirection common to COMP1 and COMP2 */
  350. #define COMP_OUTPUT_TIM1IC1 (0x00001C03U) /*!< COMP1 or COMP2 output connected to TIM1 Input Capture 1U */
  351. #define COMP_OUTPUT_TIM2IC4 (0x00002003U) /*!< COMP1 or COMP2 output connected to TIM2 Input Capture 4U */
  352. #define COMP_OUTPUT_TIM3IC1 (0x00002803U) /*!< COMP1 or COMP2 output connected to TIM3 Input Capture 1U */
  353. /* Output Redirection specific to COMP2 */
  354. #define COMP_OUTPUT_TIM20OCREFCLR (0x00003C04U) /*!< COMP2 output connected to TIM20 OCREF Clear */
  355. /* Output Redirection specific to COMP3 */
  356. #define COMP_OUTPUT_TIM4IC1 (0x00001C04U) /*!< COMP3 output connected to TIM4 Input Capture 1U */
  357. #define COMP_OUTPUT_TIM3IC2 (0x00002004U) /*!< COMP3 output connected to TIM3 Input Capture 2U */
  358. #define COMP_OUTPUT_TIM15IC1 (0x00002804U) /*!< COMP3 output connected to TIM15 Input Capture 1U */
  359. #define COMP_OUTPUT_TIM15BKIN (0x00002C04U) /*!< COMP3 output connected to TIM15 Break Input (BKIN) */
  360. /* Output Redirection specific to COMP4 */
  361. #define COMP_OUTPUT_TIM3IC3 (0x00001808U) /*!< COMP4 output connected to TIM3 Input Capture 3U */
  362. #define COMP_OUTPUT_TIM15IC2 (0x00002008U) /*!< COMP4 output connected to TIM15 Input Capture 2U */
  363. #define COMP_OUTPUT_TIM4IC2 (0x00002408U) /*!< COMP4 output connected to TIM4 Input Capture 2U */
  364. #define COMP_OUTPUT_TIM15OCREFCLR (0x00002808U) /*!< COMP4 output connected to TIM15 OCREF Clear */
  365. /* Output Redirection specific to COMP5 */
  366. #define COMP_OUTPUT_TIM2IC1 (0x00001810U) /*!< COMP5 output connected to TIM2 Input Capture 1U */
  367. #define COMP_OUTPUT_TIM17IC1 (0x00002010U) /*!< COMP5 output connected to TIM17 Input Capture 1U */
  368. #define COMP_OUTPUT_TIM4IC3 (0x00002410U) /*!< COMP5 output connected to TIM4 Input Capture 3U */
  369. #define COMP_OUTPUT_TIM16BKIN (0x00002810U) /*!< COMP5 output connected to TIM16 Break Input (BKIN) */
  370. /* Output Redirection specific to COMP6 */
  371. #define COMP_OUTPUT_TIM2IC2 (0x00001820U) /*!< COMP6 output connected to TIM2 Input Capture 2U */
  372. #define COMP_OUTPUT_COMP6_TIM2OCREFCLR (0x00002020U) /*!< COMP6 output connected to TIM2 OCREF Clear */
  373. #define COMP_OUTPUT_TIM16OCREFCLR (0x00002420U) /*!< COMP6 output connected to TIM16 OCREF Clear */
  374. #define COMP_OUTPUT_TIM16IC1 (0x00002820U) /*!< COMP6 output connected to TIM16 Input Capture 1U */
  375. #define COMP_OUTPUT_TIM4IC4 (0x00002C20U) /*!< COMP6 output connected to TIM4 Input Capture 4U */
  376. /* Output Redirection specific to COMP7 */
  377. #define COMP_OUTPUT_TIM2IC3 (0x00002040U) /*!< COMP7 output connected to TIM2 Input Capture 3U */
  378. #define COMP_OUTPUT_TIM1IC2 (0x00002440U) /*!< COMP7 output connected to TIM1 Input Capture 2U */
  379. #define COMP_OUTPUT_TIM17OCREFCLR (0x00002840U) /*!< COMP7 output connected to TIM17 OCREF Clear */
  380. #define COMP_OUTPUT_TIM17BKIN (0x00002C40U) /*!< COMP7 output connected to TIM17 Break Input (BKIN) */
  381. /**
  382. * @}
  383. */
  384. #elif defined(STM32F373xC) || defined(STM32F378xx)
  385. /** @defgroup COMPEx_Output COMP Extended Output (STM32F373xC/STM32F378xx Product devices)
  386. * Elements value convention: 00000XXX000000YYb
  387. * - YY : Applicable comparator instance number (bitmap format: 01 for COMP1, 10 for COMP2)
  388. * - XXX : COMPxOUTSEL value
  389. * @{
  390. */
  391. /* Output Redirection values common to all comparators COMP1 and COMP2 */
  392. #define COMP_OUTPUT_NONE (0x0003U) /*!< COMP1 or COMP2 output isn't connected to other peripherals */
  393. #define COMP_OUTPUT_TIM2IC4 (0x0403U) /*!< COMP1 or COMP2 output connected to TIM2 Input Capture 4U */
  394. #define COMP_OUTPUT_TIM2OCREFCLR (0x0503U) /*!< COMP1 or COMP2 output connected to TIM2 OCREF Clear */
  395. /* Output Redirection specific to COMP1 */
  396. #define COMP_OUTPUT_TIM15BKIN (0x0101U) /*!< COMP1 output connected to TIM15 Break Input */
  397. #define COMP_OUTPUT_COMP1_TIM3IC1 (0x0201U) /*!< COMP1 output connected to TIM3 Input Capture 1U */
  398. #define COMP_OUTPUT_COMP1_TIM3OCREFCLR (0x0301U) /*!< COMP1 output connected to TIM3 OCREF Clear */
  399. #define COMP_OUTPUT_TIM5IC4 (0x0601U) /*!< COMP1 output connected to TIM5 Input Capture 4U */
  400. #define COMP_OUTPUT_TIM5OCREFCLR (0x0701U) /*!< COMP1 output connected to TIM5 OCREF Clear */
  401. /* Output Redirection specific to COMP2 */
  402. #define COMP_OUTPUT_TIM16BKIN (0x0102U) /*!< COMP2 output connected to TIM16 Break Input */
  403. #define COMP_OUTPUT_TIM4IC1 (0x0202U) /*!< COMP2 output connected to TIM4 Input Capture 1U */
  404. #define COMP_OUTPUT_TIM4OCREFCLR (0x0302U) /*!< COMP2 output connected to TIM4 OCREF Clear */
  405. #define COMP_OUTPUT_COMP2_TIM3IC1 (0x0602U) /*!< COMP2 output connected to TIM3 Input Capture 1U */
  406. #define COMP_OUTPUT_COMP2_TIM3OCREFCLR (0x0702U) /*!< COMP2 output connected to TIM3 OCREF Clear */
  407. /**
  408. * @}
  409. */
  410. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  411. #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
  412. /** @defgroup COMPEx_WindowMode COMP Extended WindowMode (STM32F302xC/STM32F303xC/STM32F358xx Product devices)
  413. * @{
  414. */
  415. #define COMP_WINDOWMODE_DISABLE (0x00000000U) /*!< Window mode disabled */
  416. #define COMP_WINDOWMODE_ENABLE COMP_CSR_COMPxWNDWEN /*!< Window mode enabled: non inverting input of comparator X (x=2U,4,6U)
  417. is connected to the non inverting input of comparator X-1U */
  418. /**
  419. * @}
  420. */
  421. #elif defined(STM32F373xC) || defined(STM32F378xx)
  422. /** @defgroup COMPEx_WindowMode COMP Extended WindowMode (STM32F373xC/STM32F378xx Product devices)
  423. * @{
  424. */
  425. #define COMP_WINDOWMODE_DISABLE (0x00000000U) /*!< Window mode disabled */
  426. #define COMP_WINDOWMODE_ENABLE ((uint32_t)COMP_CSR_COMPxWNDWEN) /*!< Window mode enabled: non inverting input of comparator 2
  427. is connected to the non inverting input of comparator 1 (PA1) */
  428. /**
  429. * @}
  430. */
  431. #else
  432. /** @defgroup COMPEx_WindowMode COMP Extended WindowMode (Other Product devices)
  433. * @{
  434. */
  435. #define COMP_WINDOWMODE_DISABLE (0x00000000U) /*!< Window mode disabled (not available) */
  436. /**
  437. * @}
  438. */
  439. #endif /* STM32F302xC || STM32F303xC || STM32F358xx */
  440. /** @defgroup COMPEx_Mode COMP Extended Mode
  441. * @{
  442. */
  443. #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  444. defined(STM32F373xC) || defined(STM32F378xx)
  445. /* Please refer to the electrical characteristics in the device datasheet for
  446. the power consumption values */
  447. #define COMP_MODE_HIGHSPEED (0x00000000U) /*!< High Speed */
  448. #define COMP_MODE_MEDIUMSPEED COMP_CSR_COMPxMODE_0 /*!< Medium Speed */
  449. #define COMP_MODE_LOWPOWER COMP_CSR_COMPxMODE_1 /*!< Low power mode */
  450. #define COMP_MODE_ULTRALOWPOWER COMP_CSR_COMPxMODE /*!< Ultra-low power mode */
  451. #endif /* STM32F302xC || STM32F303xC || STM32F358xx || */
  452. /* STM32F373xC || STM32F378xx */
  453. /**
  454. * @}
  455. */
  456. /** @defgroup COMPEx_Hysteresis COMP Extended Hysteresis
  457. * @{
  458. */
  459. #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  460. defined(STM32F373xC) || defined(STM32F378xx)
  461. #define COMP_HYSTERESIS_NONE (0x00000000U) /*!< No hysteresis */
  462. #define COMP_HYSTERESIS_LOW COMP_CSR_COMPxHYST_0 /*!< Hysteresis level low */
  463. #define COMP_HYSTERESIS_MEDIUM COMP_CSR_COMPxHYST_1 /*!< Hysteresis level medium */
  464. #define COMP_HYSTERESIS_HIGH COMP_CSR_COMPxHYST /*!< Hysteresis level high */
  465. #else
  466. #define COMP_HYSTERESIS_NONE (0x00000000U) /*!< No hysteresis */
  467. #endif /* STM32F302xC || STM32F303xC || STM32F358xx || */
  468. /* STM32F373xC || STM32F378xx */
  469. /**
  470. * @}
  471. */
  472. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || \
  473. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  474. /** @defgroup COMPEx_BlankingSrce COMP Extended Blanking Source (STM32F301x8/STM32F302x8/STM32F303x8/STM32F334x8/STM32F318xx/STM32F328xx Product devices)
  475. * @{
  476. */
  477. /* No blanking source can be selected for all comparators */
  478. #define COMP_BLANKINGSRCE_NONE (0x00000000U) /*!< No blanking source */
  479. /* Blanking source for COMP2 */
  480. #define COMP_BLANKINGSRCE_TIM1OC5 COMP_CSR_COMPxBLANKING_0 /*!< TIM1 OC5 selected as blanking source for COMP2 */
  481. #define COMP_BLANKINGSRCE_TIM2OC3 COMP_CSR_COMPxBLANKING_1 /*!< TIM2 OC3 selected as blanking source for COMP2 */
  482. #define COMP_BLANKINGSRCE_TIM3OC3 (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1) /*!< TIM3 OC3 selected as blanking source for COMP2 */
  483. /* Blanking source for COMP4 */
  484. #define COMP_BLANKINGSRCE_TIM3OC4 COMP_CSR_COMPxBLANKING_0 /*!< TIM3 OC4 selected as blanking source for COMP4 */
  485. #define COMP_BLANKINGSRCE_TIM15OC1 (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1) /*!< TIM15 OC1 selected as blanking source for COMP4 */
  486. /* Blanking source for COMP6 */
  487. #define COMP_BLANKINGSRCE_TIM2OC4 (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1) /*!< TIM2 OC4 selected as blanking source for COMP6 */
  488. #define COMP_BLANKINGSRCE_TIM15OC2 COMP_CSR_COMPxBLANKING_2 /*!< TIM15 OC2 selected as blanking source for COMP6 */
  489. /**
  490. * @}
  491. */
  492. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx || */
  493. /* STM32F303x8 || STM32F334x8 || STM32F328xx */
  494. #if defined(STM32F302xE) ||\
  495. defined(STM32F302xC)
  496. /** @defgroup COMPEx_BlankingSrce COMP Extended Blanking Source (STM32F302xE/STM32F302xC Product devices)
  497. * @{
  498. */
  499. /* No blanking source can be selected for all comparators */
  500. #define COMP_BLANKINGSRCE_NONE (0x00000000U) /*!< No blanking source */
  501. /* Blanking source common for COMP1 and COMP2 */
  502. #define COMP_BLANKINGSRCE_TIM1OC5 COMP_CSR_COMPxBLANKING_0 /*!< TIM1 OC5 selected as blanking source for COMP1 and COMP2 */
  503. /* Blanking source common for COMP1 and COMP2 */
  504. #define COMP_BLANKINGSRCE_TIM2OC3 COMP_CSR_COMPxBLANKING_1 /*!< TIM2 OC3 selected as blanking source for COMP1 and COMP2 */
  505. /* Blanking source common for COMP1 and COMP2 */
  506. #define COMP_BLANKINGSRCE_TIM3OC3 (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1) /*!< TIM3 OC3 selected as blanking source for COMP1 and COMP2 */
  507. /* Blanking source for COMP4 */
  508. #define COMP_BLANKINGSRCE_TIM3OC4 COMP_CSR_COMPxBLANKING_0 /*!< TIM3 OC4 selected as blanking source for COMP4 */
  509. #define COMP_BLANKINGSRCE_TIM15OC1 (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1) /*!< TIM15 OC1 selected as blanking source for COMP4 */
  510. /* Blanking source for COMP6 */
  511. #define COMP_BLANKINGSRCE_TIM2OC4 (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1) /*!< TIM2 OC4 selected as blanking source for COMP6 */
  512. #define COMP_BLANKINGSRCE_TIM15OC2 COMP_CSR_COMPxBLANKING_2 /*!< TIM15 OC2 selected as blanking source for COMP6 */
  513. /**
  514. * @}
  515. */
  516. #endif /* STM32F302xE || */
  517. /* STM32F302xC */
  518. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  519. defined(STM32F303xC) || defined(STM32F358xx)
  520. /** @defgroup COMPEx_BlankingSrce COMP Extended Blanking Source (STM32F303xE/STM32F398xx/STM32F303xC/STM32F358xx Product devices)
  521. * @{
  522. */
  523. /* No blanking source can be selected for all comparators */
  524. #define COMP_BLANKINGSRCE_NONE (0x00000000U) /*!< No blanking source */
  525. /* Blanking source common for COMP1, COMP2, COMP3 and COMP7 */
  526. #define COMP_BLANKINGSRCE_TIM1OC5 COMP_CSR_COMPxBLANKING_0 /*!< TIM1 OC5 selected as blanking source for COMP1, COMP2, COMP3 and COMP7 */
  527. /* Blanking source common for COMP1 and COMP2 */
  528. #define COMP_BLANKINGSRCE_TIM2OC3 COMP_CSR_COMPxBLANKING_1 /*!< TIM2 OC5 selected as blanking source for COMP1 and COMP2 */
  529. /* Blanking source common for COMP1, COMP2 and COMP5 */
  530. #define COMP_BLANKINGSRCE_TIM3OC3 (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1) /*!< TIM2 OC3 selected as blanking source for COMP1, COMP2 and COMP5 */
  531. /* Blanking source common for COMP3 and COMP6 */
  532. #define COMP_BLANKINGSRCE_TIM2OC4 (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1) /*!< TIM2 OC4 selected as blanking source for COMP3 and COMP6 */
  533. /* Blanking source common for COMP4, COMP5, COMP6 and COMP7 */
  534. #define COMP_BLANKINGSRCE_TIM8OC5 COMP_CSR_COMPxBLANKING_1 /*!< TIM8 OC5 selected as blanking source for COMP4, COMP5, COMP6 and COMP7 */
  535. /* Blanking source for COMP4 */
  536. #define COMP_BLANKINGSRCE_TIM3OC4 COMP_CSR_COMPxBLANKING_0 /*!< TIM3 OC4 selected as blanking source for COMP4 */
  537. #define COMP_BLANKINGSRCE_TIM15OC1 (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1) /*!< TIM15 OC1 selected as blanking source for COMP4 */
  538. /* Blanking source common for COMP6 and COMP7 */
  539. #define COMP_BLANKINGSRCE_TIM15OC2 COMP_CSR_COMPxBLANKING_2 /*!< TIM15 OC2 selected as blanking source for COMP6 and COMP7 */
  540. /**
  541. * @}
  542. */
  543. #endif /* STM32F303xE || STM32F398xx || */
  544. /* STM32F303xC || STM32F358xx */
  545. #if defined(STM32F373xC) || defined(STM32F378xx)
  546. /** @defgroup COMPEx_BlankingSrce COMP Extended Blanking Source (STM32F373xC/STM32F378xx Product devices)
  547. * @{
  548. */
  549. /* No blanking source can be selected for all comparators */
  550. #define COMP_BLANKINGSRCE_NONE (0x00000000U) /*!< No blanking source */
  551. /**
  552. * @}
  553. */
  554. #endif /* STM32F373xC || STM32F378xx */
  555. /** @defgroup COMP_Flag COMP Flag
  556. * @{
  557. */
  558. #if defined(STM32F373xC) || defined(STM32F378xx)
  559. #define COMP_FLAG_LOCK COMP_CSR_COMP1LOCK /*!< Lock flag */
  560. #else
  561. #define COMP_FLAG_LOCK COMP_CSR_LOCK /*!< Lock flag */
  562. #endif /* STM32F373xC || STM32F378xx */
  563. /**
  564. * @}
  565. */
  566. /**
  567. * @}
  568. */
  569. /* Exported macro ------------------------------------------------------------*/
  570. /** @defgroup COMPEx_Exported_Macros COMP Extended Exported Macros
  571. * @{
  572. */
  573. #if defined(STM32F373xC) || defined(STM32F378xx)
  574. /**
  575. * @brief Enable the specified comparator.
  576. * @param __HANDLE__ COMP handle.
  577. * @retval None
  578. */
  579. #define __HAL_COMP_ENABLE(__HANDLE__) \
  580. do { \
  581. uint32_t regshift = COMP_CSR_COMP1_SHIFT; \
  582. \
  583. if((__HANDLE__)->Instance == COMP2) \
  584. { \
  585. regshift = COMP_CSR_COMP2_SHIFT; \
  586. } \
  587. SET_BIT(COMP->CSR, (uint32_t)COMP_CSR_COMPxEN << regshift); \
  588. } while(0U)
  589. /**
  590. * @brief Disable the specified comparator.
  591. * @param __HANDLE__ COMP handle.
  592. * @retval None
  593. */
  594. #define __HAL_COMP_DISABLE(__HANDLE__) \
  595. do { \
  596. uint32_t regshift = COMP_CSR_COMP1_SHIFT; \
  597. \
  598. if((__HANDLE__)->Instance == COMP2) \
  599. { \
  600. regshift = COMP_CSR_COMP2_SHIFT; \
  601. } \
  602. CLEAR_BIT(COMP->CSR, (uint32_t)COMP_CSR_COMPxEN << regshift); \
  603. } while(0U)
  604. /**
  605. * @brief Lock a comparator instance
  606. * @param __HANDLE__ COMP handle
  607. * @retval None.
  608. */
  609. #define __HAL_COMP_LOCK(__HANDLE__) \
  610. do { \
  611. uint32_t regshift = COMP_CSR_COMP1_SHIFT; \
  612. \
  613. if((__HANDLE__)->Instance == COMP2) \
  614. { \
  615. regshift = COMP_CSR_COMP2_SHIFT; \
  616. } \
  617. SET_BIT(COMP->CSR, (uint32_t)COMP_CSR_COMPxLOCK << regshift); \
  618. } while(0U)
  619. /** @brief Check whether the specified COMP flag is set or not.
  620. * @param __HANDLE__ COMP Handle.
  621. * @param __FLAG__ flag to check.
  622. * This parameter can be one of the following values:
  623. * @arg @ref COMP_FLAG_LOCK lock flag
  624. * @retval The new state of __FLAG__ (TRUE or FALSE).
  625. */
  626. #define __HAL_COMP_GET_FLAG(__HANDLE__, __FLAG__) \
  627. (((__HANDLE__)->Instance == COMP1) ? (((__HANDLE__)->Instance->CSR & (__FLAG__)) == (__FLAG__)) \
  628. (((__HANDLE__)->Instance->CSR & (uint32_t)((__FLAG__) << COMP_CSR_COMP2_SHIFT) == (__FLAG__))))
  629. #else
  630. /**
  631. * @brief Enable the specified comparator.
  632. * @param __HANDLE__ COMP handle.
  633. * @retval None
  634. */
  635. #define __HAL_COMP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_COMPxEN)
  636. /**
  637. * @brief Disable the specified comparator.
  638. * @param __HANDLE__ COMP handle.
  639. * @retval None
  640. */
  641. #define __HAL_COMP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_COMPxEN)
  642. /**
  643. * @brief Lock a comparator instance
  644. * @param __HANDLE__ COMP handle
  645. * @retval None.
  646. */
  647. #define __HAL_COMP_LOCK(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_COMPxLOCK)
  648. /** @brief Check whether the specified COMP flag is set or not.
  649. * @param __HANDLE__ COMP Handle.
  650. * @param __FLAG__ flag to check.
  651. * This parameter can be one of the following values:
  652. * @arg @ref COMP_FLAG_LOCK lock flag
  653. * @retval The new state of __FLAG__ (TRUE or FALSE).
  654. */
  655. #define __HAL_COMP_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->CSR & (__FLAG__)) == (__FLAG__))
  656. #endif /* STM32F373xC || STM32F378xx */
  657. #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  658. defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  659. defined(STM32F373xC) || defined(STM32F378xx)
  660. /**
  661. * @brief Enable the COMP1 EXTI line rising edge trigger.
  662. * @retval None
  663. */
  664. #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP1)
  665. /**
  666. * @brief Disable the COMP1 EXTI line rising edge trigger.
  667. * @retval None
  668. */
  669. #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP1)
  670. /**
  671. * @brief Enable the COMP1 EXTI line falling edge trigger.
  672. * @retval None
  673. */
  674. #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP1)
  675. /**
  676. * @brief Disable the COMP1 EXTI line falling edge trigger.
  677. * @retval None
  678. */
  679. #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP1)
  680. /**
  681. * @brief Enable the COMP1 EXTI line rising & falling edge trigger.
  682. * @retval None
  683. */
  684. #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  685. __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE(); \
  686. __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE(); \
  687. } while(0U)
  688. /**
  689. * @brief Disable the COMP1 EXTI line rising & falling edge trigger.
  690. * @retval None
  691. */
  692. #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  693. __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE(); \
  694. __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE(); \
  695. } while(0U)
  696. /**
  697. * @brief Enable the COMP1 EXTI line in interrupt mode.
  698. * @retval None
  699. */
  700. #define __HAL_COMP_COMP1_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP1)
  701. /**
  702. * @brief Disable the COMP1 EXTI line in interrupt mode.
  703. * @retval None
  704. */
  705. #define __HAL_COMP_COMP1_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP1)
  706. /**
  707. * @brief Generate a software interrupt on the COMP1 EXTI line.
  708. * @retval None
  709. */
  710. #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, COMP_EXTI_LINE_COMP1)
  711. /**
  712. * @brief Enable the COMP1 EXTI line in event mode.
  713. * @retval None
  714. */
  715. #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP1)
  716. /**
  717. * @brief Disable the COMP1 EXTI line in event mode.
  718. * @retval None
  719. */
  720. #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP1)
  721. /**
  722. * @brief Check whether the COMP1 EXTI line flag is set or not.
  723. * @retval RESET or SET
  724. */
  725. #define __HAL_COMP_COMP1_EXTI_GET_FLAG() READ_BIT(EXTI->PR, COMP_EXTI_LINE_COMP1)
  726. /**
  727. * @brief Clear the COMP1 EXTI flag.
  728. * @retval None
  729. */
  730. #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR, COMP_EXTI_LINE_COMP1)
  731. #endif /* STM32F302xC || STM32F303xC || STM32F358xx || */
  732. /* STM32F302xE || STM32F303xE || STM32F398xx || */
  733. /* STM32F373xC || STM32F378xx */
  734. /**
  735. * @brief Enable the COMP2 EXTI line rising edge trigger.
  736. * @retval None
  737. */
  738. #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP2)
  739. /**
  740. * @brief Disable the COMP2 EXTI line rising edge trigger.
  741. * @retval None
  742. */
  743. #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP2)
  744. /**
  745. * @brief Enable the COMP2 EXTI line falling edge trigger.
  746. * @retval None
  747. */
  748. #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP2)
  749. /**
  750. * @brief Disable the COMP2 EXTI line falling edge trigger.
  751. * @retval None
  752. */
  753. #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP2)
  754. /**
  755. * @brief Enable the COMP2 EXTI line rising & falling edge trigger.
  756. * @retval None
  757. */
  758. #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  759. __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE(); \
  760. __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE(); \
  761. } while(0U)
  762. /**
  763. * @brief Disable the COMP2 EXTI line rising & falling edge trigger.
  764. * @retval None
  765. */
  766. #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  767. __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE(); \
  768. __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE(); \
  769. } while(0U)
  770. /**
  771. * @brief Enable the COMP2 EXTI line in interrupt mode.
  772. * @retval None
  773. */
  774. #define __HAL_COMP_COMP2_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP2)
  775. /**
  776. * @brief Disable the COMP2 EXTI line in interrupt mode.
  777. * @retval None
  778. */
  779. #define __HAL_COMP_COMP2_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP2)
  780. /**
  781. * @brief Generate a software interrupt on the COMP2 EXTI line.
  782. * @retval None
  783. */
  784. #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, COMP_EXTI_LINE_COMP2)
  785. /**
  786. * @brief Enable the COMP2 EXTI line in event mode.
  787. * @retval None
  788. */
  789. #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP2)
  790. /**
  791. * @brief Disable the COMP2 EXTI line in event mode.
  792. * @retval None
  793. */
  794. #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP2)
  795. /**
  796. * @brief Check whether the COMP2 EXTI line flag is set or not.
  797. * @retval RESET or SET
  798. */
  799. #define __HAL_COMP_COMP2_EXTI_GET_FLAG() READ_BIT(EXTI->PR, COMP_EXTI_LINE_COMP2)
  800. /**
  801. * @brief Clear the COMP2 EXTI flag.
  802. * @retval None
  803. */
  804. #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR, COMP_EXTI_LINE_COMP2)
  805. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  806. defined(STM32F303xC) || defined(STM32F358xx)
  807. /**
  808. * @brief Enable the COMP3 EXTI line rising edge trigger.
  809. * @retval None
  810. */
  811. #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP3)
  812. /**
  813. * @brief Disable the COMP3 EXTI line rising edge trigger.
  814. * @retval None
  815. */
  816. #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP3)
  817. /**
  818. * @brief Enable the COMP3 EXTI line falling edge trigger.
  819. * @retval None
  820. */
  821. #define __HAL_COMP_COMP3_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP3)
  822. /**
  823. * @brief Disable the COMP3 EXTI line falling edge trigger.
  824. * @retval None
  825. */
  826. #define __HAL_COMP_COMP3_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP3)
  827. /**
  828. * @brief Enable the COMP3 EXTI line rising & falling edge trigger.
  829. * @retval None
  830. */
  831. #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  832. __HAL_COMP_COMP3_EXTI_ENABLE_RISING_EDGE(); \
  833. __HAL_COMP_COMP3_EXTI_ENABLE_FALLING_EDGE(); \
  834. } while(0U)
  835. /**
  836. * @brief Disable the COMP3 EXTI line rising & falling edge trigger.
  837. * @retval None
  838. */
  839. #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  840. __HAL_COMP_COMP3_EXTI_DISABLE_RISING_EDGE(); \
  841. __HAL_COMP_COMP3_EXTI_DISABLE_FALLING_EDGE(); \
  842. } while(0U)
  843. /**
  844. * @brief Enable the COMP3 EXTI line in interrupt mode.
  845. * @retval None
  846. */
  847. #define __HAL_COMP_COMP3_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP3)
  848. /**
  849. * @brief Disable the COMP3 EXTI line in interrupt mode.
  850. * @retval None
  851. */
  852. #define __HAL_COMP_COMP3_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP3)
  853. /**
  854. * @brief Generate a software interrupt on the COMP3 EXTI line.
  855. * @retval None
  856. */
  857. #define __HAL_COMP_COMP3_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, COMP_EXTI_LINE_COMP3)
  858. /**
  859. * @brief Enable the COMP3 EXTI line in event mode.
  860. * @retval None
  861. */
  862. #define __HAL_COMP_COMP3_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP3)
  863. /**
  864. * @brief Disable the COMP3 EXTI line in event mode.
  865. * @retval None
  866. */
  867. #define __HAL_COMP_COMP3_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP3)
  868. /**
  869. * @brief Check whether the COMP3 EXTI line flag is set or not.
  870. * @retval RESET or SET
  871. */
  872. #define __HAL_COMP_COMP3_EXTI_GET_FLAG() READ_BIT(EXTI->PR, COMP_EXTI_LINE_COMP3)
  873. /**
  874. * @brief Clear the COMP3 EXTI flag.
  875. * @retval None
  876. */
  877. #define __HAL_COMP_COMP3_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR, COMP_EXTI_LINE_COMP3)
  878. #endif /* STM32F303xE || STM32F398xx || */
  879. /* STM32F303xC || STM32F358xx */
  880. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || \
  881. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  882. defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  883. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  884. /**
  885. * @brief Enable the COMP4 EXTI line rising edge trigger.
  886. * @retval None
  887. */
  888. #define __HAL_COMP_COMP4_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP4)
  889. /**
  890. * @brief Disable the COMP4 EXTI line rising edge trigger.
  891. * @retval None
  892. */
  893. #define __HAL_COMP_COMP4_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP4)
  894. /**
  895. * @brief Enable the COMP4 EXTI line falling edge trigger.
  896. * @retval None
  897. */
  898. #define __HAL_COMP_COMP4_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP4)
  899. /**
  900. * @brief Disable the COMP4 EXTI line falling edge trigger.
  901. * @retval None
  902. */
  903. #define __HAL_COMP_COMP4_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP4)
  904. /**
  905. * @brief Enable the COMP4 EXTI line rising & falling edge trigger.
  906. * @retval None
  907. */
  908. #define __HAL_COMP_COMP4_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  909. __HAL_COMP_COMP4_EXTI_ENABLE_RISING_EDGE(); \
  910. __HAL_COMP_COMP4_EXTI_ENABLE_FALLING_EDGE(); \
  911. } while(0U)
  912. /**
  913. * @brief Disable the COMP4 EXTI line rising & falling edge trigger.
  914. * @retval None
  915. */
  916. #define __HAL_COMP_COMP4_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  917. __HAL_COMP_COMP4_EXTI_DISABLE_RISING_EDGE(); \
  918. __HAL_COMP_COMP4_EXTI_DISABLE_FALLING_EDGE(); \
  919. } while(0U)
  920. /**
  921. * @brief Enable the COMP4 EXTI line in interrupt mode.
  922. * @retval None
  923. */
  924. #define __HAL_COMP_COMP4_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP4)
  925. /**
  926. * @brief Disable the COMP4 EXTI line in interrupt mode.
  927. * @retval None
  928. */
  929. #define __HAL_COMP_COMP4_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP4)
  930. /**
  931. * @brief Generate a software interrupt on the COMP4 EXTI line.
  932. * @retval None
  933. */
  934. #define __HAL_COMP_COMP4_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, COMP_EXTI_LINE_COMP4)
  935. /**
  936. * @brief Enable the COMP4 EXTI line in event mode.
  937. * @retval None
  938. */
  939. #define __HAL_COMP_COMP4_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP4)
  940. /**
  941. * @brief Disable the COMP4 EXTI line in event mode.
  942. * @retval None
  943. */
  944. #define __HAL_COMP_COMP4_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP4)
  945. /**
  946. * @brief Check whether the COMP4 EXTI line flag is set or not.
  947. * @retval RESET or SET
  948. */
  949. #define __HAL_COMP_COMP4_EXTI_GET_FLAG() READ_BIT(EXTI->PR, COMP_EXTI_LINE_COMP4)
  950. /**
  951. * @brief Clear the COMP4 EXTI flag.
  952. * @retval None
  953. */
  954. #define __HAL_COMP_COMP4_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR, COMP_EXTI_LINE_COMP4)
  955. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx || */
  956. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  957. /* STM32F302xE || STM32F303xE || STM32F398xx || */
  958. /* STM32F303x8 || STM32F334x8 || STM32F328xx */
  959. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  960. defined(STM32F303xC) || defined(STM32F358xx)
  961. /**
  962. * @brief Enable the COMP5 EXTI line rising edge trigger.
  963. * @retval None
  964. */
  965. #define __HAL_COMP_COMP5_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP5)
  966. /**
  967. * @brief Disable the COMP5 EXTI line rising edge trigger.
  968. * @retval None
  969. */
  970. #define __HAL_COMP_COMP5_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP5)
  971. /**
  972. * @brief Enable the COMP5 EXTI line falling edge trigger.
  973. * @retval None
  974. */
  975. #define __HAL_COMP_COMP5_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP5)
  976. /**
  977. * @brief Disable the COMP5 EXTI line falling edge trigger.
  978. * @retval None
  979. */
  980. #define __HAL_COMP_COMP5_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP5)
  981. /**
  982. * @brief Enable the COMP5 EXTI line rising & falling edge trigger.
  983. * @retval None
  984. */
  985. #define __HAL_COMP_COMP5_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  986. __HAL_COMP_COMP5_EXTI_ENABLE_RISING_EDGE(); \
  987. __HAL_COMP_COMP5_EXTI_ENABLE_FALLING_EDGE(); \
  988. } while(0U)
  989. /**
  990. * @brief Disable the COMP5 EXTI line rising & falling edge trigger.
  991. * @retval None
  992. */
  993. #define __HAL_COMP_COMP5_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  994. __HAL_COMP_COMP5_EXTI_DISABLE_RISING_EDGE(); \
  995. __HAL_COMP_COMP5_EXTI_DISABLE_FALLING_EDGE(); \
  996. } while(0U)
  997. /**
  998. * @brief Enable the COMP5 EXTI line in interrupt mode.
  999. * @retval None
  1000. */
  1001. #define __HAL_COMP_COMP5_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP5)
  1002. /**
  1003. * @brief Disable the COMP5 EXTI line in interrupt mode.
  1004. * @retval None
  1005. */
  1006. #define __HAL_COMP_COMP5_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP5)
  1007. /**
  1008. * @brief Generate a software interrupt on the COMP5 EXTI line.
  1009. * @retval None
  1010. */
  1011. #define __HAL_COMP_COMP5_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER, COMP_EXTI_LINE_COMP5)
  1012. /**
  1013. * @brief Enable the COMP5 EXTI line in event mode.
  1014. * @retval None
  1015. */
  1016. #define __HAL_COMP_COMP5_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP5)
  1017. /**
  1018. * @brief Disable the COMP5 EXTI line in event mode.
  1019. * @retval None
  1020. */
  1021. #define __HAL_COMP_COMP5_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP5)
  1022. /**
  1023. * @brief Check whether the COMP5 EXTI line flag is set or not.
  1024. * @retval RESET or SET
  1025. */
  1026. #define __HAL_COMP_COMP5_EXTI_GET_FLAG() READ_BIT(EXTI->PR, COMP_EXTI_LINE_COMP5)
  1027. /**
  1028. * @brief Clear the COMP5 EXTI flag.
  1029. * @retval None
  1030. */
  1031. #define __HAL_COMP_COMP5_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR, COMP_EXTI_LINE_COMP5)
  1032. #endif /* STM32F303xE || STM32F398xx || */
  1033. /* STM32F303xC || STM32F358xx */
  1034. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || \
  1035. defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
  1036. defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
  1037. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  1038. /**
  1039. * @brief Enable the COMP6 EXTI line rising edge trigger.
  1040. * @retval None
  1041. */
  1042. #define __HAL_COMP_COMP6_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR2, COMP_EXTI_LINE_COMP6)
  1043. /**
  1044. * @brief Disable the COMP6 EXTI line rising edge trigger.
  1045. * @retval None
  1046. */
  1047. #define __HAL_COMP_COMP6_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR2, COMP_EXTI_LINE_COMP6)
  1048. /**
  1049. * @brief Enable the COMP6 EXTI line falling edge trigger.
  1050. * @retval None
  1051. */
  1052. #define __HAL_COMP_COMP6_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR2, COMP_EXTI_LINE_COMP6)
  1053. /**
  1054. * @brief Disable the COMP6 EXTI line falling edge trigger.
  1055. * @retval None
  1056. */
  1057. #define __HAL_COMP_COMP6_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR2, COMP_EXTI_LINE_COMP6)
  1058. /**
  1059. * @brief Enable the COMP6 EXTI line rising & falling edge trigger.
  1060. * @retval None
  1061. */
  1062. #define __HAL_COMP_COMP6_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  1063. __HAL_COMP_COMP6_EXTI_ENABLE_RISING_EDGE(); \
  1064. __HAL_COMP_COMP6_EXTI_ENABLE_FALLING_EDGE(); \
  1065. } while(0U)
  1066. /**
  1067. * @brief Disable the COMP6 EXTI line rising & falling edge trigger.
  1068. * @retval None
  1069. */
  1070. #define __HAL_COMP_COMP6_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  1071. __HAL_COMP_COMP6_EXTI_DISABLE_RISING_EDGE(); \
  1072. __HAL_COMP_COMP6_EXTI_DISABLE_FALLING_EDGE(); \
  1073. } while(0U)
  1074. /**
  1075. * @brief Enable the COMP6 EXTI line in interrupt mode.
  1076. * @retval None
  1077. */
  1078. #define __HAL_COMP_COMP6_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR2, COMP_EXTI_LINE_COMP6)
  1079. /**
  1080. * @brief Disable the COMP6 EXTI line in interrupt mode.
  1081. * @retval None
  1082. */
  1083. #define __HAL_COMP_COMP6_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR2, COMP_EXTI_LINE_COMP6)
  1084. /**
  1085. * @brief Generate a software interrupt on the COMP6 EXTI line.
  1086. * @retval None
  1087. */
  1088. #define __HAL_COMP_COMP6_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER2, COMP_EXTI_LINE_COMP6)
  1089. /**
  1090. * @brief Enable the COMP6 EXTI line in event mode.
  1091. * @retval None
  1092. */
  1093. #define __HAL_COMP_COMP6_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR2, COMP_EXTI_LINE_COMP6)
  1094. /**
  1095. * @brief Disable the COMP6 EXTI line in event mode.
  1096. * @retval None
  1097. */
  1098. #define __HAL_COMP_COMP6_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR2, COMP_EXTI_LINE_COMP6)
  1099. /**
  1100. * @brief Check whether the COMP6 EXTI line flag is set or not.
  1101. * @retval RESET or SET
  1102. */
  1103. #define __HAL_COMP_COMP6_EXTI_GET_FLAG() READ_BIT(EXTI->PR2, COMP_EXTI_LINE_COMP6)
  1104. /**
  1105. * @brief Clear the COMP6 EXTI flag.
  1106. * @retval None
  1107. */
  1108. #define __HAL_COMP_COMP6_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR2, COMP_EXTI_LINE_COMP6)
  1109. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx || */
  1110. /* STM32F302xC || STM32F303xC || STM32F358xx || */
  1111. /* STM32F302xE || STM32F303xE || STM32F398xx || */
  1112. /* STM32F303x8 || STM32F334x8 || STM32F328xx */
  1113. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  1114. defined(STM32F303xC) || defined(STM32F358xx)
  1115. /**
  1116. * @brief Enable the COMP7 EXTI line rising edge trigger.
  1117. * @retval None
  1118. */
  1119. #define __HAL_COMP_COMP7_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR2, COMP_EXTI_LINE_COMP7)
  1120. /**
  1121. * @brief Disable the COMP7 EXTI line rising edge trigger.
  1122. * @retval None
  1123. */
  1124. #define __HAL_COMP_COMP7_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR2, COMP_EXTI_LINE_COMP7)
  1125. /**
  1126. * @brief Enable the COMP7 EXTI line falling edge trigger.
  1127. * @retval None
  1128. */
  1129. #define __HAL_COMP_COMP7_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR2, COMP_EXTI_LINE_COMP7)
  1130. /**
  1131. * @brief Disable the COMP7 EXTI line falling edge trigger.
  1132. * @retval None
  1133. */
  1134. #define __HAL_COMP_COMP7_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR2, COMP_EXTI_LINE_COMP7)
  1135. /**
  1136. * @brief Enable the COMP7 EXTI line rising & falling edge trigger.
  1137. * @retval None
  1138. */
  1139. #define __HAL_COMP_COMP7_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  1140. __HAL_COMP_COMP7_EXTI_ENABLE_RISING_EDGE(); \
  1141. __HAL_COMP_COMP7_EXTI_ENABLE_FALLING_EDGE(); \
  1142. } while(0U)
  1143. /**
  1144. * @brief Disable the COMP7 EXTI line rising & falling edge trigger.
  1145. * @retval None
  1146. */
  1147. #define __HAL_COMP_COMP7_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  1148. __HAL_COMP_COMP7_EXTI_DISABLE_RISING_EDGE(); \
  1149. __HAL_COMP_COMP7_EXTI_DISABLE_FALLING_EDGE(); \
  1150. } while(0U)
  1151. /**
  1152. * @brief Enable the COMP7 EXTI line in interrupt mode.
  1153. * @retval None
  1154. */
  1155. #define __HAL_COMP_COMP7_EXTI_ENABLE_IT() SET_BIT(EXTI->IMR2, COMP_EXTI_LINE_COMP7)
  1156. /**
  1157. * @brief Disable the COMP7 EXTI line in interrupt mode.
  1158. * @retval None
  1159. */
  1160. #define __HAL_COMP_COMP7_EXTI_DISABLE_IT() CLEAR_BIT(EXTI->IMR2, COMP_EXTI_LINE_COMP7)
  1161. /**
  1162. * @brief Generate a software interrupt on the COMP7 EXTI line.
  1163. * @retval None
  1164. */
  1165. #define __HAL_COMP_COMP7_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER2, COMP_EXTI_LINE_COMP7)
  1166. /**
  1167. * @brief Enable the COMP7 EXTI line in event mode.
  1168. * @retval None
  1169. */
  1170. #define __HAL_COMP_COMP7_EXTI_ENABLE_EVENT() SET_BIT(EXTI->EMR2, COMP_EXTI_LINE_COMP7)
  1171. /**
  1172. * @brief Disable the COMP7 EXTI line in event mode.
  1173. * @retval None
  1174. */
  1175. #define __HAL_COMP_COMP7_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI->EMR2, COMP_EXTI_LINE_COMP7)
  1176. /**
  1177. * @brief Check whether the COMP7 EXTI line flag is set or not.
  1178. * @retval RESET or SET
  1179. */
  1180. #define __HAL_COMP_COMP7_EXTI_GET_FLAG() READ_BIT(EXTI->PR2, COMP_EXTI_LINE_COMP7)
  1181. /**
  1182. * @brief Clear the COMP7 EXTI flag.
  1183. * @retval None
  1184. */
  1185. #define __HAL_COMP_COMP7_EXTI_CLEAR_FLAG() WRITE_REG(EXTI->PR2, COMP_EXTI_LINE_COMP7)
  1186. #endif /* STM32F303xE || STM32F398xx || */
  1187. /* STM32F303xC || STM32F358xx */
  1188. /**
  1189. * @}
  1190. */
  1191. /* Private types -------------------------------------------------------------*/
  1192. /* Private constants ---------------------------------------------------------*/
  1193. /** @defgroup COMPEx_Private_Constants COMP Extended Private Constants
  1194. * @{
  1195. */
  1196. /** @defgroup COMPEx_ExtiLineEvent COMP Extended EXTI lines
  1197. * @{
  1198. */
  1199. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || \
  1200. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  1201. #define COMP_EXTI_LINE_COMP2 EXTI_IMR_MR22 /*!< External interrupt line 22 connected to COMP2 */
  1202. #define COMP_EXTI_LINE_COMP4 EXTI_IMR_MR30 /*!< External interrupt line 30 connected to COMP4 */
  1203. #define COMP_EXTI_LINE_COMP6 EXTI_IMR2_MR32 /*!< External interrupt line 32 connected to COMP6 */
  1204. #define COMP_EXTI_LINE_REG2_MASK EXTI_IMR2_MR32 /*!< Mask for External interrupt line control in register xxx2 */
  1205. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx || */
  1206. /* STM32F303x8 || STM32F334x8 || STM32F328xx */
  1207. #if defined(STM32F302xE) || \
  1208. defined(STM32F302xC)
  1209. #define COMP_EXTI_LINE_COMP1 EXTI_IMR_MR21 /*!< External interrupt line 21 connected to COMP1 */
  1210. #define COMP_EXTI_LINE_COMP2 EXTI_IMR_MR22 /*!< External interrupt line 22 connected to COMP2 */
  1211. #define COMP_EXTI_LINE_COMP4 EXTI_IMR_MR30 /*!< External interrupt line 30 connected to COMP4 */
  1212. #define COMP_EXTI_LINE_COMP6 EXTI_IMR2_MR32 /*!< External interrupt line 32 connected to COMP6 */
  1213. #define COMP_EXTI_LINE_REG2_MASK EXTI_IMR2_MR32 /*!< Mask for External interrupt line control in register xxx2 */
  1214. #endif /* STM32F302xE || */
  1215. /* STM32F302xC */
  1216. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  1217. defined(STM32F303xC) || defined(STM32F358xx)
  1218. #define COMP_EXTI_LINE_COMP1 EXTI_IMR_MR21 /*!< External interrupt line 21 connected to COMP1 */
  1219. #define COMP_EXTI_LINE_COMP2 EXTI_IMR_MR22 /*!< External interrupt line 22 connected to COMP2 */
  1220. #define COMP_EXTI_LINE_COMP3 EXTI_IMR_MR29 /*!< External interrupt line 29 connected to COMP3 */
  1221. #define COMP_EXTI_LINE_COMP4 EXTI_IMR_MR30 /*!< External interrupt line 30 connected to COMP4 */
  1222. #define COMP_EXTI_LINE_COMP5 EXTI_IMR_MR31 /*!< External interrupt line 31 connected to COMP5 */
  1223. #define COMP_EXTI_LINE_COMP6 EXTI_IMR2_MR32 /*!< External interrupt line 32 connected to COMP6 */
  1224. #define COMP_EXTI_LINE_COMP7 EXTI_IMR2_MR33 /*!< External interrupt line 33 connected to COMP7 */
  1225. #define COMP_EXTI_LINE_REG2_MASK (EXTI_IMR2_MR33 | EXTI_IMR2_MR32) /*!< Mask for External interrupt line control in register xxx2 */
  1226. #endif /* STM32F303xE || STM32F398xx || */
  1227. /* STM32F303xC || STM32F358xx */
  1228. #if defined(STM32F373xC) || defined(STM32F378xx)
  1229. #define COMP_EXTI_LINE_COMP1 EXTI_IMR_MR21 /*!< External interrupt line 21 connected to COMP1 */
  1230. #define COMP_EXTI_LINE_COMP2 EXTI_IMR_MR22 /*!< External interrupt line 22 connected to COMP2 */
  1231. #endif /* STM32F373xC || STM32F378xx */
  1232. /**
  1233. * @}
  1234. */
  1235. /** @defgroup COMPEx_Misc COMP Extended miscellaneous defines
  1236. * @{
  1237. */
  1238. /* CSR masks redefinition for internal use */
  1239. #define COMP_CSR_COMPxINSEL_MASK COMP_CSR_COMPxINSEL /*!< COMP_CSR_COMPxINSEL Mask */
  1240. #define COMP_CSR_COMPxOUTSEL_MASK COMP_CSR_COMPxOUTSEL /*!< COMP_CSR_COMPxOUTSEL Mask */
  1241. #define COMP_CSR_COMPxPOL_MASK COMP_CSR_COMPxPOL /*!< COMP_CSR_COMPxPOL Mask */
  1242. #if defined(STM32F373xC) || defined(STM32F378xx)
  1243. /* CSR register reset value */
  1244. #define COMP_CSR_RESET_VALUE (0x00000000U)
  1245. #define COMP_CSR_RESET_PARAMETERS_MASK (0x00003FFFU)
  1246. #define COMP_CSR_UPDATE_PARAMETERS_MASK (0x00003FFEU)
  1247. /* CSR COMP1/COMP2 shift */
  1248. #define COMP_CSR_COMP1_SHIFT 0U
  1249. #define COMP_CSR_COMP2_SHIFT 16U
  1250. #else
  1251. /* CSR register reset value */
  1252. #define COMP_CSR_RESET_VALUE (0x00000000U)
  1253. #endif /* STM32F373xC || STM32F378xx */
  1254. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  1255. #define COMP_CSR_COMPxNONINSEL_MASK (COMP2_CSR_COMP2INPDAC) /*!< COMP_CSR_COMPxNONINSEL mask */
  1256. #define COMP_CSR_COMPxWNDWEN_MASK (0x00000000U) /*!< Mask empty: feature not available */
  1257. #define COMP_CSR_COMPxMODE_MASK (0x00000000U) /*!< Mask empty: feature not available */
  1258. #define COMP_CSR_COMPxHYST_MASK (0x00000000U) /*!< Mask empty: feature not available */
  1259. #define COMP_CSR_COMPxBLANKING_MASK COMP_CSR_COMPxBLANKING /*!< COMP_CSR_COMPxBLANKING mask */
  1260. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  1261. #if defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  1262. #define COMP_CSR_COMPxNONINSEL_MASK (0x00000000U) /*!< Mask empty: feature not available */
  1263. #define COMP_CSR_COMPxWNDWEN_MASK (0x00000000U) /*!< Mask empty: feature not available */
  1264. #define COMP_CSR_COMPxMODE_MASK (0x00000000U) /*!< Mask empty: feature not available */
  1265. #define COMP_CSR_COMPxHYST_MASK (0x00000000U) /*!< Mask empty: feature not available */
  1266. #define COMP_CSR_COMPxBLANKING_MASK COMP_CSR_COMPxBLANKING /*!< COMP_CSR_COMPxBLANKING mask */
  1267. #endif /* STM32F303x8 || STM32F334x8 || STM32F328xx */
  1268. #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
  1269. #define COMP_CSR_COMPxNONINSEL_MASK (COMP_CSR_COMPxNONINSEL | COMP1_CSR_COMP1SW1) /*!< COMP_CSR_COMPxNONINSEL mask */
  1270. #define COMP_CSR_COMPxWNDWEN_MASK COMP_CSR_COMPxWNDWEN /*!< COMP_CSR_COMPxWNDWEN mask */
  1271. #define COMP_CSR_COMPxMODE_MASK COMP_CSR_COMPxMODE /*!< COMP_CSR_COMPxMODE Mask */
  1272. #define COMP_CSR_COMPxHYST_MASK COMP_CSR_COMPxHYST /*!< COMP_CSR_COMPxHYST Mask */
  1273. #define COMP_CSR_COMPxBLANKING_MASK COMP_CSR_COMPxBLANKING /*!< COMP_CSR_COMPxBLANKING mask */
  1274. #endif /* STM32F302xC || STM32F303xC || STM32F358xx */
  1275. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx)
  1276. #define COMP_CSR_COMPxNONINSEL_MASK (COMP1_CSR_COMP1SW1) /*!< COMP_CSR_COMPxNONINSEL mask */
  1277. #define COMP_CSR_COMPxWNDWEN_MASK (0x00000000U) /*!< Mask empty: feature not available */
  1278. #define COMP_CSR_COMPxMODE_MASK (0x00000000U) /*!< Mask empty: feature not available */
  1279. #define COMP_CSR_COMPxHYST_MASK (0x00000000U) /*!< Mask empty: feature not available */
  1280. #define COMP_CSR_COMPxBLANKING_MASK COMP_CSR_COMPxBLANKING /*!< COMP_CSR_COMPxBLANKING mask */
  1281. #endif /* STM32F302xE || STM32F303xE || STM32F398xx */
  1282. #if defined(STM32F373xC) || defined(STM32F378xx)
  1283. #define COMP_CSR_COMPxNONINSEL_MASK (COMP_CSR_COMP1SW1) /*!< COMP_CSR_COMPxNONINSEL mask */
  1284. #define COMP_CSR_COMPxWNDWEN_MASK COMP_CSR_COMPxWNDWEN /*!< COMP_CSR_COMPxWNDWEN mask */
  1285. #define COMP_CSR_COMPxMODE_MASK COMP_CSR_COMPxMODE /*!< COMP_CSR_COMPxMODE Mask */
  1286. #define COMP_CSR_COMPxHYST_MASK COMP_CSR_COMPxHYST /*!< COMP_CSR_COMPxHYST Mask */
  1287. #define COMP_CSR_COMPxBLANKING_MASK (0x00000000U) /*!< Mask empty: feature not available */
  1288. #endif /* STM32F373xC || STM32F378xx */
  1289. /**
  1290. * @}
  1291. */
  1292. /**
  1293. * @}
  1294. */
  1295. /* Private macros ------------------------------------------------------------*/
  1296. /** @defgroup COMPEx_Private_Macros COMP Extended Private Macros
  1297. * @{
  1298. */
  1299. /** @defgroup COMP_GET_EXTI_LINE COMP Extended Private macro to get the EXTI line associated with a comparator handle
  1300. * @{
  1301. */
  1302. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || \
  1303. defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  1304. /**
  1305. * @brief Get the specified EXTI line for a comparator instance
  1306. * @param __INSTANCE__ specifies the COMP instance.
  1307. * @retval value of @ref COMPEx_ExtiLineEvent
  1308. */
  1309. #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 : \
  1310. ((__INSTANCE__) == COMP4) ? COMP_EXTI_LINE_COMP4 : \
  1311. COMP_EXTI_LINE_COMP6)
  1312. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx || */
  1313. /* STM32F303x8 || STM32F334x8 || STM32F328xx */
  1314. #if defined(STM32F302xE) || \
  1315. defined(STM32F302xC)
  1316. /**
  1317. * @brief Get the specified EXTI line for a comparator instance
  1318. * @param __INSTANCE__ specifies the COMP instance.
  1319. * @retval value of @ref COMPEx_ExtiLineEvent
  1320. */
  1321. #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 : \
  1322. ((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 : \
  1323. ((__INSTANCE__) == COMP4) ? COMP_EXTI_LINE_COMP4 : \
  1324. COMP_EXTI_LINE_COMP6)
  1325. #endif /* STM32F302xE || */
  1326. /* STM32F302xC */
  1327. #if defined(STM32F303xE) || defined(STM32F398xx) || \
  1328. defined(STM32F303xC) || defined(STM32F358xx)
  1329. /**
  1330. * @brief Get the specified EXTI line for a comparator instance
  1331. * @param __INSTANCE__ specifies the COMP instance.
  1332. * @retval value of @ref COMPEx_ExtiLineEvent
  1333. */
  1334. #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 : \
  1335. ((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 : \
  1336. ((__INSTANCE__) == COMP3) ? COMP_EXTI_LINE_COMP3 : \
  1337. ((__INSTANCE__) == COMP4) ? COMP_EXTI_LINE_COMP4 : \
  1338. ((__INSTANCE__) == COMP5) ? COMP_EXTI_LINE_COMP5 : \
  1339. ((__INSTANCE__) == COMP6) ? COMP_EXTI_LINE_COMP6 : \
  1340. COMP_EXTI_LINE_COMP7)
  1341. #endif /* STM32F303xE || STM32F398xx || */
  1342. /* STM32F303xC || STM32F358xx */
  1343. #if defined(STM32F373xC) || defined(STM32F378xx)
  1344. /**
  1345. * @brief Get the specified EXTI line for a comparator instance
  1346. * @param __INSTANCE__ specifies the COMP instance.
  1347. * @retval value of @ref COMPEx_ExtiLineEvent
  1348. */
  1349. #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 : \
  1350. COMP_EXTI_LINE_COMP2)
  1351. #endif /* STM32F373xC || STM32F378xx */
  1352. /**
  1353. * @}
  1354. */
  1355. /** @defgroup COMPEx_Private_Macros_Misc COMP Extended miscellaneous private macros
  1356. * @{
  1357. */
  1358. #if defined(STM32F373xC) || defined(STM32F378xx)
  1359. /**
  1360. * @brief Init a comparator instance
  1361. * @param __HANDLE__ COMP handle
  1362. * @note The common output selection is checked versus the COMP instance to set the right output configuration
  1363. * @retval None.
  1364. */
  1365. #define COMP_INIT(__HANDLE__) \
  1366. do { \
  1367. uint32_t regshift = COMP_CSR_COMP1_SHIFT; \
  1368. uint32_t compoutput = (__HANDLE__)->Init.Output & COMP_CSR_COMPxOUTSEL_MASK; \
  1369. \
  1370. if((__HANDLE__)->Instance == COMP2) \
  1371. { \
  1372. regshift = COMP_CSR_COMP2_SHIFT; \
  1373. } \
  1374. \
  1375. MODIFY_REG(COMP->CSR, \
  1376. (COMP_CSR_COMPxINSEL | COMP_CSR_COMPxNONINSEL_MASK | \
  1377. COMP_CSR_COMPxOUTSEL | COMP_CSR_COMPxPOL | \
  1378. COMP_CSR_COMPxHYST | COMP_CSR_COMPxMODE) << regshift, \
  1379. ((__HANDLE__)->Init.InvertingInput | \
  1380. (__HANDLE__)->Init.NonInvertingInput | \
  1381. compoutput | \
  1382. (__HANDLE__)->Init.OutputPol | \
  1383. (__HANDLE__)->Init.Hysteresis | \
  1384. (__HANDLE__)->Init.Mode) << regshift); \
  1385. \
  1386. if((__HANDLE__)->Init.WindowMode != COMP_WINDOWMODE_DISABLE) \
  1387. { \
  1388. COMP->CSR |= COMP_CSR_WNDWEN; \
  1389. } \
  1390. } while(0U)
  1391. /**
  1392. * @brief DeInit a comparator instance
  1393. * @param __HANDLE__ COMP handle
  1394. * @retval None.
  1395. */
  1396. #define COMP_DEINIT(__HANDLE__) \
  1397. do { \
  1398. uint32_t regshift = COMP_CSR_COMP1_SHIFT; \
  1399. \
  1400. if((__HANDLE__)->Instance == COMP2) \
  1401. { \
  1402. regshift = COMP_CSR_COMP2_SHIFT; \
  1403. } \
  1404. MODIFY_REG(COMP->CSR, \
  1405. COMP_CSR_RESET_PARAMETERS_MASK << regshift, \
  1406. COMP_CSR_RESET_VALUE << regshift); \
  1407. } while(0U)
  1408. /**
  1409. * @brief Enable the Exti Line rising edge trigger.
  1410. * @param __EXTILINE__ specifies the COMP Exti sources to be enabled.
  1411. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1412. * @retval None.
  1413. */
  1414. #define COMP_EXTI_RISING_ENABLE(__EXTILINE__) SET_BIT(EXTI->RTSR, (__EXTILINE__))
  1415. /**
  1416. * @brief Disable the Exti Line rising edge trigger.
  1417. * @param __EXTILINE__ specifies the COMP Exti sources to be disabled.
  1418. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1419. * @retval None.
  1420. */
  1421. #define COMP_EXTI_RISING_DISABLE(__EXTILINE__) CLEAR_BIT(EXTI->RTSR, (__EXTILINE__))
  1422. /**
  1423. * @brief Enable the Exti Line falling edge trigger.
  1424. * @param __EXTILINE__ specifies the COMP Exti sources to be enabled.
  1425. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1426. * @retval None.
  1427. */
  1428. #define COMP_EXTI_FALLING_ENABLE(__EXTILINE__) SET_BIT(EXTI->FTSR, (__EXTILINE__))
  1429. /**
  1430. * @brief Disable the Exti Line falling edge trigger.
  1431. * @param __EXTILINE__ specifies the COMP Exti sources to be disabled.
  1432. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1433. * @retval None.
  1434. */
  1435. #define COMP_EXTI_FALLING_DISABLE(__EXTILINE__) CLEAR_BIT(EXTI->FTSR, (__EXTILINE__))
  1436. /**
  1437. * @brief Enable the COMP Exti Line interrupt generation.
  1438. * @param __EXTILINE__ specifies the COMP Exti sources to be enabled.
  1439. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1440. * @retval None.
  1441. */
  1442. #define COMP_EXTI_ENABLE_IT(__EXTILINE__) SET_BIT(EXTI->IMR, (__EXTILINE__))
  1443. /**
  1444. * @brief Disable the COMP Exti Line interrupt generation.
  1445. * @param __EXTILINE__ specifies the COMP Exti sources to be disabled.
  1446. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1447. * @retval None.
  1448. */
  1449. #define COMP_EXTI_DISABLE_IT(__EXTILINE__) CLEAR_BIT(EXTI->IMR, (__EXTILINE__))
  1450. /**
  1451. * @brief Enable the COMP Exti Line event generation.
  1452. * @param __EXTILINE__ specifies the COMP Exti sources to be enabled.
  1453. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1454. * @retval None.
  1455. */
  1456. #define COMP_EXTI_ENABLE_EVENT(__EXTILINE__) SET_BIT(EXTI->EMR, (__EXTILINE__))
  1457. /**
  1458. * @brief Disable the COMP Exti Line event generation.
  1459. * @param __EXTILINE__ specifies the COMP Exti sources to be disabled.
  1460. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1461. * @retval None.
  1462. */
  1463. #define COMP_EXTI_DISABLE_EVENT(__EXTILINE__) CLEAR_BIT(EXTI->EMR, (__EXTILINE__))
  1464. /**
  1465. * @brief Check whether the specified EXTI line flag is set or not.
  1466. * @param __FLAG__ specifies the COMP Exti sources to be checked.
  1467. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1468. * @retval The state of __FLAG__ (SET or RESET).
  1469. */
  1470. #define COMP_EXTI_GET_FLAG(__FLAG__) READ_BIT(EXTI->PR, (__FLAG__))
  1471. /**
  1472. * @brief Clear the COMP Exti flags.
  1473. * @param __FLAG__ specifies the COMP Exti sources to be cleared.
  1474. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1475. * @retval None.
  1476. */
  1477. #define COMP_EXTI_CLEAR_FLAG(__FLAG__) WRITE_REG(EXTI->PR, (__FLAG__))
  1478. #else /* STM32F30x, STM32F32xx, STM32F35x, STM32F39x, STM32F33x */
  1479. /**
  1480. * @brief Init a comparator instance
  1481. * @param __HANDLE__ COMP handle
  1482. * @retval None.
  1483. */
  1484. #define COMP_INIT(__HANDLE__) \
  1485. do { \
  1486. __IO uint32_t csrreg = 0U; \
  1487. \
  1488. csrreg = READ_REG((__HANDLE__)->Instance->CSR); \
  1489. MODIFY_REG(csrreg, COMP_CSR_COMPxINSEL_MASK, (__HANDLE__)->Init.InvertingInput); \
  1490. MODIFY_REG(csrreg, COMP_CSR_COMPxNONINSEL_MASK, (__HANDLE__)->Init.NonInvertingInput); \
  1491. MODIFY_REG(csrreg, COMP_CSR_COMPxBLANKING_MASK, (__HANDLE__)->Init.BlankingSrce); \
  1492. MODIFY_REG(csrreg, COMP_CSR_COMPxOUTSEL_MASK, (__HANDLE__)->Init.Output & COMP_CSR_COMPxOUTSEL_MASK); \
  1493. MODIFY_REG(csrreg, COMP_CSR_COMPxPOL_MASK, (__HANDLE__)->Init.OutputPol); \
  1494. MODIFY_REG(csrreg, COMP_CSR_COMPxHYST_MASK, (__HANDLE__)->Init.Hysteresis); \
  1495. MODIFY_REG(csrreg, COMP_CSR_COMPxMODE_MASK, (__HANDLE__)->Init.Mode); \
  1496. MODIFY_REG(csrreg, COMP_CSR_COMPxWNDWEN_MASK, (__HANDLE__)->Init.WindowMode); \
  1497. WRITE_REG((__HANDLE__)->Instance->CSR, csrreg); \
  1498. } while(0U)
  1499. /**
  1500. * @brief DeInit a comparator instance
  1501. * @param __HANDLE__ COMP handle
  1502. * @retval None.
  1503. */
  1504. #define COMP_DEINIT(__HANDLE__) WRITE_REG((__HANDLE__)->Instance->CSR, COMP_CSR_RESET_VALUE)
  1505. /**
  1506. * @brief Enable the Exti Line rising edge trigger.
  1507. * @param __EXTILINE__ specifies the COMP Exti sources to be enabled.
  1508. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1509. * @retval None.
  1510. */
  1511. #define COMP_EXTI_RISING_ENABLE(__EXTILINE__) ((((__EXTILINE__) & COMP_EXTI_LINE_REG2_MASK) != RESET) ? SET_BIT(EXTI->RTSR2, (__EXTILINE__)) : SET_BIT(EXTI->RTSR, (__EXTILINE__)))
  1512. /**
  1513. * @brief Disable the Exti Line rising edge trigger.
  1514. * @param __EXTILINE__ specifies the COMP Exti sources to be disabled.
  1515. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1516. * @retval None.
  1517. */
  1518. #define COMP_EXTI_RISING_DISABLE(__EXTILINE__) ((((__EXTILINE__) & COMP_EXTI_LINE_REG2_MASK) != RESET) ? CLEAR_BIT(EXTI->RTSR2, (__EXTILINE__)) : CLEAR_BIT(EXTI->RTSR, (__EXTILINE__)))
  1519. /**
  1520. * @brief Enable the Exti Line falling edge trigger.
  1521. * @param __EXTILINE__ specifies the COMP Exti sources to be enabled.
  1522. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1523. * @retval None.
  1524. */
  1525. #define COMP_EXTI_FALLING_ENABLE(__EXTILINE__) ((((__EXTILINE__) & COMP_EXTI_LINE_REG2_MASK) != RESET) ? SET_BIT(EXTI->FTSR2, (__EXTILINE__)) : SET_BIT(EXTI->FTSR, (__EXTILINE__)))
  1526. /**
  1527. * @brief Disable the Exti Line falling edge trigger.
  1528. * @param __EXTILINE__ specifies the COMP Exti sources to be disabled.
  1529. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1530. * @retval None.
  1531. */
  1532. #define COMP_EXTI_FALLING_DISABLE(__EXTILINE__) ((((__EXTILINE__) & COMP_EXTI_LINE_REG2_MASK) != RESET) ? CLEAR_BIT(EXTI->FTSR2, (__EXTILINE__)) : CLEAR_BIT(EXTI->FTSR, (__EXTILINE__)))
  1533. /**
  1534. * @brief Enable the COMP Exti Line interrupt generation.
  1535. * @param __EXTILINE__ specifies the COMP Exti sources to be enabled.
  1536. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1537. * @retval None.
  1538. */
  1539. #define COMP_EXTI_ENABLE_IT(__EXTILINE__) ((((__EXTILINE__) & COMP_EXTI_LINE_REG2_MASK) != RESET) ? SET_BIT(EXTI->IMR2, (__EXTILINE__)) : SET_BIT(EXTI->IMR, (__EXTILINE__)))
  1540. /**
  1541. * @brief Disable the COMP Exti Line interrupt generation.
  1542. * @param __EXTILINE__ specifies the COMP Exti sources to be disabled.
  1543. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1544. * @retval None.
  1545. */
  1546. #define COMP_EXTI_DISABLE_IT(__EXTILINE__) ((((__EXTILINE__) & COMP_EXTI_LINE_REG2_MASK) != RESET) ? CLEAR_BIT(EXTI->IMR2, (__EXTILINE__)) : CLEAR_BIT(EXTI->IMR, (__EXTILINE__)))
  1547. /**
  1548. * @brief Enable the COMP Exti Line event generation.
  1549. * @param __EXTILINE__ specifies the COMP Exti sources to be enabled.
  1550. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1551. * @retval None.
  1552. */
  1553. #define COMP_EXTI_ENABLE_EVENT(__EXTILINE__) ((((__EXTILINE__) & COMP_EXTI_LINE_REG2_MASK) != RESET) ? SET_BIT(EXTI->EMR2, (__EXTILINE__)) : SET_BIT(EXTI->EMR, (__EXTILINE__)))
  1554. /**
  1555. * @brief Disable the COMP Exti Line event generation.
  1556. * @param __EXTILINE__ specifies the COMP Exti sources to be disabled.
  1557. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1558. * @retval None.
  1559. */
  1560. #define COMP_EXTI_DISABLE_EVENT(__EXTILINE__) ((((__EXTILINE__) & COMP_EXTI_LINE_REG2_MASK) != RESET) ? CLEAR_BIT(EXTI->EMR2, (__EXTILINE__)) : CLEAR_BIT(EXTI->EMR, (__EXTILINE__)))
  1561. /**
  1562. * @brief Check whether the specified EXTI line flag is set or not.
  1563. * @param __FLAG__ specifies the COMP Exti sources to be checked.
  1564. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1565. * @retval The state of __FLAG__ (SET or RESET).
  1566. */
  1567. #define COMP_EXTI_GET_FLAG(__FLAG__) ((((__FLAG__) & COMP_EXTI_LINE_REG2_MASK) != RESET) ? READ_BIT(EXTI->PR2, (__FLAG__)) : READ_BIT(EXTI->PR, (__FLAG__)))
  1568. /**
  1569. * @brief Clear the COMP Exti flags.
  1570. * @param __FLAG__ specifies the COMP Exti sources to be cleared.
  1571. * This parameter can be a value of @ref COMPEx_ExtiLineEvent
  1572. * @retval None.
  1573. */
  1574. #define COMP_EXTI_CLEAR_FLAG(__FLAG__) ((((__FLAG__) & COMP_EXTI_LINE_REG2_MASK) != RESET) ? WRITE_REG(EXTI->PR2, (__FLAG__)) : WRITE_REG(EXTI->PR, (__FLAG__)))
  1575. #endif /* STM32F373xC || STM32F378xx */
  1576. /**
  1577. * @brief Manage inverting input comparator inverting input connected to a GPIO
  1578. * for STM32F302x, STM32F32xx, STM32F33x.
  1579. * - On devices STM32F302x, STM32F32xx, STM32F33x, there is
  1580. * only 1 comparator inverting input connected to a GPIO.
  1581. * Legacy definition of literal COMP_INVERTINGINPUT_IO1
  1582. * was initially the only selection, but depending on
  1583. * comparator instance it corresponds to COMP_INVERTINGINPUT_IO2
  1584. * (for instances COMP4, COMP6).
  1585. * Since, COMP_INVERTINGINPUT_IO2 has been created and this macro
  1586. * selects the correct literal COMP_INVERTINGINPUT_IOx in function
  1587. * of comparator instance.
  1588. * - On other STM32F3 devices, this macro performs no action.
  1589. * @param __COMP_INSTANCE__ COMP instance
  1590. * @param __INVERTINGINPUT__ COMP inverting input
  1591. * @retval None.
  1592. */
  1593. #if defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  1594. #define COMP_INVERTINGINPUT_SELECTION(__COMP_INSTANCE__, __INVERTINGINPUT__) \
  1595. (((__INVERTINGINPUT__) != COMP_INVERTINGINPUT_IO1) \
  1596. ? ( \
  1597. (__INVERTINGINPUT__) \
  1598. ) \
  1599. : \
  1600. (((__COMP_INSTANCE__) == COMP2) \
  1601. ? ( \
  1602. (COMP_INVERTINGINPUT_IO1) \
  1603. ) \
  1604. : \
  1605. ( \
  1606. (COMP_INVERTINGINPUT_IO2) \
  1607. ) \
  1608. ) \
  1609. )
  1610. #else
  1611. #define COMP_INVERTINGINPUT_SELECTION(__COMP_INSTANCE__, __INVERTINGINPUT__) \
  1612. (__INVERTINGINPUT__)
  1613. #endif
  1614. /**
  1615. * @}
  1616. */
  1617. /** @defgroup COMPEx_IS_COMP_Definitions COMP Extended Private macros to check input parameters
  1618. * @{
  1619. */
  1620. #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
  1621. #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \
  1622. ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \
  1623. ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \
  1624. ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \
  1625. ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH1) || \
  1626. ((INPUT) == COMP_INVERTINGINPUT_IO1))
  1627. #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
  1628. ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))
  1629. /* STM32F301x6/x8, STM32F302x6/x8, STM32F318xx devices comparator instances non inverting source values */
  1630. #define IS_COMP_NONINVERTINGINPUT_INSTANCE(INSTANCE, INPUT) \
  1631. ((((INSTANCE) == COMP2) && \
  1632. (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
  1633. ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))) \
  1634. || \
  1635. (((INPUT) == COMP_NONINVERTINGINPUT_IO1)))
  1636. #define IS_COMP_WINDOWMODE(WINDOWMODE) ((WINDOWMODE) == (WINDOWMODE)) /*!< Not available: check always true */
  1637. #define IS_COMP_MODE(MODE) ((MODE) == (MODE)) /*!< Not available: check always true */
  1638. #define IS_COMP_HYSTERESIS(HYSTERESIS) ((HYSTERESIS) == (HYSTERESIS)) /*!< Not available: check always true */
  1639. #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1640. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1641. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  1642. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1643. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  1644. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  1645. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  1646. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  1647. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  1648. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  1649. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  1650. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR) || \
  1651. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  1652. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR))
  1653. #define IS_COMP_OUTPUT_INSTANCE(INSTANCE, OUTPUT) \
  1654. ((((INSTANCE) == COMP2) && \
  1655. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1656. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1657. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  1658. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1659. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  1660. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  1661. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  1662. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR))) \
  1663. || \
  1664. (((INSTANCE) == COMP4) && \
  1665. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1666. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1667. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  1668. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1669. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  1670. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR))) \
  1671. || \
  1672. (((INSTANCE) == COMP6) && \
  1673. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1674. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1675. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  1676. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1677. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  1678. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  1679. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  1680. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR))))
  1681. #define IS_COMP_BLANKINGSRCE(SOURCE) (((SOURCE) == COMP_BLANKINGSRCE_NONE) || \
  1682. ((SOURCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  1683. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  1684. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC3) || \
  1685. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  1686. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  1687. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC1) || \
  1688. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC2))
  1689. /* STM32F301x6/x8, STM32F302x6/x8, STM32F303x6/x8, STM32F334x4/6U/8U, STM32F318xx/STM32F328xx devices comparator instances blanking source values */
  1690. #define IS_COMP_BLANKINGSRCE_INSTANCE(INSTANCE, BLANKINGSRCE) \
  1691. ((((INSTANCE) == COMP2) && \
  1692. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  1693. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  1694. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  1695. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3))) \
  1696. || \
  1697. (((INSTANCE) == COMP4) && \
  1698. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  1699. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  1700. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC1))) \
  1701. || \
  1702. (((INSTANCE) == COMP6) && \
  1703. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  1704. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  1705. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2))))
  1706. #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx */
  1707. #if defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
  1708. #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \
  1709. ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \
  1710. ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \
  1711. ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \
  1712. ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH1) || \
  1713. ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH2) || \
  1714. ((INPUT) == COMP_INVERTINGINPUT_IO1) || \
  1715. ((INPUT) == COMP_INVERTINGINPUT_IO2) || \
  1716. ((INPUT) == COMP_INVERTINGINPUT_DAC2_CH1))
  1717. /*!< Non inverting input not available */
  1718. #define IS_COMP_NONINVERTINGINPUT(INPUT) ((INPUT) == (INPUT)) /*!< Multiple selection not available: check always true */
  1719. #define IS_COMP_NONINVERTINGINPUT_INSTANCE(INSTANCE, INPUT) ((INPUT) == (INPUT)) /*!< Multiple selection not available: check always true */
  1720. #define IS_COMP_WINDOWMODE(WINDOWMODE) ((WINDOWMODE) == (WINDOWMODE)) /*!< Not available: check always true */
  1721. #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1722. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1723. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1724. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  1725. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  1726. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  1727. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  1728. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  1729. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  1730. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  1731. ((OUTPUT) == COMP_OUTPUT_TIM3IC3) || \
  1732. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  1733. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  1734. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR) || \
  1735. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  1736. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR))
  1737. #define IS_COMP_OUTPUT_INSTANCE(INSTANCE, OUTPUT) \
  1738. ((((INSTANCE) == COMP2) && \
  1739. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1740. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1741. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1742. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  1743. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  1744. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  1745. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  1746. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  1747. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR))) \
  1748. || \
  1749. (((INSTANCE) == COMP4) && \
  1750. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1751. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1752. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1753. ((OUTPUT) == COMP_OUTPUT_TIM3IC3) || \
  1754. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  1755. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  1756. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR))) \
  1757. || \
  1758. (((INSTANCE) == COMP6) && \
  1759. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1760. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1761. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1762. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  1763. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  1764. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  1765. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR))))
  1766. #define IS_COMP_MODE(MODE) ((MODE) == (MODE)) /*!< Not available: check always true */
  1767. #define IS_COMP_HYSTERESIS(HYSTERESIS) ((HYSTERESIS) == (HYSTERESIS)) /*!< Not available: check always true */
  1768. #define IS_COMP_BLANKINGSRCE(SOURCE) (((SOURCE) == COMP_BLANKINGSRCE_NONE) || \
  1769. ((SOURCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  1770. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  1771. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC3) || \
  1772. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  1773. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  1774. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC1) || \
  1775. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC2))
  1776. /* STM32F301x6/x8, STM32F302x6/x8, STM32F303x6/x8, STM32F334x4/6U/8U, STM32F318xx/STM32F328xx devices comparator instances blanking source values */
  1777. #define IS_COMP_BLANKINGSRCE_INSTANCE(INSTANCE, BLANKINGSRCE) \
  1778. ((((INSTANCE) == COMP2) && \
  1779. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  1780. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  1781. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  1782. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3))) \
  1783. || \
  1784. (((INSTANCE) == COMP4) && \
  1785. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  1786. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  1787. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC1))) \
  1788. || \
  1789. (((INSTANCE) == COMP6) && \
  1790. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  1791. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  1792. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2))))
  1793. #endif /* STM32F303x8 || STM32F334x8 || STM32F328xx */
  1794. #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
  1795. #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \
  1796. ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \
  1797. ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \
  1798. ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \
  1799. ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH1) || \
  1800. ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH2) || \
  1801. ((INPUT) == COMP_INVERTINGINPUT_IO1) || \
  1802. ((INPUT) == COMP_INVERTINGINPUT_IO2))
  1803. #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
  1804. ((INPUT) == COMP_NONINVERTINGINPUT_IO2) || \
  1805. ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))
  1806. /* STM32F302xB/xC, STM32F303xB/xC, STM32F358xx devices comparator instances non inverting source values */
  1807. #define IS_COMP_NONINVERTINGINPUT_INSTANCE(INSTANCE, INPUT) \
  1808. ((((INSTANCE) == COMP1) && \
  1809. (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
  1810. ((INPUT) == COMP_NONINVERTINGINPUT_IO2) || \
  1811. ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))) \
  1812. || \
  1813. ((((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
  1814. ((INPUT) == COMP_NONINVERTINGINPUT_IO2))))
  1815. #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLE) || \
  1816. ((WINDOWMODE) == COMP_WINDOWMODE_ENABLE))
  1817. #define IS_COMP_MODE(MODE) (((MODE) == COMP_MODE_HIGHSPEED) || \
  1818. ((MODE) == COMP_MODE_MEDIUMSPEED) || \
  1819. ((MODE) == COMP_MODE_LOWPOWER) || \
  1820. ((MODE) == COMP_MODE_ULTRALOWPOWER))
  1821. #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_HYSTERESIS_NONE) || \
  1822. ((HYSTERESIS) == COMP_HYSTERESIS_LOW) || \
  1823. ((HYSTERESIS) == COMP_HYSTERESIS_MEDIUM) || \
  1824. ((HYSTERESIS) == COMP_HYSTERESIS_HIGH))
  1825. #if defined(STM32F302xC)
  1826. #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1827. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1828. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  1829. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1830. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  1831. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  1832. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  1833. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  1834. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  1835. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  1836. ((OUTPUT) == COMP_OUTPUT_TIM3IC3) || \
  1837. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  1838. ((OUTPUT) == COMP_OUTPUT_TIM4IC2) || \
  1839. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR) || \
  1840. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  1841. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  1842. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR) || \
  1843. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  1844. ((OUTPUT) == COMP_OUTPUT_TIM4IC4))
  1845. #define IS_COMP_OUTPUT_INSTANCE(INSTANCE, OUTPUT) \
  1846. ((((INSTANCE) == COMP1) && \
  1847. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1848. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1849. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  1850. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1851. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  1852. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  1853. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  1854. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  1855. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  1856. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR))) \
  1857. || \
  1858. (((INSTANCE) == COMP2) && \
  1859. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1860. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1861. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  1862. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1863. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  1864. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  1865. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  1866. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  1867. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  1868. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR))) \
  1869. || \
  1870. (((INSTANCE) == COMP4) && \
  1871. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1872. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1873. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  1874. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1875. ((OUTPUT) == COMP_OUTPUT_TIM3IC3) || \
  1876. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  1877. ((OUTPUT) == COMP_OUTPUT_TIM4IC2) || \
  1878. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  1879. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR))) \
  1880. || \
  1881. (((INSTANCE) == COMP6) && \
  1882. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1883. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1884. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  1885. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1886. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  1887. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  1888. ((OUTPUT) == COMP_OUTPUT_TIM4IC4) || \
  1889. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  1890. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR))))
  1891. #define IS_COMP_BLANKINGSRCE(SOURCE) (((SOURCE) == COMP_BLANKINGSRCE_NONE) || \
  1892. ((SOURCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  1893. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  1894. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC3) || \
  1895. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  1896. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  1897. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC1) || \
  1898. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC2))
  1899. /* STM32F302xB/STM32F302xC/STM32F302xE devices comparator instances blanking source values */
  1900. #define IS_COMP_BLANKINGSRCE_INSTANCE(INSTANCE, BLANKINGSRCE) \
  1901. (((((INSTANCE) == COMP1) || ((INSTANCE) == COMP2)) && \
  1902. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  1903. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  1904. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  1905. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3))) \
  1906. || \
  1907. (((INSTANCE) == COMP4) && \
  1908. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  1909. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  1910. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC1))) \
  1911. || \
  1912. (((INSTANCE) == COMP6) && \
  1913. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  1914. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  1915. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2))))
  1916. #endif /* STM32F302xC */
  1917. #if defined(STM32F303xC) || defined(STM32F358xx)
  1918. #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1919. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1920. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1921. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  1922. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  1923. ((OUTPUT) == COMP_OUTPUT_TIM1IC2) || \
  1924. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  1925. ((OUTPUT) == COMP_OUTPUT_TIM2IC1) || \
  1926. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  1927. ((OUTPUT) == COMP_OUTPUT_TIM2IC3) || \
  1928. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  1929. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  1930. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  1931. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  1932. ((OUTPUT) == COMP_OUTPUT_TIM3IC2) || \
  1933. ((OUTPUT) == COMP_OUTPUT_TIM3IC3) || \
  1934. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  1935. ((OUTPUT) == COMP_OUTPUT_TIM4IC1) || \
  1936. ((OUTPUT) == COMP_OUTPUT_TIM4IC2) || \
  1937. ((OUTPUT) == COMP_OUTPUT_TIM4IC3) || \
  1938. ((OUTPUT) == COMP_OUTPUT_TIM4IC4) || \
  1939. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  1940. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  1941. ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR) || \
  1942. ((OUTPUT) == COMP_OUTPUT_TIM15IC1) || \
  1943. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  1944. ((OUTPUT) == COMP_OUTPUT_TIM15BKIN) || \
  1945. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR) || \
  1946. ((OUTPUT) == COMP_OUTPUT_TIM16BKIN) || \
  1947. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  1948. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR) || \
  1949. ((OUTPUT) == COMP_OUTPUT_TIM17BKIN) || \
  1950. ((OUTPUT) == COMP_OUTPUT_TIM17IC1) || \
  1951. ((OUTPUT) == COMP_OUTPUT_TIM17OCREFCLR))
  1952. #define IS_COMP_OUTPUT_INSTANCE(INSTANCE, OUTPUT) \
  1953. ((((INSTANCE) == COMP1) && \
  1954. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1955. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1956. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1957. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  1958. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  1959. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  1960. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  1961. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  1962. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  1963. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  1964. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  1965. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR))) \
  1966. || \
  1967. (((INSTANCE) == COMP2) && \
  1968. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1969. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1970. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1971. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  1972. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  1973. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  1974. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  1975. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  1976. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  1977. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  1978. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  1979. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR))) \
  1980. || \
  1981. (((INSTANCE) == COMP3) && \
  1982. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1983. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1984. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1985. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  1986. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  1987. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  1988. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  1989. ((OUTPUT) == COMP_OUTPUT_TIM3IC2) || \
  1990. ((OUTPUT) == COMP_OUTPUT_TIM4IC1) || \
  1991. ((OUTPUT) == COMP_OUTPUT_TIM15IC1) || \
  1992. ((OUTPUT) == COMP_OUTPUT_TIM15BKIN))) \
  1993. || \
  1994. (((INSTANCE) == COMP4) && \
  1995. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  1996. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  1997. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  1998. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  1999. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2000. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2001. ((OUTPUT) == COMP_OUTPUT_TIM3IC3) || \
  2002. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  2003. ((OUTPUT) == COMP_OUTPUT_TIM4IC2) || \
  2004. ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR) || \
  2005. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  2006. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR))) \
  2007. || \
  2008. (((INSTANCE) == COMP5) && \
  2009. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2010. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2011. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2012. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  2013. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2014. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2015. ((OUTPUT) == COMP_OUTPUT_TIM2IC1) || \
  2016. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  2017. ((OUTPUT) == COMP_OUTPUT_TIM4IC3) || \
  2018. ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR) || \
  2019. ((OUTPUT) == COMP_OUTPUT_TIM16BKIN) || \
  2020. ((OUTPUT) == COMP_OUTPUT_TIM17IC1))) \
  2021. || \
  2022. (((INSTANCE) == COMP6) && \
  2023. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2024. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2025. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2026. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  2027. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2028. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2029. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  2030. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  2031. ((OUTPUT) == COMP_OUTPUT_TIM4IC4) || \
  2032. ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR) || \
  2033. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  2034. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR))) \
  2035. || \
  2036. (((INSTANCE) == COMP7) && \
  2037. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2038. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2039. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2040. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  2041. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2042. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2043. ((OUTPUT) == COMP_OUTPUT_TIM1IC2) || \
  2044. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  2045. ((OUTPUT) == COMP_OUTPUT_TIM2IC3) || \
  2046. ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR) || \
  2047. ((OUTPUT) == COMP_OUTPUT_TIM17BKIN) || \
  2048. ((OUTPUT) == COMP_OUTPUT_TIM17OCREFCLR))))
  2049. #define IS_COMP_BLANKINGSRCE(SOURCE) (((SOURCE) == COMP_BLANKINGSRCE_NONE) || \
  2050. ((SOURCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  2051. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  2052. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC3) || \
  2053. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  2054. ((SOURCE) == COMP_BLANKINGSRCE_TIM8OC5) || \
  2055. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  2056. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC1) || \
  2057. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC2))
  2058. /* STM32F303xE/STM32F398xx/STM32F303xB/STM32F303xC/STM32F358xx devices comparator instances blanking source values */
  2059. #define IS_COMP_BLANKINGSRCE_INSTANCE(INSTANCE, BLANKINGSRCE) \
  2060. (((((INSTANCE) == COMP1) || ((INSTANCE) == COMP2)) && \
  2061. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2062. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  2063. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  2064. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3))) \
  2065. || \
  2066. (((INSTANCE) == COMP3) && \
  2067. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2068. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  2069. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4))) \
  2070. || \
  2071. (((INSTANCE) == COMP4) && \
  2072. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2073. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  2074. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) || \
  2075. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC1))) \
  2076. || \
  2077. (((INSTANCE) == COMP5) && \
  2078. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2079. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) || \
  2080. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3))) \
  2081. || \
  2082. (((INSTANCE) == COMP6) && \
  2083. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2084. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) || \
  2085. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  2086. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2))) \
  2087. || \
  2088. (((INSTANCE) == COMP7) && \
  2089. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2090. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  2091. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) || \
  2092. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2))))
  2093. #endif /* STM32F303xC || STM32F358xx */
  2094. #endif /* STM32F302xC || STM32F303xC || STM32F358xx */
  2095. #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx)
  2096. #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \
  2097. ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \
  2098. ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \
  2099. ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \
  2100. ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH1) || \
  2101. ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH2) || \
  2102. ((INPUT) == COMP_INVERTINGINPUT_IO1) || \
  2103. ((INPUT) == COMP_INVERTINGINPUT_IO2))
  2104. #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
  2105. ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))
  2106. /* STM32F302xE/STM32F303xE/STM32F398xx devices comparator instances non inverting source values */
  2107. #define IS_COMP_NONINVERTINGINPUT_INSTANCE(INSTANCE, INPUT) \
  2108. ((((INSTANCE) == COMP1) && \
  2109. (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
  2110. ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))) \
  2111. || \
  2112. (((INPUT) == COMP_NONINVERTINGINPUT_IO1)))
  2113. #define IS_COMP_WINDOWMODE(WINDOWMODE) ((WINDOWMODE) == (WINDOWMODE)) /*!< Not available: check always true */
  2114. #define IS_COMP_MODE(MODE) ((MODE) == (MODE)) /*!< Not available: check always true */
  2115. #define IS_COMP_HYSTERESIS(HYSTERESIS) ((HYSTERESIS) == (HYSTERESIS)) /*!< Not available: check always true */
  2116. #if defined(STM32F302xE)
  2117. #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2118. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2119. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  2120. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2121. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  2122. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  2123. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  2124. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  2125. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  2126. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  2127. ((OUTPUT) == COMP_OUTPUT_TIM3IC3) || \
  2128. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  2129. ((OUTPUT) == COMP_OUTPUT_TIM4IC2) || \
  2130. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR) || \
  2131. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  2132. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  2133. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR) || \
  2134. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  2135. ((OUTPUT) == COMP_OUTPUT_TIM4IC4))
  2136. #define IS_COMP_OUTPUT_INSTANCE(INSTANCE, OUTPUT) \
  2137. ((((INSTANCE) == COMP1) && \
  2138. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2139. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2140. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  2141. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2142. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  2143. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  2144. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  2145. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  2146. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  2147. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR))) \
  2148. || \
  2149. (((INSTANCE) == COMP2) && \
  2150. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2151. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2152. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  2153. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2154. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  2155. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  2156. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  2157. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  2158. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  2159. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR))) \
  2160. || \
  2161. (((INSTANCE) == COMP4) && \
  2162. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2163. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2164. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  2165. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2166. ((OUTPUT) == COMP_OUTPUT_TIM3IC3) || \
  2167. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  2168. ((OUTPUT) == COMP_OUTPUT_TIM4IC2) || \
  2169. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  2170. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR))) \
  2171. || \
  2172. (((INSTANCE) == COMP6) && \
  2173. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2174. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2175. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2) || \
  2176. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2177. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  2178. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  2179. ((OUTPUT) == COMP_OUTPUT_TIM4IC4) || \
  2180. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  2181. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR))))
  2182. #define IS_COMP_BLANKINGSRCE(SOURCE) (((SOURCE) == COMP_BLANKINGSRCE_NONE) || \
  2183. ((SOURCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  2184. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  2185. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC3) || \
  2186. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  2187. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  2188. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC1) || \
  2189. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC2))
  2190. /* STM32F302xB/STM32F302xC/STM32F302xE devices comparator instances blanking source values */
  2191. #define IS_COMP_BLANKINGSRCE_INSTANCE(INSTANCE, BLANKINGSRCE) \
  2192. (((((INSTANCE) == COMP1) || ((INSTANCE) == COMP2)) && \
  2193. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2194. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  2195. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  2196. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3))) \
  2197. || \
  2198. (((INSTANCE) == COMP4) && \
  2199. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2200. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  2201. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC1))) \
  2202. || \
  2203. (((INSTANCE) == COMP6) && \
  2204. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2205. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  2206. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2))))
  2207. #endif /* STM32F302xE */
  2208. #if defined(STM32F303xE) || defined(STM32F398xx)
  2209. #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2210. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2211. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  2212. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  2213. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  2214. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  2215. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  2216. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  2217. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  2218. ((OUTPUT) == COMP_OUTPUT_TIM20OCREFCLR) || \
  2219. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  2220. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2221. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2222. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR) || \
  2223. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2224. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN) || \
  2225. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN2) || \
  2226. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2) || \
  2227. ((OUTPUT) == COMP_OUTPUT_TIM3IC2) || \
  2228. ((OUTPUT) == COMP_OUTPUT_TIM4IC1) || \
  2229. ((OUTPUT) == COMP_OUTPUT_TIM15IC1) || \
  2230. ((OUTPUT) == COMP_OUTPUT_TIM15BKIN) || \
  2231. ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR) || \
  2232. ((OUTPUT) == COMP_OUTPUT_TIM3IC3) || \
  2233. ((OUTPUT) == COMP_OUTPUT_TIM4IC2) || \
  2234. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  2235. ((OUTPUT) == COMP_OUTPUT_TIM2IC1) || \
  2236. ((OUTPUT) == COMP_OUTPUT_TIM4IC3) || \
  2237. ((OUTPUT) == COMP_OUTPUT_TIM16BKIN) || \
  2238. ((OUTPUT) == COMP_OUTPUT_TIM17IC1) || \
  2239. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  2240. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  2241. ((OUTPUT) == COMP_OUTPUT_TIM4IC4) || \
  2242. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR) || \
  2243. ((OUTPUT) == COMP_OUTPUT_TIM2IC3) || \
  2244. ((OUTPUT) == COMP_OUTPUT_TIM1IC2) || \
  2245. ((OUTPUT) == COMP_OUTPUT_TIM17BKIN) || \
  2246. ((OUTPUT) == COMP_OUTPUT_TIM17OCREFCLR))
  2247. #define IS_COMP_OUTPUT_INSTANCE(INSTANCE, OUTPUT) \
  2248. ((((INSTANCE) == COMP1) && \
  2249. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2250. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2251. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2252. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  2253. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2254. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2255. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN) || \
  2256. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN2) || \
  2257. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2) || \
  2258. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  2259. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  2260. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  2261. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  2262. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  2263. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR))) \
  2264. || \
  2265. (((INSTANCE) == COMP2) && \
  2266. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2267. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2268. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2269. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  2270. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2271. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2272. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN) || \
  2273. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN2) || \
  2274. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2) || \
  2275. ((OUTPUT) == COMP_OUTPUT_TIM1IC1) || \
  2276. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  2277. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  2278. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  2279. ((OUTPUT) == COMP_OUTPUT_TIM3IC1) || \
  2280. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  2281. ((OUTPUT) == COMP_OUTPUT_TIM20OCREFCLR))) \
  2282. || \
  2283. (((INSTANCE) == COMP3) && \
  2284. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2285. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2286. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2287. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  2288. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2289. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2290. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN) || \
  2291. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN2) || \
  2292. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2) || \
  2293. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  2294. ((OUTPUT) == COMP_OUTPUT_TIM3IC2) || \
  2295. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  2296. ((OUTPUT) == COMP_OUTPUT_TIM4IC1) || \
  2297. ((OUTPUT) == COMP_OUTPUT_TIM15IC1) || \
  2298. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  2299. ((OUTPUT) == COMP_OUTPUT_TIM15BKIN))) \
  2300. || \
  2301. (((INSTANCE) == COMP4) && \
  2302. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2303. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2304. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2305. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  2306. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2307. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2308. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN) || \
  2309. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN2) || \
  2310. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2) || \
  2311. ((OUTPUT) == COMP_OUTPUT_TIM3IC3) || \
  2312. ((OUTPUT) == COMP_OUTPUT_TIM4IC2) || \
  2313. ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR) || \
  2314. ((OUTPUT) == COMP_OUTPUT_TIM15IC2) || \
  2315. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  2316. ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR))) \
  2317. || \
  2318. (((INSTANCE) == COMP5) && \
  2319. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2320. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2321. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2322. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  2323. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2324. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2325. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN) || \
  2326. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN2) || \
  2327. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2) || \
  2328. ((OUTPUT) == COMP_OUTPUT_TIM2IC1) || \
  2329. ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR) || \
  2330. ((OUTPUT) == COMP_OUTPUT_TIM4IC3) || \
  2331. ((OUTPUT) == COMP_OUTPUT_TIM16BKIN) || \
  2332. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  2333. ((OUTPUT) == COMP_OUTPUT_TIM17IC1))) \
  2334. || \
  2335. (((INSTANCE) == COMP6) && \
  2336. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2337. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2338. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2339. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  2340. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2341. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2342. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN) || \
  2343. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN2) || \
  2344. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2) || \
  2345. ((OUTPUT) == COMP_OUTPUT_TIM2IC2) || \
  2346. ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR) || \
  2347. ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR) || \
  2348. ((OUTPUT) == COMP_OUTPUT_TIM4IC4) || \
  2349. ((OUTPUT) == COMP_OUTPUT_TIM16IC1) || \
  2350. ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR))) \
  2351. || \
  2352. (((INSTANCE) == COMP7) && \
  2353. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2354. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN) || \
  2355. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2) || \
  2356. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN) || \
  2357. ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2) || \
  2358. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
  2359. ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR) || \
  2360. ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR) || \
  2361. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN) || \
  2362. ((OUTPUT) == COMP_OUTPUT_TIM20BKIN2) || \
  2363. ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2) || \
  2364. ((OUTPUT) == COMP_OUTPUT_TIM1IC2) || \
  2365. ((OUTPUT) == COMP_OUTPUT_TIM2IC3) || \
  2366. ((OUTPUT) == COMP_OUTPUT_TIM17BKIN) || \
  2367. ((OUTPUT) == COMP_OUTPUT_TIM17OCREFCLR))))
  2368. #define IS_COMP_BLANKINGSRCE(SOURCE) (((SOURCE) == COMP_BLANKINGSRCE_NONE) || \
  2369. ((SOURCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  2370. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  2371. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC3) || \
  2372. ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  2373. ((SOURCE) == COMP_BLANKINGSRCE_TIM8OC5) || \
  2374. ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  2375. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC1) || \
  2376. ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC2))
  2377. /* STM32F303xE/STM32F398xx/STM32F303xB/STM32F303xC/STM32F358xx devices comparator instances blanking source values */
  2378. #define IS_COMP_BLANKINGSRCE_INSTANCE(INSTANCE, BLANKINGSRCE) \
  2379. (((((INSTANCE) == COMP1) || ((INSTANCE) == COMP2)) && \
  2380. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2381. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  2382. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC3) || \
  2383. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3))) \
  2384. || \
  2385. (((INSTANCE) == COMP3) && \
  2386. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2387. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  2388. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4))) \
  2389. || \
  2390. (((INSTANCE) == COMP4) && \
  2391. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2392. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC4) || \
  2393. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) || \
  2394. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC1))) \
  2395. || \
  2396. (((INSTANCE) == COMP5) && \
  2397. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2398. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) || \
  2399. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3))) \
  2400. || \
  2401. (((INSTANCE) == COMP6) && \
  2402. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2403. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) || \
  2404. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4) || \
  2405. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2))) \
  2406. || \
  2407. (((INSTANCE) == COMP7) && \
  2408. (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE) || \
  2409. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) || \
  2410. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) || \
  2411. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2))))
  2412. #endif /* STM32F303xE || STM32F398xx */
  2413. #endif /* STM32F302xE || STM32F303xE || STM32F398xx */
  2414. #if defined(STM32F373xC) || defined(STM32F378xx)
  2415. #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \
  2416. ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \
  2417. ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \
  2418. ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \
  2419. ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH1) || \
  2420. ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH2) || \
  2421. ((INPUT) == COMP_INVERTINGINPUT_IO1) || \
  2422. ((INPUT) == COMP_INVERTINGINPUT_DAC2_CH1))
  2423. #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
  2424. ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))
  2425. /* STM32F373xB/xC, STM32F378xx devices comparator instances non inverting source values */
  2426. #define IS_COMP_NONINVERTINGINPUT_INSTANCE(INSTANCE, INPUT) \
  2427. ((((INSTANCE) == COMP1) && \
  2428. (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
  2429. ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))) \
  2430. || \
  2431. (((INPUT) == COMP_NONINVERTINGINPUT_IO1)))
  2432. #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLE) || \
  2433. ((WINDOWMODE) == COMP_WINDOWMODE_ENABLE))
  2434. #define IS_COMP_MODE(MODE) (((MODE) == COMP_MODE_HIGHSPEED) || \
  2435. ((MODE) == COMP_MODE_MEDIUMSPEED) || \
  2436. ((MODE) == COMP_MODE_LOWPOWER) || \
  2437. ((MODE) == COMP_MODE_ULTRALOWPOWER))
  2438. #define IS_COMP_HYSTERESIS(HYSTERESIS) (((HYSTERESIS) == COMP_HYSTERESIS_NONE) || \
  2439. ((HYSTERESIS) == COMP_HYSTERESIS_LOW) || \
  2440. ((HYSTERESIS) == COMP_HYSTERESIS_MEDIUM) || \
  2441. ((HYSTERESIS) == COMP_HYSTERESIS_HIGH))
  2442. #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2443. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  2444. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  2445. ((OUTPUT) == COMP_OUTPUT_COMP1_TIM3IC1) || \
  2446. ((OUTPUT) == COMP_OUTPUT_COMP1_TIM3OCREFCLR) || \
  2447. ((OUTPUT) == COMP_OUTPUT_COMP2_TIM3IC1) || \
  2448. ((OUTPUT) == COMP_OUTPUT_COMP2_TIM3OCREFCLR) || \
  2449. ((OUTPUT) == COMP_OUTPUT_TIM4IC1) || \
  2450. ((OUTPUT) == COMP_OUTPUT_TIM4OCREFCLR) || \
  2451. ((OUTPUT) == COMP_OUTPUT_TIM5IC4) || \
  2452. ((OUTPUT) == COMP_OUTPUT_TIM5OCREFCLR) || \
  2453. ((OUTPUT) == COMP_OUTPUT_TIM15BKIN) || \
  2454. ((OUTPUT) == COMP_OUTPUT_TIM16BKIN))
  2455. #define IS_COMP_OUTPUT_INSTANCE(INSTANCE, OUTPUT) \
  2456. ((((INSTANCE) == COMP1) && \
  2457. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2458. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  2459. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  2460. ((OUTPUT) == COMP_OUTPUT_COMP1_TIM3IC1) || \
  2461. ((OUTPUT) == COMP_OUTPUT_COMP1_TIM3OCREFCLR) || \
  2462. ((OUTPUT) == COMP_OUTPUT_TIM5IC4) || \
  2463. ((OUTPUT) == COMP_OUTPUT_TIM5OCREFCLR) || \
  2464. ((OUTPUT) == COMP_OUTPUT_TIM15BKIN))) \
  2465. || \
  2466. (((INSTANCE) == COMP2) && \
  2467. (((OUTPUT) == COMP_OUTPUT_NONE) || \
  2468. ((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  2469. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  2470. ((OUTPUT) == COMP_OUTPUT_COMP2_TIM3IC1) || \
  2471. ((OUTPUT) == COMP_OUTPUT_COMP2_TIM3OCREFCLR) || \
  2472. ((OUTPUT) == COMP_OUTPUT_TIM4IC1) || \
  2473. ((OUTPUT) == COMP_OUTPUT_TIM4OCREFCLR) || \
  2474. ((OUTPUT) == COMP_OUTPUT_TIM16BKIN))))
  2475. #define IS_COMP_BLANKINGSRCE(SOURCE) ((SOURCE) == (SOURCE)) /*!< Not available: check always true */
  2476. /* STM32F373xB/STM32F373xC/STM32F378xx devices comparator instances blanking source values */
  2477. #define IS_COMP_BLANKINGSRCE_INSTANCE(INSTANCE, BLANKINGSRCE) \
  2478. ((((INSTANCE) == COMP1) || ((INSTANCE) == COMP2)) && \
  2479. ((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE))
  2480. #endif /* STM32F373xC || STM32F378xx */
  2481. /**
  2482. * @}
  2483. */
  2484. /**
  2485. * @}
  2486. */
  2487. /**
  2488. * @}
  2489. */
  2490. /**
  2491. * @}
  2492. */
  2493. #ifdef __cplusplus
  2494. }
  2495. #endif
  2496. #endif /* __STM32F3xx_HAL_COMP_EX_H */