|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ! ` \6 p3 G6 q: I& K
- [code]EDMA sample test application
! O- B" ^8 W' v5 X+ l" o) p - /*
- c4 m, M5 p8 }1 v" i - * edma_test.c; I; P# ]# Z' f9 h2 f, x/ H( O) f
- *9 B; Q) b* |7 D* P
- * brief EDMA3 Test Application# x3 e/ D& e/ Q3 D
- *3 \: z0 c/ W2 Z7 H4 \2 s
- * This file contains EDMA3 Test code.4 b$ p2 a8 R+ u
- */ P h( p$ r6 o5 L/ u2 W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE* H8 y$ i: Z4 f* h# x U, @
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( x6 S* R7 B: V$ { - * TO CHANGE.( u7 F1 }" s1 a9 D& B& b( A
- *) \4 M# o3 U2 P, i+ x0 y0 v
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- n) w! ^* z0 s2 {( I5 H
- *
3 z( ~8 s$ }# {. I/ W - * This program is free software; you can redistribute it and/or, w8 S; k! b* W3 y0 t" Y
- * modify it under the terms of the GNU General Public License as- S4 f4 u& ?/ L
- * published by the Free Software Foundation version 2.
7 \% ? d: x; p# h9 k( P - *# c7 u- ]0 o7 ]& V
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 u7 U1 N' ^3 q% K3 ^8 P$ L - * kind, whether express or implied; without even the implied warranty; W) k( m1 Y" Z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. I/ Q5 o' M/ S {5 Z& g
- * GNU General Public License for more details.
+ p( P$ U0 Q% p; Y) R+ ]7 h- N; n - */
' ~2 N# {0 [8 l2 _& T, Z. j' {
( x W3 V, L$ [/ p9 u g6 a- #include <linux/module.h>
( N; W6 W, W ?& d( e1 ] - #include <linux/init.h>) w: Q; z. U; }1 f5 q8 T
- #include <linux/errno.h>
) G* L! K6 P' p3 Z4 R4 K: | - #include <linux/types.h>: A4 J0 B' J- e8 ]1 E
- #include <linux/interrupt.h>
% k5 q" p/ J- y0 A m4 Q I - #include <asm/io.h>
1 Q) |$ ^6 D* t S7 c1 Q - #include <linux/moduleparam.h>
; @+ B) e N$ \1 V - #include <linux/sysctl.h> r: ]% F3 K) h) T% h
- #include <linux/mm.h>8 z5 q) b+ C+ w3 `5 v+ R
- #include <linux/dma-mapping.h>
1 ?7 H( L: z1 p' R( E$ q" C4 x
$ A9 F( I' z J5 K: {. L- #include <mach/memory.h>' D$ l1 \9 `" L2 t
- #include <mach/hardware.h>! C( q; x4 A1 u6 B$ p
- #include <mach/irqs.h>1 g" B) H( C7 [( y# b9 y% K# o/ M
- #include <asm/hardware/edma.h>+ B; R/ X+ _$ ]2 b U
& \" u5 s; V/ V7 e- #undef EDMA3_DEBUG
2 [: M% O+ t, [+ K0 F1 |7 `1 V - /*#define EDMA3_DEBUG*/& X( [% ~% }# n5 }
' e* f# R) y) t- #ifdef EDMA3_DEBUG3 Q2 H/ o" `4 w
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( F/ A2 R. }+ K! p) [* ~
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. m6 R0 r5 | Q9 Y( y' w* t - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% J! @" I' a( g# [4 R' _
- #else: n3 S0 S" s1 ]/ y8 z8 U" k; U
- #define DMA_PRINTK( x... ); ]" x' U V2 b8 Z" W9 k2 ^
- #define DMA_FN_IN" w5 |$ d0 y/ q# P2 {$ y$ @
- #define DMA_FN_OUT2 N" D( Q; C! Q6 S* X9 J$ f* z* k
- #endif$ X7 ]. V, {9 P. b. x. E$ m6 @$ A! c
* ^" b& U- L. E+ g- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& A- [ `/ a z8 l3 r* n$ R2 v - #define STATIC_SHIFT 3
2 x" u% N, C& m& z0 \9 f - #define TCINTEN_SHIFT 20# F4 D" \0 E! x6 D) F8 N. P
- #define ITCINTEN_SHIFT 219 x* \+ W! g( n4 y$ t% }- }+ _8 W
- #define TCCHEN_SHIFT 228 X: h1 j) Q' q5 I( \9 |5 n
- #define ITCCHEN_SHIFT 23
& L4 x! J3 e- X9 s - : f" J6 Z. w6 Z. v0 |, ]+ x
- static volatile int irqraised1 = 0;
( h$ n# Z0 H9 a- ^ - static volatile int irqraised2 = 0;6 L: C. u) R# j
* [8 U1 T+ Q2 ?" K! W- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 d) H4 R6 A$ s) t& V - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# ?' ~' M9 b; h( E. H
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( G; c/ ~ m* h$ f
- # B; V. N6 o' B. s' J6 i- ~1 ?
- dma_addr_t dmaphyssrc1 = 0;; v0 N8 I) ^" S7 j
- dma_addr_t dmaphyssrc2 = 0; r0 Z1 D |, I# B4 B+ b
- dma_addr_t dmaphysdest1 = 0;$ T/ y9 @7 @' q0 [/ n5 v
- dma_addr_t dmaphysdest2 = 0;
+ ] q/ N$ p; z3 `3 u - ( x8 }9 H( p! `, C% c& w" W
- char *dmabufsrc1 = NULL;
* p& D7 U9 P) {, Z& L - char *dmabufsrc2 = NULL;
! b# ]8 t' a" p* R! ]1 | - char *dmabufdest1 = NULL;: [3 v4 z- |0 \! w1 D
- char *dmabufdest2 = NULL;
* z* M5 A, m/ Q2 [9 \& ]7 \ ^ - 0 K/ a. |7 a5 M
- static int acnt = 512;
8 D) V9 v/ O" f! @ g( ` - static int bcnt = 8;
9 ?. w" R% S8 e% K! |8 S% I* X - static int ccnt = 8;
+ j5 c$ _ C( C& f; Y
% |. W/ @' o# V- module_param(acnt, int, S_IRUGO);! [7 ^' P, w& ?5 T3 R* o! ?' z
- module_param(bcnt, int, S_IRUGO);
; X M9 y0 X0 ]0 q7 o - module_param(ccnt, int, S_IRUGO);
复制代码 2 d7 U: B5 f& W: x8 R; B" h
7 ?: [& v$ {4 T, A$ q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) g9 t' b- E. b/ s
arm-none-linux-gnueabi-gcc -I /home/tl/omapl138/linux-3.3/arch/arm/include -I /home/tl/omapl138/linux-3.3/include EDMA3test.cpp -o EDMA3这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# u B, `% T B- V/ H 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。! p, Q ~! }/ g8 d& j
2 d2 @% k$ N" G0 S; w
3 a G2 X b2 j( n$ _, N C7 n# D" {" y3 T |
|