]> git.sur5r.net Git - freertos/blob - Demo/CORTEX_M0_STM32F0518_IAR/Libraries/STM32F0xx_StdPeriph_Driver/inc/stm32f0xx_comp.h
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / CORTEX_M0_STM32F0518_IAR / Libraries / STM32F0xx_StdPeriph_Driver / inc / stm32f0xx_comp.h
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32f0xx_comp.h\r
4   * @author  MCD Application Team\r
5   * @version V1.0.0RC1\r
6   * @date    27-January-2012\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   * FOR MORE INFORMATION PLEASE READ CAREFULLY THE LICENSE AGREEMENT FILE\r
20   * LOCATED IN THE ROOT DIRECTORY OF THIS FIRMWARE PACKAGE.\r
21   *\r
22   * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>\r
23   ******************************************************************************\r
24   */\r
25 \r
26 /* Define to prevent recursive inclusion -------------------------------------*/\r
27 #ifndef __STM32F0XX_COMP_H\r
28 #define __STM32F0XX_COMP_H\r
29 \r
30 #ifdef __cplusplus\r
31  extern "C" {\r
32 #endif\r
33 \r
34 /* Includes ------------------------------------------------------------------*/\r
35 #include "stm32f0xx.h"\r
36 \r
37 /** @addtogroup STM32F0xx_StdPeriph_Driver\r
38   * @{\r
39   */\r
40 \r
41 /** @addtogroup COMP\r
42   * @{\r
43   */\r
44 \r
45 /* Exported types ------------------------------------------------------------*/\r
46 \r
47 /** \r
48   * @brief  COMP Init structure definition  \r
49   */\r
50   \r
51 typedef struct\r
52 {\r
53 \r
54   uint32_t COMP_InvertingInput;     /*!< Selects the inverting input of the comparator.\r
55                                           This parameter can be a value of @ref COMP_InvertingInput */\r
56 \r
57   uint32_t COMP_Output;             /*!< Selects the output redirection of the comparator.\r
58                                           This parameter can be a value of @ref COMP_Output */\r
59 \r
60   uint32_t COMP_OutputPol;           /*!< Selects the output polarity of the comparator.\r
61                                           This parameter can be a value of @ref COMP_OutputPolarity */\r
62 \r
63   uint32_t COMP_Hysteresis;         /*!< Selects the hysteresis voltage of the comparator.\r
64                                           This parameter can be a value of @ref COMP_Hysteresis */\r
65 \r
66   uint32_t COMP_Mode;               /*!< Selects the operating mode of the comparator\r
67                                          and allows to adjust the speed/consumption.\r
68                                           This parameter can be a value of @ref COMP_Mode */\r
69 \r
70 }COMP_InitTypeDef;\r
71 \r
72 /* Exported constants --------------------------------------------------------*/\r
73    \r
74 /** @defgroup COMP_Exported_Constants\r
75   * @{\r
76   */ \r
77 \r
78 /** @defgroup COMP_Selection\r
79   * @{\r
80   */\r
81 \r
82 #define COMP_Selection_COMP1                    ((uint32_t)0x00000000) /*!< COMP1 Selection */\r
83 #define COMP_Selection_COMP2                    ((uint32_t)0x00000010) /*!< COMP2 Selection */\r
84 \r
85 #define IS_COMP_ALL_PERIPH(PERIPH) (((PERIPH) == COMP_Selection_COMP1) || \\r
86                                     ((PERIPH) == COMP_Selection_COMP2))\r
87  \r
88 /**\r
89   * @}\r
90   */ \r
91 \r
92 /** @defgroup COMP_InvertingInput\r
93   * @{\r
94   */\r
95 \r
96 #define COMP_InvertingInput_1_4VREFINT          ((uint32_t)0x00000000) /*!< 1/4 VREFINT connected to comparator inverting input */\r
97 #define COMP_InvertingInput_1_2VREFINT          COMP_CSR_COMP1INSEL_0 /*!< 1/2 VREFINT connected to comparator inverting input */\r
98 #define COMP_InvertingInput_3_4VREFINT          COMP_CSR_COMP1INSEL_1 /*!< 3/4 VREFINT connected to comparator inverting input */\r
99 #define COMP_InvertingInput_VREFINT             ((uint32_t)0x00000030) /*!< VREFINT connected to comparator inverting input */\r
100 #define COMP_InvertingInput_DAC1                COMP_CSR_COMP1INSEL_2 /*!< DAC1_OUT connected to comparator inverting input */\r
101 #define COMP_InvertingInput_IO                  ((uint32_t)0x00000060) /*!< I/O (PA0 for COMP1 and PA2 for COMP2) connected to comparator inverting input */\r
102 \r
103 #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_1_4VREFINT) || \\r
104                                         ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \\r
105                                         ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \\r
106                                         ((INPUT) == COMP_InvertingInput_VREFINT)    || \\r
107                                         ((INPUT) == COMP_InvertingInput_DAC1)       || \\r
108                                         ((INPUT) == COMP_InvertingInput_1_4VREFINT) || \\r
109                                         ((INPUT) == COMP_InvertingInput_IO))\r
110 /**\r
111   * @}\r
112   */ \r
113   \r
114 /** @defgroup COMP_Output\r
115   * @{\r
116   */\r
117 \r
118 #define COMP_Output_None                  ((uint32_t)0x00000000)   /*!< COMP output isn't connected to other peripherals */\r
119 #define COMP_Output_TIM1BKIN              COMP_CSR_COMP1OUTSEL_0   /*!< COMP output connected to TIM1 Break Input (BKIN) */\r
120 #define COMP_Output_TIM1IC1               COMP_CSR_COMP1OUTSEL_1   /*!< COMP output connected to TIM1 Input Capture 1 */\r
121 #define COMP_Output_TIM1OCREFCLR          ((uint32_t)0x00000300)   /*!< COMP output connected to TIM1 OCREF Clear */\r
122 #define COMP_Output_TIM2IC4               COMP_CSR_COMP1OUTSEL_2   /*!< COMP output connected to TIM2 Input Capture 4 */\r
123 #define COMP_Output_TIM2OCREFCLR          ((uint32_t)0x00000500)   /*!< COMP output connected to TIM2 OCREF Clear */\r
124 #define COMP_Output_TIM3IC1               ((uint32_t)0x00000600)   /*!< COMP output connected to TIM3 Input Capture 1 */\r
125 #define COMP_Output_TIM3OCREFCLR          COMP_CSR_COMP1OUTSEL     /*!< COMP output connected to TIM3 OCREF Clear */\r
126 \r
127 \r
128 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_Output_None)         || \\r
129                                 ((OUTPUT) == COMP_Output_TIM1BKIN)     || \\r
130                                 ((OUTPUT) == COMP_Output_TIM1IC1)      || \\r
131                                 ((OUTPUT) == COMP_Output_TIM1OCREFCLR) || \\r
132                                 ((OUTPUT) == COMP_Output_TIM2IC4)      || \\r
133                                 ((OUTPUT) == COMP_Output_TIM2OCREFCLR) || \\r
134                                 ((OUTPUT) == COMP_Output_TIM3IC1)      || \\r
135                                 ((OUTPUT) == COMP_Output_TIM3OCREFCLR))\r
136 /**\r
137   * @}\r
138   */ \r
139 \r
140 /** @defgroup COMP_OutputPolarity\r
141   * @{\r
142   */\r
143 #define COMP_OutputPol_NonInverted          ((uint32_t)0x00000000)  /*!< COMP output on GPIO isn't inverted */\r
144 #define COMP_OutputPol_Inverted             COMP_CSR_COMP1POL       /*!< COMP output on GPIO is inverted */\r
145 \r
146 #define IS_COMP_OUTPUT_POL(POL) (((POL) == COMP_OutputPol_NonInverted)  || \\r
147                                  ((POL) == COMP_OutputPol_Inverted))\r
148 \r
149 /**\r
150   * @}\r
151   */ \r
152 \r
153 /** @defgroup COMP_Hysteresis\r
154   * @{\r
155   */\r
156 /* Please refer to the electrical characteristics in the device datasheet for\r
157    the hysteresis level */\r
158 #define COMP_Hysteresis_No                         0x00000000           /*!< No hysteresis */\r
159 #define COMP_Hysteresis_Low                        COMP_CSR_COMP1HYST_0 /*!< Hysteresis level low */\r
160 #define COMP_Hysteresis_Medium                     COMP_CSR_COMP1HYST_1 /*!< Hysteresis level medium */\r
161 #define COMP_Hysteresis_High                       COMP_CSR_COMP1HYST   /*!< Hysteresis level high */\r
162 \r
163 #define IS_COMP_HYSTERESIS(HYSTERESIS)    (((HYSTERESIS) == COMP_Hysteresis_No) || \\r
164                                            ((HYSTERESIS) == COMP_Hysteresis_Low) || \\r
165                                            ((HYSTERESIS) == COMP_Hysteresis_Medium) || \\r
166                                            ((HYSTERESIS) == COMP_Hysteresis_High))\r
167 /**\r
168   * @}\r
169   */\r
170 \r
171 /** @defgroup COMP_Mode\r
172   * @{\r
173   */\r
174 /* Please refer to the electrical characteristics in the device datasheet for\r
175    the power consumption values */\r
176 #define COMP_Mode_UltraLowPower                  0x00000000           /*!< Ultra-low power mode */\r
177 #define COMP_Mode_LowPower                       COMP_CSR_COMP1MODE_0 /*!< Low power mode */\r
178 #define COMP_Mode_MediumSpeed                    COMP_CSR_COMP1MODE_1 /*!< Medium Speed */\r
179 #define COMP_Mode_HighSpeed                      COMP_CSR_COMP1MODE   /*!< High Speed */\r
180 \r
181 #define IS_COMP_MODE(MODE)    (((MODE) == COMP_Mode_UltraLowPower) || \\r
182                                ((MODE) == COMP_Mode_LowPower)      || \\r
183                                ((MODE) == COMP_Mode_MediumSpeed)   || \\r
184                                ((MODE) == COMP_Mode_HighSpeed))\r
185 /**\r
186   * @}\r
187   */\r
188 \r
189 /** @defgroup COMP_OutputLevel\r
190   * @{\r
191   */ \r
192 /* When output polarity is not inverted, comparator output is high when\r
193    the non-inverting input is at a higher voltage than the inverting input */\r
194 #define COMP_OutputLevel_High                   COMP_CSR_COMP1OUT\r
195 /* When output polarity is not inverted, comparator output is low when\r
196    the non-inverting input is at a lower voltage than the inverting input*/\r
197 #define COMP_OutputLevel_Low                    ((uint32_t)0x00000000)\r
198 \r
199 /**\r
200   * @}\r
201   */ \r
202 \r
203 /**\r
204   * @}\r
205   */ \r
206 \r
207 /* Exported macro ------------------------------------------------------------*/\r
208 /* Exported functions ------------------------------------------------------- */\r
209 \r
210 /*  Function used to set the COMP configuration to the default reset state ****/\r
211 void COMP_DeInit(void);\r
212 \r
213 /* Initialization and Configuration functions *********************************/\r
214 void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef* COMP_InitStruct);\r
215 void COMP_StructInit(COMP_InitTypeDef* COMP_InitStruct);\r
216 void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState);\r
217 void COMP_SwitchCmd(FunctionalState NewState);\r
218 uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection);\r
219 \r
220 /* Window mode control function ***********************************************/\r
221 void COMP_WindowCmd(FunctionalState NewState);\r
222 \r
223 /* COMP configuration locking function ****************************************/\r
224 void COMP_LockConfig(uint32_t COMP_Selection);\r
225 \r
226 #ifdef __cplusplus\r
227 }\r
228 #endif\r
229 \r
230 #endif /*__STM32F0XX_COMP_H */\r
231 \r
232 /**\r
233   * @}\r
234   */ \r
235 \r
236 /**\r
237   * @}\r
238   */\r
239 \r
240 /******************* (C) COPYRIGHT 2012 STMicroelectronics *****END OF FILE****/\r