File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
src/modm/platform/adc/stm32f3 Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,25 @@ public:
290290%% endif
291291 };
292292
293+ enum class DmaMode : uint32_t
294+ {
295+ Disabled = 0,
296+ %% if target["family"] in ["h7"] and resolution == 12:
297+ OneShot = ADC3_CFGR_DMAEN,
298+ Circular = ADC3_CFGR_DMACFG | ADC3_CFGR_DMAEN,
299+ Mask = Circular
300+ %% elif target["family"] in ["h7"] and resolution == 16:
301+ OneShot = ADC_CFGR_DMNGT_0,
302+ Dfsdm = ADC_CFGR_DMNGT_1,
303+ Circular = ADC_CFGR_DMNGT_1 | ADC_CFGR_DMNGT_0,
304+ Mask = ADC_CFGR_DMNGT_Msk
305+ %% else
306+ OneShot = ADC_CFGR_DMAEN,
307+ Circular = ADC_CFGR_DMACFG | ADC_CFGR_DMAEN,
308+ Mask = Circular
309+ %% endif
310+ };
311+
293312 enum class Interrupt : uint32_t
294313 {
295314 Ready = ADC_IER_ADRDYIE,
@@ -581,6 +600,16 @@ public:
581600 static inline void
582601 acknowledgeInterruptFlags(const InterruptFlag_t flags);
583602
603+ /// @return ADC data register pointer, for DMA use only.
604+ static inline volatile uint32_t*
605+ dataRegister()
606+ {
607+ return &(ADC{{ id }}->DR);
608+ }
609+
610+ static inline void
611+ setDmaMode(DmaMode mode);
612+
584613private:
585614 static inline bool
586615 configureChannel(Channel channel, SampleTime sampleTime);
Original file line number Diff line number Diff line change @@ -357,6 +357,13 @@ modm::platform::Adc{{ id }}::isInjectedConversionFinished()
357357 return static_cast<bool>(getInterruptFlags() & InterruptFlag::EndOfInjectedSequenceOfConversions);
358358}
359359
360+ void
361+ modm::platform::Adc{{ id }}::setDmaMode(DmaMode mode)
362+ {
363+ constexpr uint32_t mask = std::to_underlying(DmaMode::Mask);
364+ ADC{{ id }}->CFGR = (ADC{{ id }}->CFGR & ~mask) | std::to_underlying(mode);
365+ }
366+
360367// ----------------------------------------------------------------------------
361368void
362369modm::platform::Adc{{ id }}::enableInterruptVector(const uint32_t priority,
You can’t perform that action at this time.
0 commit comments