|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) G) \7 ]5 d+ W- [code]EDMA sample test application
) O) s- _0 q8 [% \+ M, a! h - /*4 i* s7 M: V h o8 |3 A
- * edma_test.c
/ F" q5 T8 @1 G/ h+ o: @ - *1 K U% ]/ j; b1 X' h# t% c1 ]
- * brief EDMA3 Test Application& I' m1 p+ j" Y: w, t6 d
- *
* S* \. J1 f! T( a( _ - * This file contains EDMA3 Test code.
6 {7 g O- T% m* y1 ]) C - *. M) s* F6 {9 r; y4 m' y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 v' m& A5 N ~
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" g' B4 }! X9 u3 d" o - * TO CHANGE.3 s9 A* U& Y4 Q. Y- d
- *
9 [3 G* g. o0 O9 N) i( j: M - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 J7 G, W% o+ _9 h ?, G" r: ~
- *- c( z) d4 Q4 ?5 h: r
- * This program is free software; you can redistribute it and/or
3 s3 N4 i" X( A% I0 Q - * modify it under the terms of the GNU General Public License as% |* R" [5 g m, d2 w
- * published by the Free Software Foundation version 2.$ z6 A% b* x, W, F
- *: Z! e( W- N. _
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. X8 R+ L4 i5 O1 Q4 J0 l9 c5 j - * kind, whether express or implied; without even the implied warranty
% Q3 x9 c3 n! _) W6 H - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# v) x- M# _, s4 w4 u2 ^8 E- m6 Q
- * GNU General Public License for more details.
4 [+ C3 }8 h) ^ - *// H( d: z" F* }3 L: t
/ | i" n4 ^, n5 k- #include <linux/module.h>
% W5 r- X/ ^" x - #include <linux/init.h>
! J6 A& I: P0 |/ J3 v - #include <linux/errno.h>- e, u! ^; o1 O9 s- X% T, s
- #include <linux/types.h>6 A. q. [0 C, ?, m+ r
- #include <linux/interrupt.h>
' d6 a, T/ d; P( g, o! R - #include <asm/io.h>2 i; J: t8 J$ M) f& f
- #include <linux/moduleparam.h>
. S5 x J, y- e/ @& C - #include <linux/sysctl.h>
) y, y% F2 ^) Y7 A" U) B - #include <linux/mm.h>0 q5 S5 I/ `' ?1 V6 u# Y
- #include <linux/dma-mapping.h>2 ~# |$ Z+ F/ V! D6 y: K
- " h, }9 f6 m% I4 ]6 V0 Y& d* U
- #include <mach/memory.h>
9 ]- G0 W; G1 @/ Q0 m5 n - #include <mach/hardware.h>
) f$ p4 t0 w8 X* A- |& V - #include <mach/irqs.h>6 L9 x2 ^3 q2 ?* Y8 {! s
- #include <asm/hardware/edma.h>
- I: |* ?0 `9 f- v9 u
+ N2 v& C4 K& z' g8 r/ K2 ^& B- #undef EDMA3_DEBUG5 y E6 Z/ J! m. T- ^
- /*#define EDMA3_DEBUG*/" g( n7 X$ m/ V6 y L, |
) X! I# {' m1 q& Q. X+ Z7 y- #ifdef EDMA3_DEBUG: U' ~ S+ m- i |. ^- `
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). k8 D) [$ L& c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)$ p0 y; Z" O1 G) ^0 O$ v6 p
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& l$ @# R- U4 q& t* R1 x7 _8 i
- #else
- z f7 C1 _7 t6 G9 y - #define DMA_PRINTK( x... )
1 x3 k: N0 O1 v. u+ M% a( c/ J( Q - #define DMA_FN_IN* c0 D; j, _7 ~
- #define DMA_FN_OUT0 K0 |- u- F. a9 h
- #endif: O9 P' z, Q3 e1 U% ~( Z/ g7 K
- ! K# m% e. o" U+ H
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
4 e. C% w% q; p+ ]( j: @% F% u - #define STATIC_SHIFT 3
" N5 W! D+ r" x7 ]& @+ a$ z4 E - #define TCINTEN_SHIFT 20! Q) P. k6 V& ]7 h5 P
- #define ITCINTEN_SHIFT 21
' y+ t; K: M0 m4 @9 w3 ? - #define TCCHEN_SHIFT 22' r8 w1 A! ~# E/ M+ y
- #define ITCCHEN_SHIFT 23) w5 S) J! E# F' e( ]! |0 f7 n& c8 p
- : q& Z1 _% Z; W. t% M
- static volatile int irqraised1 = 0;
2 a/ P3 L( s, R9 a8 B% t! |, s" T - static volatile int irqraised2 = 0;
7 c3 M/ s8 f" T: C8 X4 Y- m - - g: ?1 @' i8 f7 B: _
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 r; e! ^; {* J! e. V) P) w4 e4 u
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 x/ \/ n$ r" _- Y) v3 P' E
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 Y" d2 W: A$ L/ F t. J6 n
* d% |7 T: Z2 L+ X Y- dma_addr_t dmaphyssrc1 = 0;7 n' |3 t5 s A c6 \
- dma_addr_t dmaphyssrc2 = 0;
" [+ w/ a/ @/ H8 ]9 r% l - dma_addr_t dmaphysdest1 = 0;
5 t* |0 e* B( V' h( l3 ` - dma_addr_t dmaphysdest2 = 0;
" s! v9 x) Z. s: {1 J4 i: K) Q - ; W: x1 D1 N. q' `" f1 f& ?- V
- char *dmabufsrc1 = NULL;( f3 `' \# R9 h4 t
- char *dmabufsrc2 = NULL;( z! U( x1 A4 l" ~ ?! _( w
- char *dmabufdest1 = NULL;- c- G& D+ o! X0 g6 L: x
- char *dmabufdest2 = NULL;
" W3 [8 a$ z" P - 8 S2 |$ z- r. X5 i
- static int acnt = 512;
3 O0 }, R/ y- \7 f& U - static int bcnt = 8;
) @" F# c! l- L- n, x% n% Z j - static int ccnt = 8;- D0 w4 u7 ~/ v
* ?! c8 X' P& e6 X- module_param(acnt, int, S_IRUGO);, ]+ j! A5 l; ]) S' H
- module_param(bcnt, int, S_IRUGO);5 s. l! J R% m8 d. i2 t8 m6 v
- module_param(ccnt, int, S_IRUGO);
复制代码 & a# l$ o7 @9 @/ x
& G( Q U% \9 c: b* f
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 W& k8 o3 D( E: V2 g3 ~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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- B; }* I, y1 a5 C7 O' n3 R! U 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' i( E D+ B9 Y7 {, }8 I9 |
. `. O# \( U( b4 s( f
4 u4 H+ `- |: ^5 [ |
|