|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, O- [) r- Q# b! k- ?$ L& K- [code]EDMA sample test application
) M$ b2 v3 ?+ } - /*
. V/ t5 q. f9 k* @! c - * edma_test.c+ [7 D. ?+ q2 P; w7 t' G: A
- *+ Z8 A6 P: R! R# G; f/ W# y
- * brief EDMA3 Test Application
; ]6 _, H. E" B4 Y5 O6 i* c - *
- I- \1 B! N. y0 k' _ - * This file contains EDMA3 Test code.& @7 x3 q% {" P0 i
- *
/ ]( U) _/ J% G6 C! U - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
/ G+ S# d) R! a/ U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) G9 E( q6 z" ~; R. c1 z
- * TO CHANGE.
; a& }& S0 H) {1 r - *4 Q& t# Q1 [2 ]' Y6 O4 K7 [
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. c. O2 Z. S, [! ? w
- */ F+ h( g( q' d+ ?5 S. ]
- * This program is free software; you can redistribute it and/or9 O% u( P2 \ I O
- * modify it under the terms of the GNU General Public License as1 F3 P; p: s1 f6 ?
- * published by the Free Software Foundation version 2.) h7 ?3 n4 Q! p* k
- *# I# @$ h, y' s9 z! q( U
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 D/ o' V- Y$ ^) V- d* p, a% E
- * kind, whether express or implied; without even the implied warranty) s$ D; r2 S1 v+ r
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" t4 N: t% c) j6 q, b. t# W - * GNU General Public License for more details.
5 t; K/ @9 e% Y2 P% Z+ D& F - */
; h$ P/ c+ N. o# ]0 n; D C* t - : A/ F9 b4 l; g3 v5 ?
- #include <linux/module.h>5 ~3 W0 N6 V7 i n$ k1 @+ A3 M+ l
- #include <linux/init.h>
- `/ Z+ ]9 Z$ t- c2 B - #include <linux/errno.h>1 c% Y0 F/ f: B" r: J7 g3 M
- #include <linux/types.h>
: Z! o5 k. |4 d3 s - #include <linux/interrupt.h>. E& G' P. o( G2 \: N$ W
- #include <asm/io.h>
6 n5 y3 G# q7 e: L. L4 [ - #include <linux/moduleparam.h>
% H0 n; r8 W" ~/ x8 ?+ x0 {2 y - #include <linux/sysctl.h>
6 l) R5 W" S. S* R! ~) t0 }' z - #include <linux/mm.h>0 k! k3 I$ m2 l3 C9 K5 n, y2 Y
- #include <linux/dma-mapping.h>
8 z, u- I6 Z8 F" m8 D
; k; H' b* `- k0 s" Q1 b2 X- #include <mach/memory.h>2 Z9 _, u/ O) h$ N
- #include <mach/hardware.h>0 U1 J2 ?. D8 R( H! ~7 ? F0 T
- #include <mach/irqs.h>; I7 L) K4 ]0 K. ?! p1 S) F# V
- #include <asm/hardware/edma.h>
; B; D+ y- V5 `# F( ^# m
6 q2 C1 g4 B8 q" |8 L2 {- #undef EDMA3_DEBUG
+ w [% u0 f6 J) V H - /*#define EDMA3_DEBUG*/
. I6 P9 K( P {6 g- l' L a - % j6 }9 l6 R6 c5 x7 K5 h
- #ifdef EDMA3_DEBUG
/ J4 y& H5 C" ^% F% ]& [5 c - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# O: j6 [! v m0 D& ~% B/ V# ] - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, E5 N$ f @; X* b9 {5 ^/ B( L - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
+ e# L# P$ m' i& Z/ h: j' Q - #else
/ G# l G+ L( m: o* b1 g: Q - #define DMA_PRINTK( x... )5 `/ j: E: |, E
- #define DMA_FN_IN6 n+ P3 O7 t$ u9 ]$ q6 ^2 ]# I3 w/ C
- #define DMA_FN_OUT. M1 ]! c6 K9 g" B
- #endif6 J, F: D j. r2 y6 X
% O; k: E, g2 P G2 m& w6 r- V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 F# E1 z c8 Z - #define STATIC_SHIFT 33 c" }- j$ q* Q D: T$ N( M' W. f6 ^; q
- #define TCINTEN_SHIFT 20
& N! }6 R& s9 C$ [4 F - #define ITCINTEN_SHIFT 21
6 ?0 r0 j& d6 [, e, N - #define TCCHEN_SHIFT 22
( G( w" [- ^3 q; [- a- f: G - #define ITCCHEN_SHIFT 23
5 t0 L+ O. p. a2 Z8 ? - 6 X* o( K" E$ k9 ]) p
- static volatile int irqraised1 = 0;
1 g6 |1 f$ U; _0 b - static volatile int irqraised2 = 0;
: Q) h$ C7 E0 M8 C# Z# I
" p& c+ n/ j$ B- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ H. R, v3 _. z$ _- Y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- d% \) e# F8 `4 c; A2 l - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 |5 I, i, B$ x& c# o
- - |, e/ j! E' y
- dma_addr_t dmaphyssrc1 = 0;
# x4 N, S- M% l: [7 L6 j$ o$ {/ l - dma_addr_t dmaphyssrc2 = 0;
& \/ `" I) r" z6 Q2 d/ ^! C' [9 J! | - dma_addr_t dmaphysdest1 = 0;
. \/ C" D" P' [ - dma_addr_t dmaphysdest2 = 0;
/ w, h9 m5 R% p - , S) l2 g$ L7 s3 _: ?% _
- char *dmabufsrc1 = NULL;* p' v- K' ^; h
- char *dmabufsrc2 = NULL;
8 n9 H# e) b' w: o% E& Z, @ - char *dmabufdest1 = NULL;
% X8 o, S8 Z% u - char *dmabufdest2 = NULL;
4 C. s6 k- Q& f: A# X9 f! V0 x - / \: x2 x1 \: W4 i3 l: C! R1 d
- static int acnt = 512;
" ?. ~: `. @% F' d; i' w6 K - static int bcnt = 8;+ g) u: B( p/ a* U/ ?$ R4 Z4 l
- static int ccnt = 8;
+ k+ U* T; `) F* T0 l - % u/ k: ?: Y! b
- module_param(acnt, int, S_IRUGO);
% M" Q$ r' i* V3 y! F+ n+ N6 v - module_param(bcnt, int, S_IRUGO);/ P) r4 I" p. d0 ~
- module_param(ccnt, int, S_IRUGO);
复制代码 ; L5 Y! a" a' K2 g; \
% l$ H9 z! `9 K% Q A
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 j- c9 a2 C5 }$ G n- D
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# Q. \. m7 j: ]. S4 Y$ k; o6 b 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; s& y& f0 c5 q& x3 H) b; E- J+ L! s6 b8 e( y
- B. r" U( V) j; P* D/ C$ F' I
|
|