Skip to content

Commit

Permalink
[examples] use AdcInterrupt in f3 discovery example
Browse files Browse the repository at this point in the history
  • Loading branch information
XDjackieXD authored and salkinium committed Sep 29, 2021
1 parent 500086d commit 420cd4b
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions examples/stm32f3_discovery/adc/interrupt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,20 @@ main()
// initialize Adc4
Adc4::initialize(Adc4::ClockMode::Asynchronous, Adc4::Prescaler::Div256,
Adc4::CalibrationMode::SingleEndedInputsMode, true);
Adc4::connect<AdcIn0::In3>();
Adc4::setPinChannel<AdcIn0>(Adc4::SampleTime::Cycles182);

Adc4::enableInterruptVector(5);
Adc4::enableInterrupt(Adc4::Interrupt::EndOfRegularConversion);

Adc4::connect<AdcIn0::In3>();
Adc4::setPinChannel<AdcIn0>(Adc4::SampleTime::Cycles182);
AdcInterrupt4::attachInterruptHandler(printAdc);

while (true)
{
Adc4::startConversion();
while(!Adc4::isConversionFinished);
printAdc();
modm::delay(500ms);
}

return 0;
}


MODM_ISR(ADC4)
{
if (Adc4::getInterruptFlags() & Adc4::InterruptFlag::EndOfRegularConversion) {
Adc4::acknowledgeInterruptFlag(Adc4::InterruptFlag::EndOfRegularConversion);
printAdc();
}
}

0 comments on commit 420cd4b

Please sign in to comment.