Skip to content

api: dma: add circular buffer support #15885

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 8 additions & 0 deletions drivers/dma/dma_stm32f4x.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@ static int dma_stm32_config_devcpy(struct device *dev, u32_t id,
return -EINVAL;
}

if (config->buf_cfg == DMA_BUF_CFG_CIRCULAR) {
regs->scr |= DMA_STM32_SCR_CIRC;
}

if (src_burst_size == BURST_TRANS_LENGTH_1 &&
dst_burst_size == BURST_TRANS_LENGTH_1) {
/* Enable 'direct' mode error IRQ, disable 'FIFO' error IRQ */
Expand Down Expand Up @@ -358,6 +362,10 @@ static int dma_stm32_config_memcpy(struct device *dev, u32_t id,
DMA_STM32_SCR_TCIE | /* Transfer comp IRQ enable */
DMA_STM32_SCR_TEIE; /* Transfer error IRQ enable */

if (config->buf_cfg == DMA_BUF_CFG_CIRCULAR) {
regs->scr |= DMA_STM32_SCR_CIRC;
}

regs->sfcr = DMA_STM32_SFCR_DMDIS | /* Direct mode disable */
DMA_STM32_SFCR_FTH(DMA_STM32_FIFO_THRESHOLD_FULL) |
DMA_STM32_SFCR_FEIE; /* FIFI error IRQ enable */
Expand Down
8 changes: 7 additions & 1 deletion include/dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ enum dma_addr_adj {
DMA_ADDR_ADJ_NO_CHANGE,
};

enum dma_buf_cfg {
DMA_BUF_CFG_NORMAL,
DMA_BUF_CFG_CIRCULAR,
};

/**
* @brief DMA block configuration structure.
*
Expand Down Expand Up @@ -142,7 +147,8 @@ struct dma_config {
u32_t channel_priority : 4;
u32_t source_chaining_en : 1;
u32_t dest_chaining_en : 1;
u32_t reserved : 13;
u32_t buf_cfg : 2;
u32_t reserved : 11;
u32_t source_data_size : 16;
u32_t dest_data_size : 16;
u32_t source_burst_length : 16;
Expand Down