samd21: Fix up DMA driver
authorKeith Packard <keithp@keithp.com>
Sun, 6 Nov 2022 23:08:56 +0000 (15:08 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 6 Nov 2022 23:08:56 +0000 (15:08 -0800)
Surprisingly few changes, just some function signatures and a few bit
twiddles.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/samd21/ao_dma_samd21.c
src/samd21/ao_dma_samd21.h

index 60bf34f14aa909c29ec46070df25a33c9e1e7d04..5bf9470900c0fa9d5f89a6f1edbf4cec2b827e6e 100644 (file)
  */
 
 #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;
@@ -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) |
index 725e621a3a5d1377d588cbb185482f42e297213d..624e7a921e600baf228db97586edb72bf2b601f5 100644 (file)
@@ -24,7 +24,7 @@ ao_dma_init(void);
 
 void
 _ao_dma_start_transfer(uint8_t         id,
-                      void             *src,
+                      const void       *src,
                       void             *dst,
                       uint16_t         count,
                       uint32_t         chctrlb,