You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

955 lines
41 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_comp.h
  4. * @author MCD Application Team
  5. * @brief Header file of COMP HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32H7xx_HAL_COMP_H
  21. #define STM32H7xx_HAL_COMP_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32h7xx_hal_def.h"
  27. /** @addtogroup STM32H7xx_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 WindowMode; /*!< Set window mode of a pair of comparators instances
  43. (2 consecutive instances odd and even COMP<x> and COMP<x+1>).
  44. Note: HAL COMP driver allows to set window mode from any COMP instance of the pair of COMP instances composing window mode.
  45. This parameter can be a value of @ref COMP_WindowMode */
  46. uint32_t Mode; /*!< Set comparator operating mode to adjust power and speed.
  47. Note: For the characteritics of comparator power modes
  48. (propagation delay and power consumption), refer to device datasheet.
  49. This parameter can be a value of @ref COMP_PowerMode */
  50. uint32_t NonInvertingInput; /*!< Set comparator input plus (non-inverting input).
  51. This parameter can be a value of @ref COMP_InputPlus */
  52. uint32_t InvertingInput; /*!< Set comparator input minus (inverting input).
  53. This parameter can be a value of @ref COMP_InputMinus */
  54. uint32_t Hysteresis; /*!< Set comparator hysteresis mode of the input minus.
  55. This parameter can be a value of @ref COMP_Hysteresis */
  56. uint32_t OutputPol; /*!< Set comparator output polarity.
  57. This parameter can be a value of @ref COMP_OutputPolarity */
  58. uint32_t BlankingSrce; /*!< Set comparator blanking source.
  59. This parameter can be a value of @ref COMP_BlankingSrce */
  60. uint32_t TriggerMode; /*!< Set the comparator output triggering External Interrupt Line (EXTI).
  61. This parameter can be a value of @ref COMP_EXTI_TriggerMode */
  62. }COMP_InitTypeDef;
  63. /**
  64. * @brief HAL COMP state machine: HAL COMP states definition
  65. */
  66. #define COMP_STATE_BITFIELD_LOCK ((uint32_t)0x10)
  67. typedef enum
  68. {
  69. HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized */
  70. HAL_COMP_STATE_RESET_LOCKED = (HAL_COMP_STATE_RESET | COMP_STATE_BITFIELD_LOCK), /*!< COMP not yet initialized and configuration is locked */
  71. HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */
  72. HAL_COMP_STATE_READY_LOCKED = (HAL_COMP_STATE_READY | COMP_STATE_BITFIELD_LOCK), /*!< COMP initialized but configuration is locked */
  73. HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */
  74. HAL_COMP_STATE_BUSY_LOCKED = (HAL_COMP_STATE_BUSY | COMP_STATE_BITFIELD_LOCK) /*!< COMP is running and configuration is locked */
  75. }HAL_COMP_StateTypeDef;
  76. /**
  77. * @brief COMP Handle Structure definition
  78. */
  79. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  80. typedef struct __COMP_HandleTypeDef
  81. #else
  82. typedef struct
  83. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  84. {
  85. COMP_TypeDef *Instance; /*!< Register base address */
  86. COMP_InitTypeDef Init; /*!< COMP required parameters */
  87. HAL_LockTypeDef Lock; /*!< Locking object */
  88. __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
  89. __IO uint32_t ErrorCode; /*!< COMP error code */
  90. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  91. void (* TriggerCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP trigger callback */
  92. void (* MspInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp Init callback */
  93. void (* MspDeInitCallback)(struct __COMP_HandleTypeDef *hcomp); /*!< COMP Msp DeInit callback */
  94. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  95. } COMP_HandleTypeDef;
  96. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  97. /**
  98. * @brief HAL COMP Callback ID enumeration definition
  99. */
  100. typedef enum
  101. {
  102. HAL_COMP_TRIGGER_CB_ID = 0x00U, /*!< COMP trigger callback ID */
  103. HAL_COMP_MSPINIT_CB_ID = 0x01U, /*!< COMP Msp Init callback ID */
  104. HAL_COMP_MSPDEINIT_CB_ID = 0x02U /*!< COMP Msp DeInit callback ID */
  105. } HAL_COMP_CallbackIDTypeDef;
  106. /**
  107. * @brief HAL COMP Callback pointer definition
  108. */
  109. typedef void (*pCOMP_CallbackTypeDef)(COMP_HandleTypeDef *hcomp); /*!< pointer to a COMP callback function */
  110. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  111. /**
  112. * @}
  113. */
  114. /* Exported constants --------------------------------------------------------*/
  115. /** @defgroup COMP_Exported_Constants COMP Exported Constants
  116. * @{
  117. */
  118. /** @defgroup COMP_Error_Code COMP Error Code
  119. * @{
  120. */
  121. #define HAL_COMP_ERROR_NONE (0x00U) /*!< No error */
  122. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  123. #define HAL_COMP_ERROR_INVALID_CALLBACK (0x01U) /*!< Invalid Callback error */
  124. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  125. /**
  126. * @}
  127. */
  128. /** @defgroup COMP_WindowMode COMP Window Mode
  129. * @{
  130. */
  131. #define COMP_WINDOWMODE_DISABLE ((uint32_t)0x00000000) /*!< Window mode disable: Comparators instances pair COMP1 and COMP2 are independent */
  132. #define COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CFGRx_WINMODE) /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP1 input plus (COMP2 input plus is no more accessible). */
  133. /**
  134. * @}
  135. */
  136. /** @defgroup COMP_PowerMode COMP power mode
  137. * @{
  138. */
  139. /* Note: For the characteritics of comparator power modes */
  140. /* (propagation delay and power consumption), */
  141. /* refer to device datasheet. */
  142. #define COMP_POWERMODE_HIGHSPEED ((uint32_t)0x00000000) /*!< High Speed */
  143. #define COMP_POWERMODE_MEDIUMSPEED (COMP_CFGRx_PWRMODE_0) /*!< Medium Speed */
  144. #define COMP_POWERMODE_ULTRALOWPOWER (COMP_CFGRx_PWRMODE) /*!< Ultra-low power mode */
  145. /**
  146. * @}
  147. */
  148. /** @defgroup COMP_InputPlus COMP input plus (non-inverting input)
  149. * @{
  150. */
  151. #define COMP_INPUT_PLUS_IO1 ((uint32_t)0x00000000) /*!< Comparator input plus connected to IO1 (pin PB0 for COMP1, pin PE9 for COMP2) */
  152. #define COMP_INPUT_PLUS_IO2 (COMP_CFGRx_INPSEL) /*!< Comparator input plus connected to IO2 (pin PB2 for COMP1, pin PE11 for COMP2) */
  153. #if defined (COMP_CFGRx_INP2SEL)
  154. #define COMP_INPUT_PLUS_DAC2_CH1 (COMP_CFGRx_INP2SEL) /*!< Comparator input plus 2 connected to (DAC2_CH1 for COMP1) */
  155. #endif
  156. /**
  157. * @}
  158. */
  159. /** @defgroup COMP_InputMinus COMP input minus (inverting input)
  160. * @{
  161. */
  162. #define COMP_INPUT_MINUS_1_4VREFINT ( COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN) /*!< Comparator input minus connected to 1/4 VrefInt */
  163. #define COMP_INPUT_MINUS_1_2VREFINT ( COMP_CFGRx_INMSEL_0 | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN) /*!< Comparator input minus connected to 1/2 VrefInt */
  164. #define COMP_INPUT_MINUS_3_4VREFINT ( COMP_CFGRx_INMSEL_1 | COMP_CFGRx_SCALEN | COMP_CFGRx_BRGEN) /*!< Comparator input minus connected to 3/4 VrefInt */
  165. #define COMP_INPUT_MINUS_VREFINT ( COMP_CFGRx_INMSEL_1 | COMP_CFGRx_INMSEL_0 | COMP_CFGRx_SCALEN ) /*!< Comparator input minus connected to VrefInt */
  166. #define COMP_INPUT_MINUS_DAC1_CH1 ( COMP_CFGRx_INMSEL_2 ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1) */
  167. #define COMP_INPUT_MINUS_DAC1_CH2 ( COMP_CFGRx_INMSEL_2 | COMP_CFGRx_INMSEL_0 ) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2) */
  168. #define COMP_INPUT_MINUS_IO1 ( COMP_CFGRx_INMSEL_2 | COMP_CFGRx_INMSEL_1 ) /*!< Comparator input minus connected to IO1 (pin PB1 for COMP1, pin PE10 for COMP2) */
  169. #define COMP_INPUT_MINUS_IO2 ( COMP_CFGRx_INMSEL_2 | COMP_CFGRx_INMSEL_1 | COMP_CFGRx_INMSEL_0 ) /*!< Comparator input minus connected to IO2 (pin PC4 for COMP1, pin PE7 for COMP2) */
  170. #if defined (COMP_CFGRx_INMSEL_3)
  171. #define COMP_INPUT_MINUS_TPSENS_DAC2CH1 (COMP_CFGRx_INMSEL_3 ) /*!< Comparator input minus connected to (temp sensor which is exist in ADC for COMP1, DAC2_CH1 for COMP2) */
  172. #define COMP_INPUT_MINUS_VBAT_VDDAP (COMP_CFGRx_INMSEL_3 | COMP_CFGRx_INMSEL_0 ) /*!< Comparator input minus connected to (VBAT/4 for COMP1, VDDAP for COMP2) */
  173. #endif
  174. /**
  175. * @}
  176. */
  177. /** @defgroup COMP_Hysteresis COMP hysteresis
  178. * @{
  179. */
  180. #define COMP_HYSTERESIS_NONE ((uint32_t)0x00000000) /*!< No hysteresis */
  181. #define COMP_HYSTERESIS_LOW (COMP_CFGRx_HYST_0) /*!< Hysteresis level low */
  182. #define COMP_HYSTERESIS_MEDIUM (COMP_CFGRx_HYST_1) /*!< Hysteresis level medium */
  183. #define COMP_HYSTERESIS_HIGH (COMP_CFGRx_HYST) /*!< Hysteresis level high */
  184. /**
  185. * @}
  186. */
  187. /** @defgroup COMP_OutputPolarity COMP Output Polarity
  188. * @{
  189. */
  190. #define COMP_OUTPUTPOL_NONINVERTED ((uint32_t)0x00000000) /*!< COMP output level is not inverted (comparator output is high when the input plus is at a higher voltage than the input minus) */
  191. #define COMP_OUTPUTPOL_INVERTED (COMP_CFGRx_POLARITY) /*!< COMP output level is inverted (comparator output is low when the input plus is at a higher voltage than the input minus) */
  192. /**
  193. * @}
  194. */
  195. /** @defgroup COMP_BlankingSrce COMP Blanking Source
  196. * @{
  197. */
  198. /* Any blanking source can be selected for all comparators */
  199. #define COMP_BLANKINGSRC_NONE ((uint32_t)0x00000000) /*!< No blanking source */
  200. #define COMP_BLANKINGSRC_TIM1_OC5 (COMP_CFGRx_BLANKING_0) /*!< TIM1 OC5 selected as blanking source for comparator */
  201. #define COMP_BLANKINGSRC_TIM2_OC3 (COMP_CFGRx_BLANKING_1) /*!< TIM2 OC3 selected as blanking source for comparator */
  202. #define COMP_BLANKINGSRC_TIM3_OC3 (COMP_CFGRx_BLANKING_0 |COMP_CFGRx_BLANKING_1) /*!< TIM3 OC3 selected as blanking source for compartor */
  203. #define COMP_BLANKINGSRC_TIM3_OC4 (COMP_CFGRx_BLANKING_2) /*!< TIM3 OC4 selected as blanking source for comparator */
  204. #define COMP_BLANKINGSRC_TIM8_OC5 (COMP_CFGRx_BLANKING_2|COMP_CFGRx_BLANKING_0) /*!< TIM8 OC5 selected as blanking source for comparator */
  205. #define COMP_BLANKINGSRC_TIM15_OC1 (COMP_CFGRx_BLANKING_2|COMP_CFGRx_BLANKING_1) /*!< TIM15 OC1 selected as blanking source for comparator */
  206. /**
  207. * @}
  208. */
  209. /** @defgroup COMP_OutputLevel COMP Output Level
  210. * @{
  211. */
  212. /* Note: Comparator output level values are fixed to "0" and "1", */
  213. /* corresponding COMP register bit is managed by HAL function to match */
  214. /* with these values (independently of bit position in register). */
  215. /* When output polarity is not inverted, comparator output is low when
  216. the input plus is at a lower voltage than the input minus */
  217. #define COMP_OUTPUT_LEVEL_LOW ((uint32_t)0x00000000)
  218. /* When output polarity is not inverted, comparator output is high when
  219. the input plus is at a higher voltage than the input minus */
  220. #define COMP_OUTPUT_LEVEL_HIGH ((uint32_t)0x00000001)
  221. /**
  222. * @}
  223. */
  224. /** @defgroup COMP_EXTI_TriggerMode COMP output to EXTI
  225. * @{
  226. */
  227. #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< Comparator output triggering no External Interrupt Line */
  228. #define COMP_TRIGGERMODE_IT_RISING (COMP_EXTI_IT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event with interruption, on rising edge */
  229. #define COMP_TRIGGERMODE_IT_FALLING (COMP_EXTI_IT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event with interruption, on falling edge */
  230. #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 */
  231. #define COMP_TRIGGERMODE_EVENT_RISING (COMP_EXTI_EVENT | COMP_EXTI_RISING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on rising edge */
  232. #define COMP_TRIGGERMODE_EVENT_FALLING (COMP_EXTI_EVENT | COMP_EXTI_FALLING) /*!< Comparator output triggering External Interrupt Line event only (without interruption), on falling edge */
  233. #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 */
  234. /**
  235. * @}
  236. */
  237. /** @defgroup COMP_Flag COMP Flag
  238. * @{
  239. */
  240. #define COMP_FLAG_C1I COMP_SR_C1IF /*!< Comparator 1 Interrupt Flag */
  241. #define COMP_FLAG_C2I COMP_SR_C2IF /*!< Comparator 2 Interrupt Flag */
  242. #define COMP_FLAG_LOCK COMP_CFGRx_LOCK /*!< Lock flag */
  243. /**
  244. * @}
  245. */
  246. /** @defgroup COMP_IT_CLEAR_Flags COMP Interruption Clear Flags
  247. * @{
  248. */
  249. #define COMP_CLEAR_C1IF COMP_ICFR_C1IF /*!< Clear Comparator 1 Interrupt Flag */
  250. #define COMP_CLEAR_C2IF COMP_ICFR_C2IF /*!< Clear Comparator 2 Interrupt Flag */
  251. /**
  252. * @}
  253. */
  254. /** @defgroup COMP_Interrupts_Definitions COMP Interrupts Definitions
  255. * @{
  256. */
  257. #define COMP_IT_EN COMP_CFGRx_ITEN
  258. /**
  259. * @}
  260. */
  261. /**
  262. * @}
  263. */
  264. /* Exported macros -----------------------------------------------------------*/
  265. /** @defgroup COMP_Exported_Macros COMP Exported Macros
  266. * @{
  267. */
  268. /** @defgroup COMP_Handle_Management COMP Handle Management
  269. * @{
  270. */
  271. /** @brief Reset COMP handle state.
  272. * @param __HANDLE__ COMP handle
  273. * @retval None
  274. */
  275. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  276. #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) do{ \
  277. (__HANDLE__)->State = HAL_COMP_STATE_RESET; \
  278. (__HANDLE__)->MspInitCallback = NULL; \
  279. (__HANDLE__)->MspDeInitCallback = NULL; \
  280. } while(0)
  281. #else
  282. #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
  283. #endif
  284. /**
  285. * @brief Clear COMP error code (set it to no error code "HAL_COMP_ERROR_NONE").
  286. * @param __HANDLE__ COMP handle
  287. * @retval None
  288. */
  289. #define COMP_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_COMP_ERROR_NONE)
  290. /**
  291. * @brief Enable the specified comparator.
  292. * @param __HANDLE__ COMP handle
  293. * @retval None
  294. */
  295. #define __HAL_COMP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_EN)
  296. /**
  297. * @brief Disable the specified comparator.
  298. * @param __HANDLE__ COMP handle
  299. * @retval None
  300. */
  301. #define __HAL_COMP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_EN)
  302. /**
  303. * @brief Lock the specified comparator configuration.
  304. * @note Using this macro induce HAL COMP handle state machine being no
  305. * more in line with COMP instance state.
  306. * To keep HAL COMP handle state machine updated, it is recommended
  307. * to use function "HAL_COMP_Lock')".
  308. * @param __HANDLE__ COMP handle
  309. * @retval None
  310. */
  311. #define __HAL_COMP_LOCK(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_LOCK)
  312. /**
  313. * @brief Check whether the specified comparator is locked.
  314. * @param __HANDLE__ COMP handle
  315. * @retval Value 0 if COMP instance is not locked, value 1 if COMP instance is locked
  316. */
  317. #define __HAL_COMP_IS_LOCKED(__HANDLE__) (READ_BIT((__HANDLE__)->Instance->CFGR, COMP_CFGRx_LOCK) == COMP_CFGRx_LOCK)
  318. /**
  319. * @}
  320. */
  321. /** @defgroup COMP_Exti_Management COMP external interrupt line management
  322. * @{
  323. */
  324. /**
  325. * @brief Enable the COMP1 EXTI line rising edge trigger.
  326. * @retval None
  327. */
  328. #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1)
  329. /**
  330. * @brief Disable the COMP1 EXTI line rising edge trigger.
  331. * @retval None
  332. */
  333. #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP1)
  334. /**
  335. * @brief Enable the COMP1 EXTI line falling edge trigger.
  336. * @retval None
  337. */
  338. #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1)
  339. /**
  340. * @brief Disable the COMP1 EXTI line falling edge trigger.
  341. * @retval None
  342. */
  343. #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP1)
  344. /**
  345. * @brief Enable the COMP1 EXTI line rising & falling edge trigger.
  346. * @retval None
  347. */
  348. #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  349. __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE(); \
  350. __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE(); \
  351. } while(0)
  352. /**
  353. * @brief Disable the COMP1 EXTI line rising & falling edge trigger.
  354. * @retval None
  355. */
  356. #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  357. __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE(); \
  358. __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE(); \
  359. } while(0)
  360. /**
  361. * @brief Enable the COMP1 EXTI line in interrupt mode.
  362. * @retval None
  363. */
  364. #define __HAL_COMP_COMP1_EXTI_ENABLE_IT() SET_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP1)
  365. /**
  366. * @brief Disable the COMP1 EXTI line in interrupt mode.
  367. * @retval None
  368. */
  369. #define __HAL_COMP_COMP1_EXTI_DISABLE_IT() CLEAR_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP1)
  370. /**
  371. * @brief Enable the COMP1 EXTI Line in event mode.
  372. * @retval None
  373. */
  374. #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT() SET_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP1)
  375. /**
  376. * @brief Disable the COMP1 EXTI Line in event mode.
  377. * @retval None
  378. */
  379. #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP1)
  380. /**
  381. * @brief Check whether the COMP1 EXTI line flag is set or not.
  382. * @retval RESET or SET
  383. */
  384. #define __HAL_COMP_COMP1_EXTI_GET_FLAG() READ_BIT(EXTI_D1->PR1, COMP_EXTI_LINE_COMP1)
  385. /**
  386. * @brief Clear the COMP1 EXTI flag.
  387. * @retval None
  388. */
  389. #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG() WRITE_REG(EXTI_D1->PR1, COMP_EXTI_LINE_COMP1)
  390. /**
  391. * @brief Generate a software interrupt on the COMP1 EXTI line.
  392. * @retval None
  393. */
  394. #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP1)
  395. /**
  396. * @brief Enable the COMP1 D3 EXTI Line in event mode.
  397. * @retval None
  398. */
  399. #define __HAL_COMP_COMP1_EXTID3_ENABLE_EVENT() SET_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP1)
  400. /**
  401. * @brief Disable the COMP1 D3 EXTI Line in event mode.
  402. * @retval None
  403. */
  404. #define __HAL_COMP_COMP1_EXTID3_DISABLE_EVENT() CLEAR_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP1)
  405. #if defined(DUAL_CORE)
  406. /**
  407. * @brief Enable the COMP1 D2 EXTI line in interrupt mode.
  408. * @retval None
  409. */
  410. #define __HAL_COMP_COMP1_EXTID2_ENABLE_IT() SET_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP1)
  411. /**
  412. * @brief Disable the COMP1 D2 EXTI line in interrupt mode.
  413. * @retval None
  414. */
  415. #define __HAL_COMP_COMP1_EXTID2_DISABLE_IT() CLEAR_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP1)
  416. /**
  417. * @brief Enable the COMP1 D2 EXTI Line in event mode.
  418. * @retval None
  419. */
  420. #define __HAL_COMP_COMP1_EXTID2_ENABLE_EVENT() SET_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP1)
  421. /**
  422. * @brief Disable the COMP1 D2 EXTI Line in event mode.
  423. * @retval None
  424. */
  425. #define __HAL_COMP_COMP1_EXTID2_DISABLE_EVENT() CLEAR_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP1)
  426. /**
  427. * @brief Check whether the COMP1 D2 EXTI line flag is set or not.
  428. * @retval RESET or SET
  429. */
  430. #define __HAL_COMP_COMP1_EXTID2_GET_FLAG() READ_BIT(EXTI_D2->PR1, COMP_EXTI_LINE_COMP1)
  431. /**
  432. * @brief Clear the COMP1 D2 EXTI flag.
  433. * @retval None
  434. */
  435. #define __HAL_COMP_COMP1_EXTID2_CLEAR_FLAG() WRITE_REG(EXTI_D2->PR1, COMP_EXTI_LINE_COMP1)
  436. #endif
  437. /**
  438. * @brief Enable the COMP2 EXTI line rising edge trigger.
  439. * @retval None
  440. */
  441. #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE() SET_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2)
  442. /**
  443. * @brief Disable the COMP2 EXTI line rising edge trigger.
  444. * @retval None
  445. */
  446. #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE() CLEAR_BIT(EXTI->RTSR1, COMP_EXTI_LINE_COMP2)
  447. /**
  448. * @brief Enable the COMP2 EXTI line falling edge trigger.
  449. * @retval None
  450. */
  451. #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE() SET_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2)
  452. /**
  453. * @brief Disable the COMP2 EXTI line falling edge trigger.
  454. * @retval None
  455. */
  456. #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE() CLEAR_BIT(EXTI->FTSR1, COMP_EXTI_LINE_COMP2)
  457. /**
  458. * @brief Enable the COMP2 EXTI line rising & falling edge trigger.
  459. * @retval None
  460. */
  461. #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE() do { \
  462. __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE(); \
  463. __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE(); \
  464. } while(0)
  465. /**
  466. * @brief Disable the COMP2 EXTI line rising & falling edge trigger.
  467. * @retval None
  468. */
  469. #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE() do { \
  470. __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE(); \
  471. __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE(); \
  472. } while(0)
  473. /**
  474. * @brief Enable the COMP2 EXTI line.
  475. * @retval None
  476. */
  477. #define __HAL_COMP_COMP2_EXTI_ENABLE_IT() SET_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP2)
  478. /**
  479. * @brief Disable the COMP2 EXTI line.
  480. * @retval None
  481. */
  482. #define __HAL_COMP_COMP2_EXTI_DISABLE_IT() CLEAR_BIT(EXTI_D1->IMR1, COMP_EXTI_LINE_COMP2)
  483. /**
  484. * @brief Enable the COMP2 EXTI Line in event mode.
  485. * @retval None
  486. */
  487. #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT() SET_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP2)
  488. /**
  489. * @brief Disable the COMP2 EXTI Line in event mode.
  490. * @retval None
  491. */
  492. #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT() CLEAR_BIT(EXTI_D1->EMR1, COMP_EXTI_LINE_COMP2)
  493. /**
  494. * @brief Check whether the COMP2 EXTI line flag is set or not.
  495. * @retval RESET or SET
  496. */
  497. #define __HAL_COMP_COMP2_EXTI_GET_FLAG() READ_BIT(EXTI_D1->PR1, COMP_EXTI_LINE_COMP2)
  498. /**
  499. * @brief Clear the the COMP2 EXTI flag.
  500. * @retval None
  501. */
  502. #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG() WRITE_REG(EXTI_D1->PR1, COMP_EXTI_LINE_COMP2)
  503. /**
  504. * @brief Enable the COMP2 D3 EXTI Line in event mode.
  505. * @retval None
  506. */
  507. #define __HAL_COMP_COMP2_EXTID3_ENABLE_EVENT() SET_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP2)
  508. /**
  509. * @brief Disable the COMP2 D3 EXTI Line in event mode.
  510. * @retval None
  511. */
  512. #define __HAL_COMP_COMP2_EXTID3_DISABLE_EVENT() CLEAR_BIT(EXTI->D3PMR1, COMP_EXTI_LINE_COMP2)
  513. /**
  514. * @brief Generate a software interrupt on the COMP2 EXTI line.
  515. * @retval None
  516. */
  517. #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT() SET_BIT(EXTI->SWIER1, COMP_EXTI_LINE_COMP2)
  518. #if defined(DUAL_CORE)
  519. /**
  520. * @brief Enable the COMP2 D2 EXTI line
  521. * @retval None
  522. */
  523. #define __HAL_COMP_COMP2_EXTID2_ENABLE_IT() SET_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP2)
  524. /**
  525. * @brief Disable the COMP2 D2 EXTI line.
  526. * @retval None
  527. */
  528. #define __HAL_COMP_COMP2_EXTID2_DISABLE_IT() CLEAR_BIT(EXTI_D2->IMR1, COMP_EXTI_LINE_COMP2)
  529. /**
  530. * @brief Enable the COMP2 D2 EXTI Line in event mode.
  531. * @retval None
  532. */
  533. #define __HAL_COMP_COMP2_EXTID2_ENABLE_EVENT() SET_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP2)
  534. /**
  535. * @brief Disable the COMP2 D2 EXTI Line in event mode.
  536. * @retval None
  537. */
  538. #define __HAL_COMP_COMP2_EXTID2_DISABLE_EVENT() CLEAR_BIT(EXTI_D2->EMR1, COMP_EXTI_LINE_COMP2)
  539. /**
  540. * @brief Check whether the COMP2 D2 EXTI line flag is set or not.
  541. * @retval RESET or SET
  542. */
  543. #define __HAL_COMP_COMP2_EXTID2_GET_FLAG() READ_BIT(EXTI_D2->PR1, COMP_EXTI_LINE_COMP2)
  544. /**
  545. * @brief Clear the the COMP2 D2 EXTI flag.
  546. * @retval None
  547. */
  548. #define __HAL_COMP_COMP2_EXTID2_CLEAR_FLAG() WRITE_REG(EXTI_D2->PR1, COMP_EXTI_LINE_COMP2)
  549. #endif
  550. /** @brief Checks if the specified COMP interrupt source is enabled or disabled.
  551. * @param __HANDLE__: specifies the COMP Handle.
  552. * This parameter can be COMP1 where x: 1 or 2 to select the COMP peripheral.
  553. * @param __INTERRUPT__: specifies the COMP interrupt source to check.
  554. * This parameter can be one of the following values:
  555. * @arg COMP_IT_EN: Comparator interrupt enable
  556. *
  557. * @retval The new state of __IT__ (TRUE or FALSE)
  558. */
  559. #define __HAL_COMP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CFGR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  560. /** @brief Checks whether the specified COMP flag is set or not.
  561. * @param __FLAG__: specifies the flag to check.
  562. * This parameter can be one of the following values:
  563. * @arg COMP_FLAG_C1I: Comparator 1 Interrupt Flag
  564. * @arg COMP_FLAG_C2I: Comparator 2 Interrupt Flag
  565. * @retval The new state of __FLAG__ (TRUE or FALSE)
  566. */
  567. #define __HAL_COMP_GET_FLAG(__FLAG__) ((COMP12->SR & (__FLAG__)) == (__FLAG__))
  568. /** @brief Clears the specified COMP pending flag.
  569. * @param __FLAG__: specifies the flag to check.
  570. * This parameter can be any combination of the following values:
  571. * @arg COMP_CLEAR_C1IF : Clear Comparator 1 Interrupt Flag
  572. * @arg COMP_CLEAR_C2IF : Clear Comparator 2 Interrupt Flag
  573. * @retval None
  574. */
  575. #define __HAL_COMP_CLEAR_FLAG(__FLAG__) (COMP12->ICFR = (__FLAG__))
  576. /** @brief Clear the COMP C1I flag.
  577. * @retval None
  578. */
  579. #define __HAL_COMP_CLEAR_C1IFLAG() __HAL_COMP_CLEAR_FLAG( COMP_CLEAR_C1IF)
  580. /** @brief Clear the COMP C2I flag.
  581. * @retval None
  582. */
  583. #define __HAL_COMP_CLEAR_C2IFLAG() __HAL_COMP_CLEAR_FLAG( COMP_CLEAR_C2IF)
  584. /** @brief Enable the specified COMP interrupt.
  585. * @param __HANDLE__: specifies the COMP Handle.
  586. * @param __INTERRUPT__: specifies the COMP interrupt source to enable.
  587. * This parameter can be one of the following values:
  588. * @arg COMP_CFGRx_ITEN : Comparator interrupt
  589. * @retval None
  590. */
  591. #define __HAL_COMP_ENABLE_IT(__HANDLE__, __INTERRUPT__) ( ((__HANDLE__)->Instance->CFGR) |= (__INTERRUPT__) )
  592. /** @brief Disable the specified COMP interrupt.
  593. * @param __HANDLE__: specifies the COMP Handle.
  594. * @param __INTERRUPT__: specifies the COMP interrupt source to enable.
  595. * This parameter can be one of the following values:
  596. * @arg COMP_CFGRx_ITEN : Comparator interrupt
  597. * @retval None
  598. */
  599. #define __HAL_COMP_DISABLE_IT(__HANDLE__,__INTERRUPT__) (((__HANDLE__)->Instance->CFGR) &= ~(__INTERRUPT__))
  600. /**
  601. * @}
  602. */
  603. /** @brief Enable the specified bit in the Option register.
  604. * @param __AF__: specifies the Alternate Function source selection .
  605. * This parameter can be one of the following values:
  606. * @arg COMP_OR_AFOPA6 : Alternate Function PA6 source selection
  607. * @arg COMP_OR_AFOPA8 : Alternate Function PA8 source selection
  608. * @arg COMP_OR_AFOPB12 : Alternate Function PB12 source selection
  609. * @arg COMP_OR_AFOPE6 : Alternate Function PE6 source selection
  610. * @arg COMP_OR_AFOPE15 : Alternate Function PE15 source selection
  611. * @arg COMP_OR_AFOPG2 : Alternate Function PG2 source selection
  612. * @arg COMP_OR_AFOPG3 : Alternate Function PG3 source selection
  613. * @arg COMP_OR_AFOPG4 : Alternate Function PG4 source selection
  614. * @arg COMP_OR_AFOPI1 : Alternate Function PI1 source selection
  615. * @arg COMP_OR_AFOPI4 : Alternate Function PI4 source selection
  616. * @arg COMP_OR_AFOPK2 : Alternate Function PK2 source selection
  617. * @retval None
  618. */
  619. #define __HAL_COMP_ENABLE_OR(__AF__) SET_BIT(COMP12->OR, (__AF__))
  620. /** @brief Disable the specified bit in the Option register.
  621. * @param __AF__: specifies the Alternate Function source selection .
  622. * This parameter can be one of the following values:
  623. * @arg COMP_OR_AFOPA6 : Alternate Function PA6 source selection
  624. * @arg COMP_OR_AFOPA8 : Alternate Function PA8 source selection
  625. * @arg COMP_OR_AFOPB12 : Alternate Function PB12 source selection
  626. * @arg COMP_OR_AFOPE6 : Alternate Function PE6 source selection
  627. * @arg COMP_OR_AFOPE15 : Alternate Function PE15 source selection
  628. * @arg COMP_OR_AFOPG2 : Alternate Function PG2 source selection
  629. * @arg COMP_OR_AFOPG3 : Alternate Function PG3 source selection
  630. * @arg COMP_OR_AFOPG4 : Alternate Function PG4 source selection
  631. * @arg COMP_OR_AFOPI1 : Alternate Function PI1 source selection
  632. * @arg COMP_OR_AFOPI4 : Alternate Function PI4 source selection
  633. * @arg COMP_OR_AFOPK2 : Alternate Function PK2 source selection
  634. * @retval None
  635. */
  636. #define __HAL_COMP_DISABLE_OR(__AF__) CLEAR_BIT(COMP12->OR, (__AF__))
  637. /**
  638. * @}
  639. */
  640. /* Private types -------------------------------------------------------------*/
  641. /* Private constants ---------------------------------------------------------*/
  642. /** @defgroup COMP_Private_Constants COMP Private Constants
  643. * @{
  644. */
  645. /** @defgroup COMP_ExtiLine COMP EXTI Lines
  646. * @{
  647. */
  648. #define COMP_EXTI_LINE_COMP1 (EXTI_IMR1_IM20) /*!< EXTI line 20 connected to COMP1 output */
  649. #define COMP_EXTI_LINE_COMP2 (EXTI_IMR1_IM21) /*!< EXTI line 21 connected to COMP2 output */
  650. /**
  651. * @}
  652. */
  653. /** @defgroup COMP_ExtiLine COMP EXTI Lines
  654. * @{
  655. */
  656. #define COMP_EXTI_IT ((uint32_t) 0x01) /*!< EXTI line event with interruption */
  657. #define COMP_EXTI_EVENT ((uint32_t) 0x02) /*!< EXTI line event only (without interruption) */
  658. #define COMP_EXTI_RISING ((uint32_t) 0x10) /*!< EXTI line event on rising edge */
  659. #define COMP_EXTI_FALLING ((uint32_t) 0x20) /*!< EXTI line event on falling edge */
  660. /**
  661. * @}
  662. */
  663. /**
  664. * @}
  665. */
  666. /* Private macros ------------------------------------------------------------*/
  667. /** @defgroup COMP_Private_Macros COMP Private Macros
  668. * @{
  669. */
  670. /** @defgroup COMP_GET_EXTI_LINE COMP Private macros to get EXTI line associated with Comparators
  671. * @{
  672. */
  673. /**
  674. * @brief Get the specified EXTI line for a comparator instance.
  675. * @param __INSTANCE__: specifies the COMP instance.
  676. * @retval value of @ref COMP_ExtiLine
  677. */
  678. #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 : \
  679. COMP_EXTI_LINE_COMP2)
  680. /**
  681. * @}
  682. */
  683. /** @defgroup COMP_IS_COMP_Definitions COMP private macros to check input parameters
  684. * @{
  685. */
  686. #define IS_COMP_WINDOWMODE(__WINDOWMODE__) (((__WINDOWMODE__) == COMP_WINDOWMODE_DISABLE) || \
  687. ((__WINDOWMODE__) == COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON) )
  688. #define IS_COMP_POWERMODE(__POWERMODE__) (((__POWERMODE__) == COMP_POWERMODE_HIGHSPEED) || \
  689. ((__POWERMODE__) == COMP_POWERMODE_MEDIUMSPEED) || \
  690. ((__POWERMODE__) == COMP_POWERMODE_ULTRALOWPOWER) )
  691. #if defined (COMP_CFGRx_INP2SEL)
  692. #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
  693. ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2) || \
  694. ((__INPUT_PLUS__) == COMP_INPUT_PLUS_DAC2_CH1))
  695. #else
  696. #define IS_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__) (((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO1) || \
  697. ((__INPUT_PLUS__) == COMP_INPUT_PLUS_IO2))
  698. #endif
  699. #if defined (COMP_CFGRx_INMSEL_3)
  700. #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
  701. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
  702. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
  703. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
  704. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
  705. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
  706. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
  707. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2) || \
  708. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_TPSENS_DAC2CH1) || \
  709. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VBAT_VDDAP))
  710. #else
  711. #define IS_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__) (((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_4VREFINT) || \
  712. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_1_2VREFINT) || \
  713. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_3_4VREFINT) || \
  714. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_VREFINT) || \
  715. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH1) || \
  716. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_DAC1_CH2) || \
  717. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO1) || \
  718. ((__INPUT_MINUS__) == COMP_INPUT_MINUS_IO2))
  719. #endif
  720. #define IS_COMP_HYSTERESIS(__HYSTERESIS__) (((__HYSTERESIS__) == COMP_HYSTERESIS_NONE) || \
  721. ((__HYSTERESIS__) == COMP_HYSTERESIS_LOW) || \
  722. ((__HYSTERESIS__) == COMP_HYSTERESIS_MEDIUM) || \
  723. ((__HYSTERESIS__) == COMP_HYSTERESIS_HIGH))
  724. #define IS_COMP_OUTPUTPOL(__POL__) (((__POL__) == COMP_OUTPUTPOL_NONINVERTED) || \
  725. ((__POL__) == COMP_OUTPUTPOL_INVERTED))
  726. #define IS_COMP_BLANKINGSRCE(__SOURCE__) (((__SOURCE__) == COMP_BLANKINGSRC_NONE) || \
  727. ((__SOURCE__) == COMP_BLANKINGSRC_TIM1_OC5) || \
  728. ((__SOURCE__) == COMP_BLANKINGSRC_TIM2_OC3) || \
  729. ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC3) || \
  730. ((__SOURCE__) == COMP_BLANKINGSRC_TIM3_OC4) || \
  731. ((__SOURCE__) == COMP_BLANKINGSRC_TIM8_OC5) || \
  732. ((__SOURCE__) == COMP_BLANKINGSRC_TIM15_OC1))
  733. #define IS_COMP_TRIGGERMODE(__MODE__) (((__MODE__) == COMP_TRIGGERMODE_NONE) || \
  734. ((__MODE__) == COMP_TRIGGERMODE_IT_RISING) || \
  735. ((__MODE__) == COMP_TRIGGERMODE_IT_FALLING) || \
  736. ((__MODE__) == COMP_TRIGGERMODE_IT_RISING_FALLING) || \
  737. ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING) || \
  738. ((__MODE__) == COMP_TRIGGERMODE_EVENT_FALLING) || \
  739. ((__MODE__) == COMP_TRIGGERMODE_EVENT_RISING_FALLING))
  740. #define IS_COMP_OUTPUT_LEVEL(__OUTPUT_LEVEL__) (((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_LOW) || \
  741. ((__OUTPUT_LEVEL__) == COMP_OUTPUT_LEVEL_HIGH))
  742. /**
  743. * @}
  744. */
  745. /**
  746. * @}
  747. */
  748. /* Exported functions --------------------------------------------------------*/
  749. /** @addtogroup COMP_Exported_Functions
  750. * @{
  751. */
  752. /** @addtogroup COMP_Exported_Functions_Group1
  753. * @{
  754. */
  755. /* Initialization and de-initialization functions **********************************/
  756. HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
  757. HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
  758. void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
  759. void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
  760. #if (USE_HAL_COMP_REGISTER_CALLBACKS == 1)
  761. /* Callbacks Register/UnRegister functions ***********************************/
  762. HAL_StatusTypeDef HAL_COMP_RegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID, pCOMP_CallbackTypeDef pCallback);
  763. HAL_StatusTypeDef HAL_COMP_UnRegisterCallback(COMP_HandleTypeDef *hcomp, HAL_COMP_CallbackIDTypeDef CallbackID);
  764. #endif /* USE_HAL_COMP_REGISTER_CALLBACKS */
  765. /**
  766. * @}
  767. */
  768. /* IO operation functions *****************************************************/
  769. /** @addtogroup COMP_Exported_Functions_Group2
  770. * @{
  771. */
  772. HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
  773. HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
  774. HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
  775. HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
  776. void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
  777. /**
  778. * @}
  779. */
  780. /* Peripheral Control functions ************************************************/
  781. /** @addtogroup COMP_Exported_Functions_Group3
  782. * @{
  783. */
  784. HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
  785. uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
  786. /* Callback in Interrupt mode */
  787. void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
  788. /**
  789. * @}
  790. */
  791. /* Peripheral State functions **************************************************/
  792. /** @addtogroup COMP_Exported_Functions_Group4
  793. * @{
  794. */
  795. HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
  796. uint32_t HAL_COMP_GetError(COMP_HandleTypeDef *hcomp);
  797. /**
  798. * @}
  799. */
  800. /**
  801. * @}
  802. */
  803. /**
  804. * @}
  805. */
  806. /**
  807. * @}
  808. */
  809. #ifdef __cplusplus
  810. }
  811. #endif
  812. #endif /* STM32H7xx_HAL_COMP_H */
  813. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/