stm32l1xx_hal_comp.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_hal_comp.h
  4. * @author MCD Application Team
  5. * @version V1.0.0
  6. * @date 5-September-2014
  7. * @brief Header file of COMP HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef __STM32L1xx_HAL_COMP_H
  39. #define __STM32L1xx_HAL_COMP_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32l1xx_hal_def.h"
  45. /** @addtogroup STM32L1xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup COMP
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup COMP_Exported_Types COMP Exported Types
  53. * @{
  54. */
  55. /**
  56. * @brief COMP Init structure definition
  57. */
  58. typedef struct
  59. {
  60. uint32_t InvertingInput; /*!< Selects the inverting input of the comparator.
  61. This parameter can be a value of @ref COMP_InvertingInput
  62. Note: Inverting input can be changed on the fly, while comparator is running.
  63. Note: This feature is available on COMP2 only. If COMP1 is selected, this parameter is discarded (On COMP1, inverting input is fixed to Vrefint). */
  64. uint32_t NonInvertingInput; /*!< Selects the non inverting input of the comparator.
  65. This parameter can be a value of @ref COMPEx_NonInvertingInput */
  66. uint32_t Output; /*!< Selects the output redirection of the comparator.
  67. This parameter can be a value of @ref COMP_Output
  68. Note: This feature is available on COMP2 only. If COMP1 is selected, this parameter is discarded. */
  69. uint32_t Mode; /*!< Selects the operating consumption mode of the comparator
  70. to adjust the speed/consumption.
  71. This parameter can be a value of @ref COMP_Mode
  72. Note: This feature is available on COMP2 only. If COMP1 is selected, this parameter is discarded. */
  73. uint32_t WindowMode; /*!< Selects the window mode of the 2 comparators.
  74. If enabled, non-inverting inputs of the 2 comparators are connected together and are using inputs of COMP2 only (COMP1 non-inverting input is no more accessible, even from ADC channel VCOMP).
  75. This parameter can be a value of @ref COMP_WindowMode
  76. Note: This feature must be enabled from COMP2 instance. If COMP1 is selected, this parameter is discarded. */
  77. uint32_t TriggerMode; /*!< Selects the trigger mode of the comparator when using interruption on EXTI line (interrupt mode).
  78. This parameter can be a value of @ref COMP_TriggerMode
  79. Note: This feature is used with function "HAL_COMP_Start_IT()". In all other functions, this parameter is discarded. */
  80. uint32_t NonInvertingInputPull; /*!< Selects the internal pulling resistor connected on non inverting input.
  81. This parameter can be a value of @ref COMP_NonInvertingInputPull
  82. Note: To avoid extra power consumption, only one resistor should be enabled at a time.
  83. Note: This feature is available on COMP1 only. If COMP2 is selected, this parameter is discarded. */
  84. }COMP_InitTypeDef;
  85. /**
  86. * @brief HAL State structures definition
  87. */
  88. typedef enum
  89. {
  90. HAL_COMP_STATE_RESET = 0x00, /*!< COMP not yet initialized or disabled */
  91. HAL_COMP_STATE_READY = 0x01, /*!< COMP initialized and ready for use */
  92. HAL_COMP_STATE_READY_LOCKED = 0x11, /*!< COMP initialized but the configuration is locked */
  93. HAL_COMP_STATE_BUSY = 0x02, /*!< COMP is running */
  94. HAL_COMP_STATE_BUSY_LOCKED = 0x12 /*!< COMP is running and the configuration is locked */
  95. }HAL_COMP_StateTypeDef;
  96. /**
  97. * @brief COMP Handle Structure definition
  98. */
  99. typedef struct
  100. {
  101. COMP_TypeDef *Instance; /*!< Register base address */
  102. COMP_InitTypeDef Init; /*!< COMP required parameters */
  103. HAL_LockTypeDef Lock; /*!< Locking object */
  104. __IO HAL_COMP_StateTypeDef State; /*!< COMP communication state */
  105. } COMP_HandleTypeDef;
  106. /**
  107. * @}
  108. */
  109. /* Exported constants --------------------------------------------------------*/
  110. /** @defgroup COMP_Exported_Constants COMP Exported Constants
  111. * @{
  112. */
  113. /** @defgroup COMP_Output COMP Output
  114. * @{
  115. */
  116. #define COMP_OUTPUT_TIM2IC4 ((uint32_t)0x00000000) /*!< COMP2 output connected to TIM2 Input Capture 4 */
  117. #define COMP_OUTPUT_TIM2OCREFCLR ( COMP_CSR_OUTSEL_0) /*!< COMP2 output connected to TIM2 OCREF Clear */
  118. #define COMP_OUTPUT_TIM3IC4 ( COMP_CSR_OUTSEL_1 ) /*!< COMP2 output connected to TIM3 Input Capture 4 */
  119. #define COMP_OUTPUT_TIM3OCREFCLR ( COMP_CSR_OUTSEL_1 | COMP_CSR_OUTSEL_0) /*!< COMP2 output connected to TIM3 OCREF Clear */
  120. #define COMP_OUTPUT_TIM4IC4 (COMP_CSR_OUTSEL_2 ) /*!< COMP2 output connected to TIM4 Input Capture 4 */
  121. #define COMP_OUTPUT_TIM4OCREFCLR (COMP_CSR_OUTSEL_2 | COMP_CSR_OUTSEL_0) /*!< COMP2 output connected to TIM4 OCREF Clear */
  122. #define COMP_OUTPUT_TIM10IC1 (COMP_CSR_OUTSEL_2 | COMP_CSR_OUTSEL_1 ) /*!< COMP2 output connected to TIM10 Input Capture 1 */
  123. #define COMP_OUTPUT_NONE (COMP_CSR_OUTSEL_2 | COMP_CSR_OUTSEL_1 | COMP_CSR_OUTSEL_0) /*!< COMP2 output is not connected to other peripherals */
  124. #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_TIM2IC4) || \
  125. ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR) || \
  126. ((OUTPUT) == COMP_OUTPUT_TIM3IC4) || \
  127. ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR) || \
  128. ((OUTPUT) == COMP_OUTPUT_TIM4IC4) || \
  129. ((OUTPUT) == COMP_OUTPUT_TIM4OCREFCLR) || \
  130. ((OUTPUT) == COMP_OUTPUT_TIM10IC1) || \
  131. ((OUTPUT) == COMP_OUTPUT_NONE) )
  132. /**
  133. * @}
  134. */
  135. /** @defgroup COMP_InvertingInput COMP InvertingInput
  136. * @{
  137. */
  138. /* Inverting Input specific to COMP2 */
  139. #define COMP_INVERTINGINPUT_IO ( COMP_CSR_INSEL_0) /*!< External I/O (COMP2_INM connected to pin PB3) connected to comparator 2 inverting input */
  140. #define COMP_INVERTINGINPUT_VREFINT ( COMP_CSR_INSEL_1 ) /*!< VREFINT connected to comparator 2 inverting input */
  141. #define COMP_INVERTINGINPUT_3_4VREFINT ( COMP_CSR_INSEL_1 | COMP_CSR_INSEL_0) /*!< 3/4 VREFINT connected to comparator 2 inverting input */
  142. #define COMP_INVERTINGINPUT_1_2VREFINT (COMP_CSR_INSEL_2 ) /*!< 1/2 VREFINT connected to comparator 2 inverting input */
  143. #define COMP_INVERTINGINPUT_1_4VREFINT (COMP_CSR_INSEL_2 | COMP_CSR_INSEL_0) /*!< 1/4 VREFINT connected to comparator 2 inverting input */
  144. #define COMP_INVERTINGINPUT_DAC1 (COMP_CSR_INSEL_2 | COMP_CSR_INSEL_1 ) /*!< DAC_OUT1 (PA4) connected to comparator 2 inverting input */
  145. #define COMP_INVERTINGINPUT_DAC2 (COMP_CSR_INSEL_2 | COMP_CSR_INSEL_1 | COMP_CSR_INSEL_0) /*!< DAC2_OUT (PA5) connected to comparator 2 inverting input */
  146. #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_IO) || \
  147. ((INPUT) == COMP_INVERTINGINPUT_VREFINT) || \
  148. ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT) || \
  149. ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT) || \
  150. ((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT) || \
  151. ((INPUT) == COMP_INVERTINGINPUT_DAC1) || \
  152. ((INPUT) == COMP_INVERTINGINPUT_DAC2) )
  153. /**
  154. * @}
  155. */
  156. /** @defgroup COMP_Mode COMP Mode
  157. * @{
  158. */
  159. /* Please refer to the electrical characteristics in the device datasheet for
  160. the power consumption values */
  161. #define COMP_MODE_LOWSPEED ((uint32_t)0x00000000) /*!< Low Speed */
  162. #define COMP_MODE_HIGHSPEED COMP_CSR_SPEED /*!< High Speed */
  163. #define IS_COMP_MODE(SPEED) (((SPEED) == COMP_MODE_LOWSPEED) || \
  164. ((SPEED) == COMP_MODE_HIGHSPEED))
  165. /**
  166. * @}
  167. */
  168. /** @defgroup COMP_WindowMode COMP WindowMode
  169. * @{
  170. */
  171. #define COMP_WINDOWMODE_DISABLED ((uint32_t)0x00000000) /*!< Window mode disabled: COMP1 non-inverting input is independant */
  172. #define COMP_WINDOWMODE_ENABLED COMP_CSR_WNDWE /*!< Window mode enabled: COMP1 non-inverting input is no more accessible, even from ADC channel VCOMP) (connected to COMP2 non-inverting input) */
  173. #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLED) || \
  174. ((WINDOWMODE) == COMP_WINDOWMODE_ENABLED))
  175. /**
  176. * @}
  177. */
  178. /** @defgroup COMP_OutputLevel COMP OutputLevel
  179. * @{
  180. */
  181. /* Comparator output is low when the non-inverting input is at a lower */
  182. /* voltage than the inverting input. */
  183. #define COMP_OUTPUTLEVEL_LOW ((uint32_t)0x00000000)
  184. /* Comparator output is high when the non-inverting input is at a higher */
  185. /* voltage than the inverting input. */
  186. #define COMP_OUTPUTLEVEL_HIGH ((uint32_t)0x00000001)
  187. /**
  188. * @}
  189. */
  190. /** @defgroup COMP_TriggerMode COMP TriggerMode
  191. * @{
  192. */
  193. #define COMP_TRIGGERMODE_NONE ((uint32_t)0x00000000) /*!< No External Interrupt trigger detection */
  194. #define COMP_TRIGGERMODE_IT_RISING ((uint32_t)0x00000001) /*!< External Interrupt Mode with Rising edge trigger detection */
  195. #define COMP_TRIGGERMODE_IT_FALLING ((uint32_t)0x00000002) /*!< External Interrupt Mode with Falling edge trigger detection */
  196. #define COMP_TRIGGERMODE_IT_RISING_FALLING ((uint32_t)0x00000003) /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
  197. #define IS_COMP_TRIGGERMODE(MODE) (((MODE) == COMP_TRIGGERMODE_NONE) || \
  198. ((MODE) == COMP_TRIGGERMODE_IT_RISING) || \
  199. ((MODE) == COMP_TRIGGERMODE_IT_FALLING) || \
  200. ((MODE) == COMP_TRIGGERMODE_IT_RISING_FALLING) )
  201. /**
  202. * @}
  203. */
  204. /** @defgroup COMP_ExtiLineEvent COMP ExtiLineEvent
  205. * @{
  206. */
  207. #define COMP_EXTI_LINE_COMP1_EVENT EXTI_RTSR_TR21 /*!< External interrupt line 21 Connected to COMP1 */
  208. #define COMP_EXTI_LINE_COMP2_EVENT EXTI_RTSR_TR22 /*!< External interrupt line 22 Connected to COMP2 */
  209. /**
  210. * @}
  211. */
  212. /** @defgroup COMP_NonInvertingInputPull COMP NonInvertingInputPull
  213. * @{
  214. */
  215. #define COMP_NONINVERTINGINPUT_NOPULL ((uint32_t)0x00000000) /*!< No internal pull-up or pull-down resistor connected to comparator non inverting input */
  216. #define COMP_NONINVERTINGINPUT_10KPU COMP_CSR_10KPU /*!< Internal 10kOhm pull-up resistor connected to comparator non inverting input */
  217. #define COMP_NONINVERTINGINPUT_10KPD COMP_CSR_10KPD /*!< Internal 10kOhm pull-down resistor connected to comparator non inverting input */
  218. #define COMP_NONINVERTINGINPUT_400KPU COMP_CSR_400KPU /*!< Internal 400kOhm pull-up resistor connected to comparator non inverting input */
  219. #define COMP_NONINVERTINGINPUT_400KPD COMP_CSR_400KPD /*!< Internal 400kOhm pull-down resistor connected to comparator non inverting input */
  220. #define IS_COMP_NONINVERTINGINPUTPULL(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_NOPULL) || \
  221. ((INPUT) == COMP_NONINVERTINGINPUT_10KPU) || \
  222. ((INPUT) == COMP_NONINVERTINGINPUT_10KPD) || \
  223. ((INPUT) == COMP_NONINVERTINGINPUT_400KPU) || \
  224. ((INPUT) == COMP_NONINVERTINGINPUT_400KPD) )
  225. /**
  226. * @}
  227. */
  228. /**
  229. * @}
  230. */
  231. /* Exported macro ------------------------------------------------------------*/
  232. /** @defgroup COMP_Exported_Macro COMP Exported Macro
  233. * @{
  234. */
  235. /** @brief Reset COMP handle state
  236. * @param __HANDLE__: COMP handle.
  237. * @retval None
  238. */
  239. #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
  240. /**
  241. * @brief Enables the specified comparator
  242. * @param __HANDLE__: COMP handle.
  243. * @retval None.
  244. */
  245. #define __HAL_COMP_ENABLE(__HANDLE__) \
  246. ( ( ((__HANDLE__)->Instance == COMP1) \
  247. )? \
  248. SET_BIT(COMP->CSR, COMP_CSR_CMP1EN) \
  249. : \
  250. MODIFY_REG(COMP->CSR, COMP_CSR_INSEL, (__HANDLE__)->Init.InvertingInput ) \
  251. )
  252. /**
  253. * @brief Disables the specified comparator
  254. * @param __HANDLE__: COMP handle.
  255. * @retval None.
  256. */
  257. #define __HAL_COMP_DISABLE(__HANDLE__) \
  258. ( ( ((__HANDLE__)->Instance == COMP1) \
  259. )? \
  260. CLEAR_BIT(COMP->CSR, COMP_CSR_CMP1EN) \
  261. : \
  262. CLEAR_BIT(COMP->CSR, COMP_CSR_INSEL) \
  263. )
  264. /** @brief Checks whether the specified COMP flag is set or not.
  265. * @param __HANDLE__: specifies the COMP Handle.
  266. * @param __FLAG__: specifies the flag to check.
  267. * This parameter can be one of the following values:
  268. * @arg COMP_FLAG_LOCK: lock flag
  269. * @retval The new state of __FLAG__ (TRUE or FALSE).
  270. */
  271. #define __HAL_COMP_GET_FLAG(__HANDLE__, __FLAG__) (READ_BIT((__HANDLE__)->Instance->CSR, (__FLAG__)) == (__FLAG__))
  272. /**
  273. * @brief Enable the Exti Line rising edge trigger.
  274. * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
  275. * This parameter can be a value of @ref COMP_ExtiLineEvent
  276. * @retval None.
  277. */
  278. #define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (SET_BIT(EXTI->RTSR, (__EXTILINE__)))
  279. /**
  280. * @brief Disable the Exti Line rising edge trigger.
  281. * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
  282. * This parameter can be a value of @ref COMP_ExtiLineEvent
  283. * @retval None.
  284. */
  285. #define __HAL_COMP_EXTI_RISING_IT_DISABLE(__EXTILINE__) (CLEAR_BIT(EXTI->RTSR, (__EXTILINE__)))
  286. /**
  287. * @brief Enable the Exti Line falling edge trigger.
  288. * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
  289. * This parameter can be a value of @ref COMP_ExtiLineEvent
  290. * @retval None.
  291. */
  292. #define __HAL_COMP_EXTI_FALLING_IT_ENABLE(__EXTILINE__) (SET_BIT(EXTI->FTSR, (__EXTILINE__)))
  293. /**
  294. * @brief Disable the Exti Line falling edge trigger.
  295. * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
  296. * This parameter can be a value of @ref COMP_ExtiLineEvent
  297. * @retval None.
  298. */
  299. #define __HAL_COMP_EXTI_FALLING_IT_DISABLE(__EXTILINE__) (CLEAR_BIT(EXTI->FTSR, (__EXTILINE__)))
  300. /**
  301. * @brief Get the specified EXTI line for a comparator instance
  302. * @param __INSTANCE__: specifies the COMP instance.
  303. * @retval value of @ref COMP_ExtiLineEvent
  304. */
  305. #define __HAL_COMP_GET_EXTI_LINE(__INSTANCE__) \
  306. ( ( ((__INSTANCE__) == COMP1) \
  307. )? \
  308. (COMP_EXTI_LINE_COMP1_EVENT) \
  309. : \
  310. (COMP_EXTI_LINE_COMP2_EVENT) \
  311. )
  312. /**
  313. * @brief Enable the COMP Exti Line.
  314. * @param __EXTILINE__: specifies the COMP Exti sources to be enabled.
  315. * This parameter can be a value of @ref COMP_ExtiLineEvent
  316. * @retval None.
  317. */
  318. #define __HAL_COMP_EXTI_ENABLE_IT(__EXTILINE__) (SET_BIT(EXTI->IMR, (__EXTILINE__)))
  319. /**
  320. * @brief Disable the COMP Exti Line.
  321. * @param __EXTILINE__: specifies the COMP Exti sources to be disabled.
  322. * This parameter can be a value of @ref COMP_ExtiLineEvent
  323. * @retval None.
  324. */
  325. #define __HAL_COMP_EXTI_DISABLE_IT(__EXTILINE__) (CLEAR_BIT(EXTI->IMR, (__EXTILINE__)))
  326. /**
  327. * @brief Checks whether the specified EXTI line flag is set or not.
  328. * @param __FLAG__: specifies the COMP Exti sources to be checked.
  329. * This parameter can be a value of @ref COMP_ExtiLineEvent
  330. * @retval The state of __FLAG__ (SET or RESET).
  331. */
  332. #define __HAL_COMP_EXTI_GET_FLAG(__FLAG__) (READ_BIT(EXTI->PR, (__FLAG__)))
  333. /**
  334. * @brief Clear the COMP Exti flags.
  335. * @param __FLAG__: specifies the COMP Exti sources to be cleared.
  336. * This parameter can be a value of @ref COMP_ExtiLineEvent
  337. * @retval None.
  338. */
  339. #define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__) (EXTI->PR = (__FLAG__))
  340. /**
  341. * @brief Generates a Software interrupt on selected EXTI line.
  342. * @param __EXTILINE__: specifies the COMP Exti sources to trig.
  343. * This parameter can be a value of @ref COMP_ExtiLineEvent
  344. * @retval None
  345. */
  346. #define __HAL_COMP_EXTI_GENERATE_SWIT(__EXTILINE__) (SET_BIT(EXTI->SWIER, (__EXTILINE__)))
  347. /**
  348. * @}
  349. */
  350. /* Private macro -------------------------------------------------------------*/
  351. /** @defgroup COMP_Private_Macro COMP Private Macro
  352. * @{
  353. */
  354. /**
  355. * @brief Select the COMP register CSR bit CMPxOUT corresponding to the
  356. * selected COMP instance.
  357. * @param __HANDLE__: COMP handle
  358. * @retval Comparator register CSR bit COMP_CSR_CMP1OUT or COMP_CSR_CMP2OUT
  359. */
  360. #define __COMP_CSR_CMPXOUT(__HANDLE__) \
  361. ( ( ((__HANDLE__)->Instance == COMP1) \
  362. )? \
  363. (COMP_CSR_CMP1OUT) \
  364. : \
  365. (COMP_CSR_CMP2OUT) \
  366. )
  367. /**
  368. * @brief Verification of COMP state: enabled or disabled
  369. * @param __HANDLE__: COMP handle
  370. * @retval SET (COMP enabled) or RESET (COMP disabled)
  371. */
  372. #define __COMP_IS_ENABLED(__HANDLE__) \
  373. ( ( ((__HANDLE__)->Instance == COMP1) \
  374. )? \
  375. (((READ_BIT(COMP->CSR , COMP_CSR_CMP1EN) == COMP_CSR_CMP1EN) \
  376. ) ? SET : RESET) \
  377. : \
  378. (((READ_BIT(COMP->CSR , COMP_CSR_INSEL) != RESET) \
  379. ) ? SET : RESET) \
  380. )
  381. /**
  382. * @}
  383. */
  384. /* Include COMP HAL Extension module */
  385. #include "stm32l1xx_hal_comp_ex.h"
  386. /* Exported functions --------------------------------------------------------*/
  387. /** @addtogroup COMP_Exported_Functions
  388. * @{
  389. */
  390. /* Initialization and de-initialization functions ******************************/
  391. /** @addtogroup COMP_Exported_Functions_Group1
  392. * @{
  393. */
  394. HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
  395. HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
  396. void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
  397. void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
  398. /**
  399. * @}
  400. */
  401. /* I/O operation functions *****************************************************/
  402. /** @addtogroup COMP_Exported_Functions_Group2
  403. * @{
  404. */
  405. HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
  406. HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
  407. HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
  408. HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
  409. void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
  410. /**
  411. * @}
  412. */
  413. /* Peripheral Control functions ************************************************/
  414. /** @addtogroup COMP_Exported_Functions_Group3
  415. * @{
  416. */
  417. HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
  418. uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
  419. /* Callback in Interrupt mode */
  420. void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
  421. /**
  422. * @}
  423. */
  424. /* Peripheral State functions **************************************************/
  425. /** @addtogroup COMP_Exported_Functions_Group4
  426. * @{
  427. */
  428. HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
  429. /**
  430. * @}
  431. */
  432. /**
  433. * @}
  434. */
  435. /**
  436. * @}
  437. */
  438. /**
  439. * @}
  440. */
  441. #ifdef __cplusplus
  442. }
  443. #endif
  444. #endif /* __STM32L1xx_HAL_COMP_H */
  445. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/