]> Pileus Git - ~andy/csm213a-hw/blobdiff - hw2/timer_dma.c
Perform no-delay time synchronization
[~andy/csm213a-hw] / hw2 / timer_dma.c
index 529fd7e2a59d2873563995cf5d5800f698df91ba..7d06bac50e49cc7ad84c42e6ef1acc2225c0f538 100644 (file)
@@ -158,13 +158,17 @@ void tdma_start(tdma_t *port)
        //sirq_printf("isfr3: %08x\r\n", PORTD->ISFR);\r
 }\r
 \r
-void tdma_stop(tdma_t *port)\r
+void tdma_stop(tdma_t *port, int wait)\r
 {\r
        if (!port)\r
                return;\r
 \r
        //sirq_printf("isfr0: %08x\r\n", PORTD->ISFR);\r
 \r
+       for (int i = 0; port->dma->dsr & DMA_DSR_BCR_BCR_MASK; i++)\r
+               if (i > wait)\r
+                       return 0;\r
+\r
        // Disable DMA Mux\r
        port->mux->cfg &= DMAMUX_CHCFG_ENBL_MASK;\r
 \r