X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=hw2%2Ftimer_dma.c;h=7d06bac50e49cc7ad84c42e6ef1acc2225c0f538;hb=16ad7d215971b9bbd79007f7c334c4f8d9659c49;hp=529fd7e2a59d2873563995cf5d5800f698df91ba;hpb=70a817bdd055b39c1990778594ed97a532748d31;p=~andy%2Fcsm213a-hw diff --git a/hw2/timer_dma.c b/hw2/timer_dma.c index 529fd7e..7d06bac 100644 --- a/hw2/timer_dma.c +++ b/hw2/timer_dma.c @@ -158,13 +158,17 @@ void tdma_start(tdma_t *port) //sirq_printf("isfr3: %08x\r\n", PORTD->ISFR); } -void tdma_stop(tdma_t *port) +void tdma_stop(tdma_t *port, int wait) { if (!port) return; //sirq_printf("isfr0: %08x\r\n", PORTD->ISFR); + for (int i = 0; port->dma->dsr & DMA_DSR_BCR_BCR_MASK; i++) + if (i > wait) + return 0; + // Disable DMA Mux port->mux->cfg &= DMAMUX_CHCFG_ENBL_MASK;