X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fsamd21%2Fao_dma_samd21.c;h=5bf9470900c0fa9d5f89a6f1edbf4cec2b827e6e;hb=HEAD;hp=60bf34f14aa909c29ec46070df25a33c9e1e7d04;hpb=c59892cd337162c63e5d7ba8e8eec779d201022d;p=fw%2Faltos diff --git a/src/samd21/ao_dma_samd21.c b/src/samd21/ao_dma_samd21.c index 60bf34f1..5bf94709 100644 --- a/src/samd21/ao_dma_samd21.c +++ b/src/samd21/ao_dma_samd21.c @@ -17,14 +17,11 @@ */ #include -#include +#include static struct samd21_dmac_desc samd21_dmac_desc[SAMD21_DMAC_NCHAN] __attribute__((aligned(16))); static struct samd21_dmac_desc samd21_dmac_wrb[SAMD21_DMAC_NCHAN] __attribute__((aligned(16))); -static volatile uint16_t saved_intpend; -static volatile int interrupts; - static struct { void (*callback)(uint8_t id, void *closure); void *closure; @@ -35,9 +32,7 @@ samd21_dmac_isr(void) { uint16_t intpend = samd21_dmac.intpend; - ++interrupts; - saved_intpend = intpend; - if (intpend & 0xff00) { + if (intpend & 0x0700) { uint8_t id = (intpend >> SAMD21_DMAC_INTPEND_ID) & SAMD21_DMAC_INTPEND_ID_MASK; samd21_dmac.intpend = intpend; if (intpend & (1 << SAMD21_DMAC_INTPEND_TCMPL)) { @@ -50,36 +45,35 @@ samd21_dmac_isr(void) void ao_dma_dump(char *where) { - printf("DMA %s ctrl %04x intpend %04x intstatus %04x\n", + printf("DMA %s ctrl %04x intpend %04x intstatus %04lx\n", where, samd21_dmac.ctrl, samd21_dmac.intpend, samd21_dmac.intstatus); fflush(stdout); - printf(" busych %04x pendch %04x active %08x chctrla %02x\n", + printf(" busych %04lx pendch %04lx active %08lx chctrla %02x\n", samd21_dmac.busych, samd21_dmac.pendch, samd21_dmac.active, samd21_dmac.chctrla); fflush(stdout); - printf(" chctrlb %08x chintflag %02x chstatus %02x\n", + printf(" chctrlb %08lx chintflag %02x chstatus %02x\n", samd21_dmac.chctrlb, samd21_dmac.chintflag, samd21_dmac.chstatus); fflush(stdout); - printf(" btctrl %04x btcnt %04x srcaddr %08x dstaddr %08x descaddr %08x\n", + printf(" btctrl %04x btcnt %04x srcaddr %08lx dstaddr %08lx descaddr %08lx\n", samd21_dmac_desc[0].btctrl, samd21_dmac_desc[0].btcnt, samd21_dmac_desc[0].srcaddr, samd21_dmac_desc[0].dstaddr, samd21_dmac_desc[0].descaddr); fflush(stdout); - printf("intpend %04x interrupts %d\n", saved_intpend, interrupts); } void _ao_dma_start_transfer(uint8_t id, - void *src, + const void *src, void *dst, uint16_t count, uint32_t chctrlb, @@ -121,7 +115,7 @@ ao_dma_init(void) samd21_pm.ahbmask |= (1 << SAMD21_PM_AHBMASK_DMAC); samd21_pm.apbbmask |= (1 << SAMD21_PM_APBBMASK_DMAC); -#if 0 +#if 1 /* Enable HPB clocks so we can talk to peripherals */ samd21_pm.ahbmask |= ((1 << SAMD21_PM_AHBMASK_HPB0) | (1 << SAMD21_PM_AHBMASK_HPB1) |