|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. l0 [ F# p% s' [ U- ~5 M5 r8 l- [code]EDMA sample test application
5 u- S1 A6 M% s( s- m8 J - /*
+ H( O) E* b1 L' ~1 G0 f* d - * edma_test.c
6 V5 v' B8 P& E - *
; f; }* ]) T6 B - * brief EDMA3 Test Application
. S; F7 s( R/ y1 @ - *
- m* i4 F, |5 X, v - * This file contains EDMA3 Test code.
* R2 T' ^( `: l - *. }) }9 i8 e6 O( Q3 ? }
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, e/ [/ } I; D, w g# f, S* } - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 V- p) X2 s: X7 F0 c
- * TO CHANGE.
6 H; }: w# W/ M& V! F - *
$ R8 }9 }: j3 Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) m0 @$ P( j. X! g* u - *
0 A" L+ q3 C" c9 B - * This program is free software; you can redistribute it and/or. }! A1 k% v" h
- * modify it under the terms of the GNU General Public License as
$ ?8 A8 o2 N1 k _0 o - * published by the Free Software Foundation version 2." y- d6 P$ ~$ y9 T/ }/ G7 F& l
- *
$ x: ^; M: w& ]7 i: d - * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 ?9 a {$ z! r7 |6 _/ S
- * kind, whether express or implied; without even the implied warranty# b, B' P+ U% e3 D+ H& u# F8 @& R
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the& I. e2 B5 K. V4 x4 M1 h, o
- * GNU General Public License for more details.1 Q/ z4 h" W& U' W; c0 J
- */6 Z2 T+ j0 Y: g- O) _* s- M% {( t
% k/ j0 [6 b/ o8 [+ g( c. F- #include <linux/module.h>
+ x4 M% F6 U1 T. p - #include <linux/init.h>
- l+ z) E9 f& C9 e, |: z - #include <linux/errno.h>
: { c. h/ ~( H - #include <linux/types.h>0 W% C, d6 W* d1 K& L
- #include <linux/interrupt.h>
0 B/ l: X% v! F* { - #include <asm/io.h>+ d6 ~1 V( O6 M- j; W
- #include <linux/moduleparam.h>( E2 |4 Z$ w5 v
- #include <linux/sysctl.h>
8 B' W# G: t1 e& Z - #include <linux/mm.h>
0 t3 h4 ^4 K$ U; g" K5 a - #include <linux/dma-mapping.h>' X7 ^: d' Q& v Z L$ e
4 h5 ~; C* z- F% n- Q- #include <mach/memory.h>
9 S3 e; R1 a3 O) o/ R- K - #include <mach/hardware.h>4 e! N7 `2 w$ S; \( w' I
- #include <mach/irqs.h>
% @- ~9 o$ h3 j4 P* L4 K - #include <asm/hardware/edma.h>
3 ]9 V+ W( g6 M. ~) Y) i - 3 Y, g. _( s) i. u3 P1 |; e2 y
- #undef EDMA3_DEBUG# }! S6 j6 k# ~ }9 f2 i) w4 P
- /*#define EDMA3_DEBUG*/
2 h5 m/ c( i# k - 6 p8 b4 p% }; H* {9 w' a1 \) X
- #ifdef EDMA3_DEBUG: T/ A2 E* C4 [7 x, W. W! g# C
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" n5 M4 n/ T9 k/ Q) u
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" h( F! [ J) o: r
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
% ?6 d7 q1 ~# b- T+ L - #else- i1 P) n6 e5 p
- #define DMA_PRINTK( x... )
$ R: b( d4 q6 \3 v$ t - #define DMA_FN_IN" y# c. N4 C: T3 y+ E
- #define DMA_FN_OUT
f! ]5 N, O6 Z( o$ m9 G" _ - #endif6 n+ f& c5 U( `: Z) b6 Z/ R3 e4 T
- ( D# _6 o$ p* z1 h! R' f
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! ^% a- K' Z Z, V1 B1 n
- #define STATIC_SHIFT 34 m, N! E8 A% H9 G/ O
- #define TCINTEN_SHIFT 20
# a* V: T; U, C - #define ITCINTEN_SHIFT 21! J3 X1 [$ B1 | o6 P6 `
- #define TCCHEN_SHIFT 22+ S8 @ Z. l- e1 F0 T p, W) b
- #define ITCCHEN_SHIFT 23. V- m3 e" W6 a9 [ i( k; `
- " A7 U4 w6 n- ^, \7 Q* M
- static volatile int irqraised1 = 0;7 C& _# w v# `3 ?/ ]( I
- static volatile int irqraised2 = 0;
8 V! D- Q. x* Q" d' k- ?( B" G - " m3 n# n" G9 i1 B
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- o+ I, T6 b7 J1 T9 G
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 O9 ^% D# S. Y2 D
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# K% x4 t* N: @9 X* g
/ J: ?: L4 C( e4 `- J: D- dma_addr_t dmaphyssrc1 = 0;7 l9 ?2 J& x# D8 d
- dma_addr_t dmaphyssrc2 = 0;- T9 ~8 V. ?9 h) H# o x( c
- dma_addr_t dmaphysdest1 = 0;5 l) C! L* }5 h( N
- dma_addr_t dmaphysdest2 = 0;' D) m$ |' H7 N' T) c& G9 ~5 J% z3 K
, t: E8 Q; E! n$ p7 t- char *dmabufsrc1 = NULL;; O5 R6 n" X7 g9 B# w( j
- char *dmabufsrc2 = NULL;* S4 H5 t' O9 n. g8 K
- char *dmabufdest1 = NULL;
* i9 R" F; r( G8 y+ J( E" M - char *dmabufdest2 = NULL;0 u2 [' k# _' _7 N* r
- . \( w, O9 o0 T2 ?7 v1 F
- static int acnt = 512;5 I+ M8 @% s' d
- static int bcnt = 8;9 x4 ~6 `+ m$ g, F
- static int ccnt = 8;
# w( _: O: E$ H) X - # C' r: Q8 d2 M1 f4 f+ h/ w& s! @& R
- module_param(acnt, int, S_IRUGO);
2 k" f* n! C2 x- Z' F0 C3 T - module_param(bcnt, int, S_IRUGO);- i3 H' ^% Y9 ?8 i
- module_param(ccnt, int, S_IRUGO);
复制代码 ) f, r5 Z7 B7 p% R# @9 u7 V
$ N6 ^: k, |& v6 K0 F' u
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 E3 P Q4 S9 j# x% |
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 [& }, ~, a, e, }
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 }/ Y) i1 A. x( N7 M
1 w( k7 A" w2 [6 l: E
; a" J p; [9 n/ h! d- G |
|