Skip to content

ADC into low-power #58

@warcomeb

Description

@warcomeb

These functions must be added to reduce consumption (by @NicoPaolinelli ):

/*
 * 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);
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions