Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADC into low-power #58

Open
warcomeb opened this issue Nov 12, 2021 · 0 comments
Open

ADC into low-power #58

warcomeb opened this issue Nov 12, 2021 · 0 comments
Assignees

Comments

@warcomeb
Copy link
Member

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);
}
@warcomeb warcomeb self-assigned this Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant