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

ADC driver modules. More...

Modules

 ADC_Exported_Constants
 
 ADC_Private_Functions
 

Data Structures

struct  ADC_InitTypeDef
 ADC Init structure definition. More...
 

Macros

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

Functions

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_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_Cmd (ADC_TypeDef *ADCx, FunctionalState NewState)
 Enables or disables the specified ADC peripheral. 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

ADC driver modules.

Function Documentation

void ADC_AnalogWatchdogCmd ( ADC_TypeDef *  ADCx,
FunctionalState  NewState 
)

Enables or disables the analog watchdog.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
NewState,:new state of the ADCx Analog Watchdog. This parameter can be: ENABLE or DISABLE.
Return values
None
void ADC_AnalogWatchdogSingleChannelCmd ( ADC_TypeDef *  ADCx,
FunctionalState  NewState 
)

Enables or disables the ADC Analog Watchdog Single Channel.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
NewState,:new state of the ADCx ADC Analog Watchdog Single Channel. This parameter can be: ENABLE or DISABLE.
Return values
None
void ADC_AnalogWatchdogSingleChannelConfig ( ADC_TypeDef *  ADCx,
uint32_t  ADC_AnalogWatchdog_Channel 
)

Configures the analog watchdog guarded single channel.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
ADC_AnalogWatchdog_Channel,:the ADC channel to configure for the analog watchdog. This parameter can be one of the following values:
  • ADC_AnalogWatchdog_Channel_0: ADC Channel0 selected
  • ADC_AnalogWatchdog_Channel_1: ADC Channel1 selected
  • ADC_AnalogWatchdog_Channel_2: ADC Channel2 selected
  • ADC_AnalogWatchdog_Channel_3: ADC Channel3 selected
  • ADC_AnalogWatchdog_Channel_4: ADC Channel4 selected
  • ADC_AnalogWatchdog_Channel_5: ADC Channel5 selected
  • ADC_AnalogWatchdog_Channel_6: ADC Channel6 selected
  • ADC_AnalogWatchdog_Channel_7: ADC Channel7 selected
  • ADC_AnalogWatchdog_Channel_8: ADC Channel8 selected
  • ADC_AnalogWatchdog_Channel_9: ADC Channel9 selected
  • ADC_AnalogWatchdog_Channel_10: ADC Channel10 selected
  • ADC_AnalogWatchdog_Channel_11: ADC Channel11 selected
  • ADC_AnalogWatchdog_Channel_12: ADC Channel12 selected
  • ADC_AnalogWatchdog_Channel_13: ADC Channel13 selected
  • ADC_AnalogWatchdog_Channel_14: ADC Channel14 selected
  • ADC_AnalogWatchdog_Channel_15: ADC Channel15 selected
  • ADC_AnalogWatchdog_Channel_16: ADC Channel16 selected
  • ADC_AnalogWatchdog_Channel_17: ADC Channel17 selected
  • ADC_AnalogWatchdog_Channel_18: ADC Channel18 selected
Note
The channel selected on the AWDCH must be also set into the CHSELR register
Return values
None
void ADC_AnalogWatchdogThresholdsConfig ( ADC_TypeDef *  ADCx,
uint16_t  HighThreshold,
uint16_t  LowThreshold 
)

Configures the high and low thresholds of the analog watchdog.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
HighThreshold,:the ADC analog watchdog High threshold value. This parameter must be a 12bit value.
LowThreshold,:the ADC analog watchdog Low threshold value. This parameter must be a 12bit value.
Return values
None
void ADC_AutoPowerOffCmd ( ADC_TypeDef *  ADCx,
FunctionalState  NewState 
)

Enables or disables the ADC Power Off.

Note
ADC power-on and power-off can be managed by hardware to cut the consumption when the ADC is not converting.
Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
Note
The ADC can be powered down:
  • During the Auto delay phase: The ADC is powered on again at the end of the delay (until the previous data is read from the ADC data register).
  • During the ADC is waiting for a trigger event: The ADC is powered up at the next trigger event (when the conversion is started).
