122 #define CR1_DISCNUM_RESET ((uint32_t)0xFFFF1FFF)
125 #define CR1_AWDCH_RESET ((uint32_t)0xFFFFFFE0)
128 #define CR1_AWDMode_RESET ((uint32_t)0xFF3FFDFF)
131 #define CR1_CLEAR_MASK ((uint32_t)0xFCFFFEFF)
134 #define CR2_EXTEN_RESET ((uint32_t)0xCFFFFFFF)
137 #define CR2_JEXTEN_RESET ((uint32_t)0xFFCFFFFF)
140 #define CR2_JEXTSEL_RESET ((uint32_t)0xFFF0FFFF)
143 #define CR2_CLEAR_MASK ((uint32_t)0xC0FFF7FD)
146 #define SQR3_SQ_SET ((uint32_t)0x0000001F)
147 #define SQR2_SQ_SET ((uint32_t)0x0000001F)
148 #define SQR1_SQ_SET ((uint32_t)0x0000001F)
151 #define SQR1_L_RESET ((uint32_t)0xFF0FFFFF)
154 #define JSQR_JSQ_SET ((uint32_t)0x0000001F)
157 #define JSQR_JL_SET ((uint32_t)0x00300000)
158 #define JSQR_JL_RESET ((uint32_t)0xFFCFFFFF)
161 #define SMPR1_SMP_SET ((uint32_t)0x00000007)
162 #define SMPR2_SMP_SET ((uint32_t)0x00000007)
165 #define JDR_OFFSET ((uint8_t)0x28)
168 #define CDR_ADDRESS ((uint32_t)0x40012308)
171 #define CR_CLEAR_MASK ((uint32_t)0xFFFC30E0)
237 uint32_t tmpreg1 = 0;
240 assert_param(IS_ADC_ALL_PERIPH(ADCx));
246 assert_param(IS_ADC_DATA_ALIGN(ADC_InitStruct->
ADC_DataAlign));
260 ADC_InitStruct->ADC_Resolution);
268 tmpreg1 &= CR2_CLEAR_MASK;
285 tmpreg1 = ADCx->SQR1;
288 tmpreg1 &= SQR1_L_RESET;
293 tmpreg1 |= ((uint32_t)tmpreg2 << 20);
296 ADCx->SQR1 = tmpreg1;
343 uint32_t tmpreg1 = 0;
345 assert_param(IS_ADC_MODE(ADC_CommonInitStruct->
ADC_Mode));
346 assert_param(IS_ADC_PRESCALER(ADC_CommonInitStruct->
ADC_Prescaler));
354 tmpreg1 &= CR_CLEAR_MASK;
362 tmpreg1 |= (uint32_t)(ADC_CommonInitStruct->
ADC_Mode |
380 ADC_CommonInitStruct->
ADC_Mode = ADC_Mode_Independent;
399 void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState)
402 assert_param(IS_ADC_ALL_PERIPH(ADCx));
403 assert_param(IS_FUNCTIONAL_STATE(NewState));
404 if (NewState != DISABLE)
407 ADCx->CR2 |= (uint32_t)ADC_CR2_ADON;
412 ADCx->CR2 &= (uint32_t)(~ADC_CR2_ADON);
459 assert_param(IS_ADC_ALL_PERIPH(ADCx));
460 assert_param(IS_ADC_ANALOG_WATCHDOG(ADC_AnalogWatchdog));
466 tmpreg &= CR1_AWDMode_RESET;
469 tmpreg |= ADC_AnalogWatchdog;
485 uint16_t LowThreshold)
488 assert_param(IS_ADC_ALL_PERIPH(ADCx));
489 assert_param(IS_ADC_THRESHOLD(HighThreshold));
490 assert_param(IS_ADC_THRESHOLD(LowThreshold));
493 ADCx->HTR = HighThreshold;
496 ADCx->LTR = LowThreshold;
529 assert_param(IS_ADC_ALL_PERIPH(ADCx));
530 assert_param(IS_ADC_CHANNEL(ADC_Channel));
536 tmpreg &= CR1_AWDCH_RESET;
539 tmpreg |= ADC_Channel;
592 assert_param(IS_FUNCTIONAL_STATE(NewState));
593 if (NewState != DISABLE)
596 ADC->CCR |= (uint32_t)ADC_CCR_TSVREFE;
601 ADC->CCR &= (uint32_t)(~ADC_CCR_TSVREFE);
618 assert_param(IS_FUNCTIONAL_STATE(NewState));
619 if (NewState != DISABLE)
622 ADC->CCR |= (uint32_t)ADC_CCR_VBATE;
627 ADC->CCR &= (uint32_t)(~ADC_CCR_VBATE);
717 uint32_t tmpreg1 = 0, tmpreg2 = 0;
719 assert_param(IS_ADC_ALL_PERIPH(ADCx));
720 assert_param(IS_ADC_CHANNEL(ADC_Channel));
721 assert_param(IS_ADC_REGULAR_RANK(Rank));
722 assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));
725 if (ADC_Channel > ADC_Channel_9)
728 tmpreg1 = ADCx->SMPR1;
731 tmpreg2 = SMPR1_SMP_SET << (3 * (ADC_Channel - 10));
737 tmpreg2 = (uint32_t)ADC_SampleTime << (3 * (ADC_Channel - 10));
743 ADCx->SMPR1 = tmpreg1;
748 tmpreg1 = ADCx->SMPR2;
751 tmpreg2 = SMPR2_SMP_SET << (3 * ADC_Channel);
757 tmpreg2 = (uint32_t)ADC_SampleTime << (3 * ADC_Channel);
763 ADCx->SMPR2 = tmpreg1;
769 tmpreg1 = ADCx->SQR3;
772 tmpreg2 = SQR3_SQ_SET << (5 * (Rank - 1));
778 tmpreg2 = (uint32_t)ADC_Channel << (5 * (Rank - 1));
784 ADCx->SQR3 = tmpreg1;
790 tmpreg1 = ADCx->SQR2;
793 tmpreg2 = SQR2_SQ_SET << (5 * (Rank - 7));
799 tmpreg2 = (uint32_t)ADC_Channel << (5 * (Rank - 7));
805 ADCx->SQR2 = tmpreg1;
811 tmpreg1 = ADCx->SQR1;
814 tmpreg2 = SQR1_SQ_SET << (5 * (Rank - 13));
820 tmpreg2 = (uint32_t)ADC_Channel << (5 * (Rank - 13));
826 ADCx->SQR1 = tmpreg1;
838 assert_param(IS_ADC_ALL_PERIPH(ADCx));
841 ADCx->CR2 |= (uint32_t)ADC_CR2_SWSTART;
851 FlagStatus bitstatus = RESET;
853 assert_param(IS_ADC_ALL_PERIPH(ADCx));
856 if ((ADCx->CR2 & ADC_CR2_SWSTART) != (uint32_t)RESET)
882 assert_param(IS_ADC_ALL_PERIPH(ADCx));
883 assert_param(IS_FUNCTIONAL_STATE(NewState));
885 if (NewState != DISABLE)
888 ADCx->CR2 |= (uint32_t)ADC_CR2_EOCS;
893 ADCx->CR2 &= (uint32_t)(~ADC_CR2_EOCS);
907 assert_param(IS_ADC_ALL_PERIPH(ADCx));
908 assert_param(IS_FUNCTIONAL_STATE(NewState));
910 if (NewState != DISABLE)
913 ADCx->CR2 |= (uint32_t)ADC_CR2_CONT;
918 ADCx->CR2 &= (uint32_t)(~ADC_CR2_CONT);
932 uint32_t tmpreg1 = 0;
933 uint32_t tmpreg2 = 0;
936 assert_param(IS_ADC_ALL_PERIPH(ADCx));
937 assert_param(IS_ADC_REGULAR_DISC_NUMBER(Number));
943 tmpreg1 &= CR1_DISCNUM_RESET;
946 tmpreg2 = Number - 1;
947 tmpreg1 |= tmpreg2 << 13;
965 assert_param(IS_ADC_ALL_PERIPH(ADCx));
966 assert_param(IS_FUNCTIONAL_STATE(NewState));
968 if (NewState != DISABLE)
971 ADCx->CR1 |= (uint32_t)ADC_CR1_DISCEN;
976 ADCx->CR1 &= (uint32_t)(~ADC_CR1_DISCEN);
988 assert_param(IS_ADC_ALL_PERIPH(ADCx));
991 return (uint16_t) ADCx->DR;
1009 return (*(__IO uint32_t *) CDR_ADDRESS);
1055 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1056 assert_param(IS_FUNCTIONAL_STATE(NewState));
1057 if (NewState != DISABLE)
1060 ADCx->CR2 |= (uint32_t)ADC_CR2_DMA;
1065 ADCx->CR2 &= (uint32_t)(~ADC_CR2_DMA);
1079 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1080 assert_param(IS_FUNCTIONAL_STATE(NewState));
1081 if (NewState != DISABLE)
1084 ADCx->CR2 |= (uint32_t)ADC_CR2_DDS;
1089 ADCx->CR2 &= (uint32_t)(~ADC_CR2_DDS);
1106 assert_param(IS_FUNCTIONAL_STATE(NewState));
1107 if (NewState != DISABLE)
1110 ADC->CCR |= (uint32_t)ADC_CCR_DDS;
1115 ADC->CCR &= (uint32_t)(~ADC_CCR_DDS);
1192 uint32_t tmpreg1 = 0, tmpreg2 = 0, tmpreg3 = 0;
1194 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1195 assert_param(IS_ADC_CHANNEL(ADC_Channel));
1196 assert_param(IS_ADC_INJECTED_RANK(Rank));
1197 assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));
1199 if (ADC_Channel > ADC_Channel_9)
1202 tmpreg1 = ADCx->SMPR1;
1204 tmpreg2 = SMPR1_SMP_SET << (3*(ADC_Channel - 10));
1206 tmpreg1 &= ~tmpreg2;
1208 tmpreg2 = (uint32_t)ADC_SampleTime << (3*(ADC_Channel - 10));
1212 ADCx->SMPR1 = tmpreg1;
1217 tmpreg1 = ADCx->SMPR2;
1219 tmpreg2 = SMPR2_SMP_SET << (3 * ADC_Channel);
1221 tmpreg1 &= ~tmpreg2;
1223 tmpreg2 = (uint32_t)ADC_SampleTime << (3 * ADC_Channel);
1227 ADCx->SMPR2 = tmpreg1;
1231 tmpreg1 = ADCx->JSQR;
1233 tmpreg3 = (tmpreg1 & JSQR_JL_SET)>> 20;
1235 tmpreg2 = JSQR_JSQ_SET << (5 * (uint8_t)((Rank + 3) - (tmpreg3 + 1)));
1237 tmpreg1 &= ~tmpreg2;
1239 tmpreg2 = (uint32_t)ADC_Channel << (5 * (uint8_t)((Rank + 3) - (tmpreg3 + 1)));
1243 ADCx->JSQR = tmpreg1;
1255 uint32_t tmpreg1 = 0;
1256 uint32_t tmpreg2 = 0;
1258 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1259 assert_param(IS_ADC_INJECTED_LENGTH(Length));
1262 tmpreg1 = ADCx->JSQR;
1265 tmpreg1 &= JSQR_JL_RESET;
1268 tmpreg2 = Length - 1;
1269 tmpreg1 |= tmpreg2 << 20;
1272 ADCx->JSQR = tmpreg1;
1290 __IO uint32_t tmp = 0;
1292 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1293 assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel));
1294 assert_param(IS_ADC_OFFSET(Offset));
1296 tmp = (uint32_t)ADCx;
1297 tmp += ADC_InjectedChannel;
1300 *(__IO uint32_t *) tmp = (uint32_t)Offset;
1328 uint32_t tmpreg = 0;
1330 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1331 assert_param(IS_ADC_EXT_INJEC_TRIG(ADC_ExternalTrigInjecConv));
1337 tmpreg &= CR2_JEXTSEL_RESET;
1340 tmpreg |= ADC_ExternalTrigInjecConv;
1362 uint32_t tmpreg = 0;
1364 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1365 assert_param(IS_ADC_EXT_INJEC_TRIG_EDGE(ADC_ExternalTrigInjecConvEdge));
1369 tmpreg &= CR2_JEXTEN_RESET;
1371 tmpreg |= ADC_ExternalTrigInjecConvEdge;
1384 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1386 ADCx->CR2 |= (uint32_t)ADC_CR2_JSWSTART;
1396 FlagStatus bitstatus = RESET;
1398 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1401 if ((ADCx->CR2 & ADC_CR2_JSWSTART) != (uint32_t)RESET)
1426 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1427 assert_param(IS_FUNCTIONAL_STATE(NewState));
1428 if (NewState != DISABLE)
1431 ADCx->CR1 |= (uint32_t)ADC_CR1_JAUTO;
1436 ADCx->CR1 &= (uint32_t)(~ADC_CR1_JAUTO);
1452 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1453 assert_param(IS_FUNCTIONAL_STATE(NewState));
1454 if (NewState != DISABLE)
1457 ADCx->CR1 |= (uint32_t)ADC_CR1_JDISCEN;
1462 ADCx->CR1 &= (uint32_t)(~ADC_CR1_JDISCEN);
1479 __IO uint32_t tmp = 0;
1482 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1483 assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel));
1485 tmp = (uint32_t)ADCx;
1486 tmp += ADC_InjectedChannel + JDR_OFFSET;
1489 return (uint16_t) (*(__IO uint32_t*) tmp);
1584 void ADC_ITConfig(ADC_TypeDef* ADCx, uint16_t ADC_IT, FunctionalState NewState)
1586 uint32_t itmask = 0;
1588 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1589 assert_param(IS_FUNCTIONAL_STATE(NewState));
1590 assert_param(IS_ADC_IT(ADC_IT));
1593 itmask = (uint8_t)ADC_IT;
1594 itmask = (uint32_t)0x01 << itmask;
1596 if (NewState != DISABLE)
1599 ADCx->CR1 |= itmask;
1604 ADCx->CR1 &= (~(uint32_t)itmask);
1623 FlagStatus bitstatus = RESET;
1625 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1626 assert_param(IS_ADC_GET_FLAG(ADC_FLAG));
1629 if ((ADCx->SR & ADC_FLAG) != (uint8_t)RESET)
1659 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1660 assert_param(IS_ADC_CLEAR_FLAG(ADC_FLAG));
1663 ADCx->SR = ~(uint32_t)ADC_FLAG;
1679 ITStatus bitstatus = RESET;
1680 uint32_t itmask = 0, enablestatus = 0;
1683 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1684 assert_param(IS_ADC_IT(ADC_IT));
1687 itmask = ADC_IT >> 8;
1690 enablestatus = (ADCx->CR1 & ((uint32_t)0x01 << (uint8_t)ADC_IT)) ;
1693 if (((ADCx->SR & itmask) != (uint32_t)RESET) && enablestatus)
1722 assert_param(IS_ADC_ALL_PERIPH(ADCx));
1723 assert_param(IS_ADC_IT(ADC_IT));
1725 itmask = (uint8_t)(ADC_IT >> 8);
1727 ADCx->SR = ~(uint32_t)itmask;
This file contains all the functions prototypes for the RCC firmware library.
uint32_t ADC_TwoSamplingDelay
FlagStatus ADC_GetFlagStatus(ADC_TypeDef *ADCx, uint8_t ADC_FLAG)
Checks whether the specified ADC flag is set or not.
void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef *ADCx, uint8_t ADC_Channel)
Configures the analog watchdog guarded single channel.
void ADC_ContinuousModeCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
Enables or disables the ADC continuous conversion mode.
void ADC_ExternalTrigInjectedConvConfig(ADC_TypeDef *ADCx, uint32_t ADC_ExternalTrigInjecConv)
Configures the ADCx external trigger for injected channels conversion.
void ADC_ExternalTrigInjectedConvEdgeConfig(ADC_TypeDef *ADCx, uint32_t ADC_ExternalTrigInjecConvEdge)
Configures the ADCx external trigger edge for injected channels conversion.
void ADC_TempSensorVrefintCmd(FunctionalState NewState)
Enables or disables the temperature sensor and Vrefint channels.
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 samp...
void ADC_InjectedDiscModeCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
Enables or disables the discontinuous mode for injected group channel for the specified ADC...
uint32_t ADC_DMAAccessMode
ADC Init structure definition.
void ADC_Cmd(ADC_TypeDef *ADCx, FunctionalState NewState)
Enables or disables the specified ADC peripheral.
void ADC_DiscModeCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
Enables or disables the discontinuous mode on regular group channel for the specified ADC...
void ADC_CommonInit(ADC_CommonInitTypeDef *ADC_CommonInitStruct)
Initializes the ADCs peripherals according to the specified parameters in the ADC_CommonInitStruct.
ITStatus ADC_GetITStatus(ADC_TypeDef *ADCx, uint16_t ADC_IT)
Checks whether the specified ADC interrupt has occurred or not.
void ADC_VBATCmd(FunctionalState NewState)
Enables or disables the VBAT (Voltage Battery) channel.
This file contains all the functions prototypes for the ADC firmware library.
uint32_t ADC_GetMultiModeConversionValue(void)
Returns the last ADC1, ADC2 and ADC3 regular conversions results data in the selected multi mode...
void ADC_SetInjectedOffset(ADC_TypeDef *ADCx, uint8_t ADC_InjectedChannel, uint16_t Offset)
Set the injected channels conversion value offset.
void ADC_DiscModeChannelCountConfig(ADC_TypeDef *ADCx, uint8_t Number)
Configures the discontinuous mode for the selected ADC regular group channel.
uint16_t ADC_GetInjectedConversionValue(ADC_TypeDef *ADCx, uint8_t ADC_InjectedChannel)
Returns the ADC injected channel conversion result.
void ADC_DMARequestAfterLastTransferCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
Enables or disables the ADC DMA request after last transfer (Single-ADC mode)
void ADC_ClearITPendingBit(ADC_TypeDef *ADCx, uint16_t ADC_IT)
Clears the ADCx's interrupt pending bits.
FunctionalState ADC_ScanConvMode
uint32_t ADC_ExternalTrigConvEdge
void ADC_InjectedSequencerLengthConfig(ADC_TypeDef *ADCx, uint8_t Length)
Configures the sequencer length for injected channels.
uint32_t ADC_ExternalTrigConv
FunctionalState ADC_ContinuousConvMode
void ADC_Init(ADC_TypeDef *ADCx, ADC_InitTypeDef *ADC_InitStruct)
Initializes the ADCx peripheral according to the specified parameters in the ADC_InitStruct.
void ADC_ITConfig(ADC_TypeDef *ADCx, uint16_t ADC_IT, FunctionalState NewState)
Enables or disables the specified ADC interrupts.
void ADC_ClearFlag(ADC_TypeDef *ADCx, uint8_t ADC_FLAG)
Clears the ADCx's pending flags.
void ADC_SoftwareStartConv(ADC_TypeDef *ADCx)
Enables the selected ADC software start conversion of the regular channels.
void ADC_EOCOnEachRegularChannelCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
Enables or disables the EOC on each regular channel conversion.
void ADC_DMACmd(ADC_TypeDef *ADCx, FunctionalState NewState)
Enables or disables the specified ADC DMA request.
void ADC_SoftwareStartInjectedConv(ADC_TypeDef *ADCx)
Enables the selected ADC software start conversion of the injected channels.
FlagStatus ADC_GetSoftwareStartInjectedConvCmdStatus(ADC_TypeDef *ADCx)
Gets the selected ADC Software start injected conversion Status.
ADC Common Init structure definition.
uint8_t ADC_NbrOfConversion
void ADC_MultiModeDMARequestAfterLastTransferCmd(FunctionalState NewState)
Enables or disables the ADC DMA request after last transfer in multi ADC mode.
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 sampl...
void ADC_AutoInjectedConvCmd(ADC_TypeDef *ADCx, FunctionalState NewState)
Enables or disables the selected ADC automatic injected group conversion after regular one...
void ADC_CommonStructInit(ADC_CommonInitTypeDef *ADC_CommonInitStruct)
Fills each ADC_CommonInitStruct member with its default value.
FlagStatus ADC_GetSoftwareStartConvStatus(ADC_TypeDef *ADCx)
Gets the selected ADC Software start regular conversion Status.
void ADC_StructInit(ADC_InitTypeDef *ADC_InitStruct)
Fills each ADC_InitStruct member with its default value.
void ADC_AnalogWatchdogCmd(ADC_TypeDef *ADCx, uint32_t ADC_AnalogWatchdog)
Enables or disables the analog watchdog on single/all regular or injected channels.
void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
Forces or releases High Speed APB (APB2) peripheral reset.
void ADC_DeInit(void)
Deinitializes all ADCs peripherals registers to their default reset values.
uint16_t ADC_GetConversionValue(ADC_TypeDef *ADCx)
Returns the last ADCx conversion result data for regular channel.
void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef *ADCx, uint16_t HighThreshold, uint16_t LowThreshold)
Configures the high and low thresholds of the analog watchdog.