1 /*
2 * common.c
3 *
4 * Demo sample application for the EDMA3 Driver for BIOS 6.
5 *
6 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
7 *
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the
19 * distribution.
20 *
21 * Neither the name of Texas Instruments Incorporated nor the names of
22 * its contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 */
39 #include "sample.h"
42 /* Flag variable to check transfer completion on channel 1 */
43 volatile short irqRaised1 = 0;
44 /* Flag variable to check transfer completion on channel 2 */
45 volatile short irqRaised2 = 0;
48 /* Cache line aligned source buffer 1. */
49 #ifdef EDMA3_ENABLE_DCACHE
50 /**
51 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
52 * alignment boundary is the maximum of the symbol\92s default alignment value
53 * or the value of the constant in bytes. The constant must be a power of 2.
54 * The syntax of the pragma in C is:
55 * #pragma DATA_ALIGN (symbol, constant);
56 */
57 #pragma DATA_ALIGN(_srcBuff1, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
58 #endif /* #ifdef EDMA3_ENABLE_DCACHE */
59 #pragma DATA_SECTION(_srcBuff1, ".my_sect_ddr");
60 signed char _srcBuff1[MAX_BUFFER_SIZE];
63 /* Cache line aligned destination buffer 1. */
64 #ifdef EDMA3_ENABLE_DCACHE
65 /**
66 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
67 * alignment boundary is the maximum of the symbol\92s default alignment value
68 * or the value of the constant in bytes. The constant must be a power of 2.
69 * The syntax of the pragma in C is:
70 * #pragma DATA_ALIGN (symbol, constant);
71 */
72 #pragma DATA_ALIGN(_dstBuff1, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
73 #endif /* #ifdef EDMA3_ENABLE_DCACHE */
74 #pragma DATA_SECTION(_dstBuff1, ".my_sect_ddr");
75 signed char _dstBuff1[MAX_BUFFER_SIZE];
77 signed char *srcBuff1;
78 signed char *dstBuff1;
82 /* Cache line aligned source buffer 2. */
83 #ifdef EDMA3_ENABLE_DCACHE
84 /**
85 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
86 * alignment boundary is the maximum of the symbol\92s default alignment value
87 * or the value of the constant in bytes. The constant must be a power of 2.
88 * The syntax of the pragma in C is:
89 * #pragma DATA_ALIGN (symbol, constant);
90 */
91 #pragma DATA_ALIGN(_srcBuff2, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
92 #endif /* #ifdef EDMA3_ENABLE_DCACHE */
93 #pragma DATA_SECTION(_srcBuff2, ".my_sect_ddr");
94 signed char _srcBuff2[MAX_BUFFER_SIZE];
97 #ifdef EDMA3_ENABLE_DCACHE
98 /* Cache line aligned destination buffer 2. */
99 /**
100 * The DATA_ALIGN pragma aligns the symbol to an alignment boundary. The
101 * alignment boundary is the maximum of the symbol\92s default alignment value
102 * or the value of the constant in bytes. The constant must be a power of 2.
103 * The syntax of the pragma in C is:
104 * #pragma DATA_ALIGN (symbol, constant);
105 */
106 #pragma DATA_ALIGN(_dstBuff2, EDMA3_CACHE_LINE_SIZE_IN_BYTES);
107 #endif /* #ifdef EDMA3_ENABLE_DCACHE */
108 #pragma DATA_SECTION(_dstBuff2, ".my_sect_ddr");
109 signed char _dstBuff2[MAX_BUFFER_SIZE];
111 signed char *srcBuff2;
112 signed char *dstBuff2;
115 /* Callback function 1 */
116 void callback1 (unsigned int tcc, EDMA3_RM_TccStatus status,
117 void *appData)
118 {
119 (void)tcc;
120 (void)appData;
122 switch (status)
123 {
124 case EDMA3_RM_XFER_COMPLETE:
125 /* Transfer completed successfully */
126 irqRaised1 = 1;
127 break;
128 case EDMA3_RM_E_CC_DMA_EVT_MISS:
129 /* Transfer resulted in DMA event miss error. */
130 irqRaised1 = -1;
131 break;
132 case EDMA3_RM_E_CC_QDMA_EVT_MISS:
133 /* Transfer resulted in QDMA event miss error. */
134 irqRaised1 = -2;
135 break;
136 default:
137 break;
138 }
139 }
142 /* Callback function 2 */
143 void callback2 (unsigned int tcc, EDMA3_RM_TccStatus status,
144 void *appData)
145 {
146 (void)tcc;
147 (void)appData;
149 switch (status)
150 {
151 case EDMA3_RM_XFER_COMPLETE:
152 /* Transfer completed successfully */
153 irqRaised2 = 1;
154 break;
155 case EDMA3_RM_E_CC_DMA_EVT_MISS:
156 /* Transfer resulted in DMA event miss error. */
157 irqRaised2 = -1;
158 break;
159 case EDMA3_RM_E_CC_QDMA_EVT_MISS:
160 /* Transfer resulted in QDMA event miss error. */
161 irqRaised2 = -2;
162 break;
163 default:
164 break;
165 }
166 }