]> git.sur5r.net Git - freertos/blob
7f175702bc0c6845f3a92dd0af24e4aede94a5a0
[freertos] /
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32l1xx_comp.h\r
4   * @author  MCD Application Team\r
5   * @version V1.1.1\r
6   * @date    05-March-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   * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>\r
13   *\r
14   * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");\r
15   * You may not use this file except in compliance with the License.\r
16   * You may obtain a copy of the License at:\r
17   *\r
18   *        http://www.st.com/software_license_agreement_liberty_v2\r
19   *\r
20   * Unless required by applicable law or agreed to in writing, software \r
21   * distributed under the License is distributed on an "AS IS" BASIS, \r
22   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
23   * See the License for the specific language governing permissions and\r
24   * limitations under the License.\r
25   *\r
26   ******************************************************************************\r
27   */\r
28 \r
29 /* Define to prevent recursive inclusion -------------------------------------*/\r
30 #ifndef __STM32L1xx_COMP_H\r
31 #define __STM32L1xx_COMP_H\r
32 \r
33 #ifdef __cplusplus\r
34  extern "C" {\r
35 #endif\r
36 \r
37 /* Includes ------------------------------------------------------------------*/\r
38 #include "stm32l1xx.h"\r
39 \r
40 /** @addtogroup STM32L1xx_StdPeriph_Driver\r
41   * @{\r
42   */\r
43 \r
44 /** @addtogroup COMP\r
45   * @{\r
46   */\r
47 \r
48 /* Exported types ------------------------------------------------------------*/\r
49 \r
50 /** \r
51   * @brief  COMP Init structure definition  \r
52   */\r
53   \r
54 typedef struct\r
55 {\r
56   uint32_t COMP_Speed;               /*!< Defines the speed of comparator 2.\r
57                                           This parameter can be a value of @ref COMP_Speed */\r
58   uint32_t COMP_InvertingInput;      /*!< Selects the inverting input of the comparator 2.\r
59                                           This parameter can be a value of @ref COMP_InvertingInput */\r
60   uint32_t COMP_OutputSelect;        /*!< Selects the output redirection of the comparator 2.\r
61                                           This parameter can be a value of @ref COMP_OutputSelect */\r
62    \r
63 }COMP_InitTypeDef;\r
64 \r
65 /* Exported constants --------------------------------------------------------*/\r
66    \r
67 /** @defgroup COMP_Exported_Constants\r
68   * @{\r
69   */ \r
70 \r
71 #define COMP_OutputLevel_High                   ((uint32_t)0x00000001)\r
72 #define COMP_OutputLevel_Low                    ((uint32_t)0x00000000)\r
73 \r
74 /** @defgroup COMP_Selection\r
75   * @{\r
76   */\r
77 \r
78 #define COMP_Selection_COMP1                    ((uint32_t)0x00000001)\r
79 #define COMP_Selection_COMP2                    ((uint32_t)0x00000002)\r
80 \r
81 #define IS_COMP_ALL_PERIPH(PERIPH) (((PERIPH) == COMP_Selection_COMP1) || \\r
82                                     ((PERIPH) == COMP_Selection_COMP2))\r
83  \r
84 /**\r
85   * @}\r
86   */ \r
87 \r
88 /** @defgroup COMP_InvertingInput\r
89   * @{\r
90   */\r
91 \r
92 #define COMP_InvertingInput_None                ((uint32_t)0x00000000) /* COMP2 is disabled when this parameter is selected */\r
93 #define COMP_InvertingInput_IO                  ((uint32_t)0x00040000)\r
94 #define COMP_InvertingInput_VREFINT             ((uint32_t)0x00080000)\r
95 #define COMP_InvertingInput_3_4VREFINT          ((uint32_t)0x000C0000)\r
96 #define COMP_InvertingInput_1_2VREFINT          ((uint32_t)0x00100000)\r
97 #define COMP_InvertingInput_1_4VREFINT          ((uint32_t)0x00140000)\r
98 #define COMP_InvertingInput_DAC1                ((uint32_t)0x00180000)\r
99 #define COMP_InvertingInput_DAC2                ((uint32_t)0x001C0000)\r
100 \r
101 #define IS_COMP_INVERTING_INPUT(INPUT) (((INPUT) == COMP_InvertingInput_None) || \\r
102                                         ((INPUT) == COMP_InvertingInput_IO) || \\r
103                                         ((INPUT) == COMP_InvertingInput_VREFINT) || \\r
104                                         ((INPUT) == COMP_InvertingInput_3_4VREFINT) || \\r
105                                         ((INPUT) == COMP_InvertingInput_1_2VREFINT) || \\r
106                                         ((INPUT) == COMP_InvertingInput_1_4VREFINT) || \\r
107                                         ((INPUT) == COMP_InvertingInput_DAC1) || \\r
108                                         ((INPUT) == COMP_InvertingInput_DAC2))\r
109 /**\r
110   * @}\r
111   */ \r
112 \r
113 /** @defgroup COMP_OutputSelect\r
114   * @{\r
115   */\r
116 \r
117 #define COMP_OutputSelect_TIM2IC4               ((uint32_t)0x00000000)\r
118 #define COMP_OutputSelect_TIM2OCREFCLR          ((uint32_t)0x00200000)\r
119 #define COMP_OutputSelect_TIM3IC4               ((uint32_t)0x00400000)\r
120 #define COMP_OutputSelect_TIM3OCREFCLR          ((uint32_t)0x00600000)\r
121 #define COMP_OutputSelect_TIM4IC4               ((uint32_t)0x00800000)\r
122 #define COMP_OutputSelect_TIM4OCREFCLR          ((uint32_t)0x00A00000)\r
123 #define COMP_OutputSelect_TIM10IC1              ((uint32_t)0x00C00000)\r
124 #define COMP_OutputSelect_None                  ((uint32_t)0x00E00000)\r
125 \r
126 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OutputSelect_TIM2IC4) || \\r
127                                 ((OUTPUT) == COMP_OutputSelect_TIM2OCREFCLR) || \\r
128                                 ((OUTPUT) == COMP_OutputSelect_TIM3IC4) || \\r
129                                 ((OUTPUT) == COMP_OutputSelect_TIM3OCREFCLR) || \\r
130                                 ((OUTPUT) == COMP_OutputSelect_TIM4IC4) || \\r
131                                 ((OUTPUT) == COMP_OutputSelect_TIM4OCREFCLR) || \\r
132                                 ((OUTPUT) == COMP_OutputSelect_TIM10IC1) || \\r
133                                 ((OUTPUT) == COMP_OutputSelect_None))\r
134 /**\r
135   * @}\r
136   */ \r
137   \r
138 /** @defgroup COMP_Speed\r
139   * @{\r
140   */\r
141 \r
142 #define COMP_Speed_Slow                         ((uint32_t)0x00000000)\r
143 #define COMP_Speed_Fast                         ((uint32_t)0x00001000)\r
144 \r
145 #define IS_COMP_SPEED(SPEED)    (((SPEED) == COMP_Speed_Slow) || \\r
146                                  ((SPEED) == COMP_Speed_Fast))\r
147 /**\r
148   * @}\r
149   */\r
150   \r
151 /**\r
152   * @}\r
153   */ \r
154 \r
155 /* Exported macro ------------------------------------------------------------*/\r
156 /* Exported functions ------------------------------------------------------- */\r
157 \r
158 /*  Function used to set the COMP configuration to the default reset state ****/\r
159 void COMP_DeInit(void);\r
160 \r
161 /* Initialization and Configuration functions *********************************/\r
162 void COMP_Init(COMP_InitTypeDef* COMP_InitStruct);\r
163 void COMP_Cmd(FunctionalState NewState);\r
164 uint8_t COMP_GetOutputLevel(uint32_t COMP_Selection);\r
165 void COMP_SW1SwitchConfig(FunctionalState NewState);\r
166 \r
167 /* Window mode control function ***********************************************/\r
168 void COMP_WindowCmd(FunctionalState NewState);\r
169 \r
170 /* Internal Reference Voltage (VREFINT) output function ***********************/\r
171 void COMP_VrefintOutputCmd(FunctionalState NewState);\r
172 \r
173 #ifdef __cplusplus\r
174 }\r
175 #endif\r
176 \r
177 #endif /*__STM32L1xx_COMP_H */\r
178 \r
179 /**\r
180   * @}\r
181   */ \r
182 \r
183 /**\r
184   * @}\r
185   */\r
186 \r
187 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/\r