|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
t& C. n: p$ ^- m" B% [; N# L3 y- [code]EDMA sample test application
& m% \1 x( o! c% b$ Q' ? - /*
2 M: I X% N/ a1 W# o - * edma_test.c
1 i- C5 _" @( [) F1 E) i - *
' u0 b( J7 |; V - * brief EDMA3 Test Application
. W( h9 w& [" o& U6 l - *2 y9 d; J6 a7 k
- * This file contains EDMA3 Test code.) U7 @& ^6 t+ U6 c. F4 q( W% y# K
- *# \! t% [( d6 w7 A: b
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 c) e6 I9 z# U1 F - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ @+ a& x" c7 ^0 W
- * TO CHANGE.8 e8 c; @! P; G9 h1 F
- *0 E9 h5 o$ P- w3 A0 |! m
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' M7 ?/ R: @& ` k. b
- *+ x' O* R* P0 x' [0 F* d+ v
- * This program is free software; you can redistribute it and/or8 ~9 c7 K( U5 r, M
- * modify it under the terms of the GNU General Public License as. B4 D% p+ w5 q( D4 J
- * published by the Free Software Foundation version 2.
* _6 c4 {+ P# l( b; e" U - * V/ k8 O2 K6 Z& Q9 d" D6 H+ ~; x+ p# V
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 Z# Z% d9 R) c: F# l M6 N7 d( ^! ?) V
- * kind, whether express or implied; without even the implied warranty
+ g, i" O" n2 P0 w! ? - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the6 D7 H/ l3 d8 i* R% {, M. ]* |$ i- r
- * GNU General Public License for more details.
2 i0 S8 l! Q: [* b - */
3 q$ I5 v9 m6 A# |4 P - % j# d! O) a6 U N4 y& L
- #include <linux/module.h>, J$ q, T E' Y! u- b5 }
- #include <linux/init.h>* r1 S' y& ^/ ]& U7 K
- #include <linux/errno.h>. u. h# Z. d5 w, ~; C
- #include <linux/types.h>2 K4 S" ?# {5 v, A
- #include <linux/interrupt.h>7 A' R% M. { t U7 d) p* Q
- #include <asm/io.h>
8 V6 d. l' v: \7 E1 T# E - #include <linux/moduleparam.h>3 ?/ m* U6 S8 A7 r, A# U# E
- #include <linux/sysctl.h>
0 I3 B! }+ j* Z- f - #include <linux/mm.h>
- J. ^- O$ ^/ k. | - #include <linux/dma-mapping.h>6 F. h0 l% M5 d. @
8 k7 j# q1 y1 E. y1 D- #include <mach/memory.h>
4 V7 [) u/ A6 D- B - #include <mach/hardware.h># l. e# Q' h9 V! N4 j0 |
- #include <mach/irqs.h>( @8 l) C' O$ D
- #include <asm/hardware/edma.h>8 d; D) A, u+ T; }
+ ~' ^! [, q1 I7 K! u: j% i& p- #undef EDMA3_DEBUG* h( V: x. S7 T1 W ]& b9 O+ d6 u+ |
- /*#define EDMA3_DEBUG*/
5 [+ P* W4 } D4 k
$ x! F8 A, d0 _3 J$ F- #ifdef EDMA3_DEBUG
' _% b/ _4 z. m P! j U, O5 S - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# O2 ?1 x/ Y- [ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): u8 B) U) A( a- \7 r
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ c6 G% P6 G# h5 r( O* }7 V - #else5 i! i, E* f" Q0 I' w; H2 I9 @
- #define DMA_PRINTK( x... )0 v0 t# V% z" d$ S
- #define DMA_FN_IN
. I/ f+ Q8 @; Y$ ]9 V, m% s - #define DMA_FN_OUT; f$ i' d/ w4 e+ w$ j% v8 N9 j3 H2 }
- #endif
9 v8 [) w% a( z4 z. [2 j: A+ j
# y v' A4 s! }* s- #define MAX_DMA_TRANSFER_IN_BYTES (32768); u3 h% r' F; H' k
- #define STATIC_SHIFT 3
. M( Q' [; A/ Q' H - #define TCINTEN_SHIFT 20
0 Q6 e3 u' [4 f4 f1 p - #define ITCINTEN_SHIFT 21
+ G9 B% _% F1 s M1 x - #define TCCHEN_SHIFT 227 v% C# s- B" K6 H- K
- #define ITCCHEN_SHIFT 23
* Q' G: \- A- K+ q( [( D( R
! n) v" F3 A4 H. w D2 E- static volatile int irqraised1 = 0;
5 \8 S6 }" }, J* v$ z- Z1 | - static volatile int irqraised2 = 0;
$ H& \: X' \- v# W# A
% \9 f" a8 Q! J' B) V- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, h! j6 o3 n4 V! e+ N) t
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 k/ D# J' [% P$ r* F
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, U/ v9 j5 Q1 |$ d# L m
- # R+ o. \" q( Z' I
- dma_addr_t dmaphyssrc1 = 0;% O* R2 @" \( n, H# y& j; {) Y6 P
- dma_addr_t dmaphyssrc2 = 0;) C N! {; C7 n+ [6 P! }
- dma_addr_t dmaphysdest1 = 0;& m2 t6 b0 A) Z0 D& ^' K) w
- dma_addr_t dmaphysdest2 = 0;
( c" |2 Y1 { f: D - # C6 H3 ]( Y- L" |+ y! L. e! P
- char *dmabufsrc1 = NULL;: G- Y- J& \' r3 i2 t
- char *dmabufsrc2 = NULL;, ^6 t% N) q* ^( k1 B
- char *dmabufdest1 = NULL;: m w* h* }5 T
- char *dmabufdest2 = NULL;: ^) C$ m* i" a
- & [0 {- ^) h: g9 P! @
- static int acnt = 512;0 `9 b$ e/ h: _' ]. o
- static int bcnt = 8;3 H& a8 x; |% D f- M' v
- static int ccnt = 8;
; ^# Y* E! J7 R# S$ X9 x( Y; m - 2 P3 Z: [ \3 A+ |& C; ]# H4 E* S# @
- module_param(acnt, int, S_IRUGO);
`3 b3 ]8 K' a: t# `: O - module_param(bcnt, int, S_IRUGO);
2 w0 F% ~9 v& y' ~* o3 t - module_param(ccnt, int, S_IRUGO);
复制代码 2 }7 j* S7 b- p/ Z# D
& {) Z9 r, f' E- e* j* z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 M% Q4 n8 |$ v7 `+ P
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。' v0 \( t \9 |+ D; O, g* b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) L5 V5 ]6 d9 S" A4 a) M
2 ?) U6 m( d M/ Y' k
( o! _1 K7 m5 }9 }/ Z6 Z8 k; J: G |
|