STM32F0 Standard Peripheral bibliotheek  1.0
ST Microelectronics standard peripheral bibliotheek documentatie voor de STM32F0 familie
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f0xx_comp.c File Reference

This file provides firmware functions to manage the following functionalities of the comparators (COMP1 and COMP2) peripheral: More...

#include "stm32f0xx_comp.h"


#define COMP_CSR_CLEAR_MASK   ((uint32_t)0x00003FFE)


void COMP_DeInit (void)
 Deinitializes COMP peripheral registers to their default reset values. More...
void COMP_Init (uint32_t COMP_Selection, COMP_InitTypeDef *COMP_InitStruct)
 Initializes the COMP peripheral according to the specified parameters in COMP_InitStruct. More...
void COMP_StructInit (COMP_InitTypeDef *COMP_InitStruct)
 Fills each COMP_InitStruct member with its default value. More...
void COMP_Cmd (uint32_t COMP_Selection, FunctionalState NewState)
 Enable or disable the COMP peripheral. More...
void COMP_SwitchCmd (FunctionalState NewState)
 Close or Open the SW1 switch. More...
uint32_t COMP_GetOutputLevel (uint32_t COMP_Selection)
 Return the output level (high or low) of the selected comparator. More...
void COMP_WindowCmd (FunctionalState NewState)
 Enables or disables the window mode. More...
void COMP_LockConfig (uint32_t COMP_Selection)
 Lock the selected comparator (COMP1/COMP2) configuration. More...

Detailed Description

This file provides firmware functions to manage the following functionalities of the comparators (COMP1 and COMP2) peripheral:

MCD Application Team
  • Comparators configuration
  • Window mode control
                    ##### How to use this driver #####
        The device integrates two analog comparators COMP1 and COMP2:
        (+) The non inverting input is set to PA1 for COMP1 and to PA3
            for COMP2.
        (+) The inverting input can be selected among: DAC_OUT1, 
            1/4 VREFINT, 1/2 VERFINT, 3/4 VREFINT, VREFINT,
            I/O (PA0 for COMP1 and PA2 for COMP2)
        (+) The COMP output is internally is available using COMP_GetOutputLevel()
            and can be set on GPIO pins: PA0, PA6, PA11 for COMP1
            and PA2, PA7, PA12 for COMP2
        (+) The COMP output can be redirected to embedded timers (TIM1, TIM2
            and TIM3)
        (+) The two comparators COMP1 and COMP2 can be combined in window
            mode and only COMP1 non inverting (PA1) can be used as non-
            inverting input.
        (+) The two comparators COMP1 and COMP2 have interrupt capability 
            with wake-up from Sleep and Stop modes (through the EXTI controller).
            COMP1 and COMP2 outputs are internally connected to EXTI Line 21
            and EXTI Line 22 respectively.

                    ##### How to configure the comparator #####
          This driver provides functions to configure and program the Comparators 
          of all STM32F0xx devices.
   [..]   To use the comparator, perform the following steps:
        (#) Enable the SYSCFG APB clock to get write access to comparator
            register using RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
        (#) Configure the comparator input in analog mode using GPIO_Init()
        (#) Configure the comparator output in alternate function mode
            using GPIO_Init() and use GPIO_PinAFConfig() function to map the
            comparator output to the GPIO pin
        (#) Configure the comparator using COMP_Init() function:
                (++)  Select the inverting input
                (++)  Select the output polarity  
                (++)  Select the output redirection
                (++)  Select the hysteresis level
                (++)  Select the power mode
        (#) Enable the comparator using COMP_Cmd() function
        (#) If required enable the COMP interrupt by configuring and enabling
            EXTI line in Interrupt mode and selecting the desired sensitivity
            level using EXTI_Init() function. After that enable the comparator
            interrupt vector using NVIC_Init() function.

© COPYRIGHT 2012 STMicroelectronics

Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.