Parameters
NewState,:new state of the ADCx power Off. This parameter can be: ENABLE or DISABLE.
Return values
None
void ADC_ChannelConfig ( ADC_TypeDef *  ADCx,
uint32_t  ADC_Channel,
uint32_t  ADC_SampleTime 
)

Configures for the selected ADC and its sampling time.

Parameters
ADCx,:where x can be 1 to select the ADC peripheral.
ADC_Channel,:the ADC channel to configure. This parameter can be any combination of the following values:
  • ADC_Channel_0: ADC Channel0 selected
  • ADC_Channel_1: ADC Channel1 selected
  • ADC_Channel_2: ADC Channel2 selected
  • ADC_Channel_3: ADC Channel3 selected
  • ADC_Channel_4: ADC Channel4 selected
  • ADC_Channel_5: ADC Channel5 selected
  • ADC_Channel_6: ADC Channel6 selected
  • ADC_Channel_7: ADC Channel7 selected
  • ADC_Channel_8: ADC Channel8 selected
  • ADC_Channel_9: ADC Channel9 selected
  • ADC_Channel_10: ADC Channel10 selected
  • ADC_Channel_11: ADC Channel11 selected
  • ADC_Channel_12: ADC Channel12 selected
  • ADC_Channel_13: ADC Channel13 selected
  • ADC_Channel_14: ADC Channel14 selected
  • ADC_Channel_15: ADC Channel15 selected
  • ADC_Channel_16: ADC Channel16 selected
  • ADC_Channel_17: ADC Channel17 selected
  • ADC_Channel_18: ADC Channel18 selected
ADC_SampleTime,:The sample time value to be set for the selected channel. This parameter can be one of the following values:
  • ADC_SampleTime_1_5Cycles: Sample time equal to 1.5 cycles
  • ADC_SampleTime_7_5Cycles: Sample time equal to 7.5 cycles
  • ADC_SampleTime_13_5Cycles: Sample time equal to 13.5 cycles
  • ADC_SampleTime_28_5Cycles: Sample time equal to 28.5 cycles
  • ADC_SampleTime_41_5Cycles: Sample time equal to 41.5 cycles
  • ADC_SampleTime_55_5Cycles: Sample time equal to 55.5 cycles
  • ADC_SampleTime_71_5Cycles: Sample time equal to 71.5 cycles
  • ADC_SampleTime_239_5Cycles: Sample time equal to 239.5 cycles
Return values
None
void ADC_ClearFlag ( ADC_TypeDef *  ADCx,
uint32_t  ADC_FLAG 
)

Clears the ADCx's pending flags.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
ADC_FLAG,:specifies the flag to clear. This parameter can be any combination of the following values:
  • ADC_FLAG_AWD: Analog watchdog flag
  • ADC_FLAG_EOC: End of conversion flag
  • ADC_FLAG_ADRDY: ADC Ready flag
  • ADC_FLAG_EOSMP: End of sampling flag
  • ADC_FLAG_EOSEQ: End of Sequence flag
  • ADC_FLAG_OVR: Overrun flag
Return values
None
void ADC_ClearITPendingBit ( ADC_TypeDef *  ADCx,
uint32_t  ADC_IT 
)

Clears the ADCx's interrupt pending bits.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
ADC_IT,:specifies the ADC interrupt pending bit to clear. This parameter can be one of the following values:
  • ADC_IT_ADRDY: ADC ready interrupt
  • ADC_IT_EOSMP: End of sampling interrupt
  • ADC_IT_EOC: End of conversion interrupt
  • ADC_IT_EOSEQ: End of sequence of conversion interrupt
  • ADC_IT_OVR: overrun interrupt
  • ADC_IT_AWD: Analog watchdog interrupt
Return values
None
void ADC_Cmd ( ADC_TypeDef *  ADCx,
FunctionalState  NewState 
)

Enables or disables the specified ADC peripheral.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
NewState,:new state of the ADCx peripheral. This parameter can be: ENABLE or DISABLE.
Return values
None
void ADC_ContinuousModeCmd ( ADC_TypeDef *  ADCx,
FunctionalState  NewState 
)

