@@ -27,7 +27,7 @@ using namespace Board;
2727using namespace modm ::platform;
2828using Adc1Dma = AdcDma<Adc1, Dma1::Channel1>;
2929
30- std::array<uint16_t , 100 > adc_results;
30+ std::array<uint16_t , 100 > adc_results{} ;
3131volatile bool dma_completed = false ;
3232
3333void
@@ -49,26 +49,21 @@ main()
4949 LedD13::setOutput ();
5050 LedD13::reset ();
5151
52- adc_results.fill (0 );
53-
5452 Adc1::connect<GpioInputA0::In0>();
5553 Adc1::connect<GpioInputA1::In1>();
5654
57- const auto a0_channel = Adc1::getPinChannel<GpioInputA0>();
58- const auto a1_channel = Adc1::getPinChannel<GpioInputA1>();
5955 Adc1::setSampleTime (Adc1::SampleTime::Cycles3_5);
6056 Adc1::initialize<SystemClock, Adc1::ClockMode::Asynchronous>();
61- Adc1::enableScanMode ();
6257 modm::delay (500ms);
6358 // On STM32G0 Event1 means TIM1's channel 4 capture and compare event.
6459 // Each controller has a different trigger mapping, check the reference
6560 // manual for more information on the trigger mapping of your controller.
6661 Adc1::enableRegularConversionExternalTrigger (Adc1::ExternalTriggerPolarity::RisingEdge,
6762 Adc1::RegularConversionExternalTrigger::Event1);
68- Adc1::addChannel (a0_channel);
69- Adc1::addChannel (a1_channel );
63+
64+ Adc1::setChannels (Adc1::channelSequenceFromPins<GpioInputA0, GpioInputA1>() );
7065 Dma1::enable ();
71- Adc1Dma::initialize<SystemClock>(( uintptr_t )(& adc_results[ 0 ]), adc_results. size () );
66+ Adc1Dma::initialize<SystemClock>(adc_results);
7267 Adc1Dma::setCompletedConversionCallback (completedCallback);
7368 Adc1Dma::startDma ();
7469 Adc1::startConversion ();
8378 dma_completed = false ;
8479 MODM_LOG_INFO << " Measurements"
8580 << " \r " << modm::endl;
86- for (const uint16_t & sample : adc_results) { MODM_LOG_INFO << sample << " , " ; }
81+ for (uint16_t sample : adc_results) { MODM_LOG_INFO << sample << " , " ; }
8782 MODM_LOG_INFO << " \r " << modm::endl;
8883 adc_results.fill (0 );
8984 timerStart<Timer1>();
0 commit comments