I think all you have to do is clear the "GO" bit in the command register. I just realized that I was missing that functionality in my DMA routines (for a USB chip) so I added a function like this:
int AbortUSBTransfer()
{
if ((IORD_ALTERA_AVALON_DMA_STATUS(DMA_0_BASE) & ALTERA_AVALON_DMA_STATUS_BUSY_MSK) == 0)
return 1; // nothing to do
// clear control register (mainly clear "GO" bit
IOWR_ALTERA_AVALON_DMA_CONTROL(DMA_0_BASE, 0);
if ((IORD_ALTERA_AVALON_DMA_STATUS(DMA_0_BASE) & ALTERA_AVALON_DMA_STATUS_BUSY_MSK) == 0)
return 1; // abort worked
else
return -1; // abort failed
}
I just tried it and it seems to work. I started a DMA transfer but didn't send any data from the PC. I then aborted the DMA transfer and the DMA engine went back to idle (busy and done bit cleared). After that I executed some more DMA transfers and they worked fine.
Hope that helps,
Andrew