Skip to content

Commit

Permalink
fixup! fixup! fixup! cpu/stm32l1: fix ADC initialization & resolution…
Browse files Browse the repository at this point in the history
… setting
  • Loading branch information
crasbe committed Dec 11, 2024
1 parent b10bae9 commit a8acff0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cpu/stm32/periph/adc_l1.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ int32_t adc_sample(adc_t line, adc_res_t res)
prep();

/* mask and set resolution, conversion channel and single read */
ADC1->CR1 = (ADC1->CR1 & ~ADC_CR1_RES_Msk) | (res & ADC_CR1_RES_Msk);
ADC1->CR1 = (ADC1->CR1 & ~ADC_CR1_RES) | (res & ADC_CR1_RES);
ADC1->SQR1 &= ~ADC_SQR1_L;
ADC1->SQR5 = adc_config[line].chan;

/* only set ADON when ADONS bit is cleared (ADC not ready) */
if (!(ADC1->SR & ADC_SR_ADONS_Msk)) {
if (!(ADC1->SR & ADC_SR_ADONS)) {
ADC1->CR2 |= ADC_CR2_ADON;
}

Expand All @@ -176,7 +176,7 @@ int32_t adc_sample(adc_t line, adc_res_t res)

/* wait for ADC to become ready before disabling it */
while (!(ADC1->SR & ADC_SR_ADONS)) {}
ADC1->CR2 &= ~ADC_CR2_ADON_Msk;
ADC1->CR2 &= ~ADC_CR2_ADON;

/* power off and unlock device again */
done();
Expand Down

0 comments on commit a8acff0

Please sign in to comment.