stm32g4xx_hal_comp.h 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404
  1. /**
  2. ******************************************************************************
  3. * @file stm32g4xx_hal_comp.h
  4. * @author MCD Application Team
  5. * @brief Header file of COMP HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2019 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 STM32G4xx_HAL_COMP_H
  20. #define STM32G4xx_HAL_COMP_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32g4xx_hal_def.h"
  26. #include "stm32g4xx_ll_exti.h"
  27. /** @addtogroup STM32G4xx_HAL_Driver
  28. * @{
  29. */
  30. /** @addtogroup COMP
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /** @defgroup COMP_Exported_Types COMP Exported Types
  35. * @{
  36. */
  37. /**
  38. * @brief COMP Init structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t InputPlus; /*!< Set comparator input plus (non-inverting input).
  43. This parameter can be a value of @ref COMP_InputPlus */
  44. uint32_t InputMinus; /*!< Set comparator input minus (inverting input).
  45. This parameter can be a value of @ref COMP_InputMinus */
  46. uint32_t Hysteresis; /*!< Set comparator hysteresis mode of the input minus.
  47. This parameter can be a value of @ref COMP_Hysteresis */
  48. uint32_t OutputPol; /*!< Set comparator output polarity.
  49. This parameter can be a value of @ref COMP_OutputPolarity */
  50. uint32_t BlankingSrce; /*!< Set comparator blanking source.
  51. This parameter can be a value of @ref COMP_BlankingSrce */
  52. uint32_t TriggerMode; /*!< Set the comparator output triggering External Interrupt Line (EXTI).
  53. This parameter can be a value of @ref COMP_EXTI_TriggerMode */
  54. } COMP_InitTypeDef;
  55. /**
  56. * @brief HAL COMP state machine: HAL COMP states definition
  57. */
  58. #define COMP_STATE_BITFIELD_LOCK (0x10U)
  59. typedef enum
  60. {
  61. HAL_COMP_STATE_RESET = 0x00U, /*!< COMP not yet initialized */
  62. HAL_COMP_STATE_RESET_LOCKED = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */
  63. HAL_COMP_STATE_READY = 0x01U, /*!< COMP initialized and ready for use */
  64. HAL_COMP_STATE_READY_LOCKED = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked */
  65. HAL_COMP_STATE_BUSY = 0x02U, /*!< COMP is running */
  66. HAL_COMP_STATE_BUSY_LOCKED = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK) /*!< COMP is running and configuration is locked */
  67. } HAL_COMP_StateTypeDef;
  68. /**
  69. * @brief COMP Handle Structure definition
  70. */
  71. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  72. typedef struct __COMP_HandleTypeDef
  73. #else
  74. typedef struct
  75. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  76. {
  77. COMP_TypeDef *Instance; /*!< Register base address */
  78. COMP_InitTypeDef Init; /*!< COMP required parameters */
  79. HAL_LockTypeDef Lock; /*!< Locking object */
  80. __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
  81. __IO uint32_t ErrorCode; /*!< COMP error code */
  82. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  83. void (* TriggerCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP trigger callback */
  84. void (* MspInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp Init callback */
  85. void (* MspDeInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp DeInit callback */
  86. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  87. } COMP_HandleTypeDef;
  88. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  89. /**
  90. * @brief HAL COMP Callback ID enumeration definition
  91. */
  92. typedef enum
  93. {
  94. HAL_COMP_TRIGGER_CB_ID = 0x00U, /*!< COMP trigger callback ID */
  95. HAL_COMP_MSPINIT_CB_ID = 0x01U, /*!< COMP Msp Init callback ID */
  96. HAL_COMP_MSPDEINIT_CB_ID = 0x02U /*!< COMP Msp DeInit callback ID */
  97. } HAL_COMP_CallbackIDTypeDef;
  98. /**
  99. * @brief HAL COMP Callback pointer definition
  100. */
  101. typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer to a COMP callback function */
  102. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  103. /**
  104. * @}
  105. */
  106. /* Exported constants --------------------------------------------------------*/
  107. /** @defgroup COMP_Exported_Constants COMP Exported Constants
  108. * @{
  109. */
  110. /** @defgroup COMP_Error_Code COMP Error Code
  111. * @{
  112. */
  113. #define HAL_COMP_ERROR_NONE (0x00UL) /*!< No error */
  114. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  115. #define HAL_COMP_ERROR_INVALID_CALLBACK (0x01UL) /*!< Invalid Callback error */
  116. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  117. /**
  118. * @}
  119. */
  120. /** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
  121. * @{
  122. */
  123. #define COMP_INPUT_PLUS_IO1 (0x00000000UL) /*!< Comparator input plus connected to IO1 (pin PA1 for COMP1, pin PA7 for COMP2, pin PA0 for COMP3, pin PB0 for COMP4, pin PB13 for COMP5, pin PB11 for COMP6, pin PB14 for COMP7). Note: For COMPx instance availability, please refer to datasheet */
  124. #define COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL) /*!< Comparator input plus connected to IO2 (pin PB1 for COMP1, pin PA3 for COMP2, pin PC1 for COMP3, pin PE7 for COMP4, pin PD12 for COMP5, pin PD11 for COMP6, pin PD14 for COMP7). Note: For COMPx instance availability, please refer to datasheet */
  125. /**
  126. * @}
  127. */
  128. /** @defgroup COMP_InputMinus COMP input minus (inverting input)
  129. * @{
  130. */
  131. #define COMP_INPUT_MINUS_1_4VREFINT ( COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/4 VrefInt */
  132. #define COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 1/2 VrefInt */
  133. #define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_SCALEN | COMP_CSR_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */
  134. #define COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0 | COMP_CSR_SCALEN ) /*!< Comparator input minus connected to VrefInt */
  135. #define COMP_INPUT_MINUS_DAC1_CH1 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to DAC1 Channel 1 for COMP1/3/4. Note: For COMPx & DACx instances availability, please refer to datasheet */
  136. #define COMP_INPUT_MINUS_DAC1_CH2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to DAC1 Channel 2 for COMP2/5. Note: For COMPx & DACx instances availability, please refer to datasheet */
  137. #define COMP_INPUT_MINUS_DAC2_CH1 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to DAC2 Channel 1 for COMP6/7. Note: For COMPx & DACx instances availability, please refer to datasheet */
  138. #define COMP_INPUT_MINUS_DAC3_CH1 (COMP_CSR_INMSEL_2 ) /*!< Comparator input minus connected to DAC3 Channel 1 for COMP1/3. Note: For COMPx & DACx instances availability, please refer to datasheet */
  139. #define COMP_INPUT_MINUS_DAC3_CH2 (COMP_CSR_INMSEL_2 ) /*!< Comparator input minus connected to DAC3 Channel 2 for COMP2/4. Note: For COMPx & DACx instances availability, please refer to datasheet */
  140. #define COMP_INPUT_MINUS_DAC4_CH1 (COMP_CSR_INMSEL_2 ) /*!< Comparator input minus connected to DAC4 Channel 1 for COMP5/7. Note: For COMPx & DACx instances availability, please refer to datasheet */
  141. #define COMP_INPUT_MINUS_DAC4_CH2 (COMP_CSR_INMSEL_2 ) /*!< Comparator input minus connected to DAC4 Channel 2 for COMP6. Note: For COMPx & DACx instances availability, please refer to datasheet */
  142. #define COMP_INPUT_MINUS_IO1 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PA4 for COMP1, pin PA5 for COMP2, pin PF1 for COMP3, pin PE8 for COMP4, pin PB10 for COMP5, pin PD10 for COMP6, pin PD15 for COMP7). Note: For COMPx instance availability, please refer to datasheet */
  143. #define COMP_INPUT_MINUS_IO2 (COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO2 (pin PA0 for COMP1, pin PA2 for COMP2, pin PC0 for COMP3, pin PB2 for COMP4, pin PD13 for COMP5, pin PB15 for COMP6, pin PB12 for COMP7). Note: For COMPx instance availability, please refer to datasheet */
  144. /**
  145. * @}
  146. */
  147. /** @defgroup COMP_Hysteresis COMP hysteresis
  148. * @{
  149. */
  150. #define COMP_HYSTERESIS_NONE (0x00000000UL) /*!< No hysteresis */
  151. #define COMP_HYSTERESIS_10MV ( COMP_CSR_HYST_0) /*!< Hysteresis level 10mV */
  152. #define COMP_HYSTERESIS_20MV ( COMP_CSR_HYST_1 ) /*!< Hysteresis level 20mV */
  153. #define COMP_HYSTERESIS_30MV ( COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level 30mV */
  154. #define COMP_HYSTERESIS_40MV (COMP_CSR_HYST_2 ) /*!< Hysteresis level 40mV */
  155. #define COMP_HYSTERESIS_50MV (COMP_CSR_HYST_2 | COMP_CSR_HYST_0) /*!< Hysteresis level 50mV */
  156. #define COMP_HYSTERESIS_60MV (COMP_CSR_HYST_2 | COMP_CSR_HYST_1 ) /*!< Hysteresis level 60mV */
  157. #define COMP_HYSTERESIS_70MV (COMP_CSR_HYST_2 | COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level 70mV */
  158. #define COMP_HYSTERESIS_LOW COMP_HYSTERESIS_10MV /*!< Hysteresis level low */
  159. #define COMP_HYSTERESIS_MEDIUM COMP_HYSTERESIS_40MV /*!< Hysteresis level medium */
  160. #define COMP_HYSTERESIS_HIGH COMP_HYSTERESIS_70MV /*!< Hysteresis level high */
  161. /**
  162. * @}
  163. */
  164. /** @defgroup COMP_OutputPolarity COMP output Polarity
  165. * @{
  166. */
  167. #define COMP_OUTPUTPOL_NONINVERTED (0x00000000UL) /*!< COMP output level is not inverted (comparator output is high when the input plus is at a higher voltage than the input minus) */
  168. #define COMP_OUTPUTPOL_INVERTED (COMP_CSR_POLARITY) /*!< COMP output level is inverted (comparator output is low when the input plus is at a higher voltage than the input minus) */
  169. /**
  170. * @}
  171. */
  172. /** @defgroup COMP_BlankingSrce COMP blanking source
  173. * @{
  174. */
  175. #define COMP_BLANKINGSRC_NONE (0x00000000UL) /*!<Comparator output without blanking */
  176. #define COMP_BLANKINGSRC_TIM1_OC5_COMP1 ( COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP1). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  177. #define COMP_BLANKINGSRC_TIM1_OC5_COMP2 ( COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP2). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  178. #define COMP_BLANKINGSRC_TIM1_OC5_COMP3 ( COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP3). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  179. #define COMP_BLANKINGSRC_TIM1_OC5_COMP4 (COMP_CSR_BLANKING_2 ) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP4). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  180. #define COMP_BLANKINGSRC_TIM1_OC5_COMP5 (COMP_CSR_BLANKING_2 ) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP5). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  181. #define COMP_BLANKINGSRC_TIM1_OC5_COMP6 (COMP_CSR_BLANKING_2 ) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP6). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  182. #define COMP_BLANKINGSRC_TIM1_OC5_COMP7 ( COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM1 OC5 (specific to COMP instance: COMP7). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  183. #define COMP_BLANKINGSRC_TIM2_OC3_COMP1 ( COMP_CSR_BLANKING_1 ) /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP1). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  184. #define COMP_BLANKINGSRC_TIM2_OC3_COMP2 ( COMP_CSR_BLANKING_1 ) /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP2). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  185. #define COMP_BLANKINGSRC_TIM2_OC3_COMP5 ( COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM2 OC3 (specific to COMP instance: COMP5). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  186. #define COMP_BLANKINGSRC_TIM2_OC4_COMP3 ( COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM2 OC4 (specific to COMP instance: COMP3). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  187. #define COMP_BLANKINGSRC_TIM2_OC4_COMP6 ( COMP_CSR_BLANKING_1 ) /*!< Comparator output blanking source TIM2 OC4 (specific to COMP instance: COMP6). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  188. #define COMP_BLANKINGSRC_TIM3_OC3_COMP1 ( COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP1). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  189. #define COMP_BLANKINGSRC_TIM3_OC3_COMP2 ( COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP2). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  190. #define COMP_BLANKINGSRC_TIM3_OC3_COMP3 ( COMP_CSR_BLANKING_1 ) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP3). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  191. #define COMP_BLANKINGSRC_TIM3_OC3_COMP5 ( COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP5). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  192. #define COMP_BLANKINGSRC_TIM3_OC3_COMP7 ( COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM3 OC3 (specific to COMP instance: COMP7). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  193. #define COMP_BLANKINGSRC_TIM3_OC4_COMP4 ( COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM3 OC4 (specific to COMP instance: COMP4). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  194. #define COMP_BLANKINGSRC_TIM8_OC5_COMP1 (COMP_CSR_BLANKING_2 ) /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP1). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  195. #define COMP_BLANKINGSRC_TIM8_OC5_COMP2 (COMP_CSR_BLANKING_2 ) /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP2). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  196. #define COMP_BLANKINGSRC_TIM8_OC5_COMP3 (COMP_CSR_BLANKING_2 ) /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP3). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  197. #define COMP_BLANKINGSRC_TIM8_OC5_COMP4 ( COMP_CSR_BLANKING_1 ) /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP4). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  198. #define COMP_BLANKINGSRC_TIM8_OC5_COMP5 ( COMP_CSR_BLANKING_1 ) /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP5). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  199. #define COMP_BLANKINGSRC_TIM8_OC5_COMP6 ( COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP6). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  200. #define COMP_BLANKINGSRC_TIM8_OC5_COMP7 ( COMP_CSR_BLANKING_1 ) /*!< Comparator output blanking source TIM8 OC5 (specific to COMP instance: COMP7). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  201. #define COMP_BLANKINGSRC_TIM15_OC1_COMP4 ( COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM15 OC1 (specific to COMP instance: COMP4). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  202. #define COMP_BLANKINGSRC_TIM15_OC2_COMP6 ( COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM15 OC2 (specific to COMP instance: COMP6). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  203. #define COMP_BLANKINGSRC_TIM15_OC2_COMP7 (COMP_CSR_BLANKING_2 ) /*!< Comparator output blanking source TIM15 OC3 (specific to COMP instance: COMP7). Note: For COMPx & TIMx instances availability, please refer to datasheet */
  204. #define COMP_BLANKINGSRC_TIM20_OC5 (COMP_CSR_BLANKING_2 | COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM20 OC5 (Common to all COMP instances) */
  205. #define COMP_BLANKINGSRC_TIM15_OC1 (COMP_CSR_BLANKING_2 | COMP_CSR_BLANKING_1 ) /*!< Comparator output blanking source TIM15 OC1 (Common to all COMP instances) */
  206. #define COMP_BLANKINGSRC_TIM4_OC3 (COMP_CSR_BLANKING_2 | COMP_CSR_BLANKING_1 | COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM4 OC3 (Common to all COMP instances) */
  207. /**
  208. * @}
  209. */
  210. /** @defgroup COMP_OutputLevel COMP Output Level
  211. * @{
  212. */
  213. /* Note: Comparator output level values are fixed to "0" and "1", */
  214. /* corresponding COMP register bit is managed by HAL function to match */
  215. /* with these values (independently of bit position in register). */
  216. /* When output polarity is not inverted, comparator output is low when
  217. the input plus is at a lower voltage than the input minus */
  218. #define COMP_OUTPUT_LEVEL_LOW (0x00000000UL)
  219. /* When output polarity is not inverted, comparator output is high when
  220. the input plus is at a higher voltage than the input minus */
  221. #define COMP_OUTPUT_LEVEL_HIGH (0x00000001UL)
  222. /**
  223. * @}
  224. */
  225. /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI
  226. * @{
  227. */
  228. #define COMP_TRIGGERMODE_NONE (0x00000000UL) /*!< Comparator output triggering no External Interrupt Line */
  229. #define COMP_TRIGGERMODE_IT_RISING (COMP_EXTI_IT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */
  230. #define COMP_TRIGGERMODE_IT_FALLING (COMP_EXTI_IT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */
  231. #define COMP_TRIGGERMODE_IT_RISING_FALLING (COMP_EXTI_IT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on both rising and falling edges */
  232. #define COMP_TRIGGERMODE_EVENT_RISING (COMP_EXTI_EVENT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */
  233. #define COMP_TRIGGERMODE_EVENT_FALLING (COMP_EXTI_EVENT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */
  234. #define COMP_TRIGGERMODE_EVENT_RISING_FALLING (COMP_EXTI_EVENT | COMP_EXTI_RISING | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on both rising and falling edges */
  235. /**
  236. * @}
  237. */
  238. /**
  239. * @}
  240. */
  241. /* Exported macro ------------------------------------------------------------*/
  242. /** @defgroup COMP_Exported_Macros COMP Exported Macros
  243. * @{
  244. */
  245. /** @defgroup COMP_Handle_Management COMP Handle Management
  246. * @{
  247. */
  248. /** @brief Reset COMP handle state.
  249. * @param __HANDLE__ COMP handle
  250. * @retval None
  251. */
  252. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  253. #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) do{ \
  254. (__HANDLE__)->State = HAL_COMP_STATE_RESET; \
  255. (__HANDLE__)->MspInitCallback = NULL; \
  256. (__HANDLE__)->MspDeInitCallback = NULL; \
  257. } while(0)
  258. #else
  259. #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
  260. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  261. /**
  262. * @brief Clear COMP error code (set it to no error code "HAL_COMP_ERROR_NONE").
  263. * @param __HANDLE__ COMP handle
  264. * @retval None
  265. */
  266. #define COMP_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_COMP_ERROR_NONE)
  267. /**
  268. * @brief Enable the specified comparator.
  269. * @param __HANDLE__ COMP handle
  270. * @retval None
  271. */
  272. #define __HAL_COMP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
  273. /**
  274. * @brief Disable the specified comparator.
  275. * @param __HANDLE__ COMP handle
  276. * @retval None
  277. */
  278. #define __HAL_COMP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
  279. /**
  280. * @brief Lock the specified comparator configuration.
  281. * @note Using this macro induce HAL COMP handle state machine being no
  282. * more in line with COMP instance state.
  283. * To keep HAL COMP handle state machine updated, it is recommended
  284. * to use function "HAL_COMP_Lock')".
  285. * @param __HANDLE__ COMP handle
  286. * @retval None
  287. */
  288. #define __HAL_COMP_LOCK(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK)
  289. /**
  290. * @brief Check whether the specified comparator is locked.
  291. * @param __HANDLE__ COMP handle
  292. * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
  293. */
  294. #define __HAL_COMP_IS_LOCKED(__HANDLE__) (READ_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) == COMP_CSR_LOCK)
  295. /**
  296. * @}
  297. */
  298. /** @defgroup COMP_Exti_Management COMP external interrupt line management
  299. * @{
  300. */
  301. /**
  302. * @brief Enable the COMP1 EXTI line rising edge trigger.
  303. * @retval None
  304. */
  305. #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1)
  306. /**
  307. * @brief Disable the COMP1 EXTI line rising edge trigger.
  308. * @retval None
  309. */
  310. #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1)
  311. /**
  312. * @brief Enable the COMP1 EXTI line falling edge trigger.
  313. * @retval None
  314. */
  315. #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1)
  316. /**
  317. * @brief Disable the COMP1 EXTI line falling edge trigger.
  318. * @retval None
  319. */
  320. #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1)
  321. /**
  322. * @brief Enable the COMP1 EXTI line rising & falling edge trigger.
  323. * @retval None
  324. */
  325. #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  326. LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1); \
  327. LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1); \
  328. } while(0)
  329. /**
  330. * @brief Disable the COMP1 EXTI line rising & falling edge trigger.
  331. * @retval None
  332. */
  333. #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  334. LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1); \
  335. LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1);\
  336. } while(0)
  337. /**
  338. * @brief Enable the COMP1 EXTI line in interrupt mode.
  339. * @retval None
  340. */
  341. #define __HAL_COMP_COMP1_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP1)
  342. /**
  343. * @brief Disable the COMP1 EXTI line in interrupt mode.
  344. * @retval None
  345. */
  346. #define __HAL_COMP_COMP1_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP1)
  347. /**
  348. * @brief Generate a software interrupt on the COMP1 EXTI line.
  349. * @retval None
  350. */
  351. #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP1)
  352. /**
  353. * @brief Enable the COMP1 EXTI line in event mode.
  354. * @retval None
  355. */
  356. #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP1)
  357. /**
  358. * @brief Disable the COMP1 EXTI line in event mode.
  359. * @retval None
  360. */
  361. #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP1)
  362. /**
  363. * @brief Check whether the COMP1 EXTI line flag is set.
  364. * @retval RESET or SET
  365. */
  366. #define __HAL_COMP_COMP1_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP1)
  367. /**
  368. * @brief Clear the COMP1 EXTI flag.
  369. * @retval None
  370. */
  371. #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP1)
  372. /**
  373. * @brief Enable the COMP2 EXTI line rising edge trigger.
  374. * @retval None
  375. */
  376. #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2)
  377. /**
  378. * @brief Disable the COMP2 EXTI line rising edge trigger.
  379. * @retval None
  380. */
  381. #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2)
  382. /**
  383. * @brief Enable the COMP2 EXTI line falling edge trigger.
  384. * @retval None
  385. */
  386. #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2)
  387. /**
  388. * @brief Disable the COMP2 EXTI line falling edge trigger.
  389. * @retval None
  390. */
  391. #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2)
  392. /**
  393. * @brief Enable the COMP2 EXTI line rising & falling edge trigger.
  394. * @retval None
  395. */
  396. #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  397. LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2); \
  398. LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2); \
  399. } while(0)
  400. /**
  401. * @brief Disable the COMP2 EXTI line rising & falling edge trigger.
  402. * @retval None
  403. */
  404. #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  405. LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2); \
  406. LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2);\
  407. } while(0)
  408. /**
  409. * @brief Enable the COMP2 EXTI line in interrupt mode.
  410. * @retval None
  411. */
  412. #define __HAL_COMP_COMP2_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP2)
  413. /**
  414. * @brief Disable the COMP2 EXTI line in interrupt mode.
  415. * @retval None
  416. */
  417. #define __HAL_COMP_COMP2_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP2)
  418. /**
  419. * @brief Generate a software interrupt on the COMP2 EXTI line.
  420. * @retval None
  421. */
  422. #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP2)
  423. /**
  424. * @brief Enable the COMP2 EXTI line in event mode.
  425. * @retval None
  426. */
  427. #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP2)
  428. /**
  429. * @brief Disable the COMP2 EXTI line in event mode.
  430. * @retval None
  431. */
  432. #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP2)
  433. /**
  434. * @brief Check whether the COMP2 EXTI line flag is set.
  435. * @retval RESET or SET
  436. */
  437. #define __HAL_COMP_COMP2_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP2)
  438. /**
  439. * @brief Clear the COMP2 EXTI flag.
  440. * @retval None
  441. */
  442. #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP2)
  443. /**
  444. * @brief Enable the COMP3 EXTI line rising edge trigger.
  445. * @retval None
  446. */
  447. #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP3)
  448. /**
  449. * @brief Disable the COMP3 EXTI line rising edge trigger.
  450. * @retval None
  451. */
  452. #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP3)
  453. /**
  454. * @brief Enable the COMP3 EXTI line falling edge trigger.
  455. * @retval None
  456. */
  457. #define __HAL_COMP_COMP3_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP3)
  458. /**
  459. * @brief Disable the COMP3 EXTI line falling edge trigger.
  460. * @retval None
  461. */
  462. #define __HAL_COMP_COMP3_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP3)
  463. /**
  464. * @brief Enable the COMP3 EXTI line rising & falling edge trigger.
  465. * @retval None
  466. */
  467. #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  468. LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP3); \
  469. LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP3); \
  470. } while(0)
  471. /**
  472. * @brief Disable the COMP3 EXTI line rising & falling edge trigger.
  473. * @retval None
  474. */
  475. #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  476. LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP3); \
  477. LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP3);\
  478. } while(0)
  479. /**
  480. * @brief Enable the COMP3 EXTI line in interrupt mode.
  481. * @retval None
  482. */
  483. #define __HAL_COMP_COMP3_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP3)
  484. /**
  485. * @brief Disable the COMP3 EXTI line in interrupt mode.
  486. * @retval None
  487. */
  488. #define __HAL_COMP_COMP3_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP3)
  489. /**
  490. * @brief Generate a software interrupt on the COMP3 EXTI line.
  491. * @retval None
  492. */
  493. #define __HAL_COMP_COMP3_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP3)
  494. /**
  495. * @brief Enable the COMP3 EXTI line in event mode.
  496. * @retval None
  497. */
  498. #define __HAL_COMP_COMP3_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP3)
  499. /**
  500. * @brief Disable the COMP3 EXTI line in event mode.
  501. * @retval None
  502. */
  503. #define __HAL_COMP_COMP3_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP3)
  504. /**
  505. * @brief Check whether the COMP3 EXTI line flag is set.
  506. * @retval RESET or SET
  507. */
  508. #define __HAL_COMP_COMP3_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP3)
  509. /**
  510. * @brief Clear the COMP3 EXTI flag.
  511. * @retval None
  512. */
  513. #define __HAL_COMP_COMP3_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP3)
  514. /**
  515. * @brief Enable the COMP4 EXTI line rising edge trigger.
  516. * @retval None
  517. */
  518. #define __HAL_COMP_COMP4_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP4)
  519. /**
  520. * @brief Disable the COMP4 EXTI line rising edge trigger.
  521. * @retval None
  522. */
  523. #define __HAL_COMP_COMP4_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP4)
  524. /**
  525. * @brief Enable the COMP4 EXTI line falling edge trigger.
  526. * @retval None
  527. */
  528. #define __HAL_COMP_COMP4_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP4)
  529. /**
  530. * @brief Disable the COMP4 EXTI line falling edge trigger.
  531. * @retval None
  532. */
  533. #define __HAL_COMP_COMP4_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP4)
  534. /**
  535. * @brief Enable the COMP4 EXTI line rising & falling edge trigger.
  536. * @retval None
  537. */
  538. #define __HAL_COMP_COMP4_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  539. LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP4); \
  540. LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP4); \
  541. } while(0)
  542. /**
  543. * @brief Disable the COMP4 EXTI line rising & falling edge trigger.
  544. * @retval None
  545. */
  546. #define __HAL_COMP_COMP4_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  547. LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP4); \
  548. LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP4);\
  549. } while(0)
  550. /**
  551. * @brief Enable the COMP4 EXTI line in interrupt mode.
  552. * @retval None
  553. */
  554. #define __HAL_COMP_COMP4_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP4)
  555. /**
  556. * @brief Disable the COMP4 EXTI line in interrupt mode.
  557. * @retval None
  558. */
  559. #define __HAL_COMP_COMP4_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP4)
  560. /**
  561. * @brief Generate a software interrupt on the COMP4 EXTI line.
  562. * @retval None
  563. */
  564. #define __HAL_COMP_COMP4_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP4)
  565. /**
  566. * @brief Enable the COMP4 EXTI line in event mode.
  567. * @retval None
  568. */
  569. #define __HAL_COMP_COMP4_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP4)
  570. /**
  571. * @brief Disable the COMP4 EXTI line in event mode.
  572. * @retval None
  573. */
  574. #define __HAL_COMP_COMP4_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP4)
  575. /**
  576. * @brief Check whether the COMP4 EXTI line flag is set.
  577. * @retval RESET or SET
  578. */
  579. #define __HAL_COMP_COMP4_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP4)
  580. /**
  581. * @brief Clear the COMP4 EXTI flag.
  582. * @retval None
  583. */
  584. #define __HAL_COMP_COMP4_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP4)
  585. #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
  586. /**
  587. * @brief Enable the COMP5 EXTI line rising edge trigger.
  588. * @retval None
  589. */
  590. #define __HAL_COMP_COMP5_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP5)
  591. /**
  592. * @brief Disable the COMP5 EXTI line rising edge trigger.
  593. * @retval None
  594. */
  595. #define __HAL_COMP_COMP5_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP5)
  596. /**
  597. * @brief Enable the COMP5 EXTI line falling edge trigger.
  598. * @retval None
  599. */
  600. #define __HAL_COMP_COMP5_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP5)
  601. /**
  602. * @brief Disable the COMP5 EXTI line falling edge trigger.
  603. * @retval None
  604. */
  605. #define __HAL_COMP_COMP5_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP5)
  606. /**
  607. * @brief Enable the COMP5 EXTI line rising & falling edge trigger.
  608. * @retval None
  609. */
  610. #define __HAL_COMP_COMP5_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  611. LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP5); \
  612. LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP5); \
  613. } while(0)
  614. /**
  615. * @brief Disable the COMP5 EXTI line rising & falling edge trigger.
  616. * @retval None
  617. */
  618. #define __HAL_COMP_COMP5_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  619. LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP5); \
  620. LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP5);\
  621. } while(0)
  622. /**
  623. * @brief Enable the COMP5 EXTI line in interrupt mode.
  624. * @retval None
  625. */
  626. #define __HAL_COMP_COMP5_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP5)
  627. /**
  628. * @brief Disable the COMP5 EXTI line in interrupt mode.
  629. * @retval None
  630. */
  631. #define __HAL_COMP_COMP5_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP5)
  632. /**
  633. * @brief Generate a software interrupt on the COMP5 EXTI line.
  634. * @retval None
  635. */
  636. #define __HAL_COMP_COMP5_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP5)
  637. /**
  638. * @brief Enable the COMP5 EXTI line in event mode.
  639. * @retval None
  640. */
  641. #define __HAL_COMP_COMP5_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP5)
  642. /**
  643. * @brief Disable the COMP5 EXTI line in event mode.
  644. * @retval None
  645. */
  646. #define __HAL_COMP_COMP5_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP5)
  647. /**
  648. * @brief Check whether the COMP5 EXTI line flag is set.
  649. * @retval RESET or SET
  650. */
  651. #define __HAL_COMP_COMP5_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_0_31(COMP_EXTI_LINE_COMP5)
  652. /**
  653. * @brief Clear the COMP5 EXTI flag.
  654. * @retval None
  655. */
  656. #define __HAL_COMP_COMP5_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_0_31(COMP_EXTI_LINE_COMP5)
  657. #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx*/
  658. #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
  659. /**
  660. * @brief Enable the COMP6 EXTI line rising edge trigger.
  661. * @retval None
  662. */
  663. #define __HAL_COMP_COMP6_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP6)
  664. /**
  665. * @brief Disable the COMP6 EXTI line rising edge trigger.
  666. * @retval None
  667. */
  668. #define __HAL_COMP_COMP6_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP6)
  669. /**
  670. * @brief Enable the COMP6 EXTI line falling edge trigger.
  671. * @retval None
  672. */
  673. #define __HAL_COMP_COMP6_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP6)
  674. /**
  675. * @brief Disable the COMP6 EXTI line falling edge trigger.
  676. * @retval None
  677. */
  678. #define __HAL_COMP_COMP6_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP6)
  679. /**
  680. * @brief Enable the COMP6 EXTI line rising & falling edge trigger.
  681. * @retval None
  682. */
  683. #define __HAL_COMP_COMP6_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  684. LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP6); \
  685. LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP6); \
  686. } while(0)
  687. /**
  688. * @brief Disable the COMP6 EXTI line rising & falling edge trigger.
  689. * @retval None
  690. */
  691. #define __HAL_COMP_COMP6_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  692. LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP6);\
  693. LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP6);\
  694. } while(0)
  695. /**
  696. * @brief Enable the COMP6 EXTI line in interrupt mode.
  697. * @retval None
  698. */
  699. #define __HAL_COMP_COMP6_EXTI_ENABLE_IT() LL_EXTI_EnableIT_32_63(COMP_EXTI_LINE_COMP6)
  700. /**
  701. * @brief Disable the COMP6 EXTI line in interrupt mode.
  702. * @retval None
  703. */
  704. #define __HAL_COMP_COMP6_EXTI_DISABLE_IT() LL_EXTI_DisableIT_32_63(COMP_EXTI_LINE_COMP6)
  705. /**
  706. * @brief Generate a software interrupt on the COMP6 EXTI line.
  707. * @retval None
  708. */
  709. #define __HAL_COMP_COMP6_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_32_63(COMP_EXTI_LINE_COMP6)
  710. /**
  711. * @brief Enable the COMP6 EXTI line in event mode.
  712. * @retval None
  713. */
  714. #define __HAL_COMP_COMP6_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_32_63(COMP_EXTI_LINE_COMP6)
  715. /**
  716. * @brief Disable the COMP6 EXTI line in event mode.
  717. * @retval None
  718. */
  719. #define __HAL_COMP_COMP6_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_32_63(COMP_EXTI_LINE_COMP6)
  720. /**
  721. * @brief Check whether the COMP6 EXTI line flag is set.
  722. * @retval RESET or SET
  723. */
  724. #define __HAL_COMP_COMP6_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_32_63(COMP_EXTI_LINE_COMP6)
  725. /**
  726. * @brief Clear the COMP6 EXTI flag.
  727. * @retval None
  728. */
  729. #define __HAL_COMP_COMP6_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_32_63(COMP_EXTI_LINE_COMP6)
  730. #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx*/
  731. #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
  732. /**
  733. * @brief Enable the COMP7 EXTI line rising edge trigger.
  734. * @retval None
  735. */
  736. #define __HAL_COMP_COMP7_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP7)
  737. /**
  738. * @brief Disable the COMP7 EXTI line rising edge trigger.
  739. * @retval None
  740. */
  741. #define __HAL_COMP_COMP7_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP7)
  742. /**
  743. * @brief Enable the COMP7 EXTI line falling edge trigger.
  744. * @retval None
  745. */
  746. #define __HAL_COMP_COMP7_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP7)
  747. /**
  748. * @brief Disable the COMP7 EXTI line falling edge trigger.
  749. * @retval None
  750. */
  751. #define __HAL_COMP_COMP7_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP7)
  752. /**
  753. * @brief Enable the COMP7 EXTI line rising & falling edge trigger.
  754. * @retval None
  755. */
  756. #define __HAL_COMP_COMP7_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  757. LL_EXTI_EnableRisingTrig_32_63(COMP_EXTI_LINE_COMP7); \
  758. LL_EXTI_EnableFallingTrig_32_63(COMP_EXTI_LINE_COMP7); \
  759. } while(0)
  760. /**
  761. * @brief Disable the COMP7 EXTI line rising & falling edge trigger.
  762. * @retval None
  763. */
  764. #define __HAL_COMP_COMP7_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  765. LL_EXTI_DisableRisingTrig_32_63(COMP_EXTI_LINE_COMP7);\
  766. LL_EXTI_DisableFallingTrig_32_63(COMP_EXTI_LINE_COMP7);\
  767. } while(0)
  768. /**
  769. * @brief Enable the COMP7 EXTI line in interrupt mode.
  770. * @retval None
  771. */
  772. #define __HAL_COMP_COMP7_EXTI_ENABLE_IT() LL_EXTI_EnableIT_32_63(COMP_EXTI_LINE_COMP7)
  773. /**
  774. * @brief Disable the COMP7 EXTI line in interrupt mode.
  775. * @retval None
  776. */
  777. #define __HAL_COMP_COMP7_EXTI_DISABLE_IT() LL_EXTI_DisableIT_32_63(COMP_EXTI_LINE_COMP7)
  778. /**
  779. * @brief Generate a software interrupt on the COMP7 EXTI line.
  780. * @retval None
  781. */
  782. #define __HAL_COMP_COMP7_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_32_63(COMP_EXTI_LINE_COMP7)
  783. /**
  784. * @brief Enable the COMP7 EXTI line in event mode.
  785. * @retval None
  786. */
  787. #define __HAL_COMP_COMP7_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_32_63(COMP_EXTI_LINE_COMP7)
  788. /**
  789. * @brief Disable the COMP7 EXTI line in event mode.
  790. * @retval None
  791. */
  792. #define __HAL_COMP_COMP7_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_32_63(COMP_EXTI_LINE_COMP7)
  793. /**
  794. * @brief Check whether the COMP7 EXTI line flag is set.
  795. * @retval RESET or SET
  796. */
  797. #define __HAL_COMP_COMP7_EXTI_GET_FLAG() LL_EXTI_IsActiveFlag_32_63(COMP_EXTI_LINE_COMP7)
  798. /**
  799. * @brief Clear the COMP7 EXTI flag.
  800. * @retval None
  801. */
  802. #define __HAL_COMP_COMP7_EXTI_CLEAR_FLAG() LL_EXTI_ClearFlag_32_63(COMP_EXTI_LINE_COMP7)
  803. #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx */
  804. /**
  805. * @}
  806. */
  807. /**
  808. * @}
  809. */
  810. /* Private types -------------------------------------------------------------*/
  811. /* Private constants ---------------------------------------------------------*/
  812. /** @defgroup COMP_Private_Constants COMP Private Constants
  813. * @{
  814. */
  815. /** @defgroup COMP_ExtiLine COMP EXTI Lines
  816. * @{
  817. */
  818. #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx) || defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx) || defined(STM32G491xx) || defined(STM32G4A1xx)
  819. #define COMP_EXTI_LINE_COMP1 (LL_EXTI_LINE_21) /*!< EXTI line 21 connected to COMP1 output. Note: For COMPx instance availability, please refer to datasheet */
  820. #define COMP_EXTI_LINE_COMP2 (LL_EXTI_LINE_22) /*!< EXTI line 22 connected to COMP2 output. Note: For COMPx instance availability, please refer to datasheet */
  821. #define COMP_EXTI_LINE_COMP3 (LL_EXTI_LINE_29) /*!< EXTI line 29 connected to COMP3 output. Note: For COMPx instance availability, please refer to datasheet */
  822. #define COMP_EXTI_LINE_COMP4 (LL_EXTI_LINE_30) /*!< EXTI line 30 connected to COMP4 output. Note: For COMPx instance availability, please refer to datasheet */
  823. #elif defined(STM32G411xB) || defined(STM32G411xC)
  824. #define COMP_EXTI_LINE_COMP1 (LL_EXTI_LINE_21) /*!< EXTI line 21 connected to COMP1 output. Note: For COMPx instance availability, please refer to datasheet */
  825. #define COMP_EXTI_LINE_COMP2 (LL_EXTI_LINE_22) /*!< EXTI line 22 connected to COMP2 output. Note: For COMPx instance availability, please refer to datasheet */
  826. #define COMP_EXTI_LINE_COMP3 (LL_EXTI_LINE_29) /*!< EXTI line 29 connected to COMP3 output. Note: For COMPx instance availability, please refer to datasheet */
  827. #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx || STM32GBK1CB || STM32G431xx || STM32G441xx || STM32G471xx || STM32G491xx || STM32G4A1xx */
  828. #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
  829. #define COMP_EXTI_LINE_COMP5 (LL_EXTI_LINE_31) /*!< EXTI line 31 connected to COMP5 output. Note: For COMPx instance availability, please refer to datasheet */
  830. #define COMP_EXTI_LINE_COMP6 (LL_EXTI_LINE_32) /*!< EXTI line 32 connected to COMP6 output. Note: For COMPx instance availability, please refer to datasheet */
  831. #define COMP_EXTI_LINE_COMP7 (LL_EXTI_LINE_33) /*!< EXTI line 33 connected to COMP7 output. Note: For COMPx instance availability, please refer to datasheet */
  832. #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx */
  833. /**
  834. * @}
  835. */
  836. /** @defgroup COMP_ExtiLine COMP EXTI Lines
  837. * @{
  838. */
  839. #define COMP_EXTI_IT (0x00000001UL) /*!< EXTI line event with interruption */
  840. #define COMP_EXTI_EVENT (0x00000002UL) /*!< EXTI line event only (without interruption) */
  841. #define COMP_EXTI_RISING (0x00000010UL) /*!< EXTI line event on rising edge */
  842. #define COMP_EXTI_FALLING (0x00000020UL) /*!< EXTI line event on falling edge */
  843. /**
  844. * @}
  845. */
  846. /**
  847. * @}
  848. */
  849. /* Private macros ------------------------------------------------------------*/
  850. /** @defgroup COMP_Private_Macros COMP Private Macros
  851. * @{
  852. */
  853. /** @defgroup COMP_GET_EXTI_LINE COMP private macros to get EXTI line associated with comparators
  854. * @{
  855. */
  856. /**
  857. * @brief Get the specified EXTI line for a comparator instance.
  858. * @param __INSTANCE__ specifies the COMP instance.
  859. * @retval value of @ref COMP_ExtiLine
  860. */
  861. #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
  862. #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 \
  863. :((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 \
  864. :((__INSTANCE__) == COMP3) ? COMP_EXTI_LINE_COMP3 \
  865. :((__INSTANCE__) == COMP4) ? COMP_EXTI_LINE_COMP4 \
  866. :((__INSTANCE__) == COMP5) ? COMP_EXTI_LINE_COMP5 \
  867. :((__INSTANCE__) == COMP6) ? COMP_EXTI_LINE_COMP6 \
  868. : COMP_EXTI_LINE_COMP7)
  869. #elif defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx) || defined(STM32G491xx) || defined(STM32G4A1xx)
  870. #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 \
  871. :((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 \
  872. :((__INSTANCE__) == COMP3) ? COMP_EXTI_LINE_COMP3 \
  873. : COMP_EXTI_LINE_COMP4)
  874. #elif defined(STM32G411xB) || defined(STM32G411xC)
  875. #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 \
  876. :((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 \
  877. : COMP_EXTI_LINE_COMP3)
  878. #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx */
  879. /**
  880. * @}
  881. */
  882. /** @defgroup COMP_IS_COMP_Private_Definitions COMP private macros to check input parameters
  883. * @{
  884. */
  885. #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
  886. ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2))
  887. #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
  888. #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
  889. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
  890. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
  891. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
  892. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
  893. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \
  894. (((__COMP_INSTANCE__) == COMP1) && \
  895. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
  896. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1)) \
  897. ) || \
  898. (((__COMP_INSTANCE__) == COMP2) && \
  899. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
  900. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2)) \
  901. ) || \
  902. (((__COMP_INSTANCE__) == COMP3) && \
  903. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
  904. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1)) \
  905. ) || \
  906. (((__COMP_INSTANCE__) == COMP4) && \
  907. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
  908. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2)) \
  909. ) || \
  910. (((__COMP_INSTANCE__) == COMP5) && \
  911. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
  912. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC4_CH1)) \
  913. ) || \
  914. (((__COMP_INSTANCE__) == COMP6) && \
  915. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC2_CH1) || \
  916. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC4_CH2)) \
  917. ) || \
  918. (((__COMP_INSTANCE__) == COMP7) && \
  919. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC2_CH1) || \
  920. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC4_CH1)) \
  921. ))
  922. #elif defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx) || defined(STM32G491xx) || defined(STM32G4A1xx)
  923. #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
  924. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
  925. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
  926. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
  927. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
  928. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \
  929. (((__COMP_INSTANCE__) == COMP1) && \
  930. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
  931. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1)) \
  932. ) || \
  933. (((__COMP_INSTANCE__) == COMP2) && \
  934. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
  935. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2)) \
  936. ) || \
  937. (((__COMP_INSTANCE__) == COMP3) && \
  938. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
  939. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1)) \
  940. ) || \
  941. (((__COMP_INSTANCE__) == COMP4) && \
  942. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
  943. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2)) \
  944. ))
  945. #elif defined(STM32G411xB) || defined(STM32G411xC)
  946. #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
  947. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
  948. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
  949. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
  950. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
  951. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \
  952. (((__COMP_INSTANCE__) == COMP1) && \
  953. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
  954. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1)) \
  955. ) || \
  956. (((__COMP_INSTANCE__) == COMP2) && \
  957. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
  958. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH2)) \
  959. ) || \
  960. (((__COMP_INSTANCE__) == COMP3) && \
  961. (((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
  962. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC3_CH1)) \
  963. ))
  964. #endif
  965. #define IS_COMP_HYSTERESIS(__HYSTERESIS__) (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE) || \
  966. ((__HYSTERESIS__) == COMP_HYSTERESIS_10MV) || \
  967. ((__HYSTERESIS__) == COMP_HYSTERESIS_20MV) || \
  968. ((__HYSTERESIS__) == COMP_HYSTERESIS_30MV) || \
  969. ((__HYSTERESIS__) == COMP_HYSTERESIS_40MV) || \
  970. ((__HYSTERESIS__) == COMP_HYSTERESIS_50MV) || \
  971. ((__HYSTERESIS__) == COMP_HYSTERESIS_60MV) || \
  972. ((__HYSTERESIS__) == COMP_HYSTERESIS_70MV) || \
  973. ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW) || \
  974. ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \
  975. ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH))
  976. #define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
  977. ((__POL__) == COMP_OUTPUTPOL_INVERTED))
  978. /* Note: Output blanking source depends on COMP instances */
  979. /* Better use IS_COMP_BLANKINGSRC_INSTANCE instead */
  980. /* Macro kept for compatibility with other STM32 series */
  981. #define IS_COMP_BLANKINGSRCE(__OUTPUT_BLANKING_SOURCE__) \
  982. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) \
  983. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) \
  984. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2) \
  985. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3) \
  986. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP4) \
  987. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP5) \
  988. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP6) \
  989. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP7) \
  990. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) \
  991. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2) \
  992. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP5) \
  993. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3) \
  994. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP6) \
  995. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1) \
  996. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2) \
  997. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3) \
  998. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP5) \
  999. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP7) \
  1000. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP4) \
  1001. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1) \
  1002. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2) \
  1003. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3) \
  1004. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP4) \
  1005. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP5) \
  1006. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP6) \
  1007. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP7) \
  1008. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP4) \
  1009. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP6) \
  1010. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP7) \
  1011. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM20_OC5) \
  1012. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1) \
  1013. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3) \
  1014. )
  1015. #if defined(STM32G414xx) || defined(STM32G474xx) || defined(STM32G484xx) || defined(STM32G473xx) || defined(STM32G483xx)
  1016. #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
  1017. ((((__INSTANCE__) == COMP1) && \
  1018. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1019. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \
  1020. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \
  1021. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1) || \
  1022. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1))) \
  1023. || \
  1024. (((__INSTANCE__) == COMP2) && \
  1025. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1026. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2) || \
  1027. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2) || \
  1028. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2) || \
  1029. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2))) \
  1030. || \
  1031. (((__INSTANCE__) == COMP3) && \
  1032. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1033. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3) || \
  1034. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3) || \
  1035. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3) || \
  1036. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3))) \
  1037. || \
  1038. (((__INSTANCE__) == COMP4) && \
  1039. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1040. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP4) || \
  1041. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP4) || \
  1042. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP4) || \
  1043. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP4))) \
  1044. || \
  1045. (((__INSTANCE__) == COMP5) && \
  1046. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1047. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP5) || \
  1048. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP5) || \
  1049. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP5) || \
  1050. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP5))) \
  1051. || \
  1052. (((__INSTANCE__) == COMP6) && \
  1053. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1054. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP6) || \
  1055. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP6) || \
  1056. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP6) || \
  1057. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP6))) \
  1058. || \
  1059. (((__INSTANCE__) == COMP7) && \
  1060. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1061. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP7) || \
  1062. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP7) || \
  1063. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP7) || \
  1064. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2_COMP7))) \
  1065. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM20_OC5) \
  1066. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1) \
  1067. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3) \
  1068. )
  1069. #elif defined(STM32GBK1CB) || defined(STM32G431xx) || defined(STM32G441xx) || defined(STM32G471xx)
  1070. #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
  1071. ((((__INSTANCE__) == COMP1) && \
  1072. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1073. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \
  1074. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \
  1075. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1) || \
  1076. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1))) \
  1077. || \
  1078. (((__INSTANCE__) == COMP2) && \
  1079. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1080. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2) || \
  1081. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2) || \
  1082. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2) || \
  1083. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2))) \
  1084. || \
  1085. (((__INSTANCE__) == COMP3) && \
  1086. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1087. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3) || \
  1088. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3) || \
  1089. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3) || \
  1090. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3))) \
  1091. || \
  1092. (((__INSTANCE__) == COMP4) && \
  1093. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1094. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP4) || \
  1095. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP4) || \
  1096. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP4) || \
  1097. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP4))) \
  1098. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1) \
  1099. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3) \
  1100. )
  1101. #elif defined(STM32G491xx) || defined(STM32G4A1xx)
  1102. #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
  1103. ((((__INSTANCE__) == COMP1) && \
  1104. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1105. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \
  1106. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \
  1107. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1) || \
  1108. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1))) \
  1109. || \
  1110. (((__INSTANCE__) == COMP2) && \
  1111. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1112. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2) || \
  1113. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2) || \
  1114. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2) || \
  1115. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2))) \
  1116. || \
  1117. (((__INSTANCE__) == COMP3) && \
  1118. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1119. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3) || \
  1120. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3) || \
  1121. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3) || \
  1122. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3))) \
  1123. || \
  1124. (((__INSTANCE__) == COMP4) && \
  1125. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1126. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP4) || \
  1127. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4_COMP4) || \
  1128. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP4) || \
  1129. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1_COMP4))) \
  1130. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM20_OC5) \
  1131. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1) \
  1132. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3) \
  1133. )
  1134. #elif defined(STM32G411xB) || defined(STM32G411xC)
  1135. #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
  1136. ((((__INSTANCE__) == COMP1) && \
  1137. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1138. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP1) || \
  1139. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP1) || \
  1140. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP1) || \
  1141. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP1))) \
  1142. || \
  1143. (((__INSTANCE__) == COMP2) && \
  1144. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1145. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP2) || \
  1146. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3_COMP2) || \
  1147. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP2) || \
  1148. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP2))) \
  1149. || \
  1150. (((__INSTANCE__) == COMP3) && \
  1151. (((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  1152. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5_COMP3) || \
  1153. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC4_COMP3) || \
  1154. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3_COMP3) || \
  1155. ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5_COMP3))) \
  1156. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM20_OC5) \
  1157. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1) \
  1158. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM4_OC3) \
  1159. )
  1160. #endif /* STM32G414xx || STM32G474xx || STM32G484xx || STM32G473xx || STM32G483xx */
  1161. #define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \
  1162. ((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \
  1163. ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \
  1164. ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \
  1165. ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \
  1166. ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \
  1167. ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
  1168. #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW) || \
  1169. ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH))
  1170. /**
  1171. * @}
  1172. */
  1173. /**
  1174. * @}
  1175. */
  1176. /* Exported functions --------------------------------------------------------*/
  1177. /** @addtogroup COMP_Exported_Functions
  1178. * @{
  1179. */
  1180. /** @addtogroup COMP_Exported_Functions_Group1
  1181. * @{
  1182. */
  1183. /* Initialization and de-initialization functions **********************************/
  1184. HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
  1185. HAL_StatusTypeDef HAL_COMP_DeInit(COMP_HandleTypeDef *hcomp);
  1186. void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
  1187. void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
  1188. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  1189. /* Callbacks Register/UnRegister functions ***********************************/
  1190. HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID,
  1191. pCOMP_CallbackTypeDef pCallback);
  1192. HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID);
  1193. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  1194. /**
  1195. * @}
  1196. */
  1197. /* IO operation functions *****************************************************/
  1198. /** @addtogroup COMP_Exported_Functions_Group2
  1199. * @{
  1200. */
  1201. HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
  1202. HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
  1203. void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
  1204. /**
  1205. * @}
  1206. */
  1207. /* Peripheral Control functions ************************************************/
  1208. /** @addtogroup COMP_Exported_Functions_Group3
  1209. * @{
  1210. */
  1211. HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
  1212. uint32_t HAL_COMP_GetOutputLevel(const COMP_HandleTypeDef *hcomp);
  1213. /* Callback in interrupt mode */
  1214. void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
  1215. /**
  1216. * @}
  1217. */
  1218. /* Peripheral State functions **************************************************/
  1219. /** @addtogroup COMP_Exported_Functions_Group4
  1220. * @{
  1221. */
  1222. HAL_COMP_StateTypeDef HAL_COMP_GetState(const COMP_HandleTypeDef *hcomp);
  1223. uint32_t HAL_COMP_GetError(const COMP_HandleTypeDef *hcomp);
  1224. /**
  1225. * @}
  1226. */
  1227. /**
  1228. * @}
  1229. */
  1230. /**
  1231. * @}
  1232. */
  1233. /**
  1234. * @}
  1235. */
  1236. #ifdef __cplusplus
  1237. }
  1238. #endif
  1239. #endif /* STM32G4xx_HAL_COMP_H */