]> rtime.felk.cvut.cz Git - pes-rpp/rpp-test-sw.git/blob - rpp/lib/rpp/src/sys/ti_drv_dma.c
0753b5a7fe6686e10eac882a7e6d16a645f3f18a
[pes-rpp/rpp-test-sw.git] / rpp / lib / rpp / src / sys / ti_drv_dma.c
1 /** @file dma.c
2 *   @brief DMA Driver Inmplmentation File
3 *   @date 22.Aug.2011
4 *   @version 1.01.000
5 *
6 */
7
8 /* (c) Texas Instruments 2009-2010, All rights reserved. */
9
10
11 #include "sys/ti_drv_dma.h"
12
13 g_dmaCTRL g_dmaCTRLPKT;
14
15 /** @fn void dmaEnable(void)
16 *   @brief enables dma module
17 *
18 *   This function brings DMA out of reset
19 */
20
21 void dmaEnable(void)
22 {
23   dmaREG->GCTRL  = 0x00000001; /* reset dma       */
24   dmaREG->GCTRL |= 0x00010000; /* enable dma      */
25   dmaREG->GCTRL |= 0x00000300; /* stop at suspend */
26 }
27
28
29
30 /** @fn void dmaReqAssign(uint32_t channel,uint32_t reqline)
31 *   @brief Initializes the DMA Driver
32 *
33 *   This function assigns dma request lines to channels
34 */
35
36 void dmaReqAssign(uint32_t channel,uint32_t reqline)
37 {
38     register uint32_t i=0,j=0;
39
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          */
44
45     /* mapping channel 'i' to request line 'j' */
46     dmaREG->DREQASI[i] &= ~(0xff<<j);
47     dmaREG->DREQASI[i] |= (reqline<<j);
48 }
49
50
51
52 /** @fn void dmaSetCtrlPacket(uint32_t channel)
53 *   @brief Initializes the DMA Driver
54 *
55 *   This function sets control packet
56 */
57
58 void dmaSetCtrlPacket(uint32_t channel)
59 {
60     register uint32_t i=0,j=0;
61
62     dmaRAMREG->PCP[channel].ISADDR  =  g_dmaCTRLPKT.SADD;
63
64     dmaRAMREG->PCP[channel].IDADDR  =  g_dmaCTRLPKT.DADD;
65
66     dmaRAMREG->PCP[channel].ITCOUNT = (g_dmaCTRLPKT.FRCNT << 16) | g_dmaCTRLPKT.ELCNT;
67
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);
70
71     dmaRAMREG->PCP[channel].CHCTRL |= (g_dmaCTRLPKT.CHCTRL << 16);
72
73     dmaRAMREG->PCP[channel].EIOFF   = (g_dmaCTRLPKT.ELDOFFSET << 16) | (g_dmaCTRLPKT.ELSOFFSET);
74
75     dmaRAMREG->PCP[channel].FIOFF   = (g_dmaCTRLPKT.FRDOFFSET << 16) | (g_dmaCTRLPKT.FRSOFFSET);
76
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 */
81
82     dmaREG->PAR[i] &= ~(0xf<<j);
83     dmaREG->PAR[i] |= (g_dmaCTRLPKT.PORTASGN<<j);
84 }
85
86
87
88 /** @fn void dmaSetCtrlPacket(uint32_t channel)
89 *   @brief Initializes the DMA Driver
90 *
91 *   This function sets control packet
92 */
93
94 void dmaSetChEnable(uint32_t channel,uint32_t type)
95 {
96     if(type == DMA_HW)
97     {
98      dmaREG->HWCHENAS = (1 << channel);
99     }
100     else if(type == DMA_SW)
101     {
102      dmaREG->SWCHENAS = (1 << channel);
103     }
104 }
105
106
107
108 /**/
109