|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" }4 F- `6 C% }/ o% b* |- [code]EDMA sample test application
8 s$ I7 f& T/ Z/ j! y( p) v - /*
' S7 x3 O9 p3 s! h* T8 l - * edma_test.c
" r; P. H v6 m( \- ~2 P. D - *
& ]& e7 e" O$ q) t. n$ s - * brief EDMA3 Test Application, u7 o. X4 p0 i8 z" C& [( V
- * ~. N* C6 @. [4 h0 y6 C+ h6 e
- * This file contains EDMA3 Test code.
8 c7 z# o& H- @, h - *7 j& ~) O- d# @( I" N1 Y4 }
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 U. v' Z+ E' y5 Y m8 ?
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 y! q) Y, A; O) M8 o7 \* o
- * TO CHANGE.
0 }; j1 M) }8 A* Z3 ^* C1 [1 J5 G - *
% [# Y0 F+ |, F4 k7 @$ Y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ s0 h) c: G% j6 p2 |- b l - *
1 e; W i3 G: |0 Y - * This program is free software; you can redistribute it and/or! \4 j* Y: M, N& y ^; \5 A
- * modify it under the terms of the GNU General Public License as
* g" [, N+ ^& Z2 h$ ?5 _ - * published by the Free Software Foundation version 2.) l( q: h e+ M9 C8 A/ n
- *4 a3 P# e) c' k" Y1 B+ [
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
6 m% {9 ^$ Z; P1 n2 Y- l+ S - * kind, whether express or implied; without even the implied warranty
1 _9 V) P% q) u7 I) } - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ H- p; V2 x& d8 |" Z H - * GNU General Public License for more details.+ _/ B1 |( U" @5 n8 `
- */
' S% }8 q2 x' W' I0 X, k2 a" v$ U
) `9 Z6 s( C% R6 Y) w- #include <linux/module.h>
: c, B! g1 s8 ~5 A - #include <linux/init.h>, y' P" I" _# O* L& D0 E6 I% H A
- #include <linux/errno.h>
/ e; e7 Z' z$ P) `+ W - #include <linux/types.h>
4 {5 J7 ~6 ]. y+ y3 Q _# Y) {7 ` - #include <linux/interrupt.h>
+ K) F4 l B: Y4 j5 D - #include <asm/io.h>
- U. U0 @' @& y: ~& A j - #include <linux/moduleparam.h>6 Y$ o. d2 E6 h0 C6 V7 |% R
- #include <linux/sysctl.h>' F, J9 U, j$ Y" ]! o
- #include <linux/mm.h>* O; X# S& U7 e
- #include <linux/dma-mapping.h>
. R8 G3 f. u% ]. b f# z0 G
+ x' E8 t4 v1 F; e. X8 i- #include <mach/memory.h>1 c# k' R0 {: J/ r% T5 j
- #include <mach/hardware.h>
$ w* c9 h. s, I! v& b - #include <mach/irqs.h>
- P2 g/ k; R1 {" o - #include <asm/hardware/edma.h>
3 A1 ]8 t: h) u$ U) Y: H" V - 8 P7 d* {( W1 N H7 ~1 ?4 B; f
- #undef EDMA3_DEBUG
& `) |' B" m7 i& x. P - /*#define EDMA3_DEBUG*/
4 `4 j7 m3 s: @4 y7 D- W - - c, `+ K+ `/ q0 z5 ^2 K5 d
- #ifdef EDMA3_DEBUG
* t- i9 _! h( B0 {; ]5 D+ W4 Y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' }# p% V0 K5 @, }
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
s! j0 O Z5 q% C4 K - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) S& f- k5 p& y! C; G
- #else7 e' F% o$ J' j8 Z
- #define DMA_PRINTK( x... )2 U2 Q" ~+ g' _! g, C2 e
- #define DMA_FN_IN
2 v. ~( g; V5 ?& P* h - #define DMA_FN_OUT8 Y) l: ~! g, z( `5 i: k
- #endif
6 T: V# n! h7 E1 p* m: d9 L0 \ - 1 K ?( X9 d9 A) d- _3 `( q
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
% [" d: Z. `. J0 _+ Z2 v" S+ {8 Z* B - #define STATIC_SHIFT 37 c5 X+ b4 U Q5 R3 R" Y
- #define TCINTEN_SHIFT 20/ P4 E- ^+ J& g
- #define ITCINTEN_SHIFT 21' c9 V- n8 ^/ \0 {+ }, S7 b3 a! V
- #define TCCHEN_SHIFT 22
: [* z( a& j! l$ K3 l1 L8 f - #define ITCCHEN_SHIFT 238 W9 A$ x- T, e) @) c$ Y' Y
9 b/ T$ e9 k$ e( \- r8 v8 T; i+ \- static volatile int irqraised1 = 0;. g2 ]! y) x J$ E8 C2 ~9 O
- static volatile int irqraised2 = 0;. B q, X2 q6 V/ I0 i, B/ D
- / x% e1 B. `# {8 F" O1 t( I8 `
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, l" v" R! }8 r( r2 r, U
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: h- a" \6 d; `6 x5 | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ f6 T% s" d8 {7 g( `4 a! q+ C
- 7 H( i, K* ^# F8 U9 R: a; J( \& h* j
- dma_addr_t dmaphyssrc1 = 0;1 D3 }0 t4 G) f) G
- dma_addr_t dmaphyssrc2 = 0;
* _! V6 e. z" t5 b# {4 n- i' U5 h8 _ - dma_addr_t dmaphysdest1 = 0;7 d' n7 Z( _ p6 w% G
- dma_addr_t dmaphysdest2 = 0;
# P. r/ f; I& F8 r
l5 m2 i+ ^1 H0 } K/ K4 h- char *dmabufsrc1 = NULL;
0 d: {+ A8 o% w8 ~( o0 I# F - char *dmabufsrc2 = NULL;9 y4 t, u7 r' }1 [
- char *dmabufdest1 = NULL;
" I' l& g/ n- t# x' u - char *dmabufdest2 = NULL;
1 n0 w3 Z5 G# _4 o5 g0 ~# q0 Y( y
8 ~% j' E( L) N; ]* |! n- static int acnt = 512;- j8 g" G/ c/ Z
- static int bcnt = 8;
" q/ K4 h. i1 ~% j, t: s! M% { - static int ccnt = 8;
) r& [. ^/ c2 K# w- g& D1 v& y7 u - $ R/ h2 m) c1 |2 Q9 W% ]1 |
- module_param(acnt, int, S_IRUGO);
& n) A! L! N3 W; P# \- L5 w, M \ - module_param(bcnt, int, S_IRUGO);
: `6 \; o* j. a0 M3 D6 c" @5 ] - module_param(ccnt, int, S_IRUGO);
复制代码 - @+ J1 J* p V0 W
: ?7 `5 u! V# w
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 P! h- u( X* h8 v1 u6 Q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. i+ }0 y' D% b# j" l$ \4 e 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
, ^; h% I& p3 @3 u4 C' _
( P4 Y B# o- I; D8 I$ M: u% s! Z2 B
|
|