Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Space_Invaders_Demo neopixels gpio_test_stm32f3_discovery gpio_test_systimer ... more
stm32f30x_comp.c
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f30x_comp.c 00004 * @author MCD Application Team 00005 * @version V1.2.3 00006 * @date 10-July-2015 00007 * @brief This file provides firmware functions to manage the following 00008 * functionalities of the 7 analog comparators (COMP1, COMP2...COMP7) peripheral: 00009 * + Comparators configuration 00010 * + Window mode control 00011 * 00012 @verbatim 00013 00014 ============================================================================== 00015 ##### COMP Peripheral features ##### 00016 ============================================================================== 00017 [..] 00018 The device integrates 7 analog comparators COMP1, COMP2...COMP7: 00019 (#) The non inverting input and inverting input can be set to GPIO pins 00020 as shown in table1. COMP Inputs below. 00021 00022 (#) The COMP output is internally is available using COMP_GetOutputLevel() 00023 and can be set on GPIO pins. Refer to table 2. COMP Outputs below. 00024 00025 (#) The COMP output can be redirected to embedded timers (TIM1, TIM2, TIM3...) 00026 Refer to table 3. COMP Outputs redirection to embedded timers below. 00027 00028 (#) The comparators COMP1 and COMP2, COMP3 and COMP4, COMP5 and COMP6 can be combined in window 00029 mode and only COMP1, COMP3 and COMP5 non inverting input can be used as non-inverting input. 00030 00031 (#) The seven comparators have interrupt capability with wake-up 00032 from Sleep and Stop modes (through the EXTI controller): 00033 (++) COMP1 is internally connected to EXTI Line 21 00034 (++) COMP2 is internally connected to EXTI Line 22 00035 (++) COMP3 is internally connected to EXTI Line 29 00036 (++) COMP4 is internally connected to EXTI Line 30 00037 (++) COMP5 is internally connected to EXTI Line 31 00038 (++) COMP6 is internally connected to EXTI Line 32 00039 (++) COMP7 is internally connected to EXTI Line 33 00040 00041 [..] Table 1. COMP Inputs 00042 +------------------------------------------------------------------------------------------+ 00043 | | | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 | 00044 |-----------------|----------------|---------------|---------------------------------------| 00045 | | 1/4 VREFINT | OK | OK | OK | OK | OK | OK | OK | 00046 | | 1/2 VREFINT | OK | OK | OK | OK | OK | OK | OK | 00047 | | 3/4 VREFINT | OK | OK | OK | OK | OK | OK | OK | 00048 | Inverting Input | VREFINT | OK | OK | OK | OK | OK | OK | OK | 00049 | | DAC1 OUT1(PA4) | OK | OK | OK | OK | OK | OK | OK | 00050 | | DAC1 OUT2(PA5) | OK | OK | OK | OK | OK | OK | OK | 00051 | | IO1 | PA0 | PA2 | PD15 | PE8 | PD13 | PD10 | PC0 | 00052 | | IO2 | --- | --- | PB12 | PB2 | PB10 | PB15 | --- | 00053 | | DAC2 OUT1(PA6) | --- | OK | --- | OK | --- | OK | --- | 00054 |-----------------|----------------|-------|-------|-------|-------|-------|-------|-------| 00055 | Non Inverting | IO1 | PA1 | PA7 | PB14 | PB0 | PD12 | PD11 | PA0 | 00056 | Input | IO2 | --- | PA3 | PD14 | PE7 | PB13 | PB11 | PC1 | 00057 +------------------------------------------------------------------------------------------+ 00058 00059 [..] Table 2. COMP Outputs 00060 +-------------------------------------------------------+ 00061 | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 | 00062 |-------|-------|-------|-------|-------|-------|-------| 00063 | PA0 | PA2 | PB1 | PC8 | PC7 | PA10 | PC2 | 00064 | PF4 | PA7 | --- | PA8 | PA9 | PC6 | --- | 00065 | PA6 | PA12 | --- | --- | --- | --- | --- | 00066 | PA11 | PB9 | --- | --- | --- | --- | --- | 00067 | PB8 | --- | --- | --- | --- | --- | --- | 00068 +-------------------------------------------------------+ 00069 00070 [..] Table 3. COMP Outputs redirection to embedded timers 00071 +----------------------------------------------------------------------------------------------------------------------+ 00072 | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 | 00073 |----------------|----------------|----------------|----------------|----------------|----------------|----------------| 00074 | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | TIM1 BKIN | 00075 | | | | | | | | 00076 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | 00077 | | | | | | | | 00078 | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | TIM8 BKIN | 00079 | | | | | | | | 00080 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | TIM8 BKIN2 | 00081 | | | | | | | | 00082 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | TIM1 BKIN2 | 00083 | + | + | + | + | + | + | + | 00084 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | TIM8BKIN2 | 00085 | | | | | | | | 00086 | TIM1 OCREFCLR | TIM1 OCREFCLR | TIM1 OCREFCLR | TIM8 OCREFCLR | TIM8 OCREFCLR | TIM8 OCREFCLR | TIM1 OCREFCLR | 00087 | | | | | | | | 00088 | TIM1 IC1 | TIM1 IC1 | TIM2 OCREFCLR | TIM3 IC3 | TIM2 IC1 | TIM2 IC2 | TIM8 OCREFCLR | 00089 | | | | | | | | 00090 | TIM2 IC4 | TIM2 IC4 | TIM3 IC2 | TIM3 OCREFCLR | TIM3 OCREFCLR | TIM2 OCREFCLR | TIM2 IC3 | 00091 | | | | | | | | 00092 | TIM2 OCREFCLR | TIM2 OCREFCLR | TIM4 IC1 | TIM4 IC2 | TIM4 IC3 | TIM16 OCREFCLR| TIM1 IC2 | 00093 | | | | | | | | 00094 | TIM3 IC1 | TIM3 IC1 | TIM15 IC1 | TIM15 OCREFCLR| TIM16 BKIN | TIM16 IC1 | TIM17 OCREFCLR| 00095 | | | | | | | | 00096 | TIM3 OCREFCLR | TIM3 OCREFCLR | TIM15 BKIN | TIM15 IC2 | TIM17 IC1 | TIM4 IC4 | TIM17 BKIN | 00097 +----------------------------------------------------------------------------------------------------------------------+ 00098 00099 [..] Table 4. COMP Outputs blanking sources 00100 +----------------------------------------------------------------------------------------------------------------------+ 00101 | COMP1 | COMP2 | COMP3 | COMP4 | COMP5 | COMP6 | COMP7 | 00102 |----------------|----------------|----------------|----------------|----------------|----------------|----------------| 00103 | TIM1 OC5 | TIM1 OC5 | TIM1 OC5 | TIM3 OC4 | TIM3 OC3 | TIM2 OC4 | TIM1 OC5 | 00104 | | | | | | | | 00105 | TIM2 OC3 | TIM2 OC3 | -------- | TIM8 OC5 | TIM8 OC5 | TIM8 OC5 | TIM8 OC5 | 00106 | | | | | | | | 00107 | TIM3 OC3 | TIM3 OC3 | TIM2 OC4 | TIM15 OC1 | TIM8 BKIN | TIM15 OC2 | TIM15 OC2 | 00108 | | | | | | | | 00109 +----------------------------------------------------------------------------------------------------------------------+ 00110 00111 00112 ##### How to use this driver ##### 00113 ============================================================================== 00114 [..] 00115 This driver provides functions to configure and program the Comparators 00116 of all STM32F30x devices. 00117 00118 To use the comparator, perform the following steps: 00119 00120 (#) Enable the SYSCFG APB clock to get write access to comparator 00121 register using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); 00122 00123 (#) Configure the comparator input in analog mode using GPIO_Init() 00124 00125 (#) Configure the comparator output in alternate function mode 00126 using GPIO_Init() and use GPIO_PinAFConfig() function to map the 00127 comparator output to the GPIO pin 00128 00129 (#) Configure the comparator using COMP_Init() function: 00130 (++) Select the inverting input 00131 (++) Select the non-inverting input 00132 (++) Select the output polarity 00133 (++) Select the output redirection 00134 (++) Select the hysteresis level 00135 (++) Select the power mode 00136 00137 (#) Enable the comparator using COMP_Cmd() function 00138 00139 (#) If required enable the COMP interrupt by configuring and enabling 00140 EXTI line in Interrupt mode and selecting the desired sensitivity 00141 level using EXTI_Init() function. After that enable the comparator 00142 interrupt vector using NVIC_Init() function. 00143 00144 @endverbatim 00145 * 00146 ****************************************************************************** 00147 * @attention 00148 * 00149 * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> 00150 * 00151 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 00152 * You may not use this file except in compliance with the License. 00153 * You may obtain a copy of the License at: 00154 * 00155 * http://www.st.com/software_license_agreement_liberty_v2 00156 * 00157 * Unless required by applicable law or agreed to in writing, software 00158 * distributed under the License is distributed on an "AS IS" BASIS, 00159 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00160 * See the License for the specific language governing permissions and 00161 * limitations under the License. 00162 * 00163 ****************************************************************************** 00164 */ 00165 00166 /* Includes ------------------------------------------------------------------*/ 00167 #include "stm32f30x_comp.h" 00168 00169 /** @addtogroup STM32F30x_StdPeriph_Driver 00170 * @{ 00171 */ 00172 00173 /** @defgroup COMP 00174 * @brief COMP driver modules 00175 * @{ 00176 */ 00177 00178 /* Private typedef -----------------------------------------------------------*/ 00179 /* Private define ------------------------------------------------------------*/ 00180 /* CSR register Mask */ 00181 #define COMP_CSR_CLEAR_MASK ((uint32_t)0x00000003) 00182 00183 /* Private macro -------------------------------------------------------------*/ 00184 /* Private variables ---------------------------------------------------------*/ 00185 /* Private function prototypes -----------------------------------------------*/ 00186 /* Private functions ---------------------------------------------------------*/ 00187 00188 /** @defgroup COMP_Private_Functions 00189 * @{ 00190 */ 00191 00192 /** @defgroup COMP_Group1 Initialization and Configuration functions 00193 * @brief Initialization and Configuration functions 00194 * 00195 @verbatim 00196 =============================================================================== 00197 ##### Initialization and Configuration functions ##### 00198 =============================================================================== 00199 00200 @endverbatim 00201 * @{ 00202 */ 00203 00204 /** 00205 * @brief Deinitializes COMP peripheral registers to their default reset values. 00206 * @note Deinitialization can't be performed if the COMP configuration is locked. 00207 * To unlock the configuration, perform a system reset. 00208 * @param COMP_Selection: the selected comparator. 00209 * This parameter can be COMP_Selection_COMPx where x can be 1 to 7 00210 * to select the COMP peripheral. 00211 * @param None 00212 * @retval None 00213 */ 00214 void COMP_DeInit(uint32_t COMP_Selection) 00215 { 00216 /*!< Set COMP_CSR register to reset value */ 00217 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) = ((uint32_t)0x00000000); 00218 } 00219 00220 /** 00221 * @brief Initializes the COMP peripheral according to the specified parameters 00222 * in COMP_InitStruct 00223 * @note If the selected comparator is locked, initialization can't be performed. 00224 * To unlock the configuration, perform a system reset. 00225 * @note By default, PA1 is selected as COMP1 non inverting input. 00226 * To use PA4 as COMP1 non inverting input call COMP_SwitchCmd() after COMP_Init() 00227 * @param COMP_Selection: the selected comparator. 00228 * This parameter can be COMP_Selection_COMPx where x can be 1 to 7 00229 * to select the COMP peripheral. 00230 * @param COMP_InitStruct: pointer to an COMP_InitTypeDef structure that contains 00231 * the configuration information for the specified COMP peripheral. 00232 * - COMP_InvertingInput specifies the inverting input of COMP 00233 * - COMP_NonInvertingInput specifies the non inverting input of COMP 00234 * - COMP_Output connect COMP output to selected timer 00235 * input (Input capture / Output Compare Reference Clear / Break Input) 00236 * - COMP_BlankingSrce specifies the blanking source of COMP 00237 * - COMP_OutputPol select output polarity 00238 * - COMP_Hysteresis configures COMP hysteresis value 00239 * - COMP_Mode configures COMP power mode 00240 * @note COMP_Hysteresis must be configured only for STM32F303xC. Otherwise, COMP_Hysteresis 00241 * must be kept at reset value(COMP_Hysteresis_No). 00242 * @note COMP_Mode field is only applicable for STM32F303xC devices. 00243 * @retval None 00244 */ 00245 void COMP_Init(uint32_t COMP_Selection, COMP_InitTypeDef* COMP_InitStruct) 00246 { 00247 uint32_t tmpreg = 0; 00248 00249 /* Check the parameters */ 00250 assert_param(IS_COMP_ALL_PERIPH(COMP_Selection)); 00251 assert_param(IS_COMP_INVERTING_INPUT(COMP_InitStruct->COMP_InvertingInput)); 00252 assert_param(IS_COMP_NONINVERTING_INPUT(COMP_InitStruct->COMP_NonInvertingInput)); 00253 assert_param(IS_COMP_OUTPUT(COMP_InitStruct->COMP_Output)); 00254 assert_param(IS_COMP_BLANKING_SOURCE(COMP_InitStruct->COMP_BlankingSrce)); 00255 assert_param(IS_COMP_OUTPUT_POL(COMP_InitStruct->COMP_OutputPol)); 00256 assert_param(IS_COMP_HYSTERESIS(COMP_InitStruct->COMP_Hysteresis)); 00257 assert_param(IS_COMP_MODE(COMP_InitStruct->COMP_Mode)); 00258 00259 /*!< Get the COMPx_CSR register value */ 00260 tmpreg = *(__IO uint32_t *) (COMP_BASE + COMP_Selection); 00261 00262 /*!< Clear the COMP1SW1, COMPxINSEL, COMPxOUTSEL, COMPxPOL, COMPxHYST and COMPxMODE bits */ 00263 tmpreg &= (uint32_t) (COMP_CSR_CLEAR_MASK); 00264 00265 /*!< Configure COMP: inverting input, output redirection, hysteresis value and power mode */ 00266 /*!< Set COMPxINSEL bits according to COMP_InitStruct->COMP_InvertingInput value */ 00267 /*!< Set COMPxNONINSEL bits according to COMP_InitStruct->COMP_NonInvertingInput value */ 00268 /*!< Set COMPxBLANKING bits according to COMP_InitStruct->COMP_BlankingSrce value */ 00269 /*!< Set COMPxOUTSEL bits according to COMP_InitStruct->COMP_Output value */ 00270 /*!< Set COMPxPOL bit according to COMP_InitStruct->COMP_OutputPol value */ 00271 /*!< Set COMPxHYST bits according to COMP_InitStruct->COMP_Hysteresis value */ 00272 /*!< Set COMPxMODE bits according to COMP_InitStruct->COMP_Mode value */ 00273 tmpreg |= (uint32_t)(COMP_InitStruct->COMP_InvertingInput | COMP_InitStruct->COMP_NonInvertingInput | 00274 COMP_InitStruct->COMP_Output | COMP_InitStruct->COMP_OutputPol | COMP_InitStruct->COMP_BlankingSrce | 00275 COMP_InitStruct->COMP_Hysteresis | COMP_InitStruct->COMP_Mode); 00276 00277 /*!< Write to COMPx_CSR register */ 00278 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) = tmpreg; 00279 } 00280 00281 /** 00282 * @brief Fills each COMP_InitStruct member with its default value. 00283 * @param COMP_InitStruct: pointer to an COMP_InitTypeDef structure which will 00284 * be initialized. 00285 * @retval None 00286 */ 00287 void COMP_StructInit(COMP_InitTypeDef* COMP_InitStruct) 00288 { 00289 COMP_InitStruct->COMP_InvertingInput = COMP_InvertingInput_1_4VREFINT; 00290 COMP_InitStruct->COMP_NonInvertingInput = COMP_NonInvertingInput_IO1; 00291 COMP_InitStruct->COMP_Output = COMP_Output_None; 00292 COMP_InitStruct->COMP_BlankingSrce = COMP_BlankingSrce_None; 00293 COMP_InitStruct->COMP_OutputPol = COMP_OutputPol_NonInverted; 00294 COMP_InitStruct->COMP_Hysteresis = COMP_Hysteresis_No; 00295 COMP_InitStruct->COMP_Mode = COMP_Mode_UltraLowPower; 00296 } 00297 00298 /** 00299 * @brief Enable or disable the COMP peripheral. 00300 * @note If the selected comparator is locked, enable/disable can't be performed. 00301 * To unlock the configuration, perform a system reset. 00302 * @param COMP_Selection: the selected comparator. 00303 * This parameter can be COMP_Selection_COMPx where x can be 1 to 7 00304 * to select the COMP peripheral. 00305 * @param NewState: new state of the COMP peripheral. 00306 * This parameter can be: ENABLE or DISABLE. 00307 * When enabled, the comparator compares the non inverting input with 00308 * the inverting input and the comparison result is available 00309 * on comparator output. 00310 * When disabled, the comparator doesn't perform comparison and the 00311 * output level is low. 00312 * @retval None 00313 */ 00314 void COMP_Cmd(uint32_t COMP_Selection, FunctionalState NewState) 00315 { 00316 /* Check the parameters */ 00317 assert_param(IS_COMP_ALL_PERIPH(COMP_Selection)); 00318 assert_param(IS_FUNCTIONAL_STATE(NewState)); 00319 00320 if (NewState != DISABLE) 00321 { 00322 /* Enable the selected COMPx peripheral */ 00323 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) (COMP_CSR_COMPxEN); 00324 } 00325 else 00326 { 00327 /* Disable the selected COMP peripheral */ 00328 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) &= (uint32_t)(~COMP_CSR_COMPxEN); 00329 } 00330 } 00331 00332 /** 00333 * @brief Close or Open the SW1 switch. 00334 * @note If the COMP1 is locked, Close/Open the SW1 switch can't be performed. 00335 * To unlock the configuration, perform a system reset. 00336 * @note This switch is solely intended to redirect signals onto high 00337 * impedance input, such as COMP1 non-inverting input (highly resistive switch) 00338 * @param NewState: New state of the analog switch. 00339 * This parameter can be 00340 * ENABLE so the SW1 is closed; PA1 is connected to PA4 00341 * or DISABLE so the SW1 switch is open; PA1 is disconnected from PA4 00342 * @retval None 00343 */ 00344 void COMP_SwitchCmd(uint32_t COMP_Selection, FunctionalState NewState) 00345 { 00346 /* Check the parameter */ 00347 assert_param(IS_FUNCTIONAL_STATE(NewState)); 00348 00349 if (NewState != DISABLE) 00350 { 00351 /* Close SW1 switch */ 00352 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) (COMP_CSR_COMP1SW1); 00353 } 00354 else 00355 { 00356 /* Open SW1 switch */ 00357 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) &= (uint32_t)(~COMP_CSR_COMP1SW1); 00358 } 00359 } 00360 00361 /** 00362 * @brief Return the output level (high or low) of the selected comparator. 00363 * The output level depends on the selected polarity. 00364 * If the polarity is not inverted: 00365 * - Comparator output is low when the non-inverting input is at a lower 00366 * voltage than the inverting input 00367 * - Comparator output is high when the non-inverting input is at a higher 00368 * voltage than the inverting input 00369 * If the polarity is inverted: 00370 * - Comparator output is high when the non-inverting input is at a lower 00371 * voltage than the inverting input 00372 * - Comparator output is low when the non-inverting input is at a higher 00373 * voltage than the inverting input 00374 * @param COMP_Selection: the selected comparator. 00375 * This parameter can be COMP_Selection_COMPx where x can be 1 to 7 00376 * to select the COMP peripheral. 00377 * @retval Returns the selected comparator output level: low or high. 00378 * 00379 */ 00380 uint32_t COMP_GetOutputLevel(uint32_t COMP_Selection) 00381 { 00382 uint32_t compout = 0x0; 00383 00384 /* Check the parameters */ 00385 assert_param(IS_COMP_ALL_PERIPH(COMP_Selection)); 00386 00387 /* Check if selected comparator output is high */ 00388 if ((*(__IO uint32_t *) (COMP_BASE + COMP_Selection) & (COMP_CSR_COMPxOUT)) != 0) 00389 { 00390 compout = COMP_OutputLevel_High; 00391 } 00392 else 00393 { 00394 compout = COMP_OutputLevel_Low; 00395 } 00396 00397 /* Return the comparator output level */ 00398 return (uint32_t)(compout); 00399 } 00400 00401 /** 00402 * @} 00403 */ 00404 00405 /** @defgroup COMP_Group2 Window mode control function 00406 * @brief Window mode control function 00407 * 00408 @verbatim 00409 =============================================================================== 00410 ##### Window mode control function ##### 00411 =============================================================================== 00412 00413 @endverbatim 00414 * @{ 00415 */ 00416 00417 /** 00418 * @brief Enables or disables the window mode. 00419 * Window mode for comparators makes use of two comparators: 00420 * COMP1 and COM2, COMP3 and COMP4, COMP5 and COMP6. 00421 * In window mode, COMPx and COMPx-1 (where x can be 2, 4 or 6) 00422 * non inverting inputs are connected together and only COMPx-1 non 00423 * inverting input can be used. 00424 * e.g When window mode enabled for COMP4, COMP3 non inverting input (PB14 or PD14) 00425 * is to be used. 00426 * @note If the COMPx is locked, ENABLE/DISABLE the window mode can't be performed. 00427 * To unlock the configuration, perform a system reset. 00428 * @param COMP_Selection: the selected comparator. 00429 * This parameter can be COMP_Selection_COMPx where x can be 2, 4 or 6 00430 * to select the COMP peripheral. 00431 * param NewState: new state of the window mode. 00432 * This parameter can be ENABLE or DISABLE. 00433 * When enbaled, COMPx and COMPx-1 non inverting inputs are connected together. 00434 * When disabled, COMPx and COMPx-1 non inverting inputs are disconnected. 00435 * @retval None 00436 */ 00437 void COMP_WindowCmd(uint32_t COMP_Selection, FunctionalState NewState) 00438 { 00439 /* Check the parameters */ 00440 assert_param(IS_FUNCTIONAL_STATE(NewState)); 00441 assert_param(IS_COMP_WINDOW(COMP_Selection)); 00442 00443 if (NewState != DISABLE) 00444 { 00445 /* Enable the window mode */ 00446 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) COMP_CSR_COMPxWNDWEN; 00447 } 00448 else 00449 { 00450 /* Disable the window mode */ 00451 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) &= (uint32_t)(~COMP_CSR_COMPxWNDWEN); 00452 } 00453 } 00454 00455 /** 00456 * @} 00457 */ 00458 00459 /** @defgroup COMP_Group3 COMP configuration locking function 00460 * @brief COMP1, COMP2,...COMP7 configuration locking function 00461 * COMP1, COMP2,...COMP7 configuration can be locked each separately. 00462 * Unlocking is performed by system reset. 00463 * 00464 @verbatim 00465 =============================================================================== 00466 ##### Configuration Lock function ##### 00467 =============================================================================== 00468 00469 @endverbatim 00470 * @{ 00471 */ 00472 00473 /** 00474 * @brief Lock the selected comparator (COMP1/COMP2) configuration. 00475 * @note Locking the configuration means that all control bits are read-only. 00476 * To unlock the comparator configuration, perform a system reset. 00477 * @param COMP_Selection: the selected comparator. 00478 * This parameter can be COMP_Selection_COMPx where x can be 1 to 7 00479 * to select the COMP peripheral. 00480 * @retval None 00481 */ 00482 void COMP_LockConfig(uint32_t COMP_Selection) 00483 { 00484 /* Check the parameter */ 00485 assert_param(IS_COMP_ALL_PERIPH(COMP_Selection)); 00486 00487 /* Set the lock bit corresponding to selected comparator */ 00488 *(__IO uint32_t *) (COMP_BASE + COMP_Selection) |= (uint32_t) (COMP_CSR_COMPxLOCK); 00489 } 00490 00491 /** 00492 * @} 00493 */ 00494 00495 /** 00496 * @} 00497 */ 00498 00499 /** 00500 * @} 00501 */ 00502 00503 /** 00504 * @} 00505 */ 00506 00507 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 17:34:44 by
