Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/AdvancedADC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ int AdvancedADC::begin(uint32_t resolution, uint32_t sample_rate, size_t n_sampl
}

// Re/enable DMA double buffer mode.
HAL_NVIC_DisableIRQ(descr->dma_irqn);
hal_dma_enable_dbm(&descr->dma, descr->dmabuf[0]->data(), descr->dmabuf[1]->data());
HAL_NVIC_EnableIRQ(descr->dma_irqn);

// Init, config and start the ADC timer.
hal_tim_config(&descr->tim, sample_rate);
Expand Down Expand Up @@ -236,8 +238,8 @@ void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *adc) {
// NOTE: CT bit is inverted, to get the DMA buffer that's Not currently in use.
size_t ct = ! hal_dma_get_ct(&descr->dma);

// Timestamp the buffer. TODO: Should move to timer IRQ.
descr->dmabuf[ct]->timestamp(HAL_GetTick());
// Timestamp the buffer.
descr->dmabuf[ct]->timestamp(us_ticker_read());

if (descr->pool->writable()) {
// Make sure any cached data is discarded.
Expand Down
2 changes: 1 addition & 1 deletion src/HALConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ int hal_dma_config(DMA_HandleTypeDef *dma, IRQn_Type irqn, uint32_t direction) {
}

// NVIC configuration for DMA Input data interrupt.
HAL_NVIC_SetPriority(irqn, 1, 0);
HAL_NVIC_SetPriority(irqn, 0, 0);
HAL_NVIC_EnableIRQ(irqn);

return 0;
Expand Down