/*
* To keep power consumption low, it is important to disable the ADC voltage regulator
* before entering lowpower mode (LPRun, LPSleep or Stop mode).
*/
void LowPower_disableADCRegulator (void)
{
if (UTILITY_READ_REGISTER_BIT(ADC1->CR, ADC_CR_ADEN) == 1)
{
UTILITY_SET_REGISTER_BIT(ADC1->CR, ADC_CR_ADDIS);
}
UTILITY_CLEAR_REGISTER_BIT(ADC1->CR, ADC_CR_ADVREGEN);
}
void LowPower_enableADCRegulator (void)
{
UTILITY_SET_REGISTER_BIT(ADC1->CR, ADC_CR_ADVREGEN);
UTILITY_SET_REGISTER_BIT(ADC1->CR, ADC_CR_ADEN);
while (UTILITY_READ_REGISTER_BIT(ADC1->CR, ADC_ISR_ADRDY) != 1);
UTILITY_SET_REGISTER_BIT(ADC1->CR, ADC_ISR_ADRDY);
}
These functions must be added to reduce consumption (by @NicoPaolinelli ):