|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) Y0 l( h7 o9 o) }! B* T+ B
- [code]EDMA sample test application
8 r. a3 Q9 i' S; E$ w. |1 r' G* Q2 Y - /*& j) J: b" n3 Q, b5 o" w+ V
- * edma_test.c
( u) U$ ^4 }4 F( J - *
) E4 N8 o$ V7 m% P - * brief EDMA3 Test Application
# p2 m/ ]& L/ a) k3 E4 p% r4 b - *
+ P$ r ]( ?, ]& V - * This file contains EDMA3 Test code.
- K8 K r) q5 {4 h3 ~- }- g) l - *
/ T$ _8 M- i4 b9 N6 y% u - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 R7 l+ T' {& d- y8 q- u b - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 F( ~ F8 O3 w# _' z" K9 x - * TO CHANGE.
5 u- w" M& { i, Q - *, [, l/ ?- h- y) F+ R# e
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. R6 [2 v) _ H, B* ?1 m$ s - *
8 f* ~+ s1 }, j; Z" @# v i, u - * This program is free software; you can redistribute it and/or
/ X# K Z7 z/ i Z7 g0 `9 S4 p) R - * modify it under the terms of the GNU General Public License as
. `5 M0 F, k/ K - * published by the Free Software Foundation version 2.5 f4 [2 w+ D3 H6 _0 w0 q1 g2 l
- *
R0 r' \: r5 [ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ D$ q# V" Q% w" \/ t$ g
- * kind, whether express or implied; without even the implied warranty! I1 V& g3 n; n0 Z
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) u/ F1 Q' P ?! J3 O: O- C, w - * GNU General Public License for more details.) T/ R1 C) q F7 r6 H- T
- */* n$ H9 X: q6 }0 [+ x$ y% w" s
- 9 Z5 h( s/ m# c, r
- #include <linux/module.h>
d* z3 I/ f9 R4 A. P' N) }9 @ - #include <linux/init.h>; j7 U# S0 A; _, G+ C4 ?
- #include <linux/errno.h>+ H3 `8 x4 ]- \, x* ]' M* Q
- #include <linux/types.h>
% |. t' l( r( i& z+ g. O) h I" ? - #include <linux/interrupt.h>( F6 o3 b: X9 b: K- l! _
- #include <asm/io.h>
+ o+ t4 j; Z Q+ f: n! a' ~* K - #include <linux/moduleparam.h>
3 z( A8 z6 I2 V* A - #include <linux/sysctl.h>* M% y: r' ]: v1 u }3 ]% @/ f
- #include <linux/mm.h>5 D( {' K* v4 y. r1 b3 H4 A: s
- #include <linux/dma-mapping.h>
( ]4 |7 Q0 j; L
1 ?7 M$ z1 A2 |- T' `5 X- #include <mach/memory.h># V: z6 ~. t' G6 r# q: L
- #include <mach/hardware.h>
+ |- I4 ?$ j3 l% e/ |! {; U - #include <mach/irqs.h>
3 v, Z, x9 t( R/ D5 z; K0 T& { - #include <asm/hardware/edma.h>
; K' D3 B' D- X' |7 B. O" Y- I" ]
; l1 ~% L1 X2 P7 f- #undef EDMA3_DEBUG
2 N7 [: V! Q3 J% j+ S: P+ ? - /*#define EDMA3_DEBUG*/* p- T: q8 d/ z, m' b
. U+ t2 L" L- M1 s) e- ]9 G, K* W; P- #ifdef EDMA3_DEBUG
|' n+ j9 f8 t( F1 V - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( E4 |; z- D& i- o: } - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" Z k1 D5 o0 w$ n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, h! _$ _2 U' o" R* H' I - #else
l' @1 Y9 G( S6 }$ j6 _7 v2 { - #define DMA_PRINTK( x... )
( f: F3 |, ]9 K, ~& x6 L N% K - #define DMA_FN_IN
: I6 H% |% m9 G9 {- Y$ |: w; h1 g - #define DMA_FN_OUT7 Q6 p: X& T8 v; v$ J0 B; Z
- #endif
: d" e- w9 m* k m; B0 y
+ Z: ?1 D" q. |! k# }3 T- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! ?$ T1 ]) O8 H4 |
- #define STATIC_SHIFT 3- K7 D8 @, R, n& p4 T6 w
- #define TCINTEN_SHIFT 20, j5 y7 x" k: @+ Z) v" h
- #define ITCINTEN_SHIFT 21
& X/ j; @% M: }4 W p, k) F4 @ - #define TCCHEN_SHIFT 22
! V; x+ Q4 w, j - #define ITCCHEN_SHIFT 23& O: S4 X- M& N
- / s* k( d" u: i9 b9 u2 s
- static volatile int irqraised1 = 0;; |& _% Y$ X" ~: v1 w. {! {
- static volatile int irqraised2 = 0;
+ ~7 y* X! N7 Q0 n% ^" `7 f - $ w% d! h0 i" Y/ V. f
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* T( ^/ s$ J. b - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" W3 [$ E. ~1 n
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 {0 O/ E( R# L' [0 c
: V- ^+ v/ |" B- x- v/ i5 \- dma_addr_t dmaphyssrc1 = 0;
- K% e3 V' Y6 j8 b- _ - dma_addr_t dmaphyssrc2 = 0;, f& n9 P' K% z
- dma_addr_t dmaphysdest1 = 0;
% w. U/ I N2 z6 \ - dma_addr_t dmaphysdest2 = 0; O+ a) z; D! u" N; X4 `
6 g- ~$ D& Y4 r3 G4 m( C& K- char *dmabufsrc1 = NULL;& Z% v3 W0 @5 q2 `! d0 q& e7 C
- char *dmabufsrc2 = NULL;
) t8 ~( w( r- |# m, F - char *dmabufdest1 = NULL;
* I4 @( S- [: n2 d& F1 ?# y - char *dmabufdest2 = NULL;: g) x2 h, g/ c7 ^; O
" i8 N' ^7 ~( g+ ~- static int acnt = 512;) }2 Q: x- u- Q- f2 n# B9 H# O+ ?% ~
- static int bcnt = 8;
2 H, x O( l! S; L( C5 b3 x - static int ccnt = 8;' S/ _+ q3 V; y) v3 c" l
- 6 E; Z( j/ s3 o
- module_param(acnt, int, S_IRUGO);
* H v: R/ I8 U3 ? - module_param(bcnt, int, S_IRUGO);
. T2 |- h- w0 _# N6 d$ e2 y - module_param(ccnt, int, S_IRUGO);
复制代码 4 n1 |) Q" Z& t) c/ M! K! G8 E
& ^3 v7 \1 X& Q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 a1 J1 {4 Z6 H( d% O7 narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- N+ w2 M7 E* w 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 D# C2 m7 L$ {) {9 Y2 f! V8 m
" U' M& I. L; v( D: Y+ g' U. O* A& V" m2 y
|
|