2 * @brief DMA Driver Inmplmentation File
8 /* (c) Texas Instruments 2009-2010, All rights reserved. */
11 #include "sys/ti_drv_dma.h"
13 g_dmaCTRL g_dmaCTRLPKT;
15 /** @fn void dmaEnable(void)
16 * @brief enables dma module
18 * This function brings DMA out of reset
23 dmaREG->GCTRL = 0x00000001; /* reset dma */
24 dmaREG->GCTRL |= 0x00010000; /* enable dma */
25 dmaREG->GCTRL |= 0x00000300; /* stop at suspend */
30 /** @fn void dmaReqAssign(uint32_t channel,uint32_t reqline)
31 * @brief Initializes the DMA Driver
33 * This function assigns dma request lines to channels
36 void dmaReqAssign(uint32_t channel,uint32_t reqline)
38 register uint32_t i=0,j=0;
40 i = channel >> 2; /* Find the register to configure */
41 j = channel -(i<<2); /* Find the offset of the type */
42 j = 3-j; /* reverse the byte order */
43 j = j<<3; /* find the bit location */
45 /* mapping channel 'i' to request line 'j' */
46 dmaREG->DREQASI[i] &= ~(0xff<<j);
47 dmaREG->DREQASI[i] |= (reqline<<j);
52 /** @fn void dmaSetCtrlPacket(uint32_t channel)
53 * @brief Initializes the DMA Driver
55 * This function sets control packet
58 void dmaSetCtrlPacket(uint32_t channel)
60 register uint32_t i=0,j=0;
62 dmaRAMREG->PCP[channel].ISADDR = g_dmaCTRLPKT.SADD;
64 dmaRAMREG->PCP[channel].IDADDR = g_dmaCTRLPKT.DADD;
66 dmaRAMREG->PCP[channel].ITCOUNT = (g_dmaCTRLPKT.FRCNT << 16) | g_dmaCTRLPKT.ELCNT;
68 dmaRAMREG->PCP[channel].CHCTRL = (g_dmaCTRLPKT.RDSIZE << 14) | (g_dmaCTRLPKT.WRSIZE << 12) | (g_dmaCTRLPKT.TTYPE << 8)| \
69 (g_dmaCTRLPKT.ADDMODERD << 3 ) | (g_dmaCTRLPKT.ADDMODEWR << 1 ) | (g_dmaCTRLPKT.AUTOINIT);
71 dmaRAMREG->PCP[channel].CHCTRL |= (g_dmaCTRLPKT.CHCTRL << 16);
73 dmaRAMREG->PCP[channel].EIOFF = (g_dmaCTRLPKT.ELDOFFSET << 16) | (g_dmaCTRLPKT.ELSOFFSET);
75 dmaRAMREG->PCP[channel].FIOFF = (g_dmaCTRLPKT.FRDOFFSET << 16) | (g_dmaCTRLPKT.FRSOFFSET);
77 i = channel >> 3; /* Find the register to write */
78 j = channel -(i << 3); /* Find the offset of the 4th bit */
79 j = 7 -j; /* Reverse the order of the 4th bit offset */
80 j = j<<2; /* Find the bit location of the 4th bit to write */
82 dmaREG->PAR[i] &= ~(0xf<<j);
83 dmaREG->PAR[i] |= (g_dmaCTRLPKT.PORTASGN<<j);
88 /** @fn void dmaSetCtrlPacket(uint32_t channel)
89 * @brief Initializes the DMA Driver
91 * This function sets control packet
94 void dmaSetChEnable(uint32_t channel,uint32_t type)
98 dmaREG->HWCHENAS = (1 << channel);
100 else if(type == DMA_SW)
102 dmaREG->SWCHENAS = (1 << channel);