Merge pull request #93 from zyp/master
[fw/stlink] / example / libs_stm / inc / stm32l1xx / stm32l1xx_comp.h
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l1xx_comp.h\r
4   * @author  MCD Application Team\r
5   * @version V1.0.0\r
6   * @date    31-December-2010\r
7   * @brief   This file contains all the functions prototypes for the COMP firmware \r
8   *          library.\r
9   ******************************************************************************\r
10   * @attention\r
11   *\r
12   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
13   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
14   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
15   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
16   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
17   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
18   *\r
19   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>\r
20   ******************************************************************************  \r
21   */ \r
22 \r
23 /* Define to prevent recursive inclusion -------------------------------------*/\r
24 #ifndef __STM32L1xx_COMP_H\r
25 #define __STM32L1xx_COMP_H\r
26 \r
27 #ifdef __cplusplus\r
28  extern "C" {\r
29 #endif\r
30 \r
31 /* Includes ------------------------------------------------------------------*/\r
32 #include "stm32l1xx.h"\r
33 \r
34 /** @addtogroup STM32L1xx_StdPeriph_Driver\r
35   * @{\r
36   */\r
37 \r
38 /** @addtogroup COMP\r
39   * @{\r
40   */\r
41 \r
42 /* Exported types ------------------------------------------------------------*/\r
43 \r
44 /** \r
45   * @brief  COMP Init structure definition  \r
46   */\r
47   \r
48 typedef struct\r
49 {\r
50   uint32_t COMP_Speed;               /*!< Defines the speed of comparator 2.\r
51                                           This parameter can be a value of @ref COMP_Speed */\r
52   uint32_t COMP_InvertingInput;      /*!< Selects the inverting input of the comparator 2.\r
53                                           This parameter can be a value of @ref COMP_InvertingInput */\r
54   uint32_t COMP_OutputSelect;        /*!< Selects the output redirection of the comparator 2.\r
55                                           This parameter can be a value of @ref COMP_OutputSelect */\r
56    \r
57 }COMP_InitTypeDef;\r
58 \r
59 /* Exported constants --------------------------------------------------------*/\r
60    \r
61 /** @defgroup COMP_Exported_Constants\r
62   * @{\r
63   */ \r
64 \r
65 #define COMP_OutputLevel_High                   ((uint32_t)0x00000001)\r
66 #define COMP_OutputLevel_Low                    ((uint32_t)0x00000000)\r
67 \r
68 /** @defgroup COMP_Selection\r
69   * @{\r
70   */\r
71 \r
72 #define COMP_Selection_COMP1                    ((uint32_t)0x00000001)\r
73 #define COMP_Selection_COMP2                    ((uint32_t)0x00000002)\r
74 \r
75 #define IS_COMP_ALL_PERIPH(PERIPH) (((PERIPH) == COMP_Selection_COMP1) || \\r
76                                     ((PERIPH) == COMP_Selection_COMP2))\r
77  \r
78 /**\r
79   * @}\r
80   */ \r
81 \r
82 /** @defgroup COMP_InvertingInput\r
83   * @{\r
84   */\r
85 \r
86 #define COMP_InvertingInput_None                ((uint32_t)0x00000000) /* COMP2 is disabled when this parameter is selected */\r
87 #define COMP_InvertingInput_IO                  ((uint32_t)0x00040000)\r
88 #define COMP_InvertingInput_VREFINT             ((uint32_t)0x00080000)\r
89 #define COMP_InvertingInput_3_4VREFINT          ((uint32_t)0x000C0000)\r
90 #define COMP_InvertingInput_1_2VREFINT          ((uint32_t)0x00100000)\r
91 #define COMP_InvertingInput_1_4VREFINT          ((uint32_t)0x00140000)\r
92 #define COMP_InvertingInput_DAC1                ((uint32_t)0x00180000)\r
93 #define COMP_InvertingInput_DAC2                ((uint32_t)0x001C0000)\r
94 \r
95 #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_None) || \\r
96                                         ((INPUT) == COMP_InvertingInput_IO) || \\r
97                                         ((INPUT) == COMP_InvertingInput_VREFINT) || \\r
98                                         ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \\r
99                                         ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \\r
100                                         ((INPUT) == COMP_InvertingInput_1_4VREFINT) || \\r
101                                         ((INPUT) == COMP_InvertingInput_DAC1) || \\r
102                                         ((INPUT) == COMP_InvertingInput_DAC2))\r
103 /**\r
104   * @}\r
105   */ \r
106 \r
107 /** @defgroup COMP_OutputSelect\r
108   * @{\r
109   */\r
110 \r
111 #define COMP_OutputSelect_TIM2IC4               ((uint32_t)0x00000000)\r
112 #define COMP_OutputSelect_TIM2OCREFCLR          ((uint32_t)0x00200000)\r
113 #define COMP_OutputSelect_TIM3IC4               ((uint32_t)0x00400000)\r
114 #define COMP_OutputSelect_TIM3OCREFCLR          ((uint32_t)0x00600000)\r
115 #define COMP_OutputSelect_TIM4IC4               ((uint32_t)0x00800000)\r
116 #define COMP_OutputSelect_TIM4OCREFCLR          ((uint32_t)0x00A00000)\r
117 #define COMP_OutputSelect_TIM10IC1              ((uint32_t)0x00C00000)\r
118 #define COMP_OutputSelect_None                  ((uint32_t)0x00E00000)\r
119 \r
120 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OutputSelect_TIM2IC4) || \\r
121                                 ((OUTPUT) == COMP_OutputSelect_TIM2OCREFCLR) || \\r
122                                 ((OUTPUT) == COMP_OutputSelect_TIM3IC4) || \\r
123                                 ((OUTPUT) == COMP_OutputSelect_TIM3OCREFCLR) || \\r
124                                 ((OUTPUT) == COMP_OutputSelect_TIM4IC4) || \\r
125                                 ((OUTPUT) == COMP_OutputSelect_TIM4OCREFCLR) || \\r
126                                 ((OUTPUT) == COMP_OutputSelect_TIM10IC1) || \\r
127                                 ((OUTPUT) == COMP_OutputSelect_None))\r
128 /**\r
129   * @}\r
130   */ \r
131   \r
132 /** @defgroup COMP_Speed\r
133   * @{\r
134   */\r
135 \r
136 #define COMP_Speed_Slow                         ((uint32_t)0x00000000)\r
137 #define COMP_Speed_Fast                         ((uint32_t)0x00001000)\r
138 \r
139 #define IS_COMP_SPEED(SPEED)    (((SPEED) == COMP_Speed_Slow) || \\r
140                                  ((SPEED) == COMP_Speed_Fast))\r
141 /**\r
142   * @}\r
143   */\r
144   \r
145 /**\r
146   * @}\r
147   */ \r
148 \r
149 /* Exported macro ------------------------------------------------------------*/\r
150 /* Exported functions ------------------------------------------------------- */\r
151 \r
152 /*  Function used to set the COMP configuration to the default reset state ****/\r
153 void COMP_DeInit(void);\r
154 \r
155 /* Initialization and Configuration functions *********************************/\r
156 void COMP_Init(COMP_InitTypeDef* COMP_InitStruct);\r
157 void COMP_Cmd(FunctionalState NewState);\r
158 uint8_t COMP_GetOutputLevel(uint32_t COMP_Selection);\r
159 \r
160 /* Window mode control function ***********************************************/\r
161 void COMP_WindowCmd(FunctionalState NewState);\r
162 \r
163 /* Internal Reference Voltage (VREFINT) output function ***********************/\r
164 void COMP_VrefintOutputCmd(FunctionalState NewState);\r
165 \r
166 #ifdef __cplusplus\r
167 }\r
168 #endif\r
169 \r
170 #endif /*__STM32L1xx_COMP_H */\r
171 \r
172 /**\r
173   * @}\r
174   */ \r
175 \r
176 /**\r
177   * @}\r
178   */\r
179 \r
180 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/\r