]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F3XX/stm32f30x_comp.c
Merge commit '1fe4406f374291ab2e86e95a97341fd9c475fcb8'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F3XX / stm32f30x_comp.c
1 /**
2 ******************************************************************************
3 * @file stm32f30x_comp.c
4 * @author MCD Application Team
5 * @version V1.1.0
6 * @date 27-February-2014
7 * @brief This file provides firmware functions to manage the following
8 * functionalities of the 7 analog comparators (COMP1, COMP2...COMP7) peripheral:
9 * + Comparators configuration
10 * + Window mode control
11 *
12 @verbatim
13
14 ==============================================================================
15 ##### COMP Peripheral features #####
16 ==============================================================================
17 [..]
18 The device integrates 7 analog comparators COMP1, COMP2...COMP7:
19 (#) The non inverting input and inverting input can be set to GPIO pins
20 as shown in table1. COMP Inputs below.
21
22 (#) The COMP output is internally is available using COMP_GetOutputLevel()
23 and can be set on GPIO pins. Refer to table 2. COMP Outputs below.
24
25 (#) The COMP output can be redirected to embedded timers (TIM1, TIM2, TIM3...)
26 Refer to table 3. COMP Outputs redirection to embedded timers below.
27
28 (#) The comparators COMP1 and COMP2, COMP3 and COMP4, COMP5 and COMP6 can be combined in window
29 mode and only COMP1, COMP3 and COMP5 non inverting input can be used as non-inverting input.
30
31 (#) The seven comparators have interrupt capability with wake-up
32 from Sleep and Stop modes (through the EXTI controller):
33 (++) COMP1 is internally connected to EXTI Line 21
34 (++) COMP2 is internally connected to EXTI Line 22
35 (++) COMP3 is internally connected to EXTI Line 29
36 (++) COMP4 is internally connected to EXTI Line 30
37 (++) COMP5 is internally connected to EXTI Line 31
38 (++) COMP6 is internally connected to EXTI Line 32
39 (++) COMP7 is internally connected to EXTI Line 33
40
41 [..] Table 1. COMP Inputs
42 +------------------------------------------------------------------------------------------+
43 | | | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 |
44 |-----------------|----------------|---------------|---------------------------------------|
45 | | 1/4 VREFINT | OK | OK | OK | OK | OK | OK | OK |
46 | | 1/2 VREFINT | OK | OK | OK | OK | OK | OK | OK |
47 | | 3/4 VREFINT | OK | OK | OK | OK | OK | OK | OK |
48 | Inverting Input | VREFINT | OK | OK | OK | OK | OK | OK | OK |
49 | | DAC1 OUT1(PA4) | OK | OK | OK | OK | OK | OK | OK |
50 | | DAC1 OUT2(PA5) | OK | OK | OK | OK | OK | OK | OK |
51 | | IO1 | PA0 | PA2 | PD15 | PE8 | PD13 | PD10 | PC0 |
52 | | IO2 | --- | --- | PB12 | PB2 | PB10 | PB15 | --- |
53 | | DAC2 OUT1(PA6) | --- | OK | --- | OK | --- | OK | --- |
54 |-----------------|----------------|-------|-------|-------|-------|-------|-------|-------|
55 | Non Inverting | IO1 | PA1 | PA7 | PB14 | PB0 | PD12 | PD11 | PA0 |
56 | Input | IO2 | --- | PA3 | PD14 | PE7 | PB13 | PB11 | PC1 |
57 +------------------------------------------------------------------------------------------+
58
59 [..] Table 2. COMP Outputs
60 +-------------------------------------------------------+
61 | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 |
62 |-------|-------|-------|-------|-------|-------|-------|
63 | PA0 | PA2 | PB1 | PC8 | PC7 | PA10 | PC2 |
64 | PF4 | PA7 | --- | PA8 | PA9 | PC6 | --- |
65 | PA6 | PA12 | --- | --- | --- | --- | --- |
66 | PA11 | PB9 | --- | --- | --- | --- | --- |
67 | PB8 | --- | --- | --- | --- | --- | --- |
68 +-------------------------------------------------------+
69
70 [..] Table 3. COMP Outputs redirection to embedded timers
71 +----------------------------------------------------------------------------------------------------------------------+
72 | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 |
73 |----------------|----------------|----------------|----------------|----------------|----------------|----------------|
74 | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN |
75 | | | | | | | |
76 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 |
77 | | | | | | | |
78 | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN |
79 | | | | | | | |
80 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 |
81 | | | | | | | |
82 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 |
83 | + | + | + | + | + | + | + |
84 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 |
85 | | | | | | | |
86 | TIM1 OCREFCLR | TIM1 OCREFCLR | TIM1 OCREFCLR | TIM8 OCREFCLR | TIM8 OCREFCLR | TIM8 OCREFCLR | TIM1 OCREFCLR |
87 | | | | | | | |
88 | TIM1 IC1 | TIM1 IC1 | TIM2 OCREFCLR | TIM3 IC3 | TIM2 IC1 | TIM2 IC2 | TIM8 OCREFCLR |
89 | | | | | | | |
90 | TIM2 IC4 | TIM2 IC4 | TIM3 IC2 | TIM3 OCREFCLR | TIM3 OCREFCLR | TIM2 OCREFCLR | TIM2 IC3 |
91 | | | | | | | |
92 | TIM2 OCREFCLR | TIM2 OCREFCLR | TIM4 IC1 | TIM4 IC2 | TIM4 IC3 | TIM16 OCREFCLR| TIM1 IC2 |
93 | | | | | | | |
94 | TIM3 IC1 | TIM3 IC1 | TIM15 IC1 | TIM15 OCREFCLR| TIM16 BKIN | TIM16 IC1 | TIM17 OCREFCLR|
95 | | | | | | | |
96 | TIM3 OCREFCLR | TIM3 OCREFCLR | TIM15 BKIN | TIM15 IC2 | TIM17 IC1 | TIM4 IC4 | TIM17 BKIN |
97 +----------------------------------------------------------------------------------------------------------------------+
98
99 [..] Table 4. COMP Outputs blanking sources
100 +----------------------------------------------------------------------------------------------------------------------+
101 | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 |
102 |----------------|----------------|----------------|----------------|----------------|----------------|----------------|
103 | TIM1 OC5 | TIM1 OC5 | TIM1 OC5 | TIM3 OC4 | TIM3 OC3 | TIM2 OC4 | TIM1 OC5 |
104 | | | | | | | |
105 | TIM2 OC3 | TIM2 OC3 | -------- | TIM8 OC5 | TIM8 OC5 | TIM8 OC5 | TIM8 OC5 |
106 | | | | | | | |
107 | TIM3 OC3 | TIM3 OC3 | TIM2 OC4 | TIM15 OC1 | TIM8 BKIN | TIM15 OC2 | TIM15 OC2 |
108 | | | | | | | |
109 +----------------------------------------------------------------------------------------------------------------------+
110
111
112 ##### How to use this driver #####
113 ==============================================================================
114 [..]
115 This driver provides functions to configure and program the Comparators
116 of all STM32F30x devices.
117
118 To use the comparator, perform the following steps:
119
120 (#) Enable the SYSCFG APB clock to get write access to comparator
121 register using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
122
123 (#) Configure the comparator input in analog mode using GPIO_Init()
124
125 (#) Configure the comparator output in alternate function mode
126 using GPIO_Init() and use GPIO_PinAFConfig() function to map the
127 comparator output to the GPIO pin
128
129 (#) Configure the comparator using COMP_Init() function:
130 (++) Select the inverting input
131 (++) Select the non-inverting input
132 (++) Select the output polarity
133 (++) Select the output redirection
134 (++) Select the hysteresis level
135 (++) Select the power mode
136
137 (#) Enable the comparator using COMP_Cmd() function
138
139 (#) If required enable the COMP interrupt by configuring and enabling
140 EXTI line in Interrupt mode and selecting the desired sensitivity
141 level using EXTI_Init() function. After that enable the comparator
142 interrupt vector using NVIC_Init() function.
143
144 @endverbatim
145 *
146 ******************************************************************************
147 * @attention
148 *
149 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
150 *
151 * Redistribution and use in source and binary forms, with or without modification,
152 * are permitted provided that the following conditions are met:
153 * 1. Redistributions of source code must retain the above copyright notice,
154 * this list of conditions and the following disclaimer.
155 * 2. Redistributions in binary form must reproduce the above copyright notice,
156 * this list of conditions and the following disclaimer in the documentation
157 * and/or other materials provided with the distribution.
158 * 3. Neither the name of STMicroelectronics nor the names of its contributors
159 * may be used to endorse or promote products derived from this software
160 * without specific prior written permission.
161 *
162 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
163 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
164 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
165 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
166 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
167 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
168 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
169 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
170 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
171 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
172 *
173 ******************************************************************************
174 */
175
176 /* Includes ------------------------------------------------------------------*/
177 #include "stm32f30x_comp.h"
178
179 /** @addtogroup STM32F30x_StdPeriph_Driver
180 * @{
181 */
182
183 /** @defgroup COMP
184 * @brief COMP driver modules
185 * @{
186 */
187
188 /* Private typedef -----------------------------------------------------------*/
189 /* Private define ------------------------------------------------------------*/
190 /* CSR register Mask */
191 #define COMP_CSR_CLEAR_MASK ((uint32_t)0x00000003)
192
193 /* Private macro -------------------------------------------------------------*/
194 /* Private variables ---------------------------------------------------------*/
195 /* Private function prototypes -----------------------------------------------*/
196 /* Private functions ---------------------------------------------------------*/
197
198 /** @defgroup COMP_Private_Functions
199 * @{
200 */
201
202 /** @defgroup COMP_Group1 Initialization and Configuration functions
203 * @brief Initialization and Configuration functions
204 *
205 @verbatim
206 ===============================================================================
207 ##### Initialization and Configuration functions #####
208 ===============================================================================
209
210 @endverbatim
211 * @{
212 */
213
214 /**
215 * @brief Deinitializes COMP peripheral registers to their default reset values.
216 * @note Deinitialization can't be performed if the COMP configuration is locked.
217 * To unlock the configuration, perform a system reset.
218 * @param COMP_Selection: the selected comparator.
219 * This parameter can be COMP_Selection_COMPx where x can be 1 to 7
220 * to select the COMP peripheral.
221 * @param None
222 * @retval None
223 */
224 void COMP_DeInit(uint32_t COMP_Selection)
225 {
226 /*!< Set COMP_CSR register to reset value */
227 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) = ((uint32_t)0x00000000);
228 }
229
230 /**
231 * @brief Initializes the COMP peripheral according to the specified parameters
232 * in COMP_InitStruct
233 * @note If the selected comparator is locked, initialization can't be performed.
234 * To unlock the configuration, perform a system reset.
235 * @note By default, PA1 is selected as COMP1 non inverting input.
236 * To use PA4 as COMP1 non inverting input call COMP_SwitchCmd() after COMP_Init()
237 * @param COMP_Selection: the selected comparator.
238 * This parameter can be COMP_Selection_COMPx where x can be 1 to 7
239 * to select the COMP peripheral.
240 * @param COMP_InitStruct: pointer to an COMP_InitTypeDef structure that contains
241 * the configuration information for the specified COMP peripheral.
242 * - COMP_InvertingInput specifies the inverting input of COMP
243 * - COMP_NonInvertingInput specifies the non inverting input of COMP
244 * - COMP_Output connect COMP output to selected timer
245 * input (Input capture / Output Compare Reference Clear / Break Input)
246 * - COMP_BlankingSrce specifies the blanking source of COMP
247 * - COMP_OutputPol select output polarity
248 * - COMP_Hysteresis configures COMP hysteresis value
249 * - COMP_Mode configures COMP power mode
250 * @retval None
251 */
252 void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef* COMP_InitStruct)
253 {
254 uint32_t tmpreg = 0;
255
256 /* Check the parameters */
257 assert_param(IS_COMP_ALL_PERIPH(COMP_Selection));
258 assert_param(IS_COMP_INVERTING_INPUT(COMP_InitStruct->COMP_InvertingInput));
259 assert_param(IS_COMP_NONINVERTING_INPUT(COMP_InitStruct->COMP_NonInvertingInput));
260 assert_param(IS_COMP_OUTPUT(COMP_InitStruct->COMP_Output));
261 assert_param(IS_COMP_BLANKING_SOURCE(COMP_InitStruct->COMP_BlankingSrce));
262 assert_param(IS_COMP_OUTPUT_POL(COMP_InitStruct->COMP_OutputPol));
263 assert_param(IS_COMP_HYSTERESIS(COMP_InitStruct->COMP_Hysteresis));
264 assert_param(IS_COMP_MODE(COMP_InitStruct->COMP_Mode));
265
266 /*!< Get the COMPx_CSR register value */
267 tmpreg = *(__IO uint32_t *) (COMP_BASE + COMP_Selection);
268
269 /*!< Clear the COMP1SW1, COMPxINSEL, COMPxOUTSEL, COMPxPOL, COMPxHYST and COMPxMODE bits */
270 tmpreg &= (uint32_t) (COMP_CSR_CLEAR_MASK);
271
272 /*!< Configure COMP: inverting input, output redirection, hysteresis value and power mode */
273 /*!< Set COMPxINSEL bits according to COMP_InitStruct->COMP_InvertingInput value */
274 /*!< Set COMPxNONINSEL bits according to COMP_InitStruct->COMP_NonInvertingInput value */
275 /*!< Set COMPxBLANKING bits according to COMP_InitStruct->COMP_BlankingSrce value */
276 /*!< Set COMPxOUTSEL bits according to COMP_InitStruct->COMP_Output value */
277 /*!< Set COMPxPOL bit according to COMP_InitStruct->COMP_OutputPol value */
278 /*!< Set COMPxHYST bits according to COMP_InitStruct->COMP_Hysteresis value */
279 /*!< Set COMPxMODE bits according to COMP_InitStruct->COMP_Mode value */
280 tmpreg |= (uint32_t)(COMP_InitStruct->COMP_InvertingInput | COMP_InitStruct->COMP_NonInvertingInput |
281 COMP_InitStruct->COMP_Output | COMP_InitStruct->COMP_OutputPol | COMP_InitStruct->COMP_BlankingSrce |
282 COMP_InitStruct->COMP_Hysteresis | COMP_InitStruct->COMP_Mode);
283
284 /*!< Write to COMPx_CSR register */
285 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) = tmpreg;
286 }
287
288 /**
289 * @brief Fills each COMP_InitStruct member with its default value.
290 * @param COMP_InitStruct: pointer to an COMP_InitTypeDef structure which will
291 * be initialized.
292 * @retval None
293 */
294 void COMP_StructInit(COMP_InitTypeDef* COMP_InitStruct)
295 {
296 COMP_InitStruct->COMP_InvertingInput = COMP_InvertingInput_1_4VREFINT;
297 COMP_InitStruct->COMP_NonInvertingInput = COMP_NonInvertingInput_IO1;
298 COMP_InitStruct->COMP_Output = COMP_Output_None;
299 COMP_InitStruct->COMP_BlankingSrce = COMP_BlankingSrce_None;
300 COMP_InitStruct->COMP_OutputPol = COMP_OutputPol_NonInverted;
301 COMP_InitStruct->COMP_Hysteresis = COMP_Hysteresis_No;
302 COMP_InitStruct->COMP_Mode = COMP_Mode_UltraLowPower;
303 }
304
305 /**
306 * @brief Enable or disable the COMP peripheral.
307 * @note If the selected comparator is locked, enable/disable can't be performed.
308 * To unlock the configuration, perform a system reset.
309 * @param COMP_Selection: the selected comparator.
310 * This parameter can be COMP_Selection_COMPx where x can be 1 to 7
311 * to select the COMP peripheral.
312 * @param NewState: new state of the COMP peripheral.
313 * This parameter can be: ENABLE or DISABLE.
314 * When enabled, the comparator compares the non inverting input with
315 * the inverting input and the comparison result is available
316 * on comparator output.
317 * When disabled, the comparator doesn't perform comparison and the
318 * output level is low.
319 * @retval None
320 */
321 void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState)
322 {
323 /* Check the parameters */
324 assert_param(IS_COMP_ALL_PERIPH(COMP_Selection));
325 assert_param(IS_FUNCTIONAL_STATE(NewState));
326
327 if (NewState != DISABLE)
328 {
329 /* Enable the selected COMPx peripheral */
330 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) (COMP_CSR_COMPxEN);
331 }
332 else
333 {
334 /* Disable the selected COMP peripheral */
335 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) &= (uint32_t)(~COMP_CSR_COMPxEN);
336 }
337 }
338
339 /**
340 * @brief Close or Open the SW1 switch.
341 * @note If the COMP1 is locked, Close/Open the SW1 switch can't be performed.
342 * To unlock the configuration, perform a system reset.
343 * @note This switch is solely intended to redirect signals onto high
344 * impedance input, such as COMP1 non-inverting input (highly resistive switch)
345 * @param NewState: New state of the analog switch.
346 * This parameter can be
347 * ENABLE so the SW1 is closed; PA1 is connected to PA4
348 * or DISABLE so the SW1 switch is open; PA1 is disconnected from PA4
349 * @retval None
350 */
351 void COMP_SwitchCmd(uint32_t COMP_Selection, FunctionalState NewState)
352 {
353 /* Check the parameter */
354 assert_param(IS_FUNCTIONAL_STATE(NewState));
355
356 if (NewState != DISABLE)
357 {
358 /* Close SW1 switch */
359 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) (COMP_CSR_COMP1SW1);
360 }
361 else
362 {
363 /* Open SW1 switch */
364 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) &= (uint32_t)(~COMP_CSR_COMP1SW1);
365 }
366 }
367
368 /**
369 * @brief Return the output level (high or low) of the selected comparator.
370 * The output level depends on the selected polarity.
371 * If the polarity is not inverted:
372 * - Comparator output is low when the non-inverting input is at a lower
373 * voltage than the inverting input
374 * - Comparator output is high when the non-inverting input is at a higher
375 * voltage than the inverting input
376 * If the polarity is inverted:
377 * - Comparator output is high when the non-inverting input is at a lower
378 * voltage than the inverting input
379 * - Comparator output is low when the non-inverting input is at a higher
380 * voltage than the inverting input
381 * @param COMP_Selection: the selected comparator.
382 * This parameter can be COMP_Selection_COMPx where x can be 1 to 7
383 * to select the COMP peripheral.
384 * @retval Returns the selected comparator output level: low or high.
385 *
386 */
387 uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection)
388 {
389 uint32_t compout = 0x0;
390
391 /* Check the parameters */
392 assert_param(IS_COMP_ALL_PERIPH(COMP_Selection));
393
394 /* Check if selected comparator output is high */
395 if ((*(__IO uint32_t *) (COMP_BASE + COMP_Selection) & (COMP_CSR_COMPxOUT)) != 0)
396 {
397 compout = COMP_OutputLevel_High;
398 }
399 else
400 {
401 compout = COMP_OutputLevel_Low;
402 }
403
404 /* Return the comparator output level */
405 return (uint32_t)(compout);
406 }
407
408 /**
409 * @}
410 */
411
412 /** @defgroup COMP_Group2 Window mode control function
413 * @brief Window mode control function
414 *
415 @verbatim
416 ===============================================================================
417 ##### Window mode control function #####
418 ===============================================================================
419
420 @endverbatim
421 * @{
422 */
423
424 /**
425 * @brief Enables or disables the window mode.
426 * Window mode for comparators makes use of two comparators:
427 * COMP1 and COM2, COMP3 and COMP4, COMP5 and COMP6.
428 * In window mode, COMPx and COMPx-1 (where x can be 2, 4 or 6)
429 * non inverting inputs are connected together and only COMPx-1 non
430 * inverting input can be used.
431 * e.g When window mode enabled for COMP4, COMP3 non inverting input (PB14 or PD14)
432 * is to be used.
433 * @note If the COMPx is locked, ENABLE/DISABLE the window mode can't be performed.
434 * To unlock the configuration, perform a system reset.
435 * @param COMP_Selection: the selected comparator.
436 * This parameter can be COMP_Selection_COMPx where x can be 2, 4 or 6
437 * to select the COMP peripheral.
438 * param NewState: new state of the window mode.
439 * This parameter can be ENABLE or DISABLE.
440 * When enbaled, COMPx and COMPx-1 non inverting inputs are connected together.
441 * When disabled, COMPx and COMPx-1 non inverting inputs are disconnected.
442 * @retval None
443 */
444 void COMP_WindowCmd(uint32_t COMP_Selection, FunctionalState NewState)
445 {
446 /* Check the parameters */
447 assert_param(IS_FUNCTIONAL_STATE(NewState));
448 assert_param(IS_COMP_WINDOW(COMP_Selection));
449
450 if (NewState != DISABLE)
451 {
452 /* Enable the window mode */
453 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) COMP_CSR_COMPxWNDWEN;
454 }
455 else
456 {
457 /* Disable the window mode */
458 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) &= (uint32_t)(~COMP_CSR_COMPxWNDWEN);
459 }
460 }
461
462 /**
463 * @}
464 */
465
466 /** @defgroup COMP_Group3 COMP configuration locking function
467 * @brief COMP1, COMP2,...COMP7 configuration locking function
468 * COMP1, COMP2,...COMP7 configuration can be locked each separately.
469 * Unlocking is performed by system reset.
470 *
471 @verbatim
472 ===============================================================================
473 ##### Configuration Lock function #####
474 ===============================================================================
475
476 @endverbatim
477 * @{
478 */
479
480 /**
481 * @brief Lock the selected comparator (COMP1/COMP2) configuration.
482 * @note Locking the configuration means that all control bits are read-only.
483 * To unlock the comparator configuration, perform a system reset.
484 * @param COMP_Selection: the selected comparator.
485 * This parameter can be COMP_Selection_COMPx where x can be 1 to 7
486 * to select the COMP peripheral.
487 * @retval None
488 */
489 void COMP_LockConfig(uint32_t COMP_Selection)
490 {
491 /* Check the parameter */
492 assert_param(IS_COMP_ALL_PERIPH(COMP_Selection));
493
494 /* Set the lock bit corresponding to selected comparator */
495 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) (COMP_CSR_COMPxLOCK);
496 }
497
498 /**
499 * @}
500 */
501
502 /**
503 * @}
504 */
505
506 /**
507 * @}
508 */
509
510 /**
511 * @}
512 */
513
514 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Imprint / Impressum