#include <otSerial.h>
#include <otTimer.h>
#include <otPrintfLite.h>
#include <otMalloc.h>
#include <otDMA.h>
#define LEN 65536U
volatile bool done = false;
U32 st, et;
FAST_CODE_1 void dmaCallback()
{
et = TimerGetCounts(TIMER0);
done = true;
}
void testDma(U32 *src, U32 *dst)
{
done = false;
DmaSetInterruptService(DMA_CH_0, dmaCallback);
st = TimerGetCounts(TIMER0);
if(!DmaMoveChecked(DMA_CH_0, src, dst, LEN, DMA_DWORD))
{
printf("DMA start failed\n");
return;
}
while(!done)
{
if(DmaHasError(DMA_CH_0))
{
printf("DMA error\n");
DmaStop(DMA_CH_0);
return;
}
}
printf("DMA transfer elapsed time: %lu us\n",
(unsigned long)ElapsedTimeUs(st, et));
DmaEnableInterrupt(DMA_CH_0, false);
DmaStop(DMA_CH_0);
}