|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . {, H+ U' J& E) K F. u( G
- [code]EDMA sample test application
2 f1 x' H( b8 Q' k! S/ z - /*
* X& _# c& y% m; W - * edma_test.c
5 k* [- w+ N2 G- z - *1 a/ @7 [+ E0 d; k- T
- * brief EDMA3 Test Application
: A5 N. g" D8 l! z8 L9 ? - *
( a) v/ R' S- M! Q - * This file contains EDMA3 Test code.
% _4 h+ Q: i3 {! Q- y2 v- M% w - *7 L6 b+ E ?- \/ x
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 J0 @( R- |5 x; h/ X+ L! `( n5 A - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, E; f3 P$ W% I- ~
- * TO CHANGE.
% {5 d. i! H7 `' ~. D - *
7 E' g0 X$ {, m. ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) k* X# ?8 ~3 a" ]4 S6 c - *
, A$ G. I+ b+ b2 y# f. G% A - * This program is free software; you can redistribute it and/or
/ A* O3 T( W9 B' Y+ C# N% @' e - * modify it under the terms of the GNU General Public License as
5 U4 o" E" m0 a- {2 I; p* y - * published by the Free Software Foundation version 2.' `5 O+ K. W1 h8 ]1 z; T* J
- *
! |7 B4 R5 N/ C - * This program is distributed "as is" WITHOUT ANY WARRANTY of any! A- t$ z9 G. C* s6 [( N
- * kind, whether express or implied; without even the implied warranty
$ A8 u( S8 M6 e - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% o. I# v$ T; G( i
- * GNU General Public License for more details.& _5 v6 O2 s1 Y5 J& m3 T% }& g
- */& B0 N: e V: p: O. C9 L
- ) d7 ^ }% f9 o6 H+ I
- #include <linux/module.h>! O( S& x/ M; I, S) |% }( Y
- #include <linux/init.h>+ x3 s1 ?% ~. n E- Z" `
- #include <linux/errno.h># ~/ h: k" b2 ~; {
- #include <linux/types.h>2 _* u. q- ~3 y3 c4 G5 R9 l
- #include <linux/interrupt.h>
1 @4 v- G W9 y" y+ b: b - #include <asm/io.h>
9 }. t( @$ b2 @+ U3 i1 N* s! h - #include <linux/moduleparam.h>% F: V& u3 s d5 Q! k u
- #include <linux/sysctl.h>5 ~% E# c# Z0 ?1 Z! r1 D% v
- #include <linux/mm.h>. L* @0 k# U d' f: a; _) N8 D
- #include <linux/dma-mapping.h>. ~5 N" }. U# m; }5 w
- 9 O" d" W* e& e y
- #include <mach/memory.h>- Z7 d# {( c' U; N" u# i( J, n; c
- #include <mach/hardware.h>" Y( B0 E0 ^$ b# L- `
- #include <mach/irqs.h>, W% X7 x6 A$ v+ V& a
- #include <asm/hardware/edma.h>
% Y0 q7 c: r( @, |0 e1 b, B7 C
! k/ y5 l j$ X, c, W* Y- #undef EDMA3_DEBUG# [' ]. A' U8 Z+ t. |
- /*#define EDMA3_DEBUG*/
/ ?" w+ S# _% V9 g1 |
) r0 x# t+ x% p+ {+ f1 @/ p" b- #ifdef EDMA3_DEBUG& I8 b3 c) v9 y- k6 P; u* ~
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) m! E) o( f7 u8 ?1 r. D6 S - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 P! b& U9 [% K p+ d0 i; J5 ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) C! j7 K5 ^4 g% }1 v( p - #else, B, c) ?$ s- i
- #define DMA_PRINTK( x... )3 U3 j% _: H% s- I. Y3 ?2 b
- #define DMA_FN_IN
. p8 h( y1 N0 |5 g) H - #define DMA_FN_OUT
$ E- h& T1 V% Q - #endif( r- O7 z/ K$ T2 b6 m* s, ^8 s
- - g, N$ X, O7 }! b: V) t! ]+ h$ {
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)2 V8 ?: A5 v- e0 f, t/ Q, P
- #define STATIC_SHIFT 3
8 k9 I/ @' P- X6 R+ n - #define TCINTEN_SHIFT 20
7 Y% B5 _7 Y- J0 S- o8 S( A - #define ITCINTEN_SHIFT 21& G* k, Z8 |0 ^0 I* |( P; m9 C
- #define TCCHEN_SHIFT 22
" V) K- p( Q% V, c - #define ITCCHEN_SHIFT 23
- R% p* i5 Y3 a8 H; R+ J3 m/ H
3 m6 Z8 p1 m e- static volatile int irqraised1 = 0;
; S& w+ v6 D6 ]* f9 X0 x# J b6 V - static volatile int irqraised2 = 0;5 o- |' W+ V: ?) m/ w6 v
4 ~* O8 Y6 V- o/ z5 X- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" K. v% D/ `5 w - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 j% ^! i5 U5 n) w# T - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% R4 M7 a3 a7 B) L4 ^. S5 o
4 e- i/ B% O) q) _8 P- dma_addr_t dmaphyssrc1 = 0;
0 T" ]5 N" V0 g/ L - dma_addr_t dmaphyssrc2 = 0;
; E+ C# W& h" B - dma_addr_t dmaphysdest1 = 0;
; b" _0 @- q2 S& s* b* x - dma_addr_t dmaphysdest2 = 0;6 K! T' i# a) d% e4 G7 F; D# o
- I3 @! t. m t
- char *dmabufsrc1 = NULL;" @3 Y/ p0 L" O' @# r: H
- char *dmabufsrc2 = NULL;
; {, J; \: g/ E% d) s - char *dmabufdest1 = NULL;
0 N2 F& l% e/ O ^' b# J0 e - char *dmabufdest2 = NULL;
# |. b! p- q; r# Q7 q: W, S$ W - ' R1 Q7 {! l# \( J
- static int acnt = 512;
2 }1 ^* `, C8 _ i4 Y+ t; ^) o - static int bcnt = 8;% G/ T; @' \/ p' C! ?* Q& Q ]
- static int ccnt = 8;0 P$ g* p/ a- V4 M- B
- 8 t3 Q$ H6 L8 Z# Z" `# J
- module_param(acnt, int, S_IRUGO);) u3 C. b" t8 B5 z! v8 _; _
- module_param(bcnt, int, S_IRUGO);1 v ^$ e2 s( P# Y ~
- module_param(ccnt, int, S_IRUGO);
复制代码 & J; N U3 o9 s$ }+ t- L) y
! x6 ?2 ~5 I T% `9 b6 U/ {4 L1 @2 u
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 w/ J% g6 @5 I4 D( h* ?! X" u/ d7 F
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 O- g+ _5 K+ q/ \ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, L: V% u/ p% D/ r- v) t n
- |8 E. ~1 [/ `% t- @3 k! r$ I
% g) M5 g6 { q' k7 G+ K |
|