]> git.donarmstrong.com Git - qmk_firmware.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F3/stm32f3xx_hal_comp_ex.h
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[qmk_firmware.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F3 / stm32f3xx_hal_comp_ex.h
1 /**
2   ******************************************************************************
3   * @file    stm32f3xx_hal_comp_ex.h
4   * @author  MCD Application Team
5   * @version V1.1.0
6   * @date    12-Sept-2014
7   * @brief   Header file of COMP HAL Extended 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
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F3xx_HAL_COMP_EX_H
40 #define __STM32F3xx_HAL_COMP_EX_H
41
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f3xx_hal_def.h"
48
49 /** @addtogroup STM32F3xx_HAL_Driver
50   * @{
51   */
52
53 /** @defgroup COMPEx COMP Extended HAL module driver
54   * @{
55   */ 
56
57 /* Exported types ------------------------------------------------------------*/ 
58 /* Exported constants --------------------------------------------------------*/
59 /** @defgroup COMPEx_Exported_Constants COMP Extended Exported Constants
60   * @{
61   */
62
63 #if defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx) || \
64     defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
65    /** @defgroup COMPEx_InvertingInput  COMP Extended InvertingInput (STM32F302xE/STM32F303xE/STM32F398xx/STM32F302xC/STM32F303xC/STM32F358xx Product devices)
66   * @{
67   */
68 #define COMP_INVERTINGINPUT_1_4VREFINT       ((uint32_t)0x00000000)                        /*!< 1/4 VREFINT connected to comparator inverting input */
69 #define COMP_INVERTINGINPUT_1_2VREFINT       COMP_CSR_COMPxINSEL_0                         /*!< 1/2 VREFINT connected to comparator inverting input */
70 #define COMP_INVERTINGINPUT_3_4VREFINT       COMP_CSR_COMPxINSEL_1                         /*!< 3/4 VREFINT connected to comparator inverting input */
71 #define COMP_INVERTINGINPUT_VREFINT          (COMP_CSR_COMPxINSEL_1|COMP_CSR_COMPxINSEL_0) /*!< VREFINT connected to comparator inverting input */
72 #define COMP_INVERTINGINPUT_DAC1_CH1         COMP_CSR_COMPxINSEL_2                         /*!< DAC1_CH1_OUT (PA4) connected to comparator inverting input */
73 #define COMP_INVERTINGINPUT_DAC1_CH2         (COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_0) /*!< DAC1_CH2_OUT (PA5) connected to comparator inverting input */
74 #define COMP_INVERTINGINPUT_IO1              (COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_1) /*!< I/O1 (PA0 for COMP1, PA2 for COMP2, PD15 for COMP3, 
75                                                                                                 PE8 for COMP4, PD13 for COMP5, PD10 for COMP6,
76                                                                                                 PC0 for COMP7) connected to comparator inverting input */
77 #define COMP_INVERTINGINPUT_IO2               COMP_CSR_COMPxINSEL                          /*!< I/O2 (PB12 for COMP3, PB2 for COMP4, PB10 for COMP5,
78                                                                                                PB15 for COMP6) connected to comparator inverting input */
79 /* Aliases for compatibility */
80 #define COMP_INVERTINGINPUT_DAC1              COMP_INVERTINGINPUT_DAC1_CH1
81 #define COMP_INVERTINGINPUT_DAC2              COMP_INVERTINGINPUT_DAC1_CH2
82
83 #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT)       || \
84                                        ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT)       || \
85                                        ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT)       || \
86                                        ((INPUT) == COMP_INVERTINGINPUT_VREFINT)          || \
87                                        ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH1)         || \
88                                        ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH2)         || \
89                                        ((INPUT) == COMP_INVERTINGINPUT_IO1)              || \
90                                        ((INPUT) == COMP_INVERTINGINPUT_IO2))
91 /**
92   * @}
93   */ 
94 #elif defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
95 /** @defgroup COMPEx_InvertingInput COMP Extended InvertingInput (STM32F301x8/STM32F302x8/STM32F318xx Product devices)
96   * @{
97   */
98 #define COMP_INVERTINGINPUT_1_4VREFINT     ((uint32_t)0x00000000)                        /*!< 1/4 VREFINT connected to comparator inverting input */
99 #define COMP_INVERTINGINPUT_1_2VREFINT     COMP_CSR_COMPxINSEL_0                         /*!< 1/2 VREFINT connected to comparator inverting input */
100 #define COMP_INVERTINGINPUT_3_4VREFINT     COMP_CSR_COMPxINSEL_1                         /*!< 3/4 VREFINT connected to comparator inverting input */
101 #define COMP_INVERTINGINPUT_VREFINT        (COMP_CSR_COMPxINSEL_1|COMP_CSR_COMPxINSEL_0) /*!< VREFINT connected to comparator inverting input */
102 #define COMP_INVERTINGINPUT_DAC1_CH1       COMP_CSR_COMPxINSEL_2                         /*!< DAC1_CH1_OUT (PA4) connected to comparator inverting input */
103 #define COMP_INVERTINGINPUT_IO1            (COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_1) /*!< I/O1 (PA2 for COMP2, PB2 for COMP4, PB15 for COMP6)
104                                                                                               connected to comparator inverting input */
105 /* Aliases for compatibility */
106 #define COMP_INVERTINGINPUT_DAC1           COMP_INVERTINGINPUT_DAC1_CH1
107
108 #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT)       || \
109                                        ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT)       || \
110                                        ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT)       || \
111                                        ((INPUT) == COMP_INVERTINGINPUT_VREFINT)          || \
112                                        ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH1)         || \
113                                        ((INPUT) == COMP_INVERTINGINPUT_IO1))
114 /**
115   * @}
116   */
117 #elif defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
118 /** @defgroup COMPEx_InvertingInput COMP Extended InvertingInput (STM32F303x8/STM32F334x8/STM32F328xx Product devices)
119   * @{
120   */
121 #define COMP_INVERTINGINPUT_1_4VREFINT     ((uint32_t)0x00000000)                        /*!< 1/4 VREFINT connected to comparator inverting input */
122 #define COMP_INVERTINGINPUT_1_2VREFINT     COMP_CSR_COMPxINSEL_0                         /*!< 1/2 VREFINT connected to comparator inverting input */
123 #define COMP_INVERTINGINPUT_3_4VREFINT     COMP_CSR_COMPxINSEL_1                         /*!< 3/4 VREFINT connected to comparator inverting input */
124 #define COMP_INVERTINGINPUT_VREFINT        (COMP_CSR_COMPxINSEL_1|COMP_CSR_COMPxINSEL_0) /*!< VREFINT connected to comparator inverting input */
125 #define COMP_INVERTINGINPUT_DAC1_CH1       COMP_CSR_COMPxINSEL_2                         /*!< DAC1_CH1_OUT (PA4) connected to comparator inverting input */
126 #define COMP_INVERTINGINPUT_DAC1_CH2       (COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_0) /*!< DAC1_CH2_OUT (PA5) connected to comparator inverting input */
127 #define COMP_INVERTINGINPUT_IO1            (COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_1) /*!< I/O1 (PA2 for COMP2, PB2 for COMP4, PB15 for COMP6)
128                                                                                               connected to comparator inverting input */
129 #define COMP_INVERTINGINPUT_DAC2_CH1       COMP_CSR_COMPxINSEL_3                         /*!< DAC2_CH1_OUT connected to comparator inverting input */
130 /* Aliases for compatibility */
131 #define COMP_INVERTINGINPUT_DAC1           COMP_INVERTINGINPUT_DAC1_CH1
132 #define COMP_INVERTINGINPUT_DAC2           COMP_INVERTINGINPUT_DAC1_CH2
133
134 #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT)       || \
135                                        ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT)       || \
136                                        ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT)       || \
137                                        ((INPUT) == COMP_INVERTINGINPUT_VREFINT)          || \
138                                        ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH1)         || \
139                                        ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH2)         || \
140                                        ((INPUT) == COMP_INVERTINGINPUT_IO1)              || \
141                                        ((INPUT) == COMP_INVERTINGINPUT_DAC2_CH1))
142 /**
143   * @}
144   */
145 #elif defined(STM32F373xC) || defined(STM32F378xx)
146 /** @defgroup COMPEx_InvertingInput COMP Extended InvertingInput (STM32F373xC/STM32F378xx Product devices)
147   * @{
148   */
149 #define COMP_INVERTINGINPUT_1_4VREFINT  ((uint32_t)0x00000000)                        /*!< 1/4 VREFINT connected to comparator inverting input */
150 #define COMP_INVERTINGINPUT_1_2VREFINT  ((uint32_t)COMP_CSR_COMPxINSEL_0)             /*!< 1/2 VREFINT connected to comparator inverting input */
151 #define COMP_INVERTINGINPUT_3_4VREFINT  ((uint32_t)COMP_CSR_COMPxINSEL_1)             /*!< 3/4 VREFINT connected to comparator inverting input */
152 #define COMP_INVERTINGINPUT_VREFINT     ((uint32_t)(COMP_CSR_COMPxINSEL_1|COMP_CSR_COMPxINSEL_0)) /*!< VREFINT connected to comparator inverting input */
153 #define COMP_INVERTINGINPUT_DAC1_CH1    ((uint32_t)COMP_CSR_COMPxINSEL_2)                         /*!< DAC1_CH1_OUT (PA4) connected to comparator inverting input */
154 #define COMP_INVERTINGINPUT_DAC1_CH2    ((uint32_t)(COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_0)) /*!< DAC1_CH2_OUT (PA5) connected to comparator inverting input */
155 #define COMP_INVERTINGINPUT_IO1         ((uint32_t)(COMP_CSR_COMPxINSEL_2|COMP_CSR_COMPxINSEL_1)) /*!< I/O1 (PA0 for COMP1, PA2 for COMP2) connected to comparator inverting input */
156 #define COMP_INVERTINGINPUT_DAC2_CH1    ((uint32_t)COMP_CSR_COMPxINSEL)                          /*!< DAC2_CH1_OUT connected to comparator inverting input */
157 /* Aliases for compatibility */
158 #define COMP_INVERTINGINPUT_DAC1        COMP_INVERTINGINPUT_DAC1_CH1
159 #define COMP_INVERTINGINPUT_DAC2        COMP_INVERTINGINPUT_DAC1_CH2
160
161 #define IS_COMP_INVERTINGINPUT(INPUT) (((INPUT) == COMP_INVERTINGINPUT_1_4VREFINT)       || \
162                                        ((INPUT) == COMP_INVERTINGINPUT_1_2VREFINT)       || \
163                                        ((INPUT) == COMP_INVERTINGINPUT_3_4VREFINT)       || \
164                                        ((INPUT) == COMP_INVERTINGINPUT_VREFINT)          || \
165                                        ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH1)         || \
166                                        ((INPUT) == COMP_INVERTINGINPUT_DAC1_CH2)         || \
167                                        ((INPUT) == COMP_INVERTINGINPUT_IO1)              || \
168                                        ((INPUT) == COMP_INVERTINGINPUT_DAC2_CH1))
169 /**
170   * @}
171   */
172 #endif /* STM32F302xE || STM32F303xE || STM32F398xx || */
173        /* STM32F302xC || STM32F303xC || STM32F358xx */
174
175 #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
176 /** @defgroup COMPEx_NonInvertingInput  COMP Extended NonInvertingInput (STM32F302xC/STM32F303xC/STM32F358xx Product devices)
177   * @{
178   */
179 #define COMP_NONINVERTINGINPUT_IO1               ((uint32_t)0x00000000) /*!< I/O1 (PA1 for COMP1, PA7 for COMP2, PB14 for COMP3, 
180                                                                              PB0 for COMP4, PD12 for COMP5, PD11 for COMP6,
181                                                                              PA0 for COMP7) connected to comparator non inverting input */
182 #define COMP_NONINVERTINGINPUT_IO2               COMP_CSR_COMPxNONINSEL /*!< I/O2 (PA3 for COMP2, PD14 for COMP3, PE7 for COMP4, PB13 for COMP5,
183                                                                              PB11 for COMP6, PC1 for COMP7) connected to comparator non inverting input */
184 #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED  COMP1_CSR_COMP1SW1     /*!< DAC ouput connected to comparator COMP1 non inverting input */
185
186 #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
187                                           ((INPUT) == COMP_NONINVERTINGINPUT_IO2) || \
188                                           ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))
189
190 /* STM32F302xB/xC, STM32F303xB/xC, STM32F358xx devices comparator instances non inverting source values */
191 #define IS_COMP_NONINVERTINGINPUT_INSTANCE(INSTANCE, INPUT)    \
192    ((((INSTANCE) == COMP1)  &&                                 \
193     (((INPUT) == COMP_NONINVERTINGINPUT_IO1)                || \
194      ((INPUT) == COMP_NONINVERTINGINPUT_IO2)                || \
195      ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED)))    \
196     ||                                                         \
197     ((((INPUT) == COMP_NONINVERTINGINPUT_IO1)               || \
198       ((INPUT) == COMP_NONINVERTINGINPUT_IO2))))
199
200 #define COMP_CSR_COMPxNONINSEL_MASK            (COMP_CSR_COMPxNONINSEL | COMP1_CSR_COMP1SW1) /*!< COMP_CSR_COMPxNONINSEL mask */
201 /**
202   * @}
203   */ 
204 #elif defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
205 /** @defgroup COMPEx_NonInvertingInput COMP Extended NonInvertingInput (STM32F301x8/STM32F302x8/STM32F318xx Product devices)
206   * @{
207   */
208 #define COMP_NONINVERTINGINPUT_IO1               ((uint32_t)0x00000000) /*!< I/O1 (PA7 for COMP2, PB0 for COMP4, PB11 for COMP6)
209                                                                              connected to comparator non inverting input */
210 #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED  COMP2_CSR_COMP2INPDAC  /*!< DAC ouput connected to comparator COMP2 non inverting input */
211
212 #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
213                                           ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))
214
215 /* STM32F301x6/x8, STM32F302x6/x8, STM32F318xx devices comparator instances non inverting source values */
216 #define IS_COMP_NONINVERTINGINPUT_INSTANCE(INSTANCE, INPUT)    \
217    ((((INSTANCE) == COMP2)  &&                                 \
218     (((INPUT) == COMP_NONINVERTINGINPUT_IO1)                || \
219      ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED)))    \
220     ||                                                         \
221     (((INPUT) == COMP_NONINVERTINGINPUT_IO1)))
222
223 #define COMP_CSR_COMPxNONINSEL_MASK              (COMP2_CSR_COMP2INPDAC) /*!< COMP_CSR_COMPxNONINSEL mask */
224 /**
225   * @}
226   */ 
227 #elif defined(STM32F373xC) || defined(STM32F378xx)
228 /** @defgroup COMPEx_NonInvertingInput COMP Extended NonInvertingInput (STM32F373xC/STM32F378xx Product devices)
229   * @{
230   */
231 #define COMP_NONINVERTINGINPUT_IO1               ((uint32_t)0x00000000) /*!< I/O1 (PA1 for COMP1, PA3 for COMP2) 
232                                                                              connected to comparator non inverting input */
233 #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED  COMP_CSR_COMP1SW1  /*!< DAC ouput connected to comparator COMP1 non inverting input */
234
235 #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
236                                           ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))
237
238 /* STM32F373xB/xC, STM32F378xx devices comparator instances non inverting source values */
239 #define IS_COMP_NONINVERTINGINPUT_INSTANCE(INSTANCE, INPUT)    \
240    ((((INSTANCE) == COMP1)  &&                                 \
241     (((INPUT) == COMP_NONINVERTINGINPUT_IO1)                || \
242      ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED)))    \
243     ||                                                         \
244     (((INPUT) == COMP_NONINVERTINGINPUT_IO1)))
245
246 #define COMP_CSR_COMPxNONINSEL_MASK              (COMP_CSR_COMP1SW1) /*!< COMP_CSR_COMPxNONINSEL mask */
247 /**
248   * @}
249   */
250 #elif defined(STM32F302xE) || defined(STM32F303xE) || defined(STM32F398xx)
251 /** @defgroup COMPEx_NonInvertingInput  COMP Extended NonInvertingInput (STM32F302xE/STM32F303xE/STM32F398xx Product devices)
252   * @{
253   */
254 #define COMP_NONINVERTINGINPUT_IO1             ((uint32_t)0x00000000)   /*!< I/O1 (PA1 for COMP1, PA7 for COMP2, PB14 for COMP3, 
255                                                                             PB0 for COMP4, PD12 for COMP5, PD11 for COMP6,
256                                                                             PA0 for COMP7) connected to comparator non inverting input */
257 #define COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED COMP1_CSR_COMP1SW1      /*!< DAC ouput connected to comparator COMP1 non inverting input */
258
259 #define IS_COMP_NONINVERTINGINPUT(INPUT) (((INPUT) == COMP_NONINVERTINGINPUT_IO1) || \
260                                           ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED))
261
262 /* STM32F302xE/STM32F303xE/STM32F398xx devices comparator instances non inverting source values */
263 #define IS_COMP_NONINVERTINGINPUT_INSTANCE(INSTANCE, INPUT)    \
264    ((((INSTANCE) == COMP1)  &&                                 \
265     (((INPUT) == COMP_NONINVERTINGINPUT_IO1)                || \
266      ((INPUT) == COMP_NONINVERTINGINPUT_DAC1SWITCHCLOSED)))    \
267     ||                                                         \
268     (((INPUT) == COMP_NONINVERTINGINPUT_IO1)))
269
270 #define COMP_CSR_COMPxNONINSEL_MASK            (COMP1_CSR_COMP1SW1) /*!< COMP_CSR_COMPxNONINSEL mask */
271 /**
272   * @}
273   */ 
274 #else
275 /** @defgroup COMPEx_NonInvertingInput COMP Extended NonInvertingInput (Other Product devices)
276   * @{
277   */
278 #define COMP_NONINVERTINGINPUT_IO1             ((uint32_t)0x00000000) /*!< I/O1 (PA7 for COMP2, PB0 for COMP4, PB11 for COMP6) 
279                                                                            connected to comparator non inverting input */
280 /*!< Non inverting input not available */
281 #define IS_COMP_NONINVERTINGINPUT(INPUT) ((INPUT) == (INPUT))  /*!< Multiple selection not available: check always true */
282
283 #define IS_COMP_NONINVERTINGINPUT_INSTANCE(INSTANCE, INPUT) ((INPUT) == (INPUT))   /*!< Multiple selection not available: check always true */
284
285 #define COMP_CSR_COMPxNONINSEL_MASK           ((uint32_t)0x00000000) /*!< Mask empty: feature not available */
286 /**
287   * @}
288   */
289 #endif /* STM32F302xC || STM32F303xC || STM32F358xx */
290
291 #if  defined(STM32F302xC)
292 /** @defgroup COMPEx_Output COMP Extended Output (STM32F302xC Product devices)
293   * @{
294   */
295 #define COMP_OUTPUT_NONE                             ((uint32_t)0x00000000)   /*!< COMP output isn't connected to other peripherals */
296 /* Output Redirection common for all comparators COMP1, COMP2, COMP4, COMP6 */
297 #define COMP_OUTPUT_TIM1BKIN                         COMP_CSR_COMPxOUTSEL_0   /*!< COMP output connected to TIM1 Break Input (BKIN) */
298 #define COMP_OUTPUT_TIM1BKIN2_BRK2                   ((uint32_t)0x00000800)   /*!< COMP output connected to TIM1 Break Input 2 (BKIN2) */
299 #define COMP_OUTPUT_TIM1BKIN2                        ((uint32_t)0x00001400)   /*!< COMP output connected to TIM1 Break Input 2 */
300 /* Output Redirection common for COMP1 and COMP2 */
301 #define COMP_OUTPUT_TIM1OCREFCLR                      ((uint32_t)0x00001800)   /*!< COMP output connected to TIM1 OCREF Clear */
302 #define COMP_OUTPUT_TIM1IC1                           ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM1 Input Capture 1 */
303 #define COMP_OUTPUT_TIM2IC4                           ((uint32_t)0x00002000)   /*!< COMP output connected to TIM2 Input Capture 4 */
304 #define COMP_OUTPUT_TIM2OCREFCLR                      ((uint32_t)0x00002400)   /*!< COMP output connected to TIM2 OCREF Clear */
305 #define COMP_OUTPUT_TIM3IC1                           ((uint32_t)0x00002800)   /*!< COMP output connected to TIM3 Input Capture 1 */
306 /* Output Redirection common for COMP1,COMP2 and COMP4 */
307 #define COMP_OUTPUT_TIM3OCREFCLR                      ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM3 OCREF Clear */
308 /* Output Redirection specific to COMP4 */
309 #define COMP_OUTPUT_TIM3IC3                           ((uint32_t)0x00001800)   /*!< COMP output connected to TIM3 Input Capture 3 */
310 #define COMP_OUTPUT_TIM15IC2                          ((uint32_t)0x00002000)   /*!< COMP output connected to TIM15 Input Capture 2 */
311 #define COMP_OUTPUT_TIM4IC2                           ((uint32_t)0x00002400)   /*!< COMP output connected to TIM4 Input Capture 2 */
312 #define COMP_OUTPUT_TIM15OCREFCLR                     ((uint32_t)0x00002800)   /*!< COMP output connected to TIM15 OCREF Clear */
313 /* Output Redirection specific to COMP6 */
314 #define COMP_OUTPUT_TIM2IC2                           ((uint32_t)0x00001800)   /*!< COMP output connected to TIM2 Input Capture 2 */
315 #define COMP_OUTPUT_COMP6TIM2OCREFCLR                 ((uint32_t)0x00002000)   /*!< COMP6 output connected to TIM2 OCREF Clear */
316 #define COMP_OUTPUT_TIM16OCREFCLR                     ((uint32_t)0x00002400)   /*!< COMP output connected to TIM16 OCREF Clear */
317 #define COMP_OUTPUT_TIM16IC1                          ((uint32_t)0x00002800)   /*!< COMP output connected to TIM16 Input Capture 1 */
318 #define COMP_OUTPUT_TIM4IC4                           ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM4 Input Capture 4 */
319
320 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE)                || \
321                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN)            || \
322                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2)      || \
323                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2)           || \
324                                 ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR)        || \
325                                 ((OUTPUT) == COMP_OUTPUT_TIM1IC1)             || \
326                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC4)             || \
327                                 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR)        || \
328                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC1)             || \
329                                 ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR)        || \
330                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC3)             || \
331                                 ((OUTPUT) == COMP_OUTPUT_TIM15IC2)            || \
332                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC2)             || \
333                                 ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR)       || \
334                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC2)             || \
335                                 ((OUTPUT) == COMP_OUTPUT_COMP6TIM2OCREFCLR)   || \
336                                 ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR)       || \
337                                 ((OUTPUT) == COMP_OUTPUT_TIM16IC1)            || \
338                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC4))
339 /**
340   * @}
341   */ 
342 #elif  defined(STM32F303xC) || defined(STM32F358xx)
343 /** @defgroup COMPEx_Output COMP Extended Output (STM32F303xC/STM32F358xx Product devices)
344   * @{
345   */
346 #define COMP_OUTPUT_NONE                  ((uint32_t)0x00000000)   /*!< COMP output isn't connected to other peripherals */
347 /* Output Redirection common for all comparators COMP1...COMP7 */
348 #define COMP_OUTPUT_TIM1BKIN              COMP_CSR_COMPxOUTSEL_0   /*!< COMP output connected to TIM1 Break Input (BKIN) */
349 #define COMP_OUTPUT_TIM1BKIN2             ((uint32_t)0x00000800)   /*!< COMP output connected to TIM1 Break Input 2 (BKIN2) */
350 #define COMP_OUTPUT_TIM8BKIN              ((uint32_t)0x00000C00)   /*!< COMP output connected to TIM8 Break Input (BKIN) */
351 #define COMP_OUTPUT_TIM8BKIN2             ((uint32_t)0x00001000)   /*!< COMP output connected to TIM8 Break Input 2 (BKIN2) */
352 #define COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2   ((uint32_t)0x00001400)   /*!< COMP output connected to TIM1 Break Input 2 and TIM8 Break Input 2 */
353 /* Output Redirection common for COMP1, COMP2 and COMP3 */
354 #define COMP_OUTPUT_TIM1OCREFCLR          ((uint32_t)0x00001800)   /*!< COMP output connected to TIM1 OCREF Clear */
355 /* Output Redirection common for COMP1 and COMP2 */
356 #define COMP_OUTPUT_TIM1IC1               ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM1 Input Capture 1 */
357 #define COMP_OUTPUT_TIM2IC4               ((uint32_t)0x00002000)   /*!< COMP output connected to TIM2 Input Capture 4 */
358 #define COMP_OUTPUT_TIM2OCREFCLR          ((uint32_t)0x00002400)   /*!< COMP output connected to TIM2 OCREF Clear */
359 #define COMP_OUTPUT_TIM3IC1               ((uint32_t)0x00002800)   /*!< COMP output connected to TIM3 Input Capture 1 */
360 #define COMP_OUTPUT_TIM3OCREFCLR          ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM3 OCREF Clear */
361 /* Output Redirection specific to COMP3 */
362 #define COMP_OUTPUT_TIM4IC1               ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM4 Input Capture 1 */
363 #define COMP_OUTPUT_TIM3IC2               ((uint32_t)0x00002000)   /*!< COMP output connected to TIM3 Input Capture 2 */
364 #define COMP_OUTPUT_TIM15IC1              ((uint32_t)0x00002800)   /*!< COMP output connected to TIM15 Input Capture 1 */
365 #define COMP_OUTPUT_TIM15BKIN             ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM15 Break Input (BKIN) */
366 /* Output Redirection specific to COMP4 */
367 #define COMP_OUTPUT_TIM3IC3               ((uint32_t)0x00001800)   /*!< COMP output connected to TIM3 Input Capture 3 */
368 #define COMP_OUTPUT_TIM8OCREFCLR          ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM8 OCREF Clear */
369 #define COMP_OUTPUT_TIM15IC2              ((uint32_t)0x00002000)   /*!< COMP output connected to TIM15 Input Capture 2 */
370 #define COMP_OUTPUT_TIM4IC2               ((uint32_t)0x00002400)   /*!< COMP output connected to TIM4 Input Capture 2 */
371 #define COMP_OUTPUT_TIM15OCREFCLR         ((uint32_t)0x00002800)   /*!< COMP output connected to TIM15 OCREF Clear */
372 #define COMP_OUTPUT_TIM3OCREFCLR          ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM3 OCREF Clear */
373 /* Output Redirection specific to COMP5 */
374 #define COMP_OUTPUT_TIM2IC1               ((uint32_t)0x00001800)   /*!< COMP output connected to TIM2 Input Capture 1 */
375 #define COMP_OUTPUT_TIM8OCREFCLR          ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM8 OCREF Clear */
376 #define COMP_OUTPUT_TIM17IC1              ((uint32_t)0x00002000)   /*!< COMP output connected to TIM17 Input Capture 1 */
377 #define COMP_OUTPUT_TIM4IC3               ((uint32_t)0x00002400)   /*!< COMP output connected to TIM4 Input Capture 3 */
378 #define COMP_OUTPUT_TIM16BKIN             ((uint32_t)0x00002800)   /*!< COMP output connected to TIM16 Break Input (BKIN) */
379 #define COMP_OUTPUT_TIM3OCREFCLR          ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM3 OCREF Clear */
380 /* Output Redirection specific to COMP6 */
381 #define COMP_OUTPUT_TIM2IC2               ((uint32_t)0x00001800)   /*!< COMP output connected to TIM2 Input Capture 2 */
382 #define COMP_OUTPUT_TIM8OCREFCLR          ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM8 OCREF Clear */
383 #define COMP_OUTPUT_COMP6_TIM2OCREFCLR    ((uint32_t)0x00002000)   /*!< COMP6 output connected to TIM2 OCREF Clear */
384 #define COMP_OUTPUT_TIM16OCREFCLR         ((uint32_t)0x00002400)   /*!< COMP output connected to TIM16 OCREF Clear */
385 #define COMP_OUTPUT_TIM16IC1              ((uint32_t)0x00002800)   /*!< COMP output connected to TIM16 Input Capture 1 */
386 #define COMP_OUTPUT_TIM4IC4               ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM4 Input Capture 4 */
387 /* Output Redirection specific to COMP7 */
388 #define COMP_OUTPUT_TIM1OCREFCLR          ((uint32_t)0x00001800)   /*!< COMP output connected to TIM1 OCREF Clear */
389 #define COMP_OUTPUT_TIM8OCREFCLR          ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM8 OCREF Clear */
390 #define COMP_OUTPUT_TIM2IC3               ((uint32_t)0x00002000)   /*!< COMP output connected to TIM2 Input Capture 3 */
391 #define COMP_OUTPUT_TIM1IC2               ((uint32_t)0x00002400)   /*!< COMP output connected to TIM1 Input Capture 2 */
392 #define COMP_OUTPUT_TIM17OCREFCLR         ((uint32_t)0x00002800)   /*!< COMP output connected to TIM16 OCREF Clear */
393 #define COMP_OUTPUT_TIM17BKIN             ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM16 Break Input (BKIN) */
394
395 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE)                || \
396                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN)            || \
397                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2)           || \
398                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
399                                 ((OUTPUT) == COMP_OUTPUT_TIM1IC1)             || \
400                                 ((OUTPUT) == COMP_OUTPUT_TIM1IC2)             || \
401                                 ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR)        || \
402                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC1)             || \
403                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC2)             || \
404                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC3)             || \
405                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC4)             || \
406                                 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR)        || \
407                                 ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR)  || \
408                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC1)             || \
409                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC2)             || \
410                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC3)             || \
411                                 ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR)        || \
412                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC1)             || \
413                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC2)             || \
414                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC3)             || \
415                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC4)             || \
416                                 ((OUTPUT) == COMP_OUTPUT_TIM8BKIN)            || \
417                                 ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2)           || \
418                                 ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR)        || \
419                                 ((OUTPUT) == COMP_OUTPUT_TIM15IC1)            || \
420                                 ((OUTPUT) == COMP_OUTPUT_TIM15IC2)            || \
421                                 ((OUTPUT) == COMP_OUTPUT_TIM15BKIN)           || \
422                                 ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR)       || \
423                                 ((OUTPUT) == COMP_OUTPUT_TIM16BKIN)           || \
424                                 ((OUTPUT) == COMP_OUTPUT_TIM16IC1)            || \
425                                 ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR)       || \
426                                 ((OUTPUT) == COMP_OUTPUT_TIM17BKIN)           || \
427                                 ((OUTPUT) == COMP_OUTPUT_TIM17IC1)            || \
428                                 ((OUTPUT) == COMP_OUTPUT_TIM17OCREFCLR))
429 /**
430   * @}
431   */ 
432 #elif defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx)
433 /** @defgroup COMPEx_Output COMP Extended Output (STM32F301x8/STM32F302x8/STM32F318xx Product devices)
434   * @{
435   */
436 #define COMP_OUTPUT_NONE                  ((uint32_t)0x00000000)   /*!< COMP output isn't connected to other peripherals */
437 /* Output Redirection common for all comparators COMP2, COMP4 and COMP6 */
438 #define COMP_OUTPUT_TIM1BKIN              COMP_CSR_COMPxOUTSEL_0   /*!< COMP output connected to TIM1 Break Input (BKIN) */
439 #define COMP_OUTPUT_TIM1BKIN2             ((uint32_t)0x00000800)   /*!< COMP output connected to TIM1 Break Input 2 (BKIN2) */
440 /* Output Redirection specific to COMP2 */
441 #define COMP_OUTPUT_TIM1OCREFCLR          ((uint32_t)0x00001800)   /*!< COMP output connected to TIM1 OCREF Clear */
442 #define COMP_OUTPUT_TIM1IC1               ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM1 Input Capture 1 */
443 #define COMP_OUTPUT_TIM2IC4               ((uint32_t)0x00002000)   /*!< COMP output connected to TIM2 Input Capture 4 */
444 #define COMP_OUTPUT_TIM2OCREFCLR          ((uint32_t)0x00002400)   /*!< COMP output connected to TIM2 OCREF Clear */
445 /* Output Redirection specific to COMP4 */
446 #define COMP_OUTPUT_TIM15IC2              ((uint32_t)0x00002000)   /*!< COMP output connected to TIM15 Input Capture 2 */
447 #define COMP_OUTPUT_TIM15OCREFCLR         ((uint32_t)0x00002800)   /*!< COMP output connected to TIM15 OCREF Clear */
448 /* Output Redirection specific to COMP6 */
449 #define COMP_OUTPUT_TIM2IC2               ((uint32_t)0x00001800)   /*!< COMP output connected to TIM2 Input Capture 2 */
450 #define COMP_OUTPUT_COMP6_TIM2OCREFCLR    ((uint32_t)0x00002000)   /*!< COMP6 output connected to TIM2 OCREF Clear */
451 #define COMP_OUTPUT_TIM16OCREFCLR         ((uint32_t)0x00002400)   /*!< COMP output connected to TIM16 OCREF Clear */
452 #define COMP_OUTPUT_TIM16IC1              ((uint32_t)0x00002800)   /*!< COMP output connected to TIM16 Input Capture 1 */
453
454 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE)                || \
455                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN)            || \
456                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2)           || \
457                                 ((OUTPUT) == COMP_OUTPUT_TIM1IC1)             || \
458                                 ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR)        || \
459                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC2)             || \
460                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC4)             || \
461                                 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR)        || \
462                                 ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR)  || \
463                                 ((OUTPUT) == COMP_OUTPUT_TIM15IC2)            || \
464                                 ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR)       || \
465                                 ((OUTPUT) == COMP_OUTPUT_TIM16IC1)            || \
466                                 ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR))
467 /**
468   * @}
469   */ 
470 #elif  defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
471 /** @defgroup COMPEx_Output COMP Extended Output (STM32F303x8/STM32F334x8/STM32F328xx Product devices)
472   * @{
473   */
474 #define COMP_OUTPUT_NONE                  ((uint32_t)0x00000000)   /*!< COMP output isn't connected to other peripherals */
475 /* Output Redirection common for all comparators COMP2, COMP4 and COMP6 */
476 #define COMP_OUTPUT_TIM1BKIN              COMP_CSR_COMPxOUTSEL_0   /*!< COMP output connected to TIM1 Break Input (BKIN) */
477 #define COMP_OUTPUT_TIM1BKIN2             ((uint32_t)0x00000800)   /*!< COMP output connected to TIM1 Break Input 2 (BKIN2) */
478 /* Output Redirection specific to COMP2 */
479 #define COMP_OUTPUT_TIM1OCREFCLR          ((uint32_t)0x00001800)   /*!< COMP output connected to TIM1 OCREF Clear */
480 #define COMP_OUTPUT_TIM1IC1               ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM1 Input Capture 1 */
481 #define COMP_OUTPUT_TIM2IC4               ((uint32_t)0x00002000)   /*!< COMP output connected to TIM2 Input Capture 4 */
482 #define COMP_OUTPUT_TIM2OCREFCLR          ((uint32_t)0x00002400)   /*!< COMP output connected to TIM2 OCREF Clear */
483 #define COMP_OUTPUT_TIM3IC1               ((uint32_t)0x00002800)   /*!< COMP output connected to TIM3 Input Capture 1 */
484 #define COMP_OUTPUT_TIM3OCREFCLR          ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM3 OCREF Clear */
485 /* Output Redirection specific to COMP4 */
486 #define COMP_OUTPUT_TIM3IC3               ((uint32_t)0x00001800)   /*!< COMP output connected to TIM3 Input Capture 3 */
487 #define COMP_OUTPUT_TIM15IC2              ((uint32_t)0x00002000)   /*!< COMP output connected to TIM15 Input Capture 2 */
488 #define COMP_OUTPUT_TIM15OCREFCLR         ((uint32_t)0x00002800)   /*!< COMP output connected to TIM15 OCREF Clear */
489 #define COMP_OUTPUT_TIM3OCREFCLR          ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM3 OCREF Clear */
490 /* Output Redirection specific to COMP6 */
491 #define COMP_OUTPUT_TIM2IC2               ((uint32_t)0x00001800)   /*!< COMP output connected to TIM2 Input Capture 2 */
492 #define COMP_OUTPUT_COMP6_TIM2OCREFCLR    ((uint32_t)0x00002000)   /*!< COMP6 output connected to TIM2 OCREF Clear */
493 #define COMP_OUTPUT_TIM16OCREFCLR         ((uint32_t)0x00002400)   /*!< COMP output connected to TIM16 OCREF Clear */
494 #define COMP_OUTPUT_TIM16IC1              ((uint32_t)0x00002800)   /*!< COMP output connected to TIM16 Input Capture 1 */
495
496 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE)                || \
497                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN)            || \
498                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2)           || \
499                                 ((OUTPUT) == COMP_OUTPUT_TIM1IC1)             || \
500                                 ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR)        || \
501                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC2)             || \
502                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC4)             || \
503                                 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR)        || \
504                                 ((OUTPUT) == COMP_OUTPUT_COMP6_TIM2OCREFCLR)  || \
505                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC1)             || \
506                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC3)             || \
507                                 ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR)        || \
508                                 ((OUTPUT) == COMP_OUTPUT_TIM15IC2)            || \
509                                 ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR)       || \
510                                 ((OUTPUT) == COMP_OUTPUT_TIM16IC1)            || \
511                                 ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR))
512 /**
513   * @}
514   */ 
515 #elif  defined(STM32F373xC) || defined(STM32F378xx)
516 /** @defgroup COMPEx_Output COMP Extended Output (STM32F373xC/STM32F378xx Product devices)
517   * @{
518   */
519 /* Output Redirection common for all comparators COMP1 and COMP2 */
520 #define COMP_OUTPUT_NONE                  ((uint32_t)0x0000)   /*!< COMP output isn't connected to other peripherals */
521 #define COMP_OUTPUT_TIM3IC1               ((uint32_t)0x0200)   /*!< COMP output connected to TIM1 Input Capture 1 */
522 #define COMP_OUTPUT_TIM3OCREFCLR          ((uint32_t)0x0300)   /*!< COMP output connected to TIM3 OCREF Clear */
523 #define COMP_OUTPUT_TIM2IC4               ((uint32_t)0x0400)   /*!< COMP output connected to TIM2 Input Capture 4 */
524 #define COMP_OUTPUT_TIM2OCREFCLR          ((uint32_t)0x0500)   /*!< COMP output connected to TIM2 OCREF Clear */
525 /* Output Redirection specific to COMP1 */
526 #define COMP_OUTPUT_TIM15BKIN             ((uint32_t)0x0100)   /*!< COMP output connected to TIM15 Break Input */
527 #define COMP_OUTPUT_TIM5IC4               ((uint32_t)0x0600)   /*!< COMP output connected to TIM5 Input Capture 4 */
528 #define COMP_OUTPUT_TIM5OCREFCLR          ((uint32_t)0x0700)   /*!< COMP output connected to TIM5 OCREF Clear */
529 /* Output Redirection specific to COMP2 */
530 #define COMP_OUTPUT_TIM16BKIN             ((uint32_t)0x0100)   /*!< COMP output connected to TIM16 Break Input */
531 #define COMP_OUTPUT_TIM4IC1               ((uint32_t)0x0200)   /*!< COMP output connected to TIM4 Input Capture 1 */
532 #define COMP_OUTPUT_TIM4OCREFCLR          ((uint32_t)0x0300)   /*!< COMP output connected to TIM4 OCREF Clear */
533
534 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE)                || \
535                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC4)             || \
536                                 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR)        || \
537                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC1)             || \
538                                 ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR)        || \
539                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC1)             || \
540                                 ((OUTPUT) == COMP_OUTPUT_TIM4OCREFCLR)        || \
541                                 ((OUTPUT) == COMP_OUTPUT_TIM5IC4)             || \
542                                 ((OUTPUT) == COMP_OUTPUT_TIM5OCREFCLR)        || \
543                                 ((OUTPUT) == COMP_OUTPUT_TIM15BKIN)           || \
544                                 ((OUTPUT) == COMP_OUTPUT_TIM16BKIN))
545 /**
546   * @}
547   */ 
548 #elif defined(STM32F302xE)
549 /** @defgroup COMPEx_Output COMP Extended Output (STM32F302xE Product devices)
550   * @{
551   */
552 #define COMP_OUTPUT_NONE                             ((uint32_t)0x00000000)   /*!< COMP output isn't connected to other peripherals */
553 /* Output Redirection common for all comparators COMP1, COMP2, COMP4, COMP6 */
554 #define COMP_OUTPUT_TIM1BKIN                         COMP_CSR_COMPxOUTSEL_0   /*!< COMP output connected to TIM1 Break Input (BKIN) */
555 #define COMP_OUTPUT_TIM1BKIN2_BRK2                   ((uint32_t)0x00000800)   /*!< COMP output connected to TIM1 Break Input 2 (BKIN2) */
556 #define COMP_OUTPUT_TIM1BKIN2                        ((uint32_t)0x00001400)   /*!< COMP output connected to TIM1 Break Input 2 */
557 /* Output Redirection common for COMP1 and COMP2 */
558 #define COMP_OUTPUT_TIM1OCREFCLR                      ((uint32_t)0x00001800)   /*!< COMP output connected to TIM1 OCREF Clear */
559 #define COMP_OUTPUT_TIM1IC1                           ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM1 Input Capture 1 */
560 #define COMP_OUTPUT_TIM2IC4                           ((uint32_t)0x00002000)   /*!< COMP output connected to TIM2 Input Capture 4 */
561 #define COMP_OUTPUT_TIM2OCREFCLR                      ((uint32_t)0x00002400)   /*!< COMP output connected to TIM2 OCREF Clear */
562 #define COMP_OUTPUT_TIM3IC1                           ((uint32_t)0x00002800)   /*!< COMP output connected to TIM3 Input Capture 1 */
563 #define COMP_OUTPUT_TIM3OCREFCLR                      ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM3 OCREF Clear */
564 /* Output Redirection specific to COMP4 */
565 #define COMP_OUTPUT_TIM3IC3                           ((uint32_t)0x00001800)   /*!< COMP output connected to TIM3 Input Capture 3 */
566 #define COMP_OUTPUT_TIM15IC2                          ((uint32_t)0x00002000)   /*!< COMP output connected to TIM15 Input Capture 2 */
567 #define COMP_OUTPUT_TIM4IC2                           ((uint32_t)0x00002400)   /*!< COMP output connected to TIM4 Input Capture 2 */
568 #define COMP_OUTPUT_TIM15OCREFCLR                     ((uint32_t)0x00002800)   /*!< COMP output connected to TIM15 OCREF Clear */
569 /* Output Redirection specific to COMP6 */
570 #define COMP_OUTPUT_TIM2IC2                           ((uint32_t)0x00001800)   /*!< COMP output connected to TIM2 Input Capture 2 */
571 #define COMP_OUTPUT_COMP6TIM2OCREFCLR                 ((uint32_t)0x00002000)   /*!< COMP output connected to TIM2 OCREF Clear */
572 #define COMP_OUTPUT_TIM16OCREFCLR                     ((uint32_t)0x00002400)   /*!< COMP output connected to TIM16 OCREF Clear */
573 #define COMP_OUTPUT_TIM16IC1                          ((uint32_t)0x00002800)   /*!< COMP output connected to TIM16 Input Capture 1 */
574 #define COMP_OUTPUT_TIM4IC4                           ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM4 Input Capture 4 */
575
576 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE)                || \
577                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN)            || \
578                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_BRK2)      || \
579                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2)           || \
580                                 ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR)        || \
581                                 ((OUTPUT) == COMP_OUTPUT_TIM1IC1)             || \
582                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC4)             || \
583                                 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR)        || \
584                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC1)             || \
585                                 ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR)        || \
586                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC3)             || \
587                                 ((OUTPUT) == COMP_OUTPUT_TIM15IC2)            || \
588                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC2)             || \
589                                 ((OUTPUT) == COMP_OUTPUT_TIM15OCREFCLR)       || \
590                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC2)             || \
591                                 ((OUTPUT) == COMP_OUTPUT_COMP6TIM2OCREFCLR)   || \
592                                 ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR)       || \
593                                 ((OUTPUT) == COMP_OUTPUT_TIM16IC1)            || \
594                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC4))
595
596 /**
597   * @}
598   */ 
599 #elif defined(STM32F303xE) || defined(STM32F398xx)
600 /** @defgroup COMPEx_Output COMP Extended Output (STM32F303xE/STM32F398xx Product devices)
601   * @{
602   */
603 #define COMP_OUTPUT_NONE                             ((uint32_t)0x00000000)   /*!< COMP output isn't connected to other peripherals */
604 /* Output Redirection common for all comparators COMP1...COMP7 */
605 #define COMP_OUTPUT_TIM1BKIN                         COMP_CSR_COMPxOUTSEL_0   /*!< COMP output connected to TIM1 Break Input (BKIN) */
606 #define COMP_OUTPUT_TIM1BKIN2                        ((uint32_t)0x00000800)   /*!< COMP output connected to TIM1 Break Input 2 (BKIN2) */
607 #define COMP_OUTPUT_TIM8BKIN                         ((uint32_t)0x00000C00)   /*!< COMP output connected to TIM8 Break Input (BKIN) */
608 #define COMP_OUTPUT_TIM8BKIN2                        ((uint32_t)0x00001000)   /*!< COMP output connected to TIM8 Break Input 2 (BKIN2) */
609 #define COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2              ((uint32_t)0x00001400)   /*!< COMP output connected to TIM1 Break Input 2 and TIM8 Break Input 2 */
610 #define COMP_OUTPUT_TIM20BKIN                        ((uint32_t)0x00003000)   /*!< COMP output connected to TIM20 Break Input (BKIN) */
611 #define COMP_OUTPUT_TIM20BKIN2                       ((uint32_t)0x00003400)   /*!< COMP output connected to TIM20 Break Input 2 (BKIN2) */
612 #define COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2   ((uint32_t)0x00003800)   /*!< COMP output connected to TIM1 Break Input 2, TIM8 Break Input 2 and TIM20 Break Input 2  */
613 /* Output Redirection common for COMP1 and COMP2 */
614 #define COMP_OUTPUT_TIM1OCREFCLR                      ((uint32_t)0x00001800)   /*!< COMP output connected to TIM1 OCREF Clear */
615 #define COMP_OUTPUT_TIM1IC1                           ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM1 Input Capture 1 */
616 #define COMP_OUTPUT_TIM2IC4                           ((uint32_t)0x00002000)   /*!< COMP output connected to TIM2 Input Capture 4 */
617 #define COMP_OUTPUT_TIM2OCREFCLR                      ((uint32_t)0x00002400)   /*!< COMP output connected to TIM2 OCREF Clear */
618 #define COMP_OUTPUT_TIM3IC1                           ((uint32_t)0x00002800)   /*!< COMP output connected to TIM3 Input Capture 1 */
619 #define COMP_OUTPUT_TIM3OCREFCLR                      ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM3 OCREF Clear */
620 /* Output Redirection specific to COMP2 */
621 #define COMP_OUTPUT_TIM20OCREFCLR                     ((uint32_t)0x00003C00)   /*!< COMP output connected to TIM20 OCREF Clear */
622 /* Output Redirection specific to COMP3 */
623 #define COMP_OUTPUT_TIM4IC1                           ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM4 Input Capture 1 */
624 #define COMP_OUTPUT_TIM3IC2                           ((uint32_t)0x00002000)   /*!< COMP output connected to TIM3 Input Capture 2 */
625 #define COMP_OUTPUT_TIM15IC1                          ((uint32_t)0x00002800)   /*!< COMP output connected to TIM15 Input Capture 1 */
626 #define COMP_OUTPUT_TIM15BKIN                         ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM15 Break Input (BKIN) */
627 /* Output Redirection specific to COMP4 */
628 #define COMP_OUTPUT_TIM3IC3                           ((uint32_t)0x00001800)   /*!< COMP output connected to TIM3 Input Capture 3 */
629 #define COMP_OUTPUT_TIM8OCREFCLR                      ((uint32_t)0x00001C00)   /*!< COMP output connected to TIM8 OCREF Clear */
630 #define COMP_OUTPUT_TIM15IC2                          ((uint32_t)0x00002000)   /*!< COMP output connected to TIM15 Input Capture 2 */
631 #define COMP_OUTPUT_TIM4IC2                           ((uint32_t)0x00002400)   /*!< COMP output connected to TIM4 Input Capture 2 */
632 #define COMP_OUTPUT_TIM15OCREFCLR                     ((uint32_t)0x00002800)   /*!< COMP output connected to TIM15 OCREF Clear */
633 /* Output Redirection specific to COMP5 */
634 #define COMP_OUTPUT_TIM2IC1                           ((uint32_t)0x00001800)   /*!< COMP output connected to TIM2 Input Capture 1 */
635 #define COMP_OUTPUT_TIM17IC1                          ((uint32_t)0x00002000)   /*!< COMP output connected to TIM17 Input Capture 1 */
636 #define COMP_OUTPUT_TIM4IC3                           ((uint32_t)0x00002400)   /*!< COMP output connected to TIM4 Input Capture 3 */
637 #define COMP_OUTPUT_TIM16BKIN                         ((uint32_t)0x00002800)   /*!< COMP output connected to TIM16 Break Input (BKIN) */
638 /* Output Redirection specific to COMP6 */
639 #define COMP_OUTPUT_TIM2IC2                           ((uint32_t)0x00001800)   /*!< COMP output connected to TIM2 Input Capture 2 */
640 #define COMP_OUTPUT_COMP6TIM2OCREFCLR                 ((uint32_t)0x00002000)   /*!< COMP output connected to TIM2 OCREF Clear */
641 #define COMP_OUTPUT_TIM16OCREFCLR                     ((uint32_t)0x00002400)   /*!< COMP output connected to TIM16 OCREF Clear */
642 #define COMP_OUTPUT_TIM16IC1                          ((uint32_t)0x00002800)   /*!< COMP output connected to TIM16 Input Capture 1 */
643 #define COMP_OUTPUT_TIM4IC4                           ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM4 Input Capture 4 */
644 /* Output Redirection specific to COMP7 */
645 #define COMP_OUTPUT_TIM2IC3                           ((uint32_t)0x00002000)   /*!< COMP output connected to TIM2 Input Capture 3 */
646 #define COMP_OUTPUT_TIM1IC2                           ((uint32_t)0x00002400)   /*!< COMP output connected to TIM1 Input Capture 2 */
647 #define COMP_OUTPUT_TIM17OCREFCLR                     ((uint32_t)0x00002800)   /*!< COMP output connected to TIM16 OCREF Clear */
648 #define COMP_OUTPUT_TIM17BKIN                         ((uint32_t)0x00002C00)   /*!< COMP output connected to TIM16 Break Input (BKIN) */
649 #define IS_COMP_OUTPUT(OUTPUT) (((OUTPUT) == COMP_OUTPUT_NONE)                || \
650                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN)            || \
651                                 ((OUTPUT) == COMP_OUTPUT_TIM1IC1)             || \
652                                 ((OUTPUT) == COMP_OUTPUT_TIM1OCREFCLR)        || \
653                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC4)             || \
654                                 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR)        || \
655                                 ((OUTPUT) == COMP_OUTPUT_COMP6TIM2OCREFCLR)   || \
656                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC1)             || \
657                                 ((OUTPUT) == COMP_OUTPUT_TIM3OCREFCLR)        || \
658                                 ((OUTPUT) == COMP_OUTPUT_TIM20OCREFCLR)       || \
659                                 ((OUTPUT) == COMP_OUTPUT_TIM8BKIN)            || \
660                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2)           || \
661                                 ((OUTPUT) == COMP_OUTPUT_TIM8BKIN2)           || \
662                                 ((OUTPUT) == COMP_OUTPUT_TIM2OCREFCLR)        || \
663                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2) || \
664                                 ((OUTPUT) == COMP_OUTPUT_TIM20BKIN)           || \
665                                 ((OUTPUT) == COMP_OUTPUT_TIM20BKIN2)          || \
666                                 ((OUTPUT) == COMP_OUTPUT_TIM1BKIN2_TIM8BKIN2_TIM20BKIN2) || \
667                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC2)             || \
668                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC1)             || \
669                                 ((OUTPUT) == COMP_OUTPUT_TIM15IC1)            || \
670                                 ((OUTPUT) == COMP_OUTPUT_TIM15BKIN)           || \
671                                 ((OUTPUT) == COMP_OUTPUT_TIM8OCREFCLR)        || \
672                                 ((OUTPUT) == COMP_OUTPUT_TIM3IC3)             || \
673                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC1)             || \
674                                 ((OUTPUT) == COMP_OUTPUT_TIM15IC1)            || \
675                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC1)             || \
676                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC3)             || \
677                                 ((OUTPUT) == COMP_OUTPUT_TIM16BKIN)           || \
678                                 ((OUTPUT) == COMP_OUTPUT_TIM17IC1)            || \
679                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC2)             || \
680                                 ((OUTPUT) == COMP_OUTPUT_TIM16IC1)            || \
681                                 ((OUTPUT) == COMP_OUTPUT_TIM4IC4)             || \
682                                 ((OUTPUT) == COMP_OUTPUT_TIM16OCREFCLR)       || \
683                                 ((OUTPUT) == COMP_OUTPUT_TIM2IC3)             || \
684                                 ((OUTPUT) == COMP_OUTPUT_TIM1IC2)             || \
685                                 ((OUTPUT) == COMP_OUTPUT_TIM17BKIN)           || \
686                                 ((OUTPUT) == COMP_OUTPUT_TIM17OCREFCLR))
687 /**
688   * @}
689   */ 
690 #endif /* STM32F302xC */
691
692 #if  defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx)
693 /** @defgroup COMPEx_WindowMode COMP Extended WindowMode (STM32F302xC/STM32F303xC/STM32F358xx Product devices)
694   * @{
695   */
696 #define COMP_WINDOWMODE_DISABLED               ((uint32_t)0x00000000)  /*!< Window mode disabled */
697 #define COMP_WINDOWMODE_ENABLED                COMP_CSR_COMPxWNDWEN    /*!< Window mode enabled: non inverting input of comparator X (x=2,4,6)
698                                                                             is connected to the non inverting input of comparator X-1 */
699 #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLED) || \
700                                         ((WINDOWMODE) == COMP_WINDOWMODE_ENABLED))
701
702 #define COMP_CSR_COMPxWNDWEN_MASK              COMP_CSR_COMPxWNDWEN /*!< COMP_CSR_COMPxWNDWEN mask */
703 /**
704   * @}
705   */
706 #elif defined(STM32F373xC) || defined(STM32F378xx)
707 /** @defgroup COMPEx_WindowMode COMP Extended WindowMode (STM32F373xC/STM32F378xx Product devices)
708   * @{
709   */
710 #define COMP_WINDOWMODE_DISABLED               ((uint32_t)0x00000000)  /*!< Window mode disabled */
711 #define COMP_WINDOWMODE_ENABLED                ((uint32_t)COMP_CSR_COMPxWNDWEN) /*!< Window mode enabled: non inverting input of comparator 2
712                                                                             is connected to the non inverting input of comparator 1 (PA1) */
713 #define IS_COMP_WINDOWMODE(WINDOWMODE) (((WINDOWMODE) == COMP_WINDOWMODE_DISABLED) || \
714                                         ((WINDOWMODE) == COMP_WINDOWMODE_ENABLED))
715
716 #define COMP_CSR_COMPxWNDWEN_MASK              COMP_CSR_COMPxWNDWEN /*!< COMP_CSR_COMPxWNDWEN mask */
717 /**
718   * @}
719   */
720 #else
721 /** @defgroup COMPEx_WindowMode COMP Extended WindowMode (Other Product devices)
722   * @{
723   */
724 #define COMP_WINDOWMODE_DISABLED               ((uint32_t)0x00000000)  /*!< Window mode disabled (not available) */
725
726 #define IS_COMP_WINDOWMODE(WINDOWMODE) ((WINDOWMODE) == (WINDOWMODE)) /*!< Not available: check always true */
727
728 #define COMP_CSR_COMPxWNDWEN_MASK              ((uint32_t)0x00000000) /*!< Mask empty: feature not available */
729 /**
730   * @}
731   */
732 #endif /* STM32F302xC || STM32F303xC || STM32F358xx */
733
734 /** @defgroup COMPEx_Mode COMP Extended Mode
735   * @{
736   */
737 #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
738     defined(STM32F373xC) || defined(STM32F378xx)
739
740 /* Please refer to the electrical characteristics in the device datasheet for
741    the power consumption values */
742 #define COMP_MODE_HIGHSPEED               ((uint32_t)0x00000000) /*!< High Speed */
743 #define COMP_MODE_MEDIUMSPEED             COMP_CSR_COMPxMODE_0   /*!< Medium Speed */
744 #define COMP_MODE_LOWPOWER                COMP_CSR_COMPxMODE_1   /*!< Low power mode */
745 #define COMP_MODE_ULTRALOWPOWER           COMP_CSR_COMPxMODE     /*!< Ultra-low power mode */
746
747 #define IS_COMP_MODE(MODE)  (((MODE) == COMP_MODE_HIGHSPEED)     || \
748                              ((MODE) == COMP_MODE_MEDIUMSPEED)   || \
749                              ((MODE) == COMP_MODE_LOWPOWER)      || \
750                              ((MODE) == COMP_MODE_ULTRALOWPOWER))
751
752 #define COMP_CSR_COMPxMODE_MASK           COMP_CSR_COMPxMODE     /*!< COMP_CSR_COMPxMODE Mask */
753
754 #else
755
756 /*!< Power mode not available */
757 #define IS_COMP_MODE(MODE)  ((MODE) == (MODE))  /*!< Not available: check always true */
758
759 #define COMP_CSR_COMPxMODE_MASK           ((uint32_t)0x00000000) /*!< Mask empty: feature not available */
760
761 #endif /* STM32F302xC || STM32F303xC || STM32F358xx || */
762        /* STM32F373xC || STM32F378xx */
763 /**
764   * @}
765   */
766
767 /** @defgroup COMPEx_Hysteresis COMP Extended Hysteresis
768   * @{
769   */
770 #if defined(STM32F302xC) || defined(STM32F303xC) || defined(STM32F358xx) || \
771     defined(STM32F373xC) || defined(STM32F378xx)
772
773 #define COMP_HYSTERESIS_NONE              ((uint32_t)0x00000000)  /*!< No hysteresis */
774 #define COMP_HYSTERESIS_LOW               COMP_CSR_COMPxHYST_0    /*!< Hysteresis level low */
775 #define COMP_HYSTERESIS_MEDIUM            COMP_CSR_COMPxHYST_1    /*!< Hysteresis level medium */
776 #define COMP_HYSTERESIS_HIGH              COMP_CSR_COMPxHYST      /*!< Hysteresis level high */
777
778 #define IS_COMP_HYSTERESIS(HYSTERESIS)    (((HYSTERESIS) == COMP_HYSTERESIS_NONE)   || \
779                                            ((HYSTERESIS) == COMP_HYSTERESIS_LOW)    || \
780                                            ((HYSTERESIS) == COMP_HYSTERESIS_MEDIUM) || \
781                                            ((HYSTERESIS) == COMP_HYSTERESIS_HIGH))
782
783 #define COMP_CSR_COMPxHYST_MASK           COMP_CSR_COMPxHYST /*!< COMP_CSR_COMPxHYST Mask */
784
785 #else
786
787 #define COMP_HYSTERESIS_NONE              ((uint32_t)0x00000000)  /*!< No hysteresis */
788
789 #define IS_COMP_HYSTERESIS(HYSTERESIS)    ((HYSTERESIS) == (HYSTERESIS)) /*!< Not available: check always true */
790
791 #define COMP_CSR_COMPxHYST_MASK           ((uint32_t)0x00000000) /*!< Mask empty: feature not available */
792
793 #endif /* STM32F302xC || STM32F303xC || STM32F358xx || */
794        /* STM32F373xC || STM32F378xx */
795 /**
796   * @}
797   */
798
799 #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || \
800     defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
801 /** @defgroup COMPEx_BlankingSrce  COMP Extended Blanking Source (STM32F301x8/STM32F302x8/STM32F303x8/STM32F334x8/STM32F318xx/STM32F328xx Product devices)
802   * @{
803   */
804 /* No blanking source can be selected for all comparators */
805 #define COMP_BLANKINGSRCE_NONE                 ((uint32_t)0x00000000)    /*!< No blanking source */
806 /* Blanking source for COMP2 */
807 #define COMP_BLANKINGSRCE_TIM1OC5              COMP_CSR_COMPxBLANKING_0  /*!< TIM1 OC5 selected as blanking source for compartor */
808 #define COMP_BLANKINGSRCE_TIM2OC3              COMP_CSR_COMPxBLANKING_1  /*!< TIM2 OC3 selected as blanking source for compartor */
809 #define COMP_BLANKINGSRCE_TIM3OC3              (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1)    /*!< TIM3 OC3 selected as blanking source for compartor */
810 /* Blanking source for COMP4 */
811 #define COMP_BLANKINGSRCE_TIM3OC4              COMP_CSR_COMPxBLANKING_0    /*!< TIM3 OC4 selected as blanking source for compartor */
812 #define COMP_BLANKINGSRCE_TIM15OC1             (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1)    /*!< TIM15 OC1 selected as blanking source for compartor */
813 /* Blanking source for COMP6 */
814 #define COMP_BLANKINGSRCE_TIM2OC4              (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1)    /*!< TIM2 OC4 selected as blanking source for compartor */
815 #define COMP_BLANKINGSRCE_TIM15OC2              COMP_CSR_COMPxBLANKING_2    /*!< TIM15 OC2 selected as blanking source for compartor */
816 #define IS_COMP_BLANKINGSRCE(SOURCE) (((SOURCE) == COMP_BLANKINGSRCE_NONE)     || \
817                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM1OC5)  || \
818                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC3)  || \
819                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC3)  || \
820                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC4)  || \
821                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC4)  || \
822                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC1) || \
823                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC2))
824
825 /* STM32F301x6/x8, STM32F302x6/x8, STM32F303x6/x8, STM32F334x4/6/8, STM32F318xx/STM32F328xx devices comparator instances blanking source values */
826 #define IS_COMP_BLANKINGSRCE_INSTANCE(INSTANCE, BLANKINGSRCE) \
827    ((((INSTANCE) == COMP2)  &&                                \
828     (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)     ||        \
829      ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5)  ||        \
830      ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC3)  ||        \
831      ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3)))          \
832     ||                                                        \
833     (((INSTANCE) == COMP4) &&                                 \
834      (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)    ||        \
835       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC4) ||        \
836       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC1)))        \
837     ||                                                        \
838     (((INSTANCE) == COMP6) &&                                 \
839      (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)    ||        \
840       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4) ||        \
841       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2))))
842
843 #define COMP_CSR_COMPxBLANKING_MASK            COMP_CSR_COMPxBLANKING /*!< COMP_CSR_COMPxBLANKING mask */
844
845 /**
846   * @}
847   */
848
849 /** @defgroup COMPEx_ExtiLineEvent COMP Extended EXTI Line Event (STM32F301x8/STM32F302x8/STM32F303x8/STM32F334x8/STM32F318xx/STM32F328xx Product devices)
850   *        Elements values convention: XXXXZYYY
851   *           - XXXX : Interrupt mask in the register list where Z equal 0x0
852   *           - YYY : Interrupt mask in the register list where Z equal 0x1
853   *           - Z  : register index(4bits)
854   *                 - 0x0: EMR/IMR/RTSR/FTSR register
855   *                 - 0x1: EMR2/IMR2/RTSR2/FTSR2 register
856   * @{
857   */  
858 #define COMP_EXTI_LINE_MASK                    ((uint32_t)0xffff0fff)  /*!< Mask on possible line values */
859 #define COMP_EXTI_LINE_REG_MASK                ((uint32_t)0x00001000)  /*!< Mask on possible register values */
860 #define COMP_EXTI_LINE_COMP2_EVENT             ((uint32_t)0x00400000)  /*!< External interrupt line 22 Connected to COMP2 */
861 #define COMP_EXTI_LINE_COMP4_EVENT             ((uint32_t)0x40000000)  /*!< External interrupt line 30 Connected to COMP4 */
862 #define COMP_EXTI_LINE_COMP6_EVENT             ((uint32_t)0x00001001)  /*!< External interrupt line 32 Connected to COMP6 */
863
864 /**
865   * @}
866   */
867 #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx || */
868        /* STM32F303x8 || STM32F334x8 || STM32F328xx */
869
870 #if defined(STM32F302xE) ||\
871     defined(STM32F302xC)
872 /** @defgroup COMPEx_BlankingSrce COMP Extended Blanking Source (STM32F302xE/STM32F302xC Product devices)
873   * @{
874   */
875 /* No blanking source can be selected for all comparators */
876 #define COMP_BLANKINGSRCE_NONE                 ((uint32_t)0x00000000)    /*!< No blanking source */
877 /* Blanking source common for COMP1 and COMP2 */
878 #define COMP_BLANKINGSRCE_TIM1OC5              COMP_CSR_COMPxBLANKING_0  /*!< TIM1 OC5 selected as blanking source for compartor */
879 /* Blanking source common for COMP1 and COMP2 */
880 #define COMP_BLANKINGSRCE_TIM2OC3              COMP_CSR_COMPxBLANKING_1  /*!< TIM2 OC3 selected as blanking source for compartor */
881 /* Blanking source common for COMP1 and COMP2 */
882 #define COMP_BLANKINGSRCE_TIM3OC3              (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1)    /*!< TIM3 OC3 selected as blanking source for comparator */
883 /* Blanking source for COMP4 */
884 #define COMP_BLANKINGSRCE_TIM3OC4              COMP_CSR_COMPxBLANKING_0    /*!< TIM3 OC4 selected as blanking source for comparator */
885 #define COMP_BLANKINGSRCE_TIM15OC1             (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1)    /*!< TIM15 OC1 selected as blanking source for comparator */
886 /* Blanking source for COMP6 */
887 #define COMP_BLANKINGSRCE_TIM2OC4              (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1)    /*!< TIM2 OC4 selected as blanking source for comparator */
888 #define COMP_BLANKINGSRCE_TIM15OC2              COMP_CSR_COMPxBLANKING_2    /*!< TIM15 OC2 selected as blanking source for comparator */
889
890 #define IS_COMP_BLANKINGSRCE(SOURCE) (((SOURCE) == COMP_BLANKINGSRCE_NONE)     || \
891                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM1OC5)  || \
892                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC3)  || \
893                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC3)  || \
894                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC4)  || \
895                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC4)  || \
896                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC1) || \
897                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC2))
898
899 /* STM32F302xB/STM32F302xC/STM32F302xE devices comparator instances blanking source values */
900 #define IS_COMP_BLANKINGSRCE_INSTANCE(INSTANCE, BLANKINGSRCE) \
901    (((((INSTANCE) == COMP1) || ((INSTANCE) == COMP2))  &&     \
902      (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)    ||        \
903       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) ||        \
904       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC3) ||        \
905       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3)))         \
906     ||                                                        \
907     (((INSTANCE) == COMP4) &&                                 \
908      (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)    ||        \
909       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC4) ||        \
910       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC1)))        \
911     ||                                                        \
912     (((INSTANCE) == COMP6) &&                                 \
913      (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)    ||        \
914       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4) ||        \
915       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2))))
916
917 #define COMP_CSR_COMPxBLANKING_MASK            COMP_CSR_COMPxBLANKING /*!< COMP_CSR_COMPxBLANKING mask */
918
919 /**
920   * @}
921   */
922
923 /** @defgroup COMPEx_ExtiLineEvent COMP Extended EXTI Line Event (STM32F302xC Product devices)
924   *        Elements values convention: XXXXZYYY
925   *           - XXXX : Interrupt mask in the register list where Z equal 0x0
926   *           - YYY : Interrupt mask in the register list where Z equal 0x1
927   *           - Z  : register index(4bits)
928   *                 - 0x0: EMR/IMR/RTSR/FTSR register
929   *                 - 0x1: EMR2/IMR2/RTSR2/FTSR2 register
930   * @{
931   */  
932 #define COMP_EXTI_LINE_MASK                    ((uint32_t)0xffff0fff)  /*!< Mask on possible line values */
933 #define COMP_EXTI_LINE_REG_MASK                ((uint32_t)0x00001000)  /*!< Mask on possible register values */
934 #define COMP_EXTI_LINE_COMP1_EVENT             ((uint32_t)0x00200000)  /*!< External interrupt line 21 Connected to COMP1 */
935 #define COMP_EXTI_LINE_COMP2_EVENT             ((uint32_t)0x00400000)  /*!< External interrupt line 22 Connected to COMP2 */
936 #define COMP_EXTI_LINE_COMP4_EVENT             ((uint32_t)0x40000000)  /*!< External interrupt line 30 Connected to COMP4 */
937 #define COMP_EXTI_LINE_COMP6_EVENT             ((uint32_t)0x00001001)  /*!< External interrupt line 32 Connected to COMP6 */
938
939 /**
940   * @}
941   */
942 #endif /* STM32F302xE || */
943        /* STM32F302xC    */
944    
945 #if defined(STM32F303xE) || defined(STM32F398xx) || \
946     defined(STM32F303xC) || defined(STM32F358xx)
947 /** @defgroup COMPEx_BlankingSrce COMP Extended Blanking Source (STM32F303xE/STM32F398xx/STM32F303xC/STM32F358xx Product devices)
948   * @{
949   */
950 /* No blanking source can be selected for all comparators */
951 #define COMP_BLANKINGSRCE_NONE                 ((uint32_t)0x00000000)    /*!< No blanking source */
952 /* Blanking source common for COMP1, COMP2, COMP3 and COMP7 */
953 #define COMP_BLANKINGSRCE_TIM1OC5              COMP_CSR_COMPxBLANKING_0  /*!< TIM1 OC5 selected as blanking source for comparator */
954 /* Blanking source common for COMP1 and COMP2 */
955 #define COMP_BLANKINGSRCE_TIM2OC3              COMP_CSR_COMPxBLANKING_1  /*!< TIM2 OC5 selected as blanking source for comparator */
956 /* Blanking source common for COMP1, COMP2 and COMP5 */
957 #define COMP_BLANKINGSRCE_TIM3OC3              (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1)    /*!< TIM2 OC3 selected as blanking source for comparator */
958 /* Blanking source common for COMP3 and COMP6 */
959 #define COMP_BLANKINGSRCE_TIM2OC4              (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1)    /*!< TIM2 OC4 selected as blanking source for comparator */
960 /* Blanking source common for COMP4, COMP5, COMP6 and COMP7 */
961 #define COMP_BLANKINGSRCE_TIM8OC5              COMP_CSR_COMPxBLANKING_1  /*!< TIM8 OC5 selected as blanking source for comparator */
962 /* Blanking source for COMP4 */
963 #define COMP_BLANKINGSRCE_TIM3OC4              COMP_CSR_COMPxBLANKING_0  /*!< TIM3 OC4 selected as blanking source for comparator */
964 #define COMP_BLANKINGSRCE_TIM15OC1             (COMP_CSR_COMPxBLANKING_0|COMP_CSR_COMPxBLANKING_1)    /*!< TIM15 OC1 selected as blanking source for comparator */
965 /* Blanking source common for COMP6 and COMP7 */
966 #define COMP_BLANKINGSRCE_TIM15OC2             COMP_CSR_COMPxBLANKING_2  /*!< TIM15 OC2 selected as blanking source for comparator */
967
968 #define IS_COMP_BLANKINGSRCE(SOURCE) (((SOURCE) == COMP_BLANKINGSRCE_NONE)     || \
969                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM1OC5)  || \
970                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC3)  || \
971                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC3)  || \
972                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM2OC4)  || \
973                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM8OC5)  || \
974                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM3OC4)  || \
975                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC1) || \
976                                       ((SOURCE) == COMP_BLANKINGSRCE_TIM15OC2))
977
978 /* STM32F303xE/STM32F398xx/STM32F303xB/STM32F303xC/STM32F358xx devices comparator instances blanking source values */
979 #define IS_COMP_BLANKINGSRCE_INSTANCE(INSTANCE, BLANKINGSRCE) \
980    (((((INSTANCE) == COMP1) || ((INSTANCE) == COMP2))  &&     \
981      (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)    ||        \
982       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) ||        \
983       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC3) ||        \
984       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3)))         \
985     ||                                                        \
986     (((INSTANCE) == COMP3) &&                                 \
987      (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)    ||        \
988       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) ||        \
989       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4)))         \
990     ||                                                        \
991     (((INSTANCE) == COMP4) &&                                 \
992      (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)    ||        \
993       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC4) ||        \
994       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) ||        \
995       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC1)))        \
996     ||                                                        \
997     (((INSTANCE) == COMP5) &&                                 \
998      (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)    ||        \
999       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) ||        \
1000       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM3OC3)))         \
1001     ||                                                        \
1002     (((INSTANCE) == COMP6) &&                                 \
1003      (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)    ||        \
1004       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) ||        \
1005       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM2OC4) ||        \
1006       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2)))        \
1007     ||                                                        \
1008     (((INSTANCE) == COMP7) &&                                 \
1009      (((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE)    ||        \
1010       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM1OC5) ||        \
1011       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM8OC5) ||        \
1012       ((BLANKINGSRCE) == COMP_BLANKINGSRCE_TIM15OC2))))
1013      
1014 #define COMP_CSR_COMPxBLANKING_MASK            COMP_CSR_COMPxBLANKING /*!< COMP_CSR_COMPxBLANKING mask */
1015
1016 /**
1017   * @}
1018   */
1019
1020 /** @defgroup COMPEx_ExtiLineEvent COMP Extended EXTI Line Event (STM32F303xE/STM32F398xx/STM32F303xC/STM32F358xx Product devices)
1021   *        Elements values convention: XXXXZYYY
1022   *           - XXXX : Interrupt mask in the register list where Z equal 0x0
1023   *           - YYY : Interrupt mask in the register list where Z equal 0x1
1024   *           - Z  : register index(4bits)
1025   *                 - 0x0: EMR/IMR/RTSR/FTSR register
1026   *                 - 0x1: EMR2/IMR2/RTSR2/FTSR2 register
1027   * @{
1028   */  
1029 #define COMP_EXTI_LINE_MASK                    ((uint32_t)0xffff0fff)  /*!< Mask on possible line values */
1030 #define COMP_EXTI_LINE_REG_MASK                ((uint32_t)0x00001000)  /*!< Mask on possible register values */
1031 #define COMP_EXTI_LINE_COMP1_EVENT             ((uint32_t)0x00200000)  /*!< External interrupt line 21 Connected to COMP1 */
1032 #define COMP_EXTI_LINE_COMP2_EVENT             ((uint32_t)0x00400000)  /*!< External interrupt line 22 Connected to COMP2 */
1033 #define COMP_EXTI_LINE_COMP3_EVENT             ((uint32_t)0x20000000)  /*!< External interrupt line 29 Connected to COMP3 */
1034 #define COMP_EXTI_LINE_COMP4_EVENT             ((uint32_t)0x40000000)  /*!< External interrupt line 30 Connected to COMP4 */
1035 #define COMP_EXTI_LINE_COMP5_EVENT             ((uint32_t)0x80000000)  /*!< External interrupt line 31 Connected to COMP5 */
1036 #define COMP_EXTI_LINE_COMP6_EVENT             ((uint32_t)0x00001001)  /*!< External interrupt line 32 Connected to COMP6 */
1037 #define COMP_EXTI_LINE_COMP7_EVENT             ((uint32_t)0x00001002)  /*!< External interrupt line 33 Connected to COMP7 */
1038
1039 /**
1040   * @}
1041   */
1042 #endif /* STM32F303xE || STM32F398xx || */
1043        /* STM32F303xC || STM32F358xx    */
1044
1045 #if defined(STM32F373xC) ||defined(STM32F378xx)
1046 /** @defgroup COMPEx_BlankingSrce COMP Extended Blanking Source (STM32F373xC/STM32F378xx Product devices)
1047   * @{
1048   */
1049 /* No blanking source can be selected for all comparators */
1050 #define COMP_BLANKINGSRCE_NONE                 ((uint32_t)0x00000000)     /*!< No blanking source */
1051
1052 #define IS_COMP_BLANKINGSRCE(SOURCE) ((SOURCE) == (SOURCE)) /*!< Not available: check always true */
1053
1054 /* STM32F373xB/STM32F373xC/STM32F378xx devices comparator instances blanking source values */
1055 #define IS_COMP_BLANKINGSRCE_INSTANCE(INSTANCE, BLANKINGSRCE) \
1056    ((((INSTANCE) == COMP1) || ((INSTANCE) == COMP2))  &&     \
1057      ((BLANKINGSRCE) == COMP_BLANKINGSRCE_NONE))         
1058
1059 #define COMP_CSR_COMPxBLANKING_MASK            ((uint32_t)0x00000000) /*!< Mask empty: feature not available */
1060
1061 /**
1062   * @}
1063   */
1064
1065 /** @defgroup COMPEx_ExtiLineEvent COMP Extended EXTI Line Event (STM32F373xC/STM32F378xx Product devices)
1066   *        Elements values convention: XXXX0000
1067   *           - XXXX : Interrupt mask in the EMR/IMR/RTSR/FTSR register
1068   * @{   
1069   */  
1070 #define COMP_EXTI_LINE_COMP1_EVENT             ((uint32_t)0x00200000)  /*!< External interrupt line 21 Connected to COMP1 */
1071 #define COMP_EXTI_LINE_COMP2_EVENT             ((uint32_t)0x00400000)  /*!< External interrupt line 22 Connected to COMP2 */
1072
1073 /**
1074   * @}
1075   */
1076 #endif /* STM32F373xC || STM32F378xx */
1077
1078 #if  defined(STM32F373xC) || defined(STM32F378xx)
1079 /* CSR register reset value */ 
1080 #define COMP_CSR_RESET_VALUE                  ((uint32_t)0x00000000)
1081 #define COMP_CSR_RESET_PARAMETERS_MASK        ((uint32_t)0x00003FFF)
1082 #define COMP_CSR_UPDATE_PARAMETERS_MASK       ((uint32_t)0x00003FFE)
1083 /* CSR COMP1/COMP2 shift */ 
1084 #define COMP_CSR_COMP1_SHIFT                  0U
1085 #define COMP_CSR_COMP2_SHIFT                  16U
1086 #else
1087 /* CSR register reset value */ 
1088 #define COMP_CSR_RESET_VALUE                  ((uint32_t)0x00000000)
1089 #endif /* STM32F373xC || STM32F378xx */
1090 /* CSR masks redefinition for internal use */
1091 #define COMP_CSR_COMPxINSEL_MASK              COMP_CSR_COMPxINSEL   /*!< COMP_CSR_COMPxINSEL Mask */
1092 #define COMP_CSR_COMPxOUTSEL_MASK             COMP_CSR_COMPxOUTSEL  /*!< COMP_CSR_COMPxOUTSEL Mask */  
1093 #define COMP_CSR_COMPxPOL_MASK                COMP_CSR_COMPxPOL     /*!< COMP_CSR_COMPxPOL Mask   */
1094
1095 /**
1096   * @}
1097   */
1098
1099 /* Exported macro ------------------------------------------------------------*/
1100 /** @defgroup USARTEx_Exported_Macros USART Extended Exported Macros
1101   * @{
1102   */
1103 #if defined(STM32F373xC) ||defined(STM32F378xx)
1104 /**
1105   * @brief  Checks whether the specified EXTI line flag is set or not.
1106   * @param  __FLAG__: specifies the COMP Exti sources to be checked.
1107   *          This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1108   * @retval The state of __FLAG__ (SET or RESET).
1109   */
1110 #define __HAL_COMP_EXTI_GET_FLAG(__FLAG__)  (EXTI->PR & (__FLAG__))
1111      
1112 /**
1113   * @brief Clear the COMP Exti flags.
1114   * @param  __FLAG__: specifies the COMP Exti sources to be cleared.
1115   *          This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1116   * @retval None.
1117   */
1118 #define __HAL_COMP_EXTI_CLEAR_FLAG(__FLAG__)   (EXTI->PR = (__FLAG__))
1119
1120 /**
1121   * @brief  Enable the COMP Exti Line.
1122   * @param  __EXTILINE__: specifies the COMP Exti sources to be enabled.
1123   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1124   * @retval None.
1125   */                                         
1126 #define __HAL_COMP_EXTI_ENABLE_IT(__EXTILINE__)   (EXTI->IMR |= (__EXTILINE__))
1127                                              
1128 /**
1129   * @brief  Disable the COMP Exti Line.
1130   * @param  __EXTILINE__: specifies the COMP Exti sources to be disabled.
1131   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1132   * @retval None.
1133   */
1134 #define __HAL_COMP_EXTI_DISABLE_IT(__EXTILINE__)  (EXTI->IMR &= ~(__EXTILINE__))
1135
1136 /**
1137   * @brief  Enable the Exti Line rising edge trigger.
1138   * @param  __EXTILINE__: specifies the COMP Exti sources to be enabled.
1139   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1140   * @retval None.
1141   */                                         
1142 #define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__) (EXTI->RTSR |= (__EXTILINE__))
1143
1144 /**
1145   * @brief  Disable the Exti Line rising edge trigger.
1146   * @param  __EXTILINE__: specifies the COMP Exti sources to be disabled.
1147   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1148   * @retval None.
1149   */                                         
1150 #define __HAL_COMP_EXTI_RISING_IT_DISABLE(__EXTILINE__) (EXTI->RTSR &= ~(__EXTILINE__))
1151
1152 /**
1153   * @brief  Enable the Exti Line falling edge trigger.
1154   * @param  __EXTILINE__: specifies the COMP Exti sources to be enabled.
1155   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1156   * @retval None.
1157   */                                         
1158 #define __HAL_COMP_EXTI_FALLING_IT_ENABLE(__EXTILINE__) (EXTI->FTSR |= (__EXTILINE__))
1159
1160 /**
1161   * @brief  Disable the Exti Line falling edge trigger.
1162   * @param  __EXTILINE__: specifies the COMP Exti sources to be disabled.
1163   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1164   * @retval None.
1165   */                                         
1166 #define __HAL_COMP_EXTI_FALLING_IT_DISABLE(__EXTILINE__) (EXTI->FTSR &= ~(__EXTILINE__))
1167
1168 /**
1169   * @brief  Init a comparator instance
1170   * @param  __HANDLE__: specifies the COMP handle
1171   * @note   The common output selection is checked versus the COMP instance to set the right output configuration
1172   * @retval None.
1173   */                                         
1174 #define COMP_OUTPUT_COMP2_TIM2IC4         ((uint32_t)0x0400)   /*!< COMP2 output connected to TIM2 Input Capture 4 */
1175 #define COMP_OUTPUT_COMP2_TIM2OCREFCLR    ((uint32_t)0x0500)   /*!< COMP2 output connected to TIM4 OCREF Clear */
1176 #define COMP_OUTPUT_COMP2_TIM3IC1         ((uint32_t)0x0600)   /*!< COMP2 output connected to TIM3 Input Capture 1 */
1177 #define COMP_OUTPUT_COMP2_TIM3OCREFCLR    ((uint32_t)0x0700)   /*!< COMP2 output connected to TIM3 OCREF Clear */
1178
1179 #define COMP_INIT(__HANDLE__)                                                  \
1180         do {                                                                   \
1181           uint32_t regshift = COMP_CSR_COMP1_SHIFT;                            \
1182           uint32_t compoutput = (__HANDLE__)->Init.Output;                     \
1183                                                                                \
1184           if((__HANDLE__)->Instance == COMP2)                                  \
1185           {                                                                    \
1186             regshift = COMP_CSR_COMP2_SHIFT;                                   \
1187             switch((__HANDLE__)->Init.Output)                                  \
1188             {                                                                  \
1189             case COMP_OUTPUT_TIM2IC4:                                          \
1190               compoutput = COMP_OUTPUT_COMP2_TIM2IC4;                          \
1191               break;                                                           \
1192             case COMP_OUTPUT_TIM2OCREFCLR:                                     \
1193               compoutput = COMP_OUTPUT_COMP2_TIM2OCREFCLR;                     \
1194               break;                                                           \
1195             case COMP_OUTPUT_TIM3IC1:                                          \
1196               compoutput = COMP_OUTPUT_COMP2_TIM3IC1;                          \
1197               break;                                                           \
1198             case COMP_OUTPUT_TIM3OCREFCLR:                                     \
1199               compoutput = COMP_OUTPUT_COMP2_TIM3OCREFCLR;                     \
1200               break;                                                           \
1201             default:                                                           \
1202               break;                                                           \
1203             }                                                                  \
1204           }                                                                    \
1205                                                                                \
1206           MODIFY_REG(COMP->CSR,                                                \
1207                      (COMP_CSR_COMPxINSEL  | COMP_CSR_COMPxNONINSEL_MASK |     \
1208                      COMP_CSR_COMPxOUTSEL  | COMP_CSR_COMPxPOL           |     \
1209                      COMP_CSR_COMPxHYST    | COMP_CSR_COMPxMODE) << regshift,  \
1210                      ((__HANDLE__)->Init.InvertingInput    |                   \
1211                      (__HANDLE__)->Init.NonInvertingInput  |                   \
1212                      compoutput                            |                   \
1213                      (__HANDLE__)->Init.OutputPol          |                   \
1214                      (__HANDLE__)->Init.Hysteresis         |                   \
1215                      (__HANDLE__)->Init.Mode) << regshift);                    \
1216                                                                                \
1217           if((__HANDLE__)->Init.WindowMode != COMP_WINDOWMODE_DISABLED)        \
1218           {                                                                    \
1219             COMP->CSR |= COMP_CSR_WNDWEN;                                      \
1220           }                                                                    \
1221         } while(0)
1222
1223 /**
1224   * @brief  DeInit a comparator instance
1225   * @param  __HANDLE__: specifies the COMP handle
1226   * @retval None.
1227   */                                         
1228 #define COMP_DEINIT(__HANDLE__)                                                \
1229         do {                                                                   \
1230           uint32_t regshift = COMP_CSR_COMP1_SHIFT;                            \
1231                                                                                \
1232           if((__HANDLE__)->Instance == COMP2)                                  \
1233           {                                                                    \
1234             regshift = COMP_CSR_COMP2_SHIFT;                                   \
1235           }                                                                    \
1236           MODIFY_REG(COMP->CSR,                                                \
1237                      COMP_CSR_RESET_PARAMETERS_MASK << regshift,               \
1238                      COMP_CSR_RESET_VALUE << regshift);                        \
1239         } while(0)
1240
1241 /**
1242   * @brief  Start a comparator instance
1243   * @param  __HANDLE__: specifies the COMP handle
1244   * @retval None.
1245   */                                         
1246 #define COMP_START(__HANDLE__)                                                 \
1247         do {                                                                   \
1248           uint32_t regshift = COMP_CSR_COMP1_SHIFT;                            \
1249                                                                                \
1250           if((__HANDLE__)->Instance == COMP2)                                  \
1251           {                                                                    \
1252             regshift = COMP_CSR_COMP2_SHIFT;                                   \
1253           }                                                                    \
1254           SET_BIT(COMP->CSR, (uint32_t)COMP_CSR_COMPxEN << regshift);                    \
1255         } while(0)
1256
1257 /**
1258   * @brief  Stop a comparator instance
1259   * @param  __HANDLE__: specifies the COMP handle
1260   * @retval None.
1261   */                                         
1262 #define COMP_STOP(__HANDLE__)                                                  \
1263         do {                                                                   \
1264           uint32_t regshift = COMP_CSR_COMP1_SHIFT;                            \
1265                                                                                \
1266           if((__HANDLE__)->Instance == COMP2)                                  \
1267           {                                                                    \
1268             regshift = COMP_CSR_COMP2_SHIFT;                                   \
1269           }                                                                    \
1270           CLEAR_BIT(COMP->CSR, (uint32_t)COMP_CSR_COMPxEN << regshift);                  \
1271         } while(0)
1272   
1273 /**
1274   * @brief  Lock a comparator instance
1275   * @param  __HANDLE__: specifies the COMP handle
1276   * @retval None.
1277   */                                         
1278 #define COMP_LOCK(__HANDLE__)                                                  \
1279         do {                                                                   \
1280           uint32_t regshift = COMP_CSR_COMP1_SHIFT;                            \
1281                                                                                \
1282           if((__HANDLE__)->Instance == COMP2)                                  \
1283           {                                                                    \
1284             regshift = COMP_CSR_COMP2_SHIFT;                                   \
1285           }                                                                    \
1286           SET_BIT(COMP->CSR, (uint32_t)COMP_CSR_COMPxLOCK << regshift);                  \
1287         } while(0)
1288
1289 #else
1290 /**
1291   * @brief  Checks whether the specified EXTI line flag is set or not.
1292   * @param  __EXTILINE__: specifies the COMP Exti sources to be checked.
1293   *          This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1294   * @retval The state of __FLAG__ (SET or RESET).
1295   */
1296 #define __HAL_COMP_EXTI_GET_FLAG(__EXTILINE__)     \
1297               ((((__EXTILINE__) & COMP_EXTI_LINE_REG_MASK) != RESET) ? (EXTI->PR2 & (__EXTILINE__)) : (EXTI->PR & (__EXTILINE__)))
1298      
1299 /**
1300   * @brief Clear the COMP Exti flags.
1301   * @param  __EXTILINE__: specifies the COMP Exti sources to be cleared.
1302   *          This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1303   * @retval None.
1304   */
1305 #define __HAL_COMP_EXTI_CLEAR_FLAG(__EXTILINE__)   \
1306               ((((__EXTILINE__) & COMP_EXTI_LINE_REG_MASK) != RESET) ? (EXTI->PR2 = (__EXTILINE__)) : (EXTI->PR = (__EXTILINE__)))
1307
1308 /**
1309   * @brief  Enable the COMP Exti Line.
1310   * @param  __EXTILINE__: specifies the COMP Exti sources to be enabled.
1311   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1312   * @retval None.
1313   */                                         
1314 #define __HAL_COMP_EXTI_ENABLE_IT(__EXTILINE__)   \
1315               ((((__EXTILINE__) & COMP_EXTI_LINE_REG_MASK) != RESET) ? (EXTI->IMR2 |= (__EXTILINE__)) : (EXTI->IMR |= (__EXTILINE__)))
1316                                              
1317 /**
1318   * @brief  Disable the COMP Exti Line.
1319   * @param  __EXTILINE__: specifies the COMP Exti sources to be disabled.
1320   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1321   * @retval None.
1322   */
1323 #define __HAL_COMP_EXTI_DISABLE_IT(__EXTILINE__)   \
1324               ((((__EXTILINE__) & COMP_EXTI_LINE_REG_MASK) != RESET) ? (EXTI->IMR2 &= ~(__EXTILINE__)) : (EXTI->IMR &= ~(__EXTILINE__)))
1325
1326 /**
1327   * @brief  Enable the Exti Line rising edge trigger.
1328   * @param  __EXTILINE__: specifies the COMP Exti sources to be enabled.
1329   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1330   * @retval None.
1331   */                                         
1332 #define __HAL_COMP_EXTI_RISING_IT_ENABLE(__EXTILINE__)   \
1333               ((((__EXTILINE__) & COMP_EXTI_LINE_REG_MASK) != RESET) ? (EXTI->RTSR2 |= (__EXTILINE__)) : (EXTI->RTSR |= (__EXTILINE__)))
1334
1335 /**
1336   * @brief  Disable the Exti Line rising edge trigger.
1337   * @param  __EXTILINE__: specifies the COMP Exti sources to be disabled.
1338   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1339   * @retval None.
1340   */                                         
1341 #define __HAL_COMP_EXTI_RISING_IT_DISABLE(__EXTILINE__)   \
1342               ((((__EXTILINE__) & COMP_EXTI_LINE_REG_MASK) != RESET) ? (EXTI->RTSR2 &= ~(__EXTILINE__)) : (EXTI->RTSR &= ~(__EXTILINE__)))
1343
1344 /**
1345   * @brief  Enable the Exti Line falling edge trigger.
1346   * @param  __EXTILINE__: specifies the COMP Exti sources to be enabled.
1347   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1348   * @retval None.
1349   */                                         
1350 #define __HAL_COMP_EXTI_FALLING_IT_ENABLE(__EXTILINE__)  \
1351               ((((__EXTILINE__) & COMP_EXTI_LINE_REG_MASK) != RESET) ? (EXTI->FTSR2 |= (__EXTILINE__)) : (EXTI->FTSR |= (__EXTILINE__)))
1352
1353 /**
1354   * @brief  Disable the Exti Line falling edge trigger.
1355   * @param  __EXTILINE__: specifies the COMP Exti sources to be disabled.
1356   *         This parameter can be a value of @ref COMPEx_ExtiLineEvent 
1357   * @retval None.
1358   */                                         
1359 #define __HAL_COMP_EXTI_FALLING_IT_DISABLE(__EXTILINE__)  \
1360               ((((__EXTILINE__) & COMP_EXTI_LINE_REG_MASK) != RESET) ? (EXTI->FTSR2 &= ~(__EXTILINE__)) : (EXTI->FTSR &= ~(__EXTILINE__)))
1361
1362
1363 /**
1364   * @brief  Init a comparator instance
1365   * @param  __HANDLE__: specifies the COMP handle
1366   * @retval None.
1367   */                                         
1368 #define COMP_INIT(__HANDLE__)                                                                    \
1369         do {                                                                                     \
1370           __IO uint32_t     csrreg = 0;                                                          \
1371                                                                                                  \
1372           csrreg = READ_REG((__HANDLE__)->Instance->CSR);                                        \
1373           MODIFY_REG(csrreg, COMP_CSR_COMPxINSEL_MASK, (__HANDLE__)->Init.InvertingInput);       \
1374           MODIFY_REG(csrreg, COMP_CSR_COMPxNONINSEL_MASK, (__HANDLE__)->Init.NonInvertingInput); \
1375           MODIFY_REG(csrreg, COMP_CSR_COMPxBLANKING_MASK, (__HANDLE__)->Init.BlankingSrce);      \
1376           MODIFY_REG(csrreg, COMP_CSR_COMPxOUTSEL_MASK, (__HANDLE__)->Init.Output);              \
1377           MODIFY_REG(csrreg, COMP_CSR_COMPxPOL_MASK, (__HANDLE__)->Init.OutputPol);              \
1378           MODIFY_REG(csrreg, COMP_CSR_COMPxHYST_MASK, (__HANDLE__)->Init.Hysteresis);            \
1379           MODIFY_REG(csrreg, COMP_CSR_COMPxMODE_MASK, (__HANDLE__)->Init.Mode);                  \
1380           MODIFY_REG(csrreg, COMP_CSR_COMPxWNDWEN_MASK, (__HANDLE__)->Init.WindowMode);          \
1381           WRITE_REG((__HANDLE__)->Instance->CSR, csrreg);                                        \
1382         } while(0)
1383
1384 /**
1385   * @brief  DeInit a comparator instance
1386   * @param  __HANDLE__: specifies the COMP handle
1387   * @retval None.
1388   */                                         
1389 #define COMP_DEINIT(__HANDLE__)    WRITE_REG((__HANDLE__)->Instance->CSR, COMP_CSR_RESET_VALUE)
1390
1391 /**
1392   * @brief  Start a comparator instance
1393   * @param  __HANDLE__: specifies the COMP handle
1394   * @retval None.
1395   */                                         
1396 #define COMP_START(__HANDLE__)     SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_COMPxEN)
1397
1398 /**
1399   * @brief  Stop a comparator instance
1400   * @param  __HANDLE__: specifies the COMP handle
1401   * @retval None.
1402   */                                         
1403 #define COMP_STOP(__HANDLE__)      CLEAR_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_COMPxEN)
1404
1405 /**
1406   * @brief  Lock a comparator instance
1407   * @param  __HANDLE__: specifies the COMP handle
1408   * @retval None.
1409   */                                         
1410 #define COMP_LOCK(__HANDLE__)      SET_BIT((__HANDLE__)->Instance->CSR, COMP_CSR_COMPxLOCK)
1411
1412 #endif /* STM32F373xC || STM32F378xx */
1413
1414 #if defined(STM32F301x8) || defined(STM32F302x8) || defined(STM32F318xx) || \
1415     defined(STM32F303x8) || defined(STM32F334x8) || defined(STM32F328xx)
1416 /**
1417   * @brief  Get the specified EXTI line for a comparator instance
1418   * @param  __INSTANCE__: specifies the COMP instance.
1419   * @retval value of @ref COMPEx_ExtiLineEvent
1420   */
1421 #define __HAL_COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2_EVENT : \
1422                                                 ((__INSTANCE__) == COMP4) ? COMP_EXTI_LINE_COMP4_EVENT : \
1423                                                 COMP_EXTI_LINE_COMP6_EVENT)
1424 #endif /* STM32F301x8 || STM32F302x8 || STM32F318xx || */
1425        /* STM32F303x8 || STM32F334x8 || STM32F328xx */
1426
1427 #if defined(STM32F302xE) || \
1428     defined(STM32F302xC)
1429 /**
1430   * @brief  Get the specified EXTI line for a comparator instance
1431   * @param  __INSTANCE__: specifies the COMP instance.
1432   * @retval value of @ref COMPEx_ExtiLineEvent
1433   */
1434 #define __HAL_COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1_EVENT : \
1435                                                 ((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2_EVENT : \
1436                                                 ((__INSTANCE__) == COMP4) ? COMP_EXTI_LINE_COMP4_EVENT : \
1437                                                 COMP_EXTI_LINE_COMP6_EVENT)
1438 #endif /* STM32F302xE || */
1439        /* STM32F302xC    */
1440    
1441 #if defined(STM32F303xE) || defined(STM32F398xx) || \
1442     defined(STM32F303xC) || defined(STM32F358xx)
1443 /**
1444   * @brief  Get the specified EXTI line for a comparator instance
1445   * @param  __INSTANCE__: specifies the COMP instance.
1446   * @retval value of @ref COMPEx_ExtiLineEvent
1447   */
1448 #define __HAL_COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1_EVENT : \
1449                                                 ((__INSTANCE__) == COMP2) ? COMP_EXTI_LINE_COMP2_EVENT : \
1450                                                 ((__INSTANCE__) == COMP3) ? COMP_EXTI_LINE_COMP3_EVENT : \
1451                                                 ((__INSTANCE__) == COMP4) ? COMP_EXTI_LINE_COMP4_EVENT : \
1452                                                 ((__INSTANCE__) == COMP5) ? COMP_EXTI_LINE_COMP5_EVENT : \
1453                                                 ((__INSTANCE__) == COMP6) ? COMP_EXTI_LINE_COMP6_EVENT : \
1454                                                 COMP_EXTI_LINE_COMP7_EVENT)
1455 #endif /* STM32F303xE || STM32F398xx || */
1456        /* STM32F303xC || STM32F358xx    */
1457                                                  
1458 #if defined(STM32F373xC) ||defined(STM32F378xx)
1459 /**
1460   * @brief  Get the specified EXTI line for a comparator instance
1461   * @param  __INSTANCE__: specifies the COMP instance.
1462   * @retval value of @ref COMPEx_ExtiLineEvent
1463   */
1464 #define __HAL_COMP_GET_EXTI_LINE(__INSTANCE__) (((__INSTANCE__) == COMP1) ? COMP_EXTI_LINE_COMP1_EVENT : \
1465                                                 COMP_EXTI_LINE_COMP2_EVENT)
1466 #endif /* STM32F373xC || STM32F378xx */
1467
1468 /**
1469   * @}
1470   */
1471   
1472 /* Exported functions --------------------------------------------------------*/
1473
1474 /* Initialization and de-initialization functions  ****************************/
1475 /* IO operation functions *****************************************************/
1476 /* Peripheral Control functions ***********************************************/
1477 /* Peripheral State and Error functions ***************************************/
1478
1479 /**
1480   * @}
1481   */ 
1482
1483 /**
1484   * @}
1485   */ 
1486
1487 #ifdef __cplusplus
1488 }
1489 #endif
1490
1491 #endif /* __STM32F3xx_HAL_COMP_EX_H */
1492
1493 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/