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

Revert "Fix #253: Use AdcStart() before each ReadAnalog value" #255

Merged
merged 1 commit into from
Jun 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/lib/stm32/stm32l0/CatenaStm32L0_ReadAnalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,15 @@ bool McciCatena::CatenaStm32L0_ReadAnalog(
ADC1->SMPR = ADC_SMPR_SMPR;
ADC->CCR = ADC_CCR_VREFEN;

/* start ADC, before each readings */
/* start ADC, which will take 2 readings */
AdcStart();

fStatusOk = AdcGetValue(&vRef);
if (fStatusOk)
{
*pValue = 5;
if (Channel != STM32L0_ADC_CHANNEL_VREFINT)
{
AdcStart();
fStatusOk = AdcGetValue(&vChannel);
}
else
vChannel = vRef;
}
Expand Down Expand Up @@ -220,7 +217,7 @@ bool McciCatena::CatenaStm32L0_ReadAnalog(
vRefInt_cal = (*pVrefintCal * 3000 + 1) / (4096 / 4);

vResult = vChannel * Multiplier;

vResult = vResult * vRefInt_cal / vRef;
// remove the factor of 4, and round
*pValue = (vResult + 2) >> 2;
Expand Down