Enable the Continuous mode for the selected ADCx channels.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
NewState,:new state of the Continuous mode. This parameter can be: ENABLE or DISABLE.
Note
It is not possible to have both discontinuous mode and continuous mode enabled. In this case (If DISCEN and CONT are Set), the ADC behaves as if continuous mode was disabled
Return values
None
void ADC_DeInit ( ADC_TypeDef *  ADCx)

Deinitializes ADC1 peripheral registers to their default reset values.

Parameters
ADCx,:where x can be 1 to select the ADC peripheral.
Return values
None
void ADC_DiscModeCmd ( ADC_TypeDef *  ADCx,
FunctionalState  NewState 
)

Enable the discontinuous mode for the selected ADC channels.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
NewState,:new state of the discontinuous mode. This parameter can be: ENABLE or DISABLE.
Note
It is not possible to have both discontinuous mode and continuous mode enabled. In this case (If DISCEN and CONT are Set), the ADC behaves as if continuous mode was disabled
Return values
None
void ADC_DMACmd ( ADC_TypeDef *  ADCx,
FunctionalState  NewState 
)

Enables or disables the specified ADC DMA request.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
NewState,:new state of the selected ADC DMA transfer. This parameter can be: ENABLE or DISABLE.
Return values
None
void ADC_DMARequestModeConfig ( ADC_TypeDef *  ADCx,
uint32_t  ADC_DMARequestMode 
)

Enables or disables the ADC DMA request after last transfer (Single-ADC mode)

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
ADC_DMARequestMode,:the ADC channel to configure. This parameter can be one of the following values:
  • ADC_DMAMode_OneShot: DMA One Shot Mode
  • ADC_DMAMode_Circular: DMA Circular Mode
Return values
None
uint32_t ADC_GetCalibrationFactor ( ADC_TypeDef *  ADCx)

Active the Calibration operation for the selected ADC.

Note
The Calibration can be initiated only when ADC is still in the reset configuration (ADEN must be equal to 0).
Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
Return values
ADCCalibration factor
uint16_t ADC_GetConversionValue ( ADC_TypeDef *  ADCx)

Returns the last ADCx conversion result data for ADC channel.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
Return values
TheData conversion value.
FlagStatus ADC_GetFlagStatus ( ADC_TypeDef *  ADCx,
uint32_t  ADC_FLAG 
)

Checks whether the specified ADC flag is set or not.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
ADC_FLAG,:specifies the flag to check. This parameter can be one of the following values:
  • ADC_FLAG_AWD: Analog watchdog flag
  • ADC_FLAG_OVR: Overrun flag
  • ADC_FLAG_EOSEQ: End of Sequence flag
  • ADC_FLAG_EOC: End of conversion flag
  • ADC_FLAG_EOSMP: End of sampling flag
  • ADC_FLAG_ADRDY: ADC Ready flag
  • ADC_FLAG_ADEN: ADC enable flag
  • ADC_FLAG_ADDIS: ADC disable flag
  • ADC_FLAG_ADSTART: ADC start flag
  • ADC_FLAG_ADSTP: ADC stop flag
  • ADC_FLAG_ADCAL: ADC Calibration flag
Return values
Thenew state of ADC_FLAG (SET or RESET).
ITStatus ADC_GetITStatus ( ADC_TypeDef *  ADCx,
uint32_t  ADC_IT 
)

Checks whether the specified ADC interrupt has occurred or not.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral
ADC_IT,:specifies the ADC interrupt source to check. This parameter can be one of the following values:
  • ADC_IT_ADRDY: ADC ready interrupt
  • ADC_IT_EOSMP: End of sampling interrupt
  • ADC_IT_EOC: End of conversion interrupt
  • ADC_IT_EOSEQ: End of sequence of conversion interrupt
  • ADC_IT_OVR: overrun interrupt
  • ADC_IT_AWD: Analog watchdog interrupt
Return values
Thenew state of ADC_IT (SET or RESET).
void ADC_Init ( ADC_TypeDef *  ADCx,
ADC_InitTypeDef ADC_InitStruct 
)

Initializes the ADCx peripheral according to the specified parameters in the ADC_InitStruct.

