Skip to content

Commit

Permalink
[ADC] move dma->enable()
Browse files Browse the repository at this point in the history
  • Loading branch information
mxmxmx committed Aug 30, 2018
1 parent fc1d3c9 commit e7a8422
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions software/C2M_X/C2M_ADC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@ DMAMEM static volatile uint16_t __attribute__((aligned(DMA_BUF_SIZE+0))) adcbuff
adc_.setConversionSpeed(kAdcConversionSpeed);
adc_.setSamplingSpeed(kAdcSamplingSpeed);
adc_.setAveraging(kAdcScanAverages);
adc_.enableDMA();

calibration_data_ = calibration_data;
std::fill(raw_, raw_ + ADC_CHANNEL_LAST, 0);
std::fill(smoothed_, smoothed_ + ADC_CHANNEL_LAST, 0);
std::fill(adcbuffer_0, adcbuffer_0 + DMA_BUF_SIZE, 0);

adc_.enableDMA();
}

void ADC::DMA_ISR() {

ADC::ready_ = true;
dma0->TCD->DADDR = &adcbuffer_0[0];
dma0->clearInterrupt();
// move enable to SCAN_DMA() ?
dma0->enable();
/* reenable in SCAN_DMA(); */
}

/*
Expand Down Expand Up @@ -88,6 +89,7 @@ void ADC::Init_DMA() {
if (ADC::ready_)
{
ADC::ready_ = false;

/*
* starts collecting results at adcbuffer_0[1] because of weird offset (--> discard adcbuffer_0[0]).
* there's 16 samples in the buffer, 1-5 / 11-15 are the pitch inputs:
Expand All @@ -103,6 +105,8 @@ void ADC::Init_DMA() {
update<ADC_CHANNEL_3_2>(adcbuffer_0[8]);
update<ADC_CHANNEL_4_2>(adcbuffer_0[9]);
update<ADC_CHANNEL_5_2>(adcbuffer_0[10]);
/* start over */
dma0->enable();
}
}

Expand Down

0 comments on commit e7a8422

Please sign in to comment.