STM32F37 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F37 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f37x_adc.c File Reference

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

#include "stm32f37x_adc.h"
#include "stm32f37x_rcc.h"

Macros

#define ADC_CR2_CLEAR_MASK   ((uint32_t)0xFFF1F7FD)
 
#define ADC_SQR_SQ_SET   ((uint32_t)0x0000001F)
 
#define ADC_JSQR_JSQ_SET   ((uint32_t)0x0000001F)
 
#define ADC_SMPR_SMP_SET   ((uint32_t)0x00000007)
 
#define ADC_JDR_OFFSET   ((uint8_t)0x28)
 

Functions

void ADC_DeInit (ADC_TypeDef *ADCx)
 Deinitializes the ADCx 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_StartCalibration (ADC_TypeDef *ADCx)
 Starts the selected ADC calibration process. More...
 
void ADC_ResetCalibration (ADC_TypeDef *ADCx)
 Resets the selected ADC calibration registers. More...
 
void ADC_AnalogWatchdogCmd (ADC_TypeDef *ADCx, uint32_t ADC_AnalogWatchdog)
 Enables or disables the analog watchdog on single/all regular or injected channels. 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, uint8_t ADC_Channel)
 Configures the analog watchdog guarded single channel. More...
 
void ADC_TempSensorVrefintCmd (FunctionalState NewState)
 Enables or disables the temperature sensor and Vrefint channel. More...
 
void ADC_RegularChannelConfig (ADC_TypeDef *ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime)
 Configures for the selected ADC regular channel its corresponding rank in the sequencer and its sample time. More...
 
void ADC_ExternalTrigConvCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the ADCx conversion through external trigger. More...
 
void ADC_SoftwareStartConv (ADC_TypeDef *ADCx)
 Enables or disables the selected ADC software start conversion . More...
 
FlagStatus ADC_GetSoftwareStartConvStatus (ADC_TypeDef *ADCx)
 Gets the selected ADC Software start conversion Status. More...
 
void ADC_ContinuousModeCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the ADC continuous conversion mode. More...
 
void ADC_DiscModeChannelCountConfig (ADC_TypeDef *ADCx, uint8_t Number)
 Configures the discontinuous mode for the selected ADC regular group channel. More...
 
void ADC_DiscModeCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the discontinuous mode on regular group channel for the specified ADC. More...
 
uint16_t ADC_GetConversionValue (ADC_TypeDef *ADCx)
 Returns the last ADCx conversion result data for regular channel. More...
 
void ADC_DMACmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the specified ADC DMA request. More...
 
void ADC_InjectedChannelConfig (ADC_TypeDef *ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime)
 Configures for the selected ADC injected channel its corresponding rank in the sequencer and its sample time. More...
 
void ADC_InjectedSequencerLengthConfig (ADC_TypeDef *ADCx, uint8_t Length)
 Configures the sequencer length for injected channels. More...
 
void ADC_SetInjectedOffset (ADC_TypeDef *ADCx, uint8_t ADC_InjectedChannel, uint16_t ADC_Offset)
 Set the injected channels conversion value offset. More...
 
void ADC_ExternalTrigInjectedConvConfig (ADC_TypeDef *ADCx, uint32_t ADC_ExternalTrigInjecConv)
 Configures the ADCx external trigger for injected channels conversion. More...
 
void ADC_ExternalTrigInjectedConvCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the ADCx injected channels conversion through external trigger. More...
 
void ADC_SoftwareStartInjectedConvCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the selected ADC start of the injected channels conversion. More...
 
FlagStatus ADC_GetSoftwareStartInjectedConvCmdStatus (ADC_TypeDef *ADCx)
 Gets the selected ADC Software start injected conversion Status. More...
 
void ADC_AutoInjectedConvCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the selected ADC automatic injected group conversion after regular one. More...
 
void ADC_InjectedDiscModeCmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the discontinuous mode for injected group channel for the specified ADC. More...
 
uint16_t ADC_GetInjectedConversionValue (ADC_TypeDef *ADCx, uint8_t ADC_InjectedChannel)
 Returns the ADC injected channel conversion result. More...
 
void ADC_ITConfig (ADC_TypeDef *ADCx, uint16_t ADC_IT, FunctionalState NewState)
 Enables or disables the specified ADC interrupts. More...
 
FlagStatus ADC_GetFlagStatus (ADC_TypeDef *ADCx, uint8_t ADC_FLAG)
 Checks whether the specified ADC flag is set or not. More...
 
void ADC_ClearFlag (ADC_TypeDef *ADCx, uint8_t ADC_FLAG)
 Clears the ADCx's pending flags. More...
 
ITStatus ADC_GetITStatus (ADC_TypeDef *ADCx, uint16_t ADC_IT)
 Checks whether the specified ADC interrupt has occurred or not. More...
 
void ADC_ClearITPendingBit (ADC_TypeDef *ADCx, uint16_t ADC_IT)
 Clears the ADCx's interrupt pending bits. More...
 
FlagStatus ADC_GetCalibrationStatus (ADC_TypeDef *ADCx)
 Gets the selected ADC calibration status. More...
 
FlagStatus ADC_GetResetCalibrationStatus (ADC_TypeDef *ADCx)
 Gets the selected ADC reset calibration registers status. More...
 

Detailed Description

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

Author
MCD Application Team
Version
V1.0.0
Date
20-September-2012
  • Initialization and Configuration
  • Analog Watchdog configuration
  • Temperature Sensor, Vrefint (Internal Reference Voltage) and VBAT (Voltage battery) management
  • Regular Channels Configuration
  • Regular Channels DMA Configuration
  • Injected channels 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 data alignment using the ADC_Init() function.
    (#) Activate the ADC peripheral using ADC_Cmd() function.

    *** Regular channels group configuration ***
    ============================================
    [..] 
    (+) To configure the ADC regular channels group features, use 
        ADC_Init() and ADC_RegularChannelConfig() functions.
    (+) To activate the continuous mode, use the ADC_ContinuousModeCmd()
        function.
    (+) To configure and activate the Discontinuous mode, use the
        ADC_DiscModeChannelCountConfig() and ADC_DiscModeCmd() functions.
    (+) To read the ADC converted values, use the ADC_GetConversionValue()
        function.

    *** DMA for Regular channels group features configuration ***
    =============================================================
    [..]
    (+) To enable the DMA mode for regular channels group, use the 
        ADC_DMACmd() function.
             
    *** Injected channels group configuration ***
    =============================================
    [..]    
    (+) To configure the ADC Injected channels group features, use 
        ADC_InjectedChannelConfig() function.
    (+) To activate the Injected Discontinuous mode, use the 
        ADC_InjectedDiscModeCmd() function.  
    (+) To activate the AutoInjected mode, use the ADC_AutoInjectedConvCmd() 
        function.
    (+) To read the ADC converted values, use the ADC_GetInjectedConversionValue() function.

  *  
Attention
<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:

       http://www.st.com/software_license_agreement_liberty_v2

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.