|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , \3 w% k" }! Z" d- k1 Z7 x3 o
- [code]EDMA sample test application! Q6 c' h. g" y; G/ D
- /*8 ^: o) B# z4 E7 g
- * edma_test.c
1 `9 }2 t+ U' v, e8 s - *$ E% ]% M- N) Q- m6 Q4 G0 N; I9 t
- * brief EDMA3 Test Application
4 k0 h/ v$ `% \# B2 D. i - *
: i* v. o3 U$ y. K5 }/ @4 ? - * This file contains EDMA3 Test code.3 `3 P- v5 ^0 h0 V5 I( D6 C6 Q
- *+ ]6 w+ J) Z6 t, k& ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 ^+ j# q) {4 ^5 A" i - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% |2 x$ C2 q8 X
- * TO CHANGE.% t! p1 U4 I* ^6 y" Q9 ?
- *
1 k5 O9 P0 ^. L, X" P - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( h$ ^: H9 a* f
- *( C2 t( {4 u( Y
- * This program is free software; you can redistribute it and/or
. t1 m* D! e' t4 X: u$ ^4 ~0 H1 ^ - * modify it under the terms of the GNU General Public License as
; T: s H3 h# S" u - * published by the Free Software Foundation version 2.2 ]& z3 F: P% H2 @# W
- *+ }) @% _7 x1 U: ~
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any- v. X- k; K; u- l
- * kind, whether express or implied; without even the implied warranty' `( B$ [5 ?+ n' p( c
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 ^" c) P+ `4 ?8 O z$ p- N1 F - * GNU General Public License for more details.9 @+ L/ m( @' {/ }0 C$ G" D) D
- */
' g( v6 \# p" b) ] - 1 c P0 y; R) A [0 \2 \8 R
- #include <linux/module.h>$ B* B8 ~6 G9 v3 v
- #include <linux/init.h>
/ M' |0 m( I' f4 V Y - #include <linux/errno.h>
3 n8 P0 E8 x. ^/ D! s2 W* H - #include <linux/types.h>
& ?" Q; @8 ~- l4 U% F - #include <linux/interrupt.h>
" ]1 X7 N0 n' r6 x" j: g4 k6 E - #include <asm/io.h> C" c* q* B4 m1 v% O8 o
- #include <linux/moduleparam.h>: [" e4 M- D% J7 z& r
- #include <linux/sysctl.h>$ P* C$ d+ ^- Z0 Z& h- f
- #include <linux/mm.h>- B% E% S" t) Z8 |1 T+ ]
- #include <linux/dma-mapping.h>5 L( U7 Q3 i8 X
$ k) O6 @6 V9 a2 W. ]$ a0 H+ f- #include <mach/memory.h>5 {, |& B% [/ F0 A' }
- #include <mach/hardware.h>% d+ M7 S) D& O8 m
- #include <mach/irqs.h>- ?, }8 r; Z, l' U0 K& J
- #include <asm/hardware/edma.h>
2 C& d7 i' q, L4 g! i7 {2 N - ! u2 _& E8 ]% l% f
- #undef EDMA3_DEBUG
9 J1 d: s5 `( U1 E - /*#define EDMA3_DEBUG*/: o+ o+ S1 v$ V& {
- 6 ?3 W6 ?( i% B* Y& u5 O7 o
- #ifdef EDMA3_DEBUG
/ B( p+ v% t# R) Q0 C4 B3 v - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) N/ S: @9 U- K& ` m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% J" v+ _5 Q( x4 f y
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 y+ e7 M7 l% s$ F* m& k
- #else, e+ A% g0 S9 q, S
- #define DMA_PRINTK( x... )1 v9 R& y4 I ^+ D0 ?) w
- #define DMA_FN_IN
c; q4 R! l' M$ C9 |( g - #define DMA_FN_OUT
9 d" I0 l) t/ v8 I8 a - #endif
" m5 V7 e( ~1 n: W/ }
. Z* @3 V+ Q' M3 X+ ?# K+ z- #define MAX_DMA_TRANSFER_IN_BYTES (32768). v9 q+ V6 z* b7 @- S, I& s
- #define STATIC_SHIFT 38 k& E( }' [0 O( f3 [, ^* D
- #define TCINTEN_SHIFT 20
@2 H3 I3 I- c. v+ u; e - #define ITCINTEN_SHIFT 21
* H+ C2 R' A7 J5 O' V& p - #define TCCHEN_SHIFT 22
: V. R7 C1 s9 y! U8 G6 B) ? - #define ITCCHEN_SHIFT 23, x4 a: S$ c1 t) C1 t h; ~
- + j: g [- i9 h7 E4 J9 i
- static volatile int irqraised1 = 0;' a2 d! b* v- C3 m
- static volatile int irqraised2 = 0;4 `0 q1 F9 N% B E, ]- |4 Y
- ; T# O* D# ~( Z* `
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& f! |! d0 m# V" I% u
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& v' ?+ B& ^; ?" M$ u$ f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); x% r6 d/ w2 ?& c8 Z6 `. @
- : [1 I- ~ @6 }! E- N
- dma_addr_t dmaphyssrc1 = 0;
6 ?/ f9 o7 K' ^2 ]# W - dma_addr_t dmaphyssrc2 = 0;
" Y9 ?0 B0 f2 t6 d r$ J" `5 f* F0 c - dma_addr_t dmaphysdest1 = 0;
, k6 O0 S! ~% n/ e - dma_addr_t dmaphysdest2 = 0;
+ R' Q7 Z! l0 Q# ?" a. w8 I - + G8 P" W! Y2 s+ V; ]" p( c. w
- char *dmabufsrc1 = NULL;
+ y, F6 z$ k' C& p& P' U8 v# F" l - char *dmabufsrc2 = NULL;
* i1 U1 G, Q: H( J- ?! B; K - char *dmabufdest1 = NULL;1 c' i3 W) Y, R- j: `
- char *dmabufdest2 = NULL;: V {! o: i/ f: Q7 z
$ ?( j1 ~) E- v& ^ r- static int acnt = 512;
5 `5 [# q, `2 o% s5 L; e2 J: ~ - static int bcnt = 8;4 E# P9 B ?- ?! o; T' w
- static int ccnt = 8;% E) |1 s3 g; S& F8 B
: F3 p' ? {, y+ E9 F6 Q- w- module_param(acnt, int, S_IRUGO);
! t+ @+ Q; i+ M - module_param(bcnt, int, S_IRUGO);3 w* M9 R" N) N' o+ P3 p2 i/ F
- module_param(ccnt, int, S_IRUGO);
复制代码 9 W3 D p" G9 x6 d# q3 ]5 d
6 W1 d' E+ z C& t( r7 n2 V
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% M: ^" j9 N7 P6 Karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# c, {$ ]9 K5 ]: W% v9 M2 R 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, w8 X7 c+ H, s$ e& k( R% s* p+ v- d$ X w4 s4 A( I1 P# C
% J) r- P" N1 _ i" U! @1 {5 u Y |
|