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_adc.c File Reference

This file provides firmware functions to manage the following functionalities of the Analog to Digital Convertor (ADC) peripheral: More...

#include "stm32f0xx_adc.h"
#include "stm32f0xx_rcc.h"


#define CFGR1_CLEAR_MASK   ((uint32_t)0xFFFFD203)
#define CALIBRATION_TIMEOUT   ((uint32_t)0x0000F000)


void ADC_DeInit (ADC_TypeDef *ADCx)
 Deinitializes ADC1 peripheral registers to their default reset values. More...
void ADC_Init (ADC_TypeDef *ADCx, ADC_InitTypeDef *ADC_InitStruct)
 Initializes the ADCx peripheral according to the specified parameters in the ADC_InitStruct. More...
void ADC_StructInit (ADC_InitTypeDef *ADC_InitStruct)
 Fills each ADC_InitStruct member with its default value. More...
void ADC_Cmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the specified ADC peripheral. More...
void ADC_JitterCmd (ADC_TypeDef *ADCx, uint32_t ADC_JitterOff, FunctionalState NewState)
 Enables or disables the jitter when the ADC is clocked by PCLK div2 or div4. More...
void ADC_AutoPowerOffCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the ADC Power Off. More...
void ADC_WaitModeCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the Wait conversion mode. More...
void ADC_AnalogWatchdogCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the analog watchdog. More...
void ADC_AnalogWatchdogThresholdsConfig (ADC_TypeDef *ADCx, uint16_t HighThreshold, uint16_t LowThreshold)
 Configures the high and low thresholds of the analog watchdog. More...
void ADC_AnalogWatchdogSingleChannelConfig (ADC_TypeDef *ADCx, uint32_t ADC_AnalogWatchdog_Channel)
 Configures the analog watchdog guarded single channel. More...
void ADC_AnalogWatchdogSingleChannelCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the ADC Analog Watchdog Single Channel. More...
void ADC_TempSensorCmd (FunctionalState NewState)
 Enables or disables the temperature sensor channel. More...
void ADC_VrefintCmd (FunctionalState NewState)
 Enables or disables the Vrefint channel. More...
void ADC_VbatCmd (FunctionalState NewState)
 Enables or disables the Vbat channel. More...
void ADC_ChannelConfig (ADC_TypeDef *ADCx, uint32_t ADC_Channel, uint32_t ADC_SampleTime)
 Configures for the selected ADC and its sampling time. More...
void ADC_ContinuousModeCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enable the Continuous mode for the selected ADCx channels. More...
void ADC_DiscModeCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enable the discontinuous mode for the selected ADC channels. More...
void ADC_OverrunModeCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enable the Overrun mode for the selected ADC channels. More...
uint32_t ADC_GetCalibrationFactor (ADC_TypeDef *ADCx)
 Active the Calibration operation for the selected ADC. More...
void ADC_StopOfConversion (ADC_TypeDef *ADCx)
 Stop the on going conversions for the selected ADC. More...
void ADC_StartOfConversion (ADC_TypeDef *ADCx)
 Start Conversion for the selected ADC channels. More...
uint16_t ADC_GetConversionValue (ADC_TypeDef *ADCx)
 Returns the last ADCx conversion result data for ADC channel. More...
void ADC_DMACmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the specified ADC DMA request. More...
void ADC_DMARequestModeConfig (ADC_TypeDef *ADCx, uint32_t ADC_DMARequestMode)
 Enables or disables the ADC DMA request after last transfer (Single-ADC mode) More...
void ADC_ITConfig (ADC_TypeDef *ADCx, uint32_t ADC_IT, FunctionalState NewState)
 Enables or disables the specified ADC interrupts. More...
FlagStatus ADC_GetFlagStatus (ADC_TypeDef *ADCx, uint32_t ADC_FLAG)
 Checks whether the specified ADC flag is set or not. More...
void ADC_ClearFlag (ADC_TypeDef *ADCx, uint32_t ADC_FLAG)
 Clears the ADCx's pending flags. More...
ITStatus ADC_GetITStatus (ADC_TypeDef *ADCx, uint32_t ADC_IT)
 Checks whether the specified ADC interrupt has occurred or not. More...
void ADC_ClearITPendingBit (ADC_TypeDef *ADCx, uint32_t ADC_IT)
 Clears the ADCx's interrupt pending bits. More...

Detailed Description

This file provides firmware functions to manage the following functionalities of the Analog to Digital Convertor (ADC) peripheral:

MCD Application Team
  • Initialization and Configuration
  • Power saving
  • Analog Watchdog configuration
  • Temperature Sensor, Vrefint (Internal Reference Voltage) and Vbat (Voltage battery) management
  • ADC Channels Configuration
  • ADC Channels DMA Configuration
  • Interrupts and flags management
                      ##### How to use this driver #####
    (#) Enable the ADC interface clock using 
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE); 
    (#) ADC pins configuration
       (++) Enable the clock for the ADC GPIOs using the following function:
            RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOx, ENABLE);   
       (++) Configure these ADC pins in analog mode using GPIO_Init();  
    (#) Configure the ADC conversion resolution, data alignment, external
        trigger and edge, scan direction and Enable/Disable the continuous mode
        using the ADC_Init() function.
    (#) Activate the ADC peripheral using ADC_Cmd() function.

    *** ADC channels group configuration ***
    (+) To configure the ADC channels features, use ADC_Init() and 
        ADC_ChannelConfig() functions.
    (+) To activate the continuous mode, use the ADC_ContinuousModeCmd()
    (+) To activate the Discontinuous mode, use the ADC_DiscModeCmd() functions. 
    (+) To activate the overrun mode, use the ADC_OverrunModeCmd() functions.
    (+) To activate the calibration mode, use the ADC_GetCalibrationFactor() functions.
    (+) To read the ADC converted values, use the ADC_GetConversionValue()

    *** DMA for ADC channels features configuration ***
    (+) To enable the DMA mode for ADC channels group, use the ADC_DMACmd() function.
    (+) To configure the DMA transfer request, use ADC_DMARequestModeConfig() function.

<h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>

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, 
See the License for the specific language governing permissions and
limitations under the License.