]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32L0/stm32l0xx_hal_comp.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32L0 / stm32l0xx_hal_comp.h
1 /**
2   ******************************************************************************
3   * @file    stm32l0xx_hal_comp.h
4   * @author  MCD Application Team
5   * @version V1.2.0
6   * @date    06-February-2015
7   * @brief   Header file of COMP HAL module.
8   ******************************************************************************
9   * @attention
10   *
11   * <h2><center>&copy; COPYRIGHT(c) 2015 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
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32L0xx_HAL_COMP_H
40 #define __STM32L0xx_HAL_COMP_H
41
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32l0xx_hal_def.h"
48
49 /** @addtogroup STM32L0xx_HAL_Driver
50   * @{
51   */
52
53 /** @defgroup COMP COMP
54   * @{
55   */ 
56
57 /* Exported types ------------------------------------------------------------*/ 
58
59 /** @defgroup COMP_Exported_Types COMP Exported Types
60   * @{
61   */
62
63    /** @defgroup COMP_Init COMP init configuration structure
64   * @{
65   */
66 /** 
67   * @brief  COMP Init structure definition  
68   */
69   
70 typedef struct
71 {
72
73   uint32_t InvertingInput;     /*!< Selects the inverting input of the comparator.
74                                     This parameter can be a value of @ref COMP_InvertingInput */
75
76   uint32_t NonInvertingInput;  /*!< Selects the non inverting input of the comparator.
77                                     This parameter can be a value of @ref COMP_NonInvertingInput */
78
79   uint32_t LPTIMConnection;     /*!< Selects if the COMP connection to the LPTIM is established or not.
80                                     This parameter can be a value of @ref COMP_LPTIMConnection */
81
82   uint32_t OutputPol;          /*!< Selects the output polarity of the comparator.
83                                     This parameter can be a value of @ref COMP_OutputPolarity */
84
85   uint32_t Mode;               /*!< Selects the operating comsumption mode of the comparator
86                                     to adjust the speed/consumption.
87                                     This parameter can be a value of @ref COMP_Mode */
88
89   uint32_t WindowMode;         /*!< Selects the window mode of the comparator 2.
90                                     This parameter can be a value of @ref COMP_WindowMode */
91
92   uint32_t TriggerMode;        /*!< Selects the trigger mode of the comparator (interrupt mode).
93                                     This parameter can be a value of @ref COMP_TriggerMode */
94   
95 }COMP_InitTypeDef;
96
97 /**
98   * @}
99   */
100
101 /** @defgroup COMP_state COMP state definition
102   * @{
103   */
104 /** 
105   * @brief  HAL State structures definition  
106   */ 
107 typedef enum
108 {
109   HAL_COMP_STATE_RESET             = 0x00,    /*!< COMP not yet initialized or disabled             */
110   HAL_COMP_STATE_READY             = 0x01,    /*!< COMP initialized and ready for use               */
111   HAL_COMP_STATE_READY_LOCKED      = 0x11,    /*!< COMP initialized but the configuration is locked */
112   HAL_COMP_STATE_BUSY              = 0x02,    /*!< COMP is running                                  */
113   HAL_COMP_STATE_BUSY_LOCKED       = 0x12     /*!< COMP is running and the configuration is locked  */
114 }HAL_COMP_StateTypeDef;
115 /**
116   * @}
117   */
118
119 /** @defgroup COMP_handle COMP handler
120   * @{
121   */
122 /** 
123   * @brief  COMP Handle Structure definition  
124   */ 
125 typedef struct
126 {
127   COMP_TypeDef       *Instance;       /*!< Register base address    */
128   COMP_InitTypeDef   Init;            /*!< COMP required parameters */
129   HAL_LockTypeDef    Lock;            /*!< Locking object           */
130   __IO HAL_COMP_StateTypeDef  State;  /*!< COMP communication state */
131 } COMP_HandleTypeDef;
132
133 /**
134   * @}
135   */
136 /**
137   * @}
138   */
139
140 /* Exported constants --------------------------------------------------------*/
141 /** @defgroup COMP_Exported_Constants COMP Exported Constants
142   * @{
143   */
144
145 /** @defgroup COMP_OutputPolarity COMP output polarity definitions
146   * @{
147   */
148 #define COMP_OUTPUTPOL_NONINVERTED             ((uint32_t)0x00000000)  /*!< COMP output on GPIO isn't inverted */
149 #define COMP_OUTPUTPOL_INVERTED                COMP_CSR_COMPxPOLARITY       /*!< COMP output on GPIO is inverted */
150 #define IS_COMP_OUTPUTPOL(POL)  (((POL) == COMP_OUTPUTPOL_NONINVERTED)  || \
151                                  ((POL) == COMP_OUTPUTPOL_INVERTED))
152 /**
153   * @}
154   */ 
155
156
157 /** @defgroup COMP_InvertingInput COMP inverting input definitions
158   * @{
159   */
160
161 /* Inverting Input specific to COMP1 */
162 #define COMP_INVERTINGINPUT_VREFINT             ((uint32_t)0x00000000) /*!< VREFINT connected to comparator1 inverting input */
163 #define COMP_INVERTINGINPUT_IO1                 ((uint32_t)0x00000010) /*!< I/O1 connected to comparator inverting input (PA0) for COMP1 and (PA2) for COMP2*/
164 #define COMP_INVERTINGINPUT_DAC1                ((uint32_t)0x00000020) /*!< DAC1_OUT (PA4) connected to comparator inverting input */
165 #define COMP_INVERTINGINPUT_IO2                 ((uint32_t)0x00000030) /*!< I/O2 (PA5) connected to comparator inverting input */
166
167 /* Inverting Input specific to COMP2 */
168 #define COMP_INVERTINGINPUT_1_4VREFINT          ((uint32_t)0x00000040) /*!< 1/4 VREFINT connected to comparator inverting input */
169 #define COMP_INVERTINGINPUT_1_2VREFINT          ((uint32_t)0x00000050) /*!< 1/2 VREFINT connected to comparator inverting input */
170 #define COMP_INVERTINGINPUT_3_4VREFINT          ((uint32_t)0x00000060) /*!< 3/4 VREFINT connected to comparator inverting input */
171 #define COMP_INVERTINGINPUT_IO3                 ((uint32_t)0x00000070) /*!< I/O3 (PB3) for COMP2 connected to comparator inverting input */
172
173
174 #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_VREFINT)     || \
175                                         ((INPUT) == COMP_INVERTINGINPUT_IO1)         || \
176                                         ((INPUT) == COMP_INVERTINGINPUT_DAC1)        || \
177                                         ((INPUT) == COMP_INVERTINGINPUT_IO2)         || \
178                                         ((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT)  || \
179                                         ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT)  || \
180                                         ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT)   || \
181                                         ((INPUT) == COMP_INVERTINGINPUT_IO3))
182
183 /**
184   * @}
185   */ 
186
187
188 /** @defgroup COMP_NonInvertingInput COMP non inverting input definitions
189   * @{
190   */
191
192 #define COMP_NONINVERTINGINPUT_IO1                 ((uint32_t)0x00000000) /*!< I/O1 (PA3) connected to comparator non inverting input */
193 #define COMP_NONINVERTINGINPUT_IO2                 ((uint32_t)0x00000100) /*!< I/O2 (PB4) connected to comparator non inverting input */
194 #define COMP_NONINVERTINGINPUT_IO3                 ((uint32_t)0x00000200) /*!< I/O3 (PB5) connected to comparator non inverting input */
195 #define COMP_NONINVERTINGINPUT_IO4                 ((uint32_t)0x00000300) /*!< I/O1 (PB6) connected to comparator non inverting input */
196 #define COMP_NONINVERTINGINPUT_IO5                 ((uint32_t)0x00000400) /*!< I/O3 (PB7) connected to comparator non inverting input */
197 #define COMP_NONINVERTINGINPUT_IO6                 ((uint32_t)0x00000500) /*!< I/O3 (PB7) connected to comparator non inverting input */
198 #define COMP_NONINVERTINGINPUT_IO7                 ((uint32_t)0x00000600) /*!< I/O3 (PB7) connected to comparator non inverting input */
199 #define COMP_NONINVERTINGINPUT_IO8                 ((uint32_t)0x00000700) /*!< I/O3 (PB7) connected to comparator non inverting input */
200
201 #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
202                                            ((INPUT) == COMP_NONINVERTINGINPUT_IO2) || \
203                                            ((INPUT) == COMP_NONINVERTINGINPUT_IO3) || \
204                                            ((INPUT) == COMP_NONINVERTINGINPUT_IO4) || \
205                                            ((INPUT) == COMP_NONINVERTINGINPUT_IO5) || \
206                                            ((INPUT) == COMP_NONINVERTINGINPUT_IO6) || \
207                                            ((INPUT) == COMP_NONINVERTINGINPUT_IO7) || \
208                                            ((INPUT) == COMP_NONINVERTINGINPUT_IO8))
209 /**
210   * @}
211   */ 
212
213
214 /** @defgroup COMP_Mode COMP mode definition
215   * @{
216   */
217 /* Please refer to the electrical characteristics in the device datasheet for
218    the power consumption values */
219 #define COMP_MODE_HIGHSPEED         COMP_CSR_COMP2SPEED     /*!< High Speed */
220 #define COMP_MODE_LOWSPEED          ((uint32_t)0x00000000)  /*!< Low Speed */ 
221
222 #define IS_COMP_MODE(SPEED)    (((SPEED) == COMP_MODE_HIGHSPEED) || \
223                                  ((SPEED) == COMP_MODE_LOWSPEED))
224 /**
225   * @}
226   */
227
228 /** @defgroup COMP_WindowMode COMP window mode definition
229   * @{
230   */
231 #define COMP_WINDOWMODE_DISABLE               ((uint32_t)0x00000000)  /*!< Window mode disabled (Plus input of comparator 1 connected to PA1)*/
232 #define COMP_WINDOWMODE_ENABLE                COMP_CSR_COMP1WM    /*!< Window mode enabled: Plus input of comparator 1 shorted with Plus input of comparator 2 */
233 #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLE) || \
234                                         ((WINDOWMODE) == COMP_WINDOWMODE_ENABLE))
235
236 #if defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L082xx) || defined (STM32L083xx)
237 #define IS_COMP_WINDOWMODE_INSTANCE(INSTANCE) (((INSTANCE) == COMP1) ||\
238                                                ((INSTANCE) == COMP2))
239 #else
240 #define IS_COMP_WINDOWMODE_INSTANCE(INSTANCE) ((INSTANCE) == COMP1)
241 #endif
242 /**
243   * @}
244   */
245
246 /** @defgroup COMP_LPTIMConnection COMP Low power timer connection definition
247   * @{
248   */
249 #define COMP_LPTIMCONNECTION_DISABLED               ((uint32_t)0x00000000)  /*!< COMPx signal is gated */
250 #define COMP_LPTIMCONNECTION_ENABLED                COMP_CSR_COMP1LPTIM1IN1    /*!< COMPx signal is connected to LPTIM */
251 #define IS_COMP_LPTIMCONNECTION(LPTIMCONNECTION)   (((LPTIMCONNECTION) == COMP_LPTIMCONNECTION_DISABLED) || \
252                                                     ((LPTIMCONNECTION) == COMP_LPTIMCONNECTION_ENABLED))
253
254 /**
255   * @}
256   */
257
258 /** @defgroup COMP_OutputLevel COMP output level definition
259   * @{
260   */ 
261 /* When output polarity is not inverted, comparator output is low when
262    the non-inverting input is at a lower voltage than the inverting input*/
263 #define COMP_OUTPUTLEVEL_LOW                   ((uint32_t)0x00000000)
264 /* When output polarity is not inverted, comparator output is high when
265    the non-inverting input is at a higher voltage than the inverting input */
266 #define COMP_OUTPUTLEVEL_HIGH                  COMP_CSR_COMPxOUTVALUE
267 /**
268   * @}
269   */ 
270
271 /* CSR register Mask */ 
272 #define COMP_CSR_UPDATE_PARAMETERS_MASK        ((uint32_t)0xC0008779)
273   
274 #define COMP_LOCK_DISABLE                      ((uint32_t)0x00000000)
275 #define COMP_LOCK_ENABLE                       COMP_CSR_COMPxLOCK
276
277 #define COMP_STATE_BIT_LOCK                    ((uint32_t)0x10)
278
279 /** @defgroup COMP_TriggerMode COMP trigger mode definition
280   * @{
281   */
282 #define COMP_TRIGGERMODE_IT_RISING             ((uint32_t)0x00000001)   /*!< External Interrupt Mode with Rising edge trigger detection */
283 #define COMP_TRIGGERMODE_IT_FALLING            ((uint32_t)0x00000002)   /*!< External Interrupt Mode with Falling edge trigger detection */
284 #define COMP_TRIGGERMODE_IT_RISING_FALLING     ((uint32_t)0x00000003)   /*!< External Interrupt Mode with Rising/Falling edge trigger detection */
285 #define IS_COMP_TRIGGERMODE(MODE)  (((MODE) == COMP_TRIGGERMODE_IT_RISING)  || \
286                                     ((MODE) == COMP_TRIGGERMODE_IT_FALLING) || \
287                                     ((MODE) == COMP_TRIGGERMODE_IT_RISING_FALLING))
288 /**
289   * @}
290   */ 
291
292 /** @defgroup COMP_ExtiLineEvent COMP EXTI line definition
293   * @{
294   */
295
296 #define COMP_EXTI_LINE_COMP2             ((uint32_t)0x00400000)  /*!< External interrupt line 22 Connected to COMP2 */
297 #define COMP_EXTI_LINE_COMP1             ((uint32_t)0x00200000)  /*!< External interrupt line 21 Connected to COMP1 */
298
299
300 /**
301   * @}
302   */ 
303 /**
304   * @}
305   */
306   
307 /* Exported macro ------------------------------------------------------------*/
308 /** @brief Reset COMP handle state
309   * @param  __HANDLE__: COMP handle.
310   * @retval None
311   */
312
313 /** @defgroup COMP_Exported_Macro COMP Exported Macro
314   * @{
315   */
316 /**
317   * @brief Reset the state machine associated to the handler
318   * @param  __HANDLE__: COMP handle.
319   * @retval None.
320   */
321
322 #define __HAL_COMP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_COMP_STATE_RESET)
323
324 /**
325   * @brief Enables the specified comparator
326   * @param  __HANDLE__: COMP handle.
327   * @retval None.
328   */
329 #define __HAL_COMP_ENABLE(__HANDLE__)          ((__HANDLE__)->Instance->CSR |= (COMP_CSR_COMPxEN))
330
331 /**
332   * @brief Disables the specified comparator
333   * @param  __HANDLE__: COMP handle.
334   * @retval None.
335   */
336 #define __HAL_COMP_DISABLE(__HANDLE__)         ((__HANDLE__)->Instance->CSR &= ~(COMP_CSR_COMPxEN))
337
338 /**
339   * @brief Lock the specified comparator configuration
340   * @param  __HANDLE__: COMP handle.
341   * @retval None.
342   */
343 #define __HAL_COMP_LOCK(__HANDLE__)            ((__HANDLE__)->Instance->CSR |= COMP_CSR_COMPxLOCK)
344
345 /** @brief  Checks whether the specified COMP flag is set or not.
346  *  @param  __HANDLE__: COMP handle.
347   * @param  __FLAG__: specifies the flag to check.
348   *        This parameter can be one of the following values:
349   *            @arg COMP_FLAG_LOCK:  lock flag
350   * @retval The new state of __FLAG__ (TRUE or FALSE).
351   */
352 #define __HAL_COMP_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->CSR & (__FLAG__)) == (__FLAG__))   
353
354 /**
355   * @brief  Enable the Exti Line rising edge trigger.
356   */                          
357 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE()    SET_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP1)
358 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE()    SET_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP2)
359
360 /**
361   * @brief  Disable the Exti Line rising edge trigger.
362   */                                         
363 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE()   CLEAR_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP1)
364 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE()   CLEAR_BIT(EXTI->RTSR, COMP_EXTI_LINE_COMP2)
365
366 /**
367   * @brief Enable the Exti Line falling edge trigger.
368   * @retval None.
369   */                                         
370 #define __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE()   SET_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP1)
371 #define __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE()   SET_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP2)
372
373 /**
374   * @brief  Disable the Exti Line falling edge trigger.
375   */                                         
376 #define __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE()  CLEAR_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP1)
377 #define __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE()  CLEAR_BIT(EXTI->FTSR, COMP_EXTI_LINE_COMP2)
378
379 /**
380   * @brief Enable the COMP1 EXTI line rising & falling edge trigger.
381   * @retval None.
382   */                                         
383 #define __HAL_COMP_COMP1_EXTI_ENABLE_RISING_FALLING_EDGE()   do { \
384                                                                __HAL_COMP_COMP1_EXTI_ENABLE_RISING_EDGE(); \
385                                                                __HAL_COMP_COMP1_EXTI_ENABLE_FALLING_EDGE(); \
386                                                              } while(0)
387
388 /**
389   * @brief  Disable the COMP1 EXTI line rising & falling edge trigger.
390   * @retval None.
391   */                                         
392 #define __HAL_COMP_COMP1_EXTI_DISABLE_RISING_FALLING_EDGE()  do { \
393                                                                __HAL_COMP_COMP1_EXTI_DISABLE_RISING_EDGE(); \
394                                                                __HAL_COMP_COMP1_EXTI_DISABLE_FALLING_EDGE(); \
395                                                              } while(0)
396
397 /**
398   * @brief Enable the COMP2 EXTI line rising & falling edge trigger.
399   * @retval None.
400   */                                         
401 #define __HAL_COMP_COMP2_EXTI_ENABLE_RISING_FALLING_EDGE()   do { \
402                                                                __HAL_COMP_COMP2_EXTI_ENABLE_RISING_EDGE(); \
403                                                                __HAL_COMP_COMP2_EXTI_ENABLE_FALLING_EDGE(); \
404                                                              } while(0)
405
406 /**
407   * @brief  Disable the COMP2 EXTI line rising & falling edge trigger.
408   * @retval None.
409   */                                         
410 #define __HAL_COMP_COMP2_EXTI_DISABLE_RISING_FALLING_EDGE()   do { \
411                                                                __HAL_COMP_COMP2_EXTI_DISABLE_RISING_EDGE(); \
412                                                                __HAL_COMP_COMP2_EXTI_DISABLE_FALLING_EDGE(); \
413                                                              } while(0)
414                                                                                                                        
415 /**
416   * @brief  Get the specified EXTI line for a comparator instance
417   * @param  __INSTANCE__: specifies the COMP instance.
418   * @retval value of @ref COMP_ExtiLineEvent
419   */
420 #define COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1 : \
421                                                 COMP_EXTI_LINE_COMP2)
422
423 /**
424   * @brief Enable the COMP Exti Line.
425   * @retval None.
426   */                                         
427
428 #define __HAL_COMP_COMP1_EXTI_ENABLE_IT()             SET_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP1)
429 #define __HAL_COMP_COMP2_EXTI_ENABLE_IT()             SET_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP2)
430
431 /**
432   * @brief Disable the COMP Exti Line.
433   * @retval None.
434   */
435
436 #define __HAL_COMP_COMP1_EXTI_DISABLE_IT()            CLEAR_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP1)
437 #define __HAL_COMP_COMP2_EXTI_DISABLE_IT()            CLEAR_BIT(EXTI->IMR, COMP_EXTI_LINE_COMP2)
438
439 /**
440   * @brief  Generate a software interrupt on the COMP EXTI line.
441   * @retval None
442   */
443 #define __HAL_COMP_COMP1_EXTI_GENERATE_SWIT()         SET_BIT(EXTI->SWIER, COMP_EXTI_LINE_COMP1)
444 #define __HAL_COMP_COMP2_EXTI_GENERATE_SWIT()         SET_BIT(EXTI->SWIER, COMP_EXTI_LINE_COMP2)
445
446
447 /**
448   * @brief  Enable the COMP EXTI Line in event mode
449   * @retval None
450   */
451 #define __HAL_COMP_COMP1_EXTI_ENABLE_EVENT()           SET_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP1)
452 #define __HAL_COMP_COMP2_EXTI_ENABLE_EVENT()           SET_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP2)
453
454 /**
455   * @brief  Disable the COMP EXTI Line in event mode.
456   * @retval None
457   */
458 #define __HAL_COMP_COMP1_EXTI_DISABLE_EVENT()          CLEAR_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP1)
459 #define __HAL_COMP_COMP2_EXTI_DISABLE_EVENT()          CLEAR_BIT(EXTI->EMR, COMP_EXTI_LINE_COMP2)
460 /**
461   * @brief  Checks whether the specified EXTI line flag is set or not.
462   * @retval The state of __FLAG__ (SET or RESET).
463   */
464
465 #define __HAL_COMP_COMP1_EXTI_GET_FLAG()              READ_BIT(EXTI->PR, COMP_EXTI_LINE_COMP1)
466 #define __HAL_COMP_COMP2_EXTI_GET_FLAG()              READ_BIT(EXTI->PR, COMP_EXTI_LINE_COMP2)
467      
468 /**
469   * @brief Clear the COMP Exti flags.
470   * @retval None.
471   */
472 #define __HAL_COMP_COMP1_EXTI_CLEAR_FLAG()            WRITE_REG(EXTI->PR, COMP_EXTI_LINE_COMP1)
473 #define __HAL_COMP_COMP2_EXTI_CLEAR_FLAG()            WRITE_REG(EXTI->PR, COMP_EXTI_LINE_COMP2)
474
475
476 /**
477   * @}
478   */
479
480 /* Include COMP HAL Extended module */
481 #include "stm32l0xx_hal_comp_ex.h"
482
483 /* Exported functions --------------------------------------------------------*/
484 /** @defgroup COMP_Exported_Functions COMP Exported Functions
485   * @{
486   */
487
488 /** @defgroup COMP_Exported_Functions_Group1 Initialization/de-initialization functions
489   * @{
490   */
491
492 /* Initialization/de-initialization functions  **********************************/
493 HAL_StatusTypeDef HAL_COMP_Init(COMP_HandleTypeDef *hcomp);
494 HAL_StatusTypeDef HAL_COMP_DeInit (COMP_HandleTypeDef *hcomp);
495 void HAL_COMP_MspInit(COMP_HandleTypeDef *hcomp);
496 void HAL_COMP_MspDeInit(COMP_HandleTypeDef *hcomp);
497 /**
498   * @}
499   */
500
501 /** @defgroup COMP_Exported_Functions_Group2 I/O operation functions
502   * @{
503   */
504 /* I/O operation functions  *****************************************************/
505 HAL_StatusTypeDef HAL_COMP_Start(COMP_HandleTypeDef *hcomp);
506 HAL_StatusTypeDef HAL_COMP_Stop(COMP_HandleTypeDef *hcomp);
507 HAL_StatusTypeDef HAL_COMP_Start_IT(COMP_HandleTypeDef *hcomp);
508 HAL_StatusTypeDef HAL_COMP_Stop_IT(COMP_HandleTypeDef *hcomp);
509 void HAL_COMP_IRQHandler(COMP_HandleTypeDef *hcomp);
510 /**
511   * @}
512   */
513
514 /** @defgroup COMP_Exported_Functions_Group3 Peripheral Control functions
515   * @{
516   */
517 /* Peripheral Control functions  ************************************************/
518 HAL_StatusTypeDef HAL_COMP_Lock(COMP_HandleTypeDef *hcomp);
519 uint32_t HAL_COMP_GetOutputLevel(COMP_HandleTypeDef *hcomp);
520
521 /* Callback in Interrupt mode */
522 void HAL_COMP_TriggerCallback(COMP_HandleTypeDef *hcomp);
523 /**
524   * @}
525   */
526
527 /** @defgroup COMP_Exported_Functions_Group4 Peripheral State functions
528   * @{
529   */
530 /* Peripheral State functions  **************************************************/
531 HAL_COMP_StateTypeDef HAL_COMP_GetState(COMP_HandleTypeDef *hcomp);
532
533 /**
534   * @}
535   */
536
537
538 /**
539   * @}
540   */
541
542 /**
543   * @}
544   */
545
546 /**
547   * @}
548   */ 
549
550 #ifdef __cplusplus
551 }
552 #endif
553
554 #endif /* __STM32L0xx_HAL_COMP_H */
555
556 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
557