*/
#include <ao.h>
-#include <ao_dma-samd21.h>
+#include <ao_dma_samd21.h>
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;
{
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)) {
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,
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) |