The dmac trigger is differnt for rx and tx.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 2 Sep 2011 16:15:48 +0000 (16:15 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 2 Sep 2011 16:15:48 +0000 (16:15 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5012 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cpu/cortex-m3/drv/hsmci_sam3.c

index b32d688be173e9adac02914c16f7449f0d6cdf3a..cc9b2718a0ebd7949a9e3fe07db66982d3864750 100644 (file)
@@ -167,6 +167,18 @@ void hsmci_prgTxDMA(uint32_t *buf, size_t word_num, size_t blk_size)
 
        hsmci_setBlockSize(blk_size);
 
+       //init DMAC
+       DMAC_EBCIDR = 0x3FFFFF;
+       DMAC_CHDR = 0x1F;
+       DMAC_CFG0 = BV(DMAC_CFG_DST_H2SEL) | DMAC_CFG_FIFOCFG_ALAP_CFG | (0x1 << DMAC_CFG_AHB_PROT_SHIFT);
+
+       pmc_periphEnable(DMAC_ID);
+       DMAC_EN = BV(DMAC_EN_ENABLE);
+       sysirq_setHandler(INT_DMAC, dmac_irq);
+
+       DMAC_EBCIER = BV(DMAC_EBCIER_BTC0) | BV(DMAC_EBCIER_ERR0);
+
+
        DMAC_CHDR = BV(DMAC_CHDR_DIS0);
 
        DMAC_SADDR0 = (uint32_t)buf;
@@ -194,6 +206,17 @@ void hsmci_prgRxDMA(uint32_t *buf, size_t word_num, size_t blk_size)
 {
        hsmci_setBlockSize(blk_size);
 
+       //init DMAC
+       DMAC_EBCIDR = 0x3FFFFF;
+       DMAC_CHDR = 0x1F;
+       DMAC_CFG0 = BV(DMAC_CFG_SRC_H2SEL) | DMAC_CFG_FIFOCFG_ALAP_CFG | (0x1 << DMAC_CFG_AHB_PROT_SHIFT);
+
+       pmc_periphEnable(DMAC_ID);
+       DMAC_EN = BV(DMAC_EN_ENABLE);
+       sysirq_setHandler(INT_DMAC, dmac_irq);
+
+       DMAC_EBCIER = BV(DMAC_EBCIER_BTC0) | BV(DMAC_EBCIER_ERR0);
+
        DMAC_CHDR = BV(DMAC_CHDR_DIS0);
 
        DMAC_SADDR0 = (uint32_t)&HSMCI_RDR;
@@ -256,16 +279,4 @@ void hsmci_init(Hsmci *hsmci)
        HSMCI_CR = BV(HSMCI_CR_MCIEN);
        HSMCI_DMA = 0;
 
-
-       //init DMAC
-       DMAC_EBCIDR = 0x3FFFFF;
-       DMAC_CHDR = 0x1F;
-       DMAC_CFG0 = BV(DMAC_CFG_SRC_H2SEL) | DMAC_CFG_FIFOCFG_ALAP_CFG | (0x1 << DMAC_CFG_AHB_PROT_SHIFT);
-
-       pmc_periphEnable(DMAC_ID);
-       DMAC_EN = BV(DMAC_EN_ENABLE);
-       sysirq_setHandler(INT_DMAC, dmac_irq);
-
-       DMAC_EBCIER = BV(DMAC_EBCIER_BTC0) | BV(DMAC_EBCIER_ERR0);
-
 }