Skip to content

Commit

Permalink
Merge branch 'feature/use_circular_dma_desc_link_in_adc_continuous_mo…
Browse files Browse the repository at this point in the history
…de' into 'master'

adc: pr 11500, use circular dma descriptors in adc continuous mode

Closes IDFGH-10235

See merge request espressif/esp-idf!24048
  • Loading branch information
Icarus113 committed Jun 8, 2023
2 parents 943fe87 + 97c30c7 commit cd7ef82
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
5 changes: 0 additions & 5 deletions components/driver/deprecated/adc_dma_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,11 +386,6 @@ static IRAM_ATTR bool s_adc_dma_intr(adc_digi_context_t *adc_digi_ctx)
}
}

if (status == ADC_HAL_DMA_DESC_NULL) {
//start next turns of dma operation
adc_hal_digi_start(&adc_digi_ctx->hal, adc_digi_ctx->rx_dma_buf);
}

return (taskAwoken == pdTRUE);
}

Expand Down
6 changes: 1 addition & 5 deletions components/esp_adc/adc_continuous.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ static IRAM_ATTR bool adc_dma_in_suc_eof_callback(gdma_channel_handle_t dma_chan
ctx->rx_eof_desc_addr = event_data->rx_eof_desc_addr;
return s_adc_dma_intr(user_data);
}

#else
static IRAM_ATTR void adc_dma_intr_handler(void *arg)
{
Expand Down Expand Up @@ -342,11 +343,6 @@ static IRAM_ATTR bool s_adc_dma_intr(adc_continuous_ctx_t *adc_digi_ctx)
}
}

if (status == ADC_HAL_DMA_DESC_NULL) {
//start next turns of dma operation
adc_hal_digi_start(&adc_digi_ctx->hal, adc_digi_ctx->rx_dma_buf);
}

return need_yield;
}

Expand Down
12 changes: 11 additions & 1 deletion components/hal/adc_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ static void adc_hal_digi_dma_link_descriptors(dma_descriptor_t *desc, uint8_t *d
HAL_ASSERT(((uint32_t)data_buf % 4) == 0);
HAL_ASSERT((per_eof_size % 4) == 0);
uint32_t n = 0;
dma_descriptor_t *desc_head = desc;

while (eof_num--) {
uint32_t eof_size = per_eof_size;
Expand All @@ -257,7 +258,7 @@ static void adc_hal_digi_dma_link_descriptors(dma_descriptor_t *desc, uint8_t *d
n++;
}
}
desc[n-1].next = NULL;
desc[n-1].next = desc_head;
}

void adc_hal_digi_start(adc_hal_dma_ctx_t *hal, uint8_t *data_buf)
Expand Down Expand Up @@ -312,15 +313,24 @@ adc_hal_dma_desc_status_t adc_hal_get_reading_result(adc_hal_dma_ctx_t *hal, con

//Find the eof list start
eof_desc = eof_desc->next;
eof_desc->dw0.owner = 1;
buffer_start = eof_desc->buffer;
eof_len += eof_desc->dw0.length;
if ((intptr_t)eof_desc == eof_desc_addr) {
goto valid;
}

//Find the eof list end
for (int i = 1; i < hal->eof_step; i++) {
eof_desc = eof_desc->next;
eof_desc->dw0.owner = 1;
eof_len += eof_desc->dw0.length;
if ((intptr_t)eof_desc == eof_desc_addr) {
goto valid;
}
}

valid:
hal->cur_desc_ptr = eof_desc;
*buffer = buffer_start;
*len = eof_len;
Expand Down

0 comments on commit cd7ef82

Please sign in to comment.