stm32g0xx_hal_comp.h 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938
  1. /**
  2. ******************************************************************************
  3. * @file stm32g0xx_hal_comp.h
  4. * @author MCD Application Team
  5. * @brief Header file of COMP HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * Copyright (c) 2018 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 STM32G0xx_HAL_COMP_H
  20. #define STM32G0xx_HAL_COMP_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32g0xx_hal_def.h"
  26. #include "stm32g0xx_ll_exti.h"
  27. /** @addtogroup STM32G0xx_HAL_Driver
  28. * @{
  29. */
  30. #if defined (COMP1) || defined (COMP2)
  31. /** @addtogroup COMP
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /** @defgroup COMP_Exported_Types COMP Exported Types
  36. * @{
  37. */
  38. /**
  39. * @brief COMP Init structure definition
  40. */
  41. typedef struct
  42. {
  43. uint32_t WindowMode; /*!< Set window mode of a pair of comparators instances
  44. (2 consecutive instances odd and even COMP<x> and COMP<x+1>).
  45. Note: HAL COMP driver allows to set window mode from any COMP instance of the pair
  46. of COMP instances composing window mode, except for window mode with COMP2 and COMP3
  47. (for devices featuring COMP3): it must be set from COMP3 instance.
  48. This parameter can be a value of @ref COMP_WindowMode */
  49. uint32_t WindowOutput; /*!< Set window mode output.
  50. This parameter can be a value of @ref COMP_WindowOutput */
  51. uint32_t Mode; /*!< Set comparator operating mode to adjust power and speed.
  52. Note: For the characteristics of comparator power modes
  53. (propagation delay and power consumption), refer to device datasheet.
  54. This parameter can be a value of @ref COMP_PowerMode */
  55. uint32_t InputPlus; /*!< Set comparator input plus (non-inverting input).
  56. This parameter can be a value of @ref COMP_InputPlus */
  57. uint32_t InputMinus; /*!< Set comparator input minus (inverting input).
  58. This parameter can be a value of @ref COMP_InputMinus */
  59. uint32_t Hysteresis; /*!< Set comparator hysteresis mode of the input minus.
  60. This parameter can be a value of @ref COMP_Hysteresis */
  61. uint32_t OutputPol; /*!< Set comparator output polarity.
  62. This parameter can be a value of @ref COMP_OutputPolarity */
  63. uint32_t BlankingSrce; /*!< Set comparator blanking source.
  64. This parameter can be a value of @ref COMP_BlankingSrce */
  65. uint32_t TriggerMode; /*!< Set the comparator output triggering External Interrupt Line (EXTI).
  66. This parameter can be a value of @ref COMP_EXTI_TriggerMode */
  67. } COMP_InitTypeDef;
  68. /**
  69. * @brief HAL COMP state machine: HAL COMP states definition
  70. */
  71. #define COMP_STATE_BITFIELD_LOCK (0x10U)
  72. typedef enum
  73. {
  74. HAL_COMP_STATE_RESET = 0x00U, /*!< COMP not yet initialized */
  75. HAL_COMP_STATE_RESET_LOCKED = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */
  76. HAL_COMP_STATE_READY = 0x01U, /*!< COMP initialized and ready for use */
  77. HAL_COMP_STATE_READY_LOCKED = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked */
  78. HAL_COMP_STATE_BUSY = 0x02U, /*!< COMP is running */
  79. HAL_COMP_STATE_BUSY_LOCKED = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK) /*!< COMP is running and configuration is locked */
  80. } HAL_COMP_StateTypeDef;
  81. /**
  82. * @brief COMP Handle Structure definition
  83. */
  84. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  85. typedef struct __COMP_HandleTypeDef
  86. #else
  87. typedef struct
  88. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  89. {
  90. COMP_TypeDef *Instance; /*!< Register base address */
  91. COMP_InitTypeDef Init; /*!< COMP required parameters */
  92. HAL_LockTypeDef Lock; /*!< Locking object */
  93. __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
  94. __IO uint32_t ErrorCode; /*!< COMP error code */
  95. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  96. void (* TriggerCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP trigger callback */
  97. void (* MspInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp Init callback */
  98. void (* MspDeInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp DeInit callback */
  99. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  100. } COMP_HandleTypeDef;
  101. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  102. /**
  103. * @brief HAL COMP Callback ID enumeration definition
  104. */
  105. typedef enum
  106. {
  107. HAL_COMP_TRIGGER_CB_ID = 0x00U, /*!< COMP trigger callback ID */
  108. HAL_COMP_MSPINIT_CB_ID = 0x01U, /*!< COMP Msp Init callback ID */
  109. HAL_COMP_MSPDEINIT_CB_ID = 0x02U /*!< COMP Msp DeInit callback ID */
  110. } HAL_COMP_CallbackIDTypeDef;
  111. /**
  112. * @brief HAL COMP Callback pointer definition
  113. */
  114. typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer to a COMP callback function */
  115. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  116. /**
  117. * @}
  118. */
  119. /* Exported constants --------------------------------------------------------*/
  120. /** @defgroup COMP_Exported_Constants COMP Exported Constants
  121. * @{
  122. */
  123. /** @defgroup COMP_Error_Code COMP Error Code
  124. * @{
  125. */
  126. #define HAL_COMP_ERROR_NONE (0x00UL) /*!< No error */
  127. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  128. #define HAL_COMP_ERROR_INVALID_CALLBACK (0x01UL) /*!< Invalid Callback error */
  129. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  130. /**
  131. * @}
  132. */
  133. /** @defgroup COMP_WindowMode COMP Window Mode
  134. * @{
  135. */
  136. #define COMP_WINDOWMODE_DISABLE (0x00000000UL) /*!< Window mode disable: Comparators
  137. instances pair COMP1 and COMP2 are
  138. independent */
  139. #define COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_WINMODE) /*!< Window mode enable: Comparators instances
  140. pair COMP1 and COMP2 have their input
  141. plus connected together.
  142. The common input is COMP1 input plus
  143. (COMP2 input plus is no more accessible).
  144. */
  145. #define COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON (COMP_CSR_WINMODE \
  146. | COMP_WINDOWMODE_COMP2) /*!< Window mode enable: if used from COMP1 or
  147. COMP2 instance, comparators instances
  148. pair COMP1 and COMP2 have their input
  149. plus connected together, the common input
  150. is COMP2 input plus (COMP1 input plus is
  151. no more accessible). If used from COMP3
  152. instance (when available), comparators
  153. instances pair COMP2 and COMP3 have their
  154. input plus connected together, the common
  155. input is COMP2 input plus (COMP3 input
  156. plus is no more accessible). */
  157. /**
  158. * @}
  159. */
  160. /** @defgroup COMP_WindowOutput COMP Window output
  161. * @{
  162. */
  163. #define COMP_WINDOWOUTPUT_EACH_COMP (0x00000000UL) /*!< Window output default mode: Comparators output are
  164. indicating each their own state.
  165. To know window mode state: each comparator output
  166. must be read, if "((COMPx exclusive or COMPy) == 1)"
  167. then monitored signal is within comparators window.*/
  168. #define COMP_WINDOWOUTPUT_COMP1 (COMP_CSR_WINOUT) /*!< Window output synthesized on COMP1 output:
  169. COMP1 output is no more indicating its own state, but
  170. global window mode state (logical high means
  171. monitored signal is within comparators window).
  172. Note: impacts only comparator output signal level
  173. (COMPx_OUT propagated to GPIO, EXTI lines,
  174. timers, ...), does not impact output digital state
  175. of comparator (COMPx_VALUE) always reflecting each
  176. comparator output state.*/
  177. #define COMP_WINDOWOUTPUT_COMP2 (COMP_CSR_WINOUT \
  178. | COMP_WINDOWMODE_COMP2) /*!< Window output synthesized on COMP2 output:
  179. COMP2 output is no more indicating its own state, but
  180. global window mode state (logical high means
  181. monitored signal is within comparators window).
  182. Note: impacts only comparator output signal level
  183. (COMPx_OUT propagated to GPIO, EXTI lines,
  184. timers, ...), does not impact output digital state
  185. of comparator (COMPx_VALUE) always reflecting each
  186. comparator output state.*/
  187. #if defined(COMP3)
  188. #define COMP_WINDOWOUTPUT_COMP3 (COMP_CSR_WINOUT) /*!< Window output synthesized on COMP3 output:
  189. COMP3 output is no more indicating its own state, but
  190. global window mode state (logical high means
  191. monitored signal is within comparators window). */
  192. #endif /* COMP3 */
  193. #define COMP_WINDOWOUTPUT_BOTH (0x00000001UL) /*!< Window output synthesized on both comparators output
  194. of pair of comparator selected (COMP1 and COMP2, or
  195. COMP2 and COMP3 for devices featuring
  196. COMP3 instance):
  197. both comparators outputs are no more indicating their
  198. own state, but global window mode state (logical high
  199. means monitored signal is within comparators window).
  200. This is a specific configuration (technically
  201. possible but not relevant from application
  202. point of view:
  203. 2 comparators output used for the same signal level),
  204. standard configuration for window mode is one of the
  205. settings above. */
  206. /**
  207. * @}
  208. */
  209. /** @defgroup COMP_PowerMode COMP power mode
  210. * @{
  211. */
  212. /* Note: For the characteristics of comparator power modes */
  213. /* (propagation delay and power consumption), */
  214. /* refer to device datasheet. */
  215. #define COMP_POWERMODE_HIGHSPEED (0x00000000UL) /*!< High Speed */
  216. #define COMP_POWERMODE_MEDIUMSPEED (COMP_CSR_PWRMODE_0) /*!< Medium Speed */
  217. /**
  218. * @}
  219. */
  220. /** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
  221. * @{
  222. */
  223. #define COMP_INPUT_PLUS_IO1 (0x00000000UL) /*!< Comparator input plus connected to IO1 (pin PC5 for COMP1, pin PB4 for COMP2, pin PB0 for COMP3 (for devices featuring COMP3 instance)) */
  224. #define COMP_INPUT_PLUS_IO2 (COMP_CSR_INPSEL_0) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PB6 for COMP2, pin PC1 for COMP3 (for devices featuring COMP3 instance)) */
  225. #define COMP_INPUT_PLUS_IO3 (COMP_CSR_INPSEL_1) /*!< Comparator input plus connected to IO3 (pin PA1 for COMP1, pin PA3 for COMP2, pin PE7 for COMP3 (for devices featuring COMP3 instance)) */
  226. /**
  227. * @}
  228. */
  229. /** @defgroup COMP_InputMinus COMP input minus (inverting input)
  230. * @{
  231. */
  232. #define COMP_INPUT_MINUS_1_4VREFINT (0x00000000UL) /*!< Comparator input minus connected to 1/4 VrefInt */
  233. #define COMP_INPUT_MINUS_1_2VREFINT ( COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to 1/2 VrefInt */
  234. #define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CSR_INMSEL_1 ) /*!< Comparator input minus connected to 3/4 VrefInt */
  235. #define COMP_INPUT_MINUS_VREFINT ( COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to VrefInt */
  236. #define COMP_INPUT_MINUS_DAC1_CH1 ( COMP_CSR_INMSEL_2 ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */
  237. #define COMP_INPUT_MINUS_DAC1_CH2 ( COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */
  238. #define COMP_INPUT_MINUS_IO1 ( COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PB1 for COMP1, pin PB3 for COMP2, pin PB2 for COMP3 (for devices featuring COMP3 instance)) */
  239. #define COMP_INPUT_MINUS_IO2 ( COMP_CSR_INMSEL_2 | COMP_CSR_INMSEL_1 | COMP_CSR_INMSEL_0) /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1, pin PB7 for COMP2, pin PC0 for COMP3 (for devices featuring COMP3 instance)) */
  240. #define COMP_INPUT_MINUS_IO3 (COMP_CSR_INMSEL_3 ) /*!< Comparator input minus connected to IO3 (pin PA0 for COMP1, pin PA2 for COMP2, pin PE8 for COMP3 (for devices featuring COMP3 instance)) */
  241. /**
  242. * @}
  243. */
  244. /** @defgroup COMP_Hysteresis COMP hysteresis
  245. * @{
  246. */
  247. #define COMP_HYSTERESIS_NONE (0x00000000UL) /*!< No hysteresis */
  248. #define COMP_HYSTERESIS_LOW ( COMP_CSR_HYST_0) /*!< Hysteresis level low */
  249. #define COMP_HYSTERESIS_MEDIUM (COMP_CSR_HYST_1 ) /*!< Hysteresis level medium */
  250. #define COMP_HYSTERESIS_HIGH (COMP_CSR_HYST_1 | COMP_CSR_HYST_0) /*!< Hysteresis level high */
  251. /**
  252. * @}
  253. */
  254. /** @defgroup COMP_OutputPolarity COMP output Polarity
  255. * @{
  256. */
  257. #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) */
  258. #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) */
  259. /**
  260. * @}
  261. */
  262. /** @defgroup COMP_BlankingSrce COMP blanking source
  263. * @{
  264. */
  265. #define COMP_BLANKINGSRC_NONE (0x00000000UL) /*!<Comparator output without blanking */
  266. /* Note: Output blanking source common to all COMP instances */
  267. #define COMP_BLANKINGSRC_TIM1_OC4 (COMP_CSR_BLANKING_0) /*!< Comparator output blanking source TIM1 OC4 (common to all COMP instances: COMP1, COMP2, COMP3 (when available)) */
  268. #define COMP_BLANKINGSRC_TIM1_OC5 (COMP_CSR_BLANKING_1) /*!< Comparator output blanking source TIM1 OC5 (common to all COMP instances: COMP1, COMP2, COMP3 (when available)) */
  269. #define COMP_BLANKINGSRC_TIM2_OC3 (COMP_CSR_BLANKING_2) /*!< Comparator output blanking source TIM2 OC3 (common to all COMP instances: COMP1, COMP2, COMP3 (when available)) */
  270. #define COMP_BLANKINGSRC_TIM3_OC3 (COMP_CSR_BLANKING_3) /*!< Comparator output blanking source TIM3 OC3 (common to all COMP instances: COMP1, COMP2, COMP3 (when available)) */
  271. #define COMP_BLANKINGSRC_TIM15_OC2 (COMP_CSR_BLANKING_4) /*!< Comparator output blanking source TIM15 OC2 (common to all COMP instances: COMP1, COMP2, COMP3 (when available)) */
  272. /**
  273. * @}
  274. */
  275. /** @defgroup COMP_OutputLevel COMP Output Level
  276. * @{
  277. */
  278. /* Note: Comparator output level values are fixed to "0" and "1", */
  279. /* corresponding COMP register bit is managed by HAL function to match */
  280. /* with these values (independently of bit position in register). */
  281. /* When output polarity is not inverted, comparator output is low when
  282. the input plus is at a lower voltage than the input minus */
  283. #define COMP_OUTPUT_LEVEL_LOW (0x00000000UL)
  284. /* When output polarity is not inverted, comparator output is high when
  285. the input plus is at a higher voltage than the input minus */
  286. #define COMP_OUTPUT_LEVEL_HIGH (0x00000001UL)
  287. /**
  288. * @}
  289. */
  290. /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI
  291. * @{
  292. */
  293. #define COMP_TRIGGERMODE_NONE (0x00000000UL) /*!< Comparator output triggering no External Interrupt Line */
  294. #define COMP_TRIGGERMODE_IT_RISING (COMP_EXTI_IT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */
  295. #define COMP_TRIGGERMODE_IT_FALLING (COMP_EXTI_IT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */
  296. #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 */
  297. #define COMP_TRIGGERMODE_EVENT_RISING (COMP_EXTI_EVENT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */
  298. #define COMP_TRIGGERMODE_EVENT_FALLING (COMP_EXTI_EVENT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */
  299. #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 */
  300. /**
  301. * @}
  302. */
  303. /**
  304. * @}
  305. */
  306. /* Exported macro ------------------------------------------------------------*/
  307. /** @defgroup COMP_Exported_Macros COMP Exported Macros
  308. * @{
  309. */
  310. /** @defgroup COMP_Handle_Management COMP Handle Management
  311. * @{
  312. */
  313. /** @brief Reset COMP handle state.
  314. * @param __HANDLE__ COMP handle
  315. * @retval None
  316. */
  317. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  318. #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) do{ \
  319. (__HANDLE__)->State = HAL_COMP_STATE_RESET; \
  320. (__HANDLE__)->MspInitCallback = NULL; \
  321. (__HANDLE__)->MspDeInitCallback = NULL; \
  322. } while(0)
  323. #else
  324. #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
  325. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  326. /**
  327. * @brief Clear COMP error code (set it to no error code "HAL_COMP_ERROR_NONE").
  328. * @param __HANDLE__ COMP handle
  329. * @retval None
  330. */
  331. #define COMP_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_COMP_ERROR_NONE)
  332. /**
  333. * @brief Enable the specified comparator.
  334. * @param __HANDLE__ COMP handle
  335. * @retval None
  336. */
  337. #define __HAL_COMP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
  338. /**
  339. * @brief Disable the specified comparator.
  340. * @param __HANDLE__ COMP handle
  341. * @retval None
  342. */
  343. #define __HAL_COMP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_EN)
  344. /**
  345. * @brief Lock the specified comparator configuration.
  346. * @note Using this macro induce HAL COMP handle state machine being no
  347. * more in line with COMP instance state.
  348. * To keep HAL COMP handle state machine updated, it is recommended
  349. * to use function "HAL_COMP_Lock')".
  350. * @param __HANDLE__ COMP handle
  351. * @retval None
  352. */
  353. #define __HAL_COMP_LOCK(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK)
  354. /**
  355. * @brief Check whether the specified comparator is locked.
  356. * @param __HANDLE__ COMP handle
  357. * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
  358. */
  359. #define __HAL_COMP_IS_LOCKED(__HANDLE__) (READ_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_LOCK) == COMP_CSR_LOCK)
  360. /**
  361. * @}
  362. */
  363. /** @defgroup COMP_Exti_Management COMP external interrupt line management
  364. * @{
  365. */
  366. /**
  367. * @brief Enable the COMP1 EXTI line rising edge trigger.
  368. * @retval None
  369. */
  370. #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1)
  371. /**
  372. * @brief Disable the COMP1 EXTI line rising edge trigger.
  373. * @retval None
  374. */
  375. #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1)
  376. /**
  377. * @brief Enable the COMP1 EXTI line falling edge trigger.
  378. * @retval None
  379. */
  380. #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1)
  381. /**
  382. * @brief Disable the COMP1 EXTI line falling edge trigger.
  383. * @retval None
  384. */
  385. #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1)
  386. /**
  387. * @brief Enable the COMP1 EXTI line rising & falling edge trigger.
  388. * @retval None
  389. */
  390. #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  391. LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP1); \
  392. LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP1);\
  393. } while(0)
  394. /**
  395. * @brief Disable the COMP1 EXTI line rising & falling edge trigger.
  396. * @retval None
  397. */
  398. #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  399. LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP1); \
  400. LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP1);\
  401. } while(0)
  402. /**
  403. * @brief Enable the COMP1 EXTI line in interrupt mode.
  404. * @retval None
  405. */
  406. #define __HAL_COMP_COMP1_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP1)
  407. /**
  408. * @brief Disable the COMP1 EXTI line in interrupt mode.
  409. * @retval None
  410. */
  411. #define __HAL_COMP_COMP1_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP1)
  412. /**
  413. * @brief Generate a software interrupt on the COMP1 EXTI line.
  414. * @retval None
  415. */
  416. #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP1)
  417. /**
  418. * @brief Enable the COMP1 EXTI line in event mode.
  419. * @retval None
  420. */
  421. #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP1)
  422. /**
  423. * @brief Disable the COMP1 EXTI line in event mode.
  424. * @retval None
  425. */
  426. #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP1)
  427. /**
  428. * @brief Check whether the COMP1 EXTI line rising flag is set.
  429. * @retval RESET or SET
  430. */
  431. #define __HAL_COMP_COMP1_EXTI_GET_RISING_FLAG() LL_EXTI_IsActiveRisingFlag_0_31(COMP_EXTI_LINE_COMP1)
  432. /**
  433. * @brief Clear the COMP1 EXTI rising flag.
  434. * @retval None
  435. */
  436. #define __HAL_COMP_COMP1_EXTI_CLEAR_RISING_FLAG() LL_EXTI_ClearRisingFlag_0_31(COMP_EXTI_LINE_COMP1)
  437. /**
  438. * @brief Check whether the COMP1 EXTI line falling flag is set.
  439. * @retval RESET or SET
  440. */
  441. #define __HAL_COMP_COMP1_EXTI_GET_FALLING_FLAG() LL_EXTI_IsActiveFallingFlag_0_31(COMP_EXTI_LINE_COMP1)
  442. /**
  443. * @brief Clear the COMP1 EXTI falling flag.
  444. * @retval None
  445. */
  446. #define __HAL_COMP_COMP1_EXTI_CLEAR_FALLING_FLAG() LL_EXTI_ClearFallingFlag_0_31(COMP_EXTI_LINE_COMP1)
  447. /**
  448. * @brief Enable the COMP2 EXTI line rising edge trigger.
  449. * @retval None
  450. */
  451. #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2)
  452. /**
  453. * @brief Disable the COMP2 EXTI line rising edge trigger.
  454. * @retval None
  455. */
  456. #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2)
  457. /**
  458. * @brief Enable the COMP2 EXTI line falling edge trigger.
  459. * @retval None
  460. */
  461. #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2)
  462. /**
  463. * @brief Disable the COMP2 EXTI line falling edge trigger.
  464. * @retval None
  465. */
  466. #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2)
  467. /**
  468. * @brief Enable the COMP2 EXTI line rising & falling edge trigger.
  469. * @retval None
  470. */
  471. #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  472. LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP2);\
  473. LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP2);\
  474. } while(0)
  475. /**
  476. * @brief Disable the COMP2 EXTI line rising & falling edge trigger.
  477. * @retval None
  478. */
  479. #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  480. LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP2);\
  481. LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP2);\
  482. } while(0)
  483. /**
  484. * @brief Enable the COMP2 EXTI line in interrupt mode.
  485. * @retval None
  486. */
  487. #define __HAL_COMP_COMP2_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP2)
  488. /**
  489. * @brief Disable the COMP2 EXTI line in interrupt mode.
  490. * @retval None
  491. */
  492. #define __HAL_COMP_COMP2_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP2)
  493. /**
  494. * @brief Generate a software interrupt on the COMP2 EXTI line.
  495. * @retval None
  496. */
  497. #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP2)
  498. /**
  499. * @brief Enable the COMP2 EXTI line in event mode.
  500. * @retval None
  501. */
  502. #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP2)
  503. /**
  504. * @brief Disable the COMP2 EXTI line in event mode.
  505. * @retval None
  506. */
  507. #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP2)
  508. /**
  509. * @brief Check whether the COMP2 EXTI line rising flag is set.
  510. * @retval RESET or SET
  511. */
  512. #define __HAL_COMP_COMP2_EXTI_GET_RISING_FLAG() LL_EXTI_IsActiveRisingFlag_0_31(COMP_EXTI_LINE_COMP2)
  513. /**
  514. * @brief Clear the COMP2 EXTI rising flag.
  515. * @retval None
  516. */
  517. #define __HAL_COMP_COMP2_EXTI_CLEAR_RISING_FLAG() LL_EXTI_ClearRisingFlag_0_31(COMP_EXTI_LINE_COMP2)
  518. /**
  519. * @brief Check whether the COMP2 EXTI line falling flag is set.
  520. * @retval RESET or SET
  521. */
  522. #define __HAL_COMP_COMP2_EXTI_GET_FALLING_FLAG() LL_EXTI_IsActiveFallingFlag_0_31(COMP_EXTI_LINE_COMP2)
  523. /**
  524. * @brief Clear the COMP2 EXTI falling flag.
  525. * @retval None
  526. */
  527. #define __HAL_COMP_COMP2_EXTI_CLEAR_FALLING_FLAG() LL_EXTI_ClearFallingFlag_0_31(COMP_EXTI_LINE_COMP2)
  528. /**
  529. * @brief Enable the COMP3 EXTI line rising edge trigger.
  530. * @retval None
  531. */
  532. #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_EDGE() LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP3)
  533. /**
  534. * @brief Disable the COMP3 EXTI line rising edge trigger.
  535. * @retval None
  536. */
  537. #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_EDGE() LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP3)
  538. /**
  539. * @brief Enable the COMP3 EXTI line falling edge trigger.
  540. * @retval None
  541. */
  542. #define __HAL_COMP_COMP3_EXTI_ENABLE_FALLING_EDGE() LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP3)
  543. /**
  544. * @brief Disable the COMP3 EXTI line falling edge trigger.
  545. * @retval None
  546. */
  547. #define __HAL_COMP_COMP3_EXTI_DISABLE_FALLING_EDGE() LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP3)
  548. /**
  549. * @brief Enable the COMP3 EXTI line rising & falling edge trigger.
  550. * @retval None
  551. */
  552. #define __HAL_COMP_COMP3_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  553. LL_EXTI_EnableRisingTrig_0_31(COMP_EXTI_LINE_COMP3); \
  554. LL_EXTI_EnableFallingTrig_0_31(COMP_EXTI_LINE_COMP3); \
  555. } while(0)
  556. /**
  557. * @brief Disable the COMP3 EXTI line rising & falling edge trigger.
  558. * @retval None
  559. */
  560. #define __HAL_COMP_COMP3_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  561. LL_EXTI_DisableRisingTrig_0_31(COMP_EXTI_LINE_COMP3); \
  562. LL_EXTI_DisableFallingTrig_0_31(COMP_EXTI_LINE_COMP3); \
  563. } while(0)
  564. /**
  565. * @brief Enable the COMP3 EXTI line in interrupt mode.
  566. * @retval None
  567. */
  568. #define __HAL_COMP_COMP3_EXTI_ENABLE_IT() LL_EXTI_EnableIT_0_31(COMP_EXTI_LINE_COMP3)
  569. /**
  570. * @brief Disable the COMP3 EXTI line in interrupt mode.
  571. * @retval None
  572. */
  573. #define __HAL_COMP_COMP3_EXTI_DISABLE_IT() LL_EXTI_DisableIT_0_31(COMP_EXTI_LINE_COMP3)
  574. /**
  575. * @brief Generate a software interrupt on the COMP3 EXTI line.
  576. * @retval None
  577. */
  578. #define __HAL_COMP_COMP3_EXTI_GENERATE_SWIT() LL_EXTI_GenerateSWI_0_31(COMP_EXTI_LINE_COMP3)
  579. /**
  580. * @brief Enable the COMP3 EXTI line in event mode.
  581. * @retval None
  582. */
  583. #define __HAL_COMP_COMP3_EXTI_ENABLE_EVENT() LL_EXTI_EnableEvent_0_31(COMP_EXTI_LINE_COMP3)
  584. /**
  585. * @brief Disable the COMP3 EXTI line in event mode.
  586. * @retval None
  587. */
  588. #define __HAL_COMP_COMP3_EXTI_DISABLE_EVENT() LL_EXTI_DisableEvent_0_31(COMP_EXTI_LINE_COMP3)
  589. /**
  590. * @brief Check whether the COMP3 EXTI line rising flag is set.
  591. * @retval RESET or SET
  592. */
  593. #define __HAL_COMP_COMP3_EXTI_GET_RISING_FLAG() LL_EXTI_IsActiveRisingFlag_0_31(COMP_EXTI_LINE_COMP3)
  594. /**
  595. * @brief Clear the COMP3 EXTI rising flag.
  596. * @retval None
  597. */
  598. #define __HAL_COMP_COMP3_EXTI_CLEAR_RISING_FLAG() LL_EXTI_ClearRisingFlag_0_31(COMP_EXTI_LINE_COMP3)
  599. /**
  600. * @brief Check whether the COMP3 EXTI line falling flag is set.
  601. * @retval RESET or SET
  602. */
  603. #define __HAL_COMP_COMP3_EXTI_GET_FALLING_FLAG() LL_EXTI_IsActiveFallingFlag_0_31(COMP_EXTI_LINE_COMP3)
  604. /**
  605. * @brief Clear the COMP3 EXTI falling flag.
  606. * @retval None
  607. */
  608. #define __HAL_COMP_COMP3_EXTI_CLEAR_FALLING_FLAG() LL_EXTI_ClearFallingFlag_0_31(COMP_EXTI_LINE_COMP3)
  609. /**
  610. * @}
  611. */
  612. /**
  613. * @}
  614. */
  615. /* Private types -------------------------------------------------------------*/
  616. /* Private constants ---------------------------------------------------------*/
  617. /** @defgroup COMP_Private_Constants COMP Private Constants
  618. * @{
  619. */
  620. /** @defgroup COMP_WindowMode_Instance_Differentiator COMP window mode instance differentiator
  621. * @{
  622. */
  623. #define COMP_WINDOWMODE_COMP2 0x00001000U /*!< COMP window mode using common input of COMP instance: COMP2 */
  624. /**
  625. * @}
  626. */
  627. /** @defgroup COMP_ExtiLine COMP EXTI Lines
  628. * @{
  629. */
  630. #define COMP_EXTI_LINE_COMP1 (EXTI_IMR1_IM17) /*!< EXTI line 17 connected to COMP1 output */
  631. #define COMP_EXTI_LINE_COMP2 (EXTI_IMR1_IM18) /*!< EXTI line 18 connected to COMP2 output */
  632. #if defined(COMP3)
  633. #define COMP_EXTI_LINE_COMP3 (EXTI_IMR1_IM20) /*!< EXTI line 20 connected to COMP3 output */
  634. #endif /* COMP3 */
  635. /**
  636. * @}
  637. */
  638. /** @defgroup COMP_ExtiLine COMP EXTI Lines
  639. * @{
  640. */
  641. #define COMP_EXTI_IT (0x00000001UL) /*!< EXTI line event with interruption */
  642. #define COMP_EXTI_EVENT (0x00000002UL) /*!< EXTI line event only (without interruption) */
  643. #define COMP_EXTI_RISING (0x00000010UL) /*!< EXTI line event on rising edge */
  644. #define COMP_EXTI_FALLING (0x00000020UL) /*!< EXTI line event on falling edge */
  645. /**
  646. * @}
  647. */
  648. /**
  649. * @}
  650. */
  651. /* Private macros ------------------------------------------------------------*/
  652. /** @defgroup COMP_Private_Macros COMP Private Macros
  653. * @{
  654. */
  655. /** @defgroup COMP_GET_EXTI_LINE COMP private macros to get EXTI line associated with comparators
  656. * @{
  657. */
  658. /**
  659. * @brief Get the specified EXTI line for a comparator instance.
  660. * @param __INSTANCE__ specifies the COMP instance.
  661. * @retval value of @ref COMP_ExtiLine
  662. */
  663. #if defined(COMP3)
  664. #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 \
  665. :((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2 \
  666. : COMP_EXTI_LINE_COMP3)
  667. #else
  668. #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 \
  669. : COMP_EXTI_LINE_COMP2)
  670. #endif /* COMP3 */
  671. /**
  672. * @}
  673. */
  674. /** @defgroup COMP_IS_COMP_Private_Definitions COMP private macros to check input parameters
  675. * @{
  676. */
  677. #if defined(COMP3)
  678. #define IS_COMP_WINDOWMODE(__INSTANCE__, __WINDOWMODE__) \
  679. (((__INSTANCE__) == COMP3) \
  680. ? \
  681. (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \
  682. ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON) ) \
  683. :\
  684. (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \
  685. ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON)|| \
  686. ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON) ) \
  687. )
  688. #else
  689. #define IS_COMP_WINDOWMODE(__INSTANCE__, __WINDOWMODE__) \
  690. (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \
  691. ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON)|| \
  692. ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP2_INPUT_PLUS_COMMON) )
  693. #endif /* COMP3 */
  694. #define IS_COMP_WINDOWOUTPUT(__WINDOWOUTPUT__) (((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_EACH_COMP) || \
  695. ((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_COMP1) || \
  696. ((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_COMP2) || \
  697. ((__WINDOWOUTPUT__) == COMP_WINDOWOUTPUT_BOTH) )
  698. #define IS_COMP_POWERMODE(__POWERMODE__) (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED) || \
  699. ((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED) )
  700. #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
  701. ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \
  702. ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO3))
  703. #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) ||\
  704. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) ||\
  705. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) ||\
  706. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) ||\
  707. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) ||\
  708. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) ||\
  709. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) ||\
  710. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) ||\
  711. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO3))
  712. #define IS_COMP_HYSTERESIS(__HYSTERESIS__) (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE) || \
  713. ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW) || \
  714. ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \
  715. ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH))
  716. #define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
  717. ((__POL__) == COMP_OUTPUTPOL_INVERTED))
  718. #define IS_COMP_BLANKINGSRCE(__OUTPUT_BLANKING_SOURCE__) \
  719. ( ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_NONE) \
  720. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC4) \
  721. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5) \
  722. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3) \
  723. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3) \
  724. || ((__OUTPUT_BLANKING_SOURCE__) == COMP_BLANKINGSRC_TIM15_OC2) \
  725. )
  726. /* Note: Output blanking source common to all COMP instances */
  727. /* Macro kept for compatibility with other STM32 series */
  728. #define IS_COMP_BLANKINGSRC_INSTANCE(__INSTANCE__, __OUTPUT_BLANKING_SOURCE__) \
  729. (IS_COMP_BLANKINGSRCE(__OUTPUT_BLANKING_SOURCE__))
  730. #define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \
  731. ((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \
  732. ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \
  733. ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \
  734. ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \
  735. ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \
  736. ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
  737. #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW) || \
  738. ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH))
  739. /**
  740. * @}
  741. */
  742. /**
  743. * @}
  744. */
  745. /* Exported functions --------------------------------------------------------*/
  746. /** @addtogroup COMP_Exported_Functions
  747. * @{
  748. */
  749. /** @addtogroup COMP_Exported_Functions_Group1
  750. * @{
  751. */
  752. /* Initialization and de-initialization functions **********************************/
  753. HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
  754. HAL_StatusTypeDef HAL_COMP_DeInit(COMP_HandleTypeDef *hcomp);
  755. void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
  756. void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
  757. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  758. /* Callbacks Register/UnRegister functions ***********************************/
  759. HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID,
  760. pCOMP_CallbackTypeDef pCallback);
  761. HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID);
  762. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  763. /**
  764. * @}
  765. */
  766. /* IO operation functions *****************************************************/
  767. /** @addtogroup COMP_Exported_Functions_Group2
  768. * @{
  769. */
  770. HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
  771. HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
  772. void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
  773. /**
  774. * @}
  775. */
  776. /* Peripheral Control functions ************************************************/
  777. /** @addtogroup COMP_Exported_Functions_Group3
  778. * @{
  779. */
  780. HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
  781. uint32_t HAL_COMP_GetOutputLevel(const COMP_HandleTypeDef *hcomp);
  782. /* Callback in interrupt mode */
  783. void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
  784. /**
  785. * @}
  786. */
  787. /* Peripheral State functions **************************************************/
  788. /** @addtogroup COMP_Exported_Functions_Group4
  789. * @{
  790. */
  791. HAL_COMP_StateTypeDef HAL_COMP_GetState(const COMP_HandleTypeDef *hcomp);
  792. uint32_t HAL_COMP_GetError(const COMP_HandleTypeDef *hcomp);
  793. /**
  794. * @}
  795. */
  796. /**
  797. * @}
  798. */
  799. /**
  800. * @}
  801. */
  802. #endif /* COMP1 || COMP2 */
  803. /**
  804. * @}
  805. */
  806. #ifdef __cplusplus
  807. }
  808. #endif
  809. #endif /* STM32G0xx_HAL_COMP_H */