Skip to content

Commit

Permalink
Merge pull request #214 from mcci-catena/issue213
Browse files Browse the repository at this point in the history
Fix #213: Remove calibration time check. So it will calibrate every time
  • Loading branch information
chwon64 authored Aug 22, 2019
2 parents f04937c + 9634d50 commit f344766
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib/stm32/stm32l0/CatenaStm32L0_ReadAnalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ using namespace McciCatena;
\****************************************************************************/

constexpr unsigned long ADC_TIMEOUT = 10;
constexpr unsigned long ADC_CALIBRATE_TIME = 2000;
constexpr int STM32L0_ADC_CHANNEL_VREFINT = 17;
constexpr int STM32L0_ADC_CHANNEL_TEMPSENSOR = 18;

Expand Down Expand Up @@ -222,6 +221,12 @@ bool McciCatena::CatenaStm32L0_ReadAnalog(
vResult = vResult * vRefInt_cal / vRef;
// remove the factor of 4, and round
*pValue = (vResult + 2) >> 2;

// gLog.printf(
// gLog.kError,
// "vRef=%u vChannel=%u *pVrefintCal=%u\t",
// vRef, vChannel, *pVrefintCal
// );
}

return fStatusOk;
Expand Down Expand Up @@ -269,7 +274,6 @@ static bool AdcDisable(void)

static bool AdcCalibrate(void)
{
static uint32_t s_uLastCalibTime = 0;
uint32_t uTime;

if (ADC1->CR & ADC_CR_ADEN)
Expand All @@ -281,10 +285,6 @@ static bool AdcCalibrate(void)
}

uTime = millis();
if ((uTime - s_uLastCalibTime) < ADC_CALIBRATE_TIME)
return true;

s_uLastCalibTime = uTime;

/* turn on the cal bit */
ADC1->ISR = ADC_ISR_EOCAL;
Expand Down

0 comments on commit f344766

Please sign in to comment.