static int dma_stm32_start(struct device *dev, u32_t id) { struct dma_stm32_device *ddata = dev->driver_data; struct dma_stm32_stream_reg *regs = &ddata->stream[id].regs; u32_t irqstatus; int ret; ret = dma_stm32_disable_stream(ddata, id); if (ret) { return ret; } dma_stm32_write(ddata, DMA_STM32_SCR(id), regs->scr); dma_stm32_write(ddata, DMA_STM32_SPAR(id), regs->spar); dma_stm32_write(ddata, DMA_STM32_SM0AR(id), regs->sm0ar); dma_stm32_write(ddata, DMA_STM32_SFCR(id), regs->sfcr); dma_stm32_write(ddata, DMA_STM32_SM1AR(id), regs->sm1ar); dma_stm32_write(ddata, DMA_STM32_SNDTR(id), regs->sndtr); /* Clear remanent IRQs from previous transfers */ irqstatus = dma_stm32_irq_status(ddata, id); if (irqstatus) { dma_stm32_irq_clear(ddata, id, irqstatus); } dma_stm32_dump_reg(ddata, id); /* Push the start button */ dma_stm32_write(ddata, DMA_STM32_SCR(id), regs->scr | DMA_STM32_SCR_EN); return 0; }
static void dma_stm32_dump_reg(struct dma_stm32_device *ddata, u32_t id) { SYS_LOG_INF("Using stream: %d\n", id); SYS_LOG_INF("SCR: 0x%x \t(config)\n", dma_stm32_read(ddata, DMA_STM32_SCR(id))); SYS_LOG_INF("SNDTR: 0x%x \t(length)\n", dma_stm32_read(ddata, DMA_STM32_SNDTR(id))); SYS_LOG_INF("SPAR: 0x%x \t(source)\n", dma_stm32_read(ddata, DMA_STM32_SPAR(id))); SYS_LOG_INF("SM0AR: 0x%x \t(destination)\n", dma_stm32_read(ddata, DMA_STM32_SM0AR(id))); SYS_LOG_INF("SM1AR: 0x%x \t(destination (double buffer mode))\n", dma_stm32_read(ddata, DMA_STM32_SM1AR(id))); SYS_LOG_INF("SFCR: 0x%x \t(fifo control)\n", dma_stm32_read(ddata, DMA_STM32_SFCR(id))); }