|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 A/ G0 u* W+ n' R8 p
- [code]EDMA sample test application
8 J3 n, q% L3 ~5 J9 |" m g$ ? - /*+ O" B5 S$ ~: A
- * edma_test.c" O+ b' c8 T4 w* M) o7 r
- *
; Y: ]7 y2 Q7 I5 \" s2 r! i - * brief EDMA3 Test Application3 Y" W1 I2 @% @3 [: d
- *9 n" P8 e8 f' ?) N2 n' a X% {/ ^
- * This file contains EDMA3 Test code.
: @6 r, B( h9 H/ M7 d9 L - *
- e9 x4 f" C# I/ H" w1 J4 }5 | - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 k4 S3 r& e1 X* V4 ]
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; I" x1 d3 R, c0 @
- * TO CHANGE.
' J' R% V" H5 }4 W2 ^ - *1 C- l! c M. i' C1 V* k
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 V$ B y) S# |+ ^5 F5 y7 m
- *
& n, y Z! n% W( a4 i - * This program is free software; you can redistribute it and/or9 x% s" Z w1 p: e4 [5 a3 `( o
- * modify it under the terms of the GNU General Public License as
+ a2 w5 G" d- e* w& Y - * published by the Free Software Foundation version 2.
; y8 Y8 J& A+ q7 D - *! l* | E+ u+ W
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any# J# _2 h! j2 f' J4 S1 q/ R) z! h) i
- * kind, whether express or implied; without even the implied warranty: Y2 }6 _* o: Y. S
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ Z3 o/ O5 C- y+ |+ B - * GNU General Public License for more details.
: h1 g) h2 ]1 f1 c$ A- N7 u - */
$ K/ N( Y, j6 K' v
6 |% y5 }- S+ |4 y- #include <linux/module.h>1 z# [% ^( |. ]( J0 S7 ?7 z: v! ~
- #include <linux/init.h>2 A# h( {5 l }7 G& I+ m8 U
- #include <linux/errno.h>. z5 k! \8 |; P6 u0 T
- #include <linux/types.h>$ |0 ]$ X" }& ^ U# F# R
- #include <linux/interrupt.h>- l. M+ I8 o* {) l8 H
- #include <asm/io.h>9 b. e9 M5 r0 Q |
- #include <linux/moduleparam.h>$ ^1 \) C1 Q. O% t4 y% i {
- #include <linux/sysctl.h>1 C. N5 h, ? e1 @, v
- #include <linux/mm.h>
; a# y0 N% D o' f+ Y# V4 ] - #include <linux/dma-mapping.h>
: i" q3 d, N6 _+ V3 J3 |7 H
0 G( I( N0 _9 B( E- #include <mach/memory.h>; A4 A9 ~# S$ b/ r. f- e: e
- #include <mach/hardware.h>
4 ^9 S+ y# P# R G/ _8 B. ^/ x - #include <mach/irqs.h>+ Q# h8 r5 r0 R I- j
- #include <asm/hardware/edma.h>
x- |" r! v- ]6 E6 X6 j3 M/ F
/ F/ x8 M( k4 L/ X/ w& E- #undef EDMA3_DEBUG
. |+ h* P! ^% m3 @5 B4 H - /*#define EDMA3_DEBUG*/* S o2 }- _( \5 w7 c
i4 \5 c, o( D! A- #ifdef EDMA3_DEBUG; Y& K& c' p+ ?0 G5 \9 U- E* u
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 T) L" c. R k* d; n `) N# ^ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)5 d' }% f( M. s# o/ v
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* e$ v# l" U% D7 R! B
- #else, y: Q0 f' w- d& J4 l6 ` Q6 D& h
- #define DMA_PRINTK( x... )
- a( r: f+ c8 c- A& b) d - #define DMA_FN_IN
4 V! @% ?# j" s* I1 s8 h2 }$ T9 a. ?5 r - #define DMA_FN_OUT& s! S' }! B9 ^0 g# f4 i$ k
- #endif- t- y7 U* S: a: w
& s1 t5 Q5 m# ^' u$ T: s4 a l- #define MAX_DMA_TRANSFER_IN_BYTES (32768)+ @0 g* T2 m+ C3 m9 X% Z& C3 |
- #define STATIC_SHIFT 3! T. A& I! E7 u2 S6 m" K1 _/ Q
- #define TCINTEN_SHIFT 20
* h' N! }- Z. V1 B - #define ITCINTEN_SHIFT 21
+ a* I( d$ h: g - #define TCCHEN_SHIFT 22! p/ O7 q0 v( @& K! y8 @
- #define ITCCHEN_SHIFT 23
n* A( Y% ~& l# P - ; k7 \+ v+ i5 A
- static volatile int irqraised1 = 0;
4 f$ N9 l! r5 U) W - static volatile int irqraised2 = 0;
1 [6 _% u1 N" L% Y* l' L* {, G7 b
/ s$ n7 ` s8 P1 P1 ?- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 j% [' W- _! M2 r
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, d/ w' q4 h9 O0 E
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: g r% a0 }. [4 I" o% ]
- $ ~/ |& i/ E) T: u1 {; y2 f
- dma_addr_t dmaphyssrc1 = 0;
6 `' q1 e. R6 X- f" Q - dma_addr_t dmaphyssrc2 = 0;
0 a& @5 t# K K v+ k' }$ b - dma_addr_t dmaphysdest1 = 0;0 V6 O { E9 j9 A. Q
- dma_addr_t dmaphysdest2 = 0;
: w5 c7 R$ M* G U
( S2 g8 o1 \, I1 {$ L4 W" k6 d- char *dmabufsrc1 = NULL;
8 j( ^' J* ?0 s4 F4 K - char *dmabufsrc2 = NULL;
) f9 p% y; W3 a - char *dmabufdest1 = NULL;
: ?3 S" t* _! o$ C - char *dmabufdest2 = NULL;0 X8 S7 O0 Q1 c/ {3 r" i/ X
- % I a3 E: `% ^* f* \( P
- static int acnt = 512;: g' g1 a0 {5 E/ m# X; }1 R- ?( A
- static int bcnt = 8;
; s; G, m. \* `0 v, V& c6 | - static int ccnt = 8;! V- ~+ f/ y% T4 c
- 6 I- b3 l' u$ B: p, k* e
- module_param(acnt, int, S_IRUGO);
" u4 Z2 p2 D- F2 m s - module_param(bcnt, int, S_IRUGO);& v) Q9 z+ x6 P* m: x7 u
- module_param(ccnt, int, S_IRUGO);
复制代码
3 j6 u* m& P m; G9 `1 W- y9 ]5 ~3 g/ r; z4 Z+ {9 F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# C p1 U0 @2 |3 }: C$ ]5 K& Zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. y+ ]) R' i. \; O2 I 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* T% i- `# p; v$ g# n& }, e0 O0 a8 l; _
. y7 Y3 x8 g- j/ _0 j3 s |
|