Note
This function is used to configure the global features of the ADC ( Resolution, Data Alignment, continuous mode activation, External trigger source and edge, Sequence Scan Direction).
Parameters
ADCx,:where x can be 1 to select the ADC peripheral.
ADC_InitStruct,:pointer to an ADC_InitTypeDef structure that contains the configuration information for the specified ADC peripheral.
Return values
None
void ADC_ITConfig ( ADC_TypeDef *  ADCx,
uint32_t  ADC_IT,
FunctionalState  NewState 
)

Enables or disables the specified ADC interrupts.

Parameters
ADCx,:where x can be 1 to select the ADC peripheral.
ADC_IT,:specifies the ADC interrupt sources to be enabled or disabled. This parameter can be one of the following values:
  • ADC_IT_ADRDY: ADC ready interrupt
  • ADC_IT_EOSMP: End of sampling interrupt
  • ADC_IT_EOC: End of conversion interrupt
  • ADC_IT_EOSEQ: End of sequence of conversion interrupt
  • ADC_IT_OVR: overrun interrupt
  • ADC_IT_AWD: Analog watchdog interrupt
NewState,:new state of the specified ADC interrupts. This parameter can be: ENABLE or DISABLE.
Return values
None
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.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
ADC_JitterOff,:This parameter can be :
  • ADC_JitterOff_PCLKDiv2: Remove jitter when ADC is clocked by PLCK divided by 2
  • ADC_JitterOff_PCLKDiv4: Remove jitter when ADC is clocked by PLCK divided by 4
NewState,:new state of the ADCx jitter. This parameter can be: ENABLE or DISABLE.
Return values
None
void ADC_OverrunModeCmd ( ADC_TypeDef *  ADCx,
FunctionalState  NewState 
)

Enable the Overrun mode for the selected ADC channels.

Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
NewState,:new state of the Overrun mode. This parameter can be: ENABLE or DISABLE.
Return values
None
void ADC_StartOfConversion ( ADC_TypeDef *  ADCx)

Start Conversion for the selected ADC channels.

Note
In continuous mode, ADSTART is not cleared by hardware with the assertion of EOSEQ because the sequence is automatic relaunched
Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
Return values
None
void ADC_StopOfConversion ( ADC_TypeDef *  ADCx)

Stop the on going conversions for the selected ADC.

Note
When ADSTP is set, any on going conversion is aborted, and the ADC data register is not updated with current conversion.
Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
Return values
None
void ADC_StructInit ( ADC_InitTypeDef ADC_InitStruct)

Fills each ADC_InitStruct member with its default value.

Note
This function is used to initialize the global features of the ADC ( Resolution, Data Alignment, continuous mode activation, External trigger source and edge, Sequence Scan Direction).
Parameters
ADC_InitStruct,:pointer to an ADC_InitTypeDef structure which will be initialized.
Return values
None
void ADC_TempSensorCmd ( FunctionalState  NewState)

Enables or disables the temperature sensor channel.

Parameters
NewState,:new state of the temperature sensor input channel. This parameter can be: ENABLE or DISABLE.
Return values
None
void ADC_VbatCmd ( FunctionalState  NewState)

Enables or disables the Vbat channel.

Parameters
NewState,:new state of the Vbat input channel. This parameter can be: ENABLE or DISABLE.
Return values
None
void ADC_VrefintCmd ( FunctionalState  NewState)

Enables or disables the Vrefint channel.

Parameters
NewState,:new state of the Vref input channel. This parameter can be: ENABLE or DISABLE.
Return values
None
void ADC_WaitModeCmd ( ADC_TypeDef *  ADCx,
FunctionalState  NewState 
)

Enables or disables the Wait conversion mode.

Note
When the CPU clock is not fast enough to manage the data rate, a Hardware delay can be introduced between ADC conversions to reduce this data rate.
The Hardware delay is inserted after each conversions and until the previous data is read from the ADC data register
This is a way to automatically adapt the speed of the ADC to the speed of the system which will read the data.
Any hardware triggers wich occur while a conversion is on going or while the automatic Delay is applied are ignored
Parameters
ADCx,:where x can be 1 to select the ADC1 peripheral.
NewState,:new state of the ADCx Auto-Delay. This parameter can be: ENABLE or DISABLE.
Return values
None