|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ L" c# Z2 t+ J- [code]EDMA sample test application
0 l5 M/ {+ u- d% Z* Z9 l) c - /*
- j. v3 }! r) e$ @3 s' u" w: h - * edma_test.c; X+ `# r, ]( A& b
- *8 m6 N4 ~& B x" n" Z. o5 Q
- * brief EDMA3 Test Application
; w* S; A2 G* E3 j2 H* g - *
8 O7 ^" R3 _! d8 \2 m - * This file contains EDMA3 Test code.
' V# s: T! ]+ e' H2 A7 [) i - *
, Q+ H3 L8 G F/ [/ U - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 o0 \" }- j* C3 }9 W - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 N" U- } R: ]! S: {3 p- p* k9 B( f - * TO CHANGE.; @+ b+ T* g2 C; z6 h! v5 Z
- *
* r* S: @" i, L - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 @5 E4 C9 C' d4 @
- *0 q8 Q' |6 Y* C1 X+ m
- * This program is free software; you can redistribute it and/or
( O; j( f7 ]8 `( h* j# C - * modify it under the terms of the GNU General Public License as3 h* q Z' s6 o
- * published by the Free Software Foundation version 2.
7 H; ]# A! Z0 P) X: b6 a6 ` - *
; U* M( t# s+ Y# W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 l0 i7 R8 X/ [( g j, j
- * kind, whether express or implied; without even the implied warranty
, X6 _! u# e I - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|" a! @* k0 X+ ^ f7 v - * GNU General Public License for more details.6 T' u% t7 L6 x4 r R0 C
- */7 l o8 }8 f4 X+ S$ c
- 0 Q3 w' ?& v% ]7 ^+ c( K
- #include <linux/module.h>7 |+ F0 S' S2 s5 s
- #include <linux/init.h>
1 f5 {* Z0 [3 X1 n - #include <linux/errno.h>
2 k+ k% }) k6 N9 s1 U - #include <linux/types.h>
" P( j) L3 o% S! P - #include <linux/interrupt.h>) z" t, j/ T' y. q1 p0 ^- C3 q
- #include <asm/io.h>
6 X$ P& l, I* O - #include <linux/moduleparam.h>7 e4 L5 T- c- U0 i
- #include <linux/sysctl.h>
" t) {1 z! ] E* o - #include <linux/mm.h>
# }% @5 P" `- ?4 s! H" F - #include <linux/dma-mapping.h>7 N2 _9 ~, k; s9 H
! {6 K, `+ m. U: B4 o) L2 u- #include <mach/memory.h>
4 ?! s- f4 R2 z+ ~, ~6 s( Z - #include <mach/hardware.h>/ _% J! I7 Y$ ?" w- i
- #include <mach/irqs.h>
) W) o/ n+ [+ O) n0 p - #include <asm/hardware/edma.h>2 I# P5 _% f" k9 a5 X
- ( V& C6 K; s: e9 n" P* y
- #undef EDMA3_DEBUG, z) M `! m; g" D
- /*#define EDMA3_DEBUG*/) W+ h. \# m3 f
- 7 O) u" p. S$ J4 Z ~# {) g
- #ifdef EDMA3_DEBUG% g1 N; i, `( ?$ J& p; c+ k
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ E$ \9 Q# e1 w& u
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) @* o g4 U! |% [
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( w" R0 C! Q% |# g( g5 x
- #else
4 l# j2 W+ f8 B3 d - #define DMA_PRINTK( x... )
$ ~, p! F* A7 C$ F$ a7 p3 l - #define DMA_FN_IN% n0 V3 r4 a. n8 u. L& y: ^# Q
- #define DMA_FN_OUT9 f8 A5 J% }( k2 y
- #endif
6 `$ g4 P3 k. O9 ~1 h
7 W9 k: a+ l+ V1 m! e5 h- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 i& P% M4 d9 f- @* P5 K
- #define STATIC_SHIFT 3
2 X7 R7 C+ k3 |" w6 |3 m9 G K4 m - #define TCINTEN_SHIFT 20% p- ~: F' ?7 R7 H' r9 Q1 W
- #define ITCINTEN_SHIFT 21
; x: Y# Y9 V% i' l" d4 c j: {1 O6 W - #define TCCHEN_SHIFT 22
* h8 b/ F& Y4 } L# Y% a - #define ITCCHEN_SHIFT 23' Y2 d+ L% O" V
- # ~: [7 y- x6 B0 m8 V
- static volatile int irqraised1 = 0;
8 E# I' J0 r! V - static volatile int irqraised2 = 0;1 {. ~8 D6 b5 [5 u: m
; x/ X' D0 b% V% l- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 ]5 `3 } p* k) \" z; T/ d - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 J7 l- V+ B( V, v$ ]1 o4 F
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: M" X& k- Z, R - & n+ S5 D6 k5 x
- dma_addr_t dmaphyssrc1 = 0;. p4 v6 t) E, y m8 ?
- dma_addr_t dmaphyssrc2 = 0;! S5 F: f6 d. v2 O0 J
- dma_addr_t dmaphysdest1 = 0;6 Y& K+ O! I+ R9 L
- dma_addr_t dmaphysdest2 = 0;8 G5 v e7 _, z5 V! h [
% M5 T9 ~) I: m7 G% ?4 m2 ~4 e- char *dmabufsrc1 = NULL;$ f9 V3 L2 L; d/ s8 J: K
- char *dmabufsrc2 = NULL;
% S4 s, J8 b( i0 Z! E/ G - char *dmabufdest1 = NULL;- {1 ~5 G$ w: ^; j9 \( W3 d
- char *dmabufdest2 = NULL;, f3 @# g4 S) D9 p
( Y+ L* [4 H& H. E' K- static int acnt = 512;7 ^' `' u9 g( ^3 T6 A& a) [. x
- static int bcnt = 8;& M! \" p$ K! U6 R- S
- static int ccnt = 8;$ b- }( o x% ~( Y' ~1 d5 i( D
- 9 r' U9 G6 s6 h" [3 {1 O J
- module_param(acnt, int, S_IRUGO);
- R$ o" g" N, i0 }. ~' B: x - module_param(bcnt, int, S_IRUGO);8 g" M! \; I4 {2 Y6 x# B1 q* B8 _
- module_param(ccnt, int, S_IRUGO);
复制代码 , H B* C' ~! Y8 w8 W4 a/ d2 c$ h
/ L. `' Q$ [0 m6 |* R& b1 G6 z( W 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 I0 P6 ]* j3 Qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 o( R& V. q; W& w! e2 t( U) ] 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. Z2 ?! ?- v6 j* F
$ H- @, E8 t1 E( N; G) W
) F$ _8 Z' ~9 U( s% k |
|