|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* w5 P) y0 Y- L! a9 s, X4 z- [code]EDMA sample test application
3 W" N: q! ~) m - /*! B: F1 P6 ]* R0 m
- * edma_test.c1 k( }0 p4 h' T* N+ }1 S# r5 Q6 E
- *
- v7 m5 F4 X8 \+ ]% P( i8 R0 m3 e - * brief EDMA3 Test Application, C6 t q8 G* P6 }5 K& o+ K% X
- *8 S* Y1 K6 ^* {
- * This file contains EDMA3 Test code.8 g) G+ o3 z. K& K/ W& F. b
- *. Z" \. e; Z3 b& f$ c/ x
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ d- R1 G# U6 j3 A - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 } w) q4 H4 D( E3 n, T( ~ c
- * TO CHANGE.# _2 j6 b2 d5 |+ @1 ^
- *4 k1 z$ K; }9 F( _3 B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 f2 T; ~* R5 m/ p) M7 F
- */ _% n8 V5 D* E9 C# k$ S. K
- * This program is free software; you can redistribute it and/or2 o3 v& I. q5 p' C, z# N
- * modify it under the terms of the GNU General Public License as
/ ]! p8 R$ i0 m! o - * published by the Free Software Foundation version 2.% N, w! @! _% w+ P+ w" I
- *
# L3 V) {* Z& q/ _ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 z$ h( |- j1 ^+ K1 k9 ^1 @* y - * kind, whether express or implied; without even the implied warranty
5 v# Q8 \! o/ B6 ]9 s - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, k( L2 G2 x/ G7 o4 H; D
- * GNU General Public License for more details.
0 v1 M. m( @0 x' g4 d - */
. U0 u& u: x# W% S - ( i0 ` H. K. C3 q' Z# ]; I# u
- #include <linux/module.h>/ E8 X! O7 C% X: z, x
- #include <linux/init.h>" N8 n( b) o1 U B! ~0 }) N
- #include <linux/errno.h>9 m/ `9 M% k6 y; [
- #include <linux/types.h>3 {- D1 z0 S- {. q9 D6 _! @& k6 |
- #include <linux/interrupt.h>
0 k# ~! I2 O& ?, p - #include <asm/io.h>' e1 n' M- d: L9 r
- #include <linux/moduleparam.h>+ O) h J4 K; D6 x1 ?* B
- #include <linux/sysctl.h>
) o/ i" V4 u2 U6 a# I/ I - #include <linux/mm.h>+ [3 [. X& b* N2 O4 Z: z# } r; [
- #include <linux/dma-mapping.h>
; Z4 X% N: h+ e; A
& x3 C3 h( J0 f9 _& J5 Y( O- Q- #include <mach/memory.h>4 p3 p% ~( s' |/ k8 V0 x
- #include <mach/hardware.h>* C: Q. |4 ], P1 j4 N1 B( ?
- #include <mach/irqs.h>2 k) c0 R6 h, |7 ^2 B3 f3 W
- #include <asm/hardware/edma.h># \# H, U" @ h8 P7 v4 f0 _7 U3 f9 { j7 U
6 g u9 @9 f+ C, I# U+ U- #undef EDMA3_DEBUG
- O7 O8 d% H$ u5 L - /*#define EDMA3_DEBUG*/
9 w4 J3 u# C- y5 k% Q - ' u5 m" ^4 Z( |3 `* m/ g& I5 B6 \
- #ifdef EDMA3_DEBUG
& ?; F7 V: l A- \' L( p - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( Q2 U% T, p7 ^1 V) m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 [4 K7 l. x( _7 @2 l; f }' X
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# Q( O r. k! @
- #else
/ d( q$ G u1 S' B% W' u - #define DMA_PRINTK( x... )* [# |- a- f4 o3 U: Z, J, v; h( Q
- #define DMA_FN_IN
6 S- M2 A$ _+ P* I/ o - #define DMA_FN_OUT
N3 }/ P1 l0 @! z2 R" H; ]4 u - #endif
; B/ L; o; j* e4 j
$ [' F6 _# X3 i4 ~1 |6 ~; U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
% G3 {4 K9 A* z+ V7 V( l4 L7 A - #define STATIC_SHIFT 3
6 _$ a' |6 ]9 F( x - #define TCINTEN_SHIFT 20
: t7 E) k; X0 v P2 u- A1 }. X - #define ITCINTEN_SHIFT 210 }7 P/ o4 E( j' e
- #define TCCHEN_SHIFT 22- J( G6 ? Z2 H9 O& n2 J# \
- #define ITCCHEN_SHIFT 23
3 U! K5 ^1 p2 N; e2 l6 y5 h4 G - 6 w' o# A1 j! {2 T. R1 Y
- static volatile int irqraised1 = 0;
6 B0 F; M% D8 z; X( n - static volatile int irqraised2 = 0;
# S% y3 Z8 E4 h8 l - , y! G; W* K k8 P, n1 |* @2 J
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 p) L: B- O. M1 @+ i" @; m
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 U1 d' [$ u# p% [3 \1 i8 k# m - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 ~1 m6 o. j4 k: [& f) u: a' c6 f& ]
' G0 E: m$ h+ ]- dma_addr_t dmaphyssrc1 = 0;
6 ]- [) S. O# v6 {3 h5 n' r1 {* l# x - dma_addr_t dmaphyssrc2 = 0;- ]7 o8 K; K, ^; n
- dma_addr_t dmaphysdest1 = 0;
2 O! ]6 m) h x6 P+ c; f - dma_addr_t dmaphysdest2 = 0;9 i: \; t, j. h% a3 c' H0 n/ K
- ) S6 D% R( f! R( N4 o* A4 M5 [1 b
- char *dmabufsrc1 = NULL;( g8 j& Q" w7 e9 }' K
- char *dmabufsrc2 = NULL;4 ? o1 J9 l' M7 Y& F- D; T
- char *dmabufdest1 = NULL;; R* y. D5 C% T1 S$ J" ~
- char *dmabufdest2 = NULL;; F" L- f6 f! | M1 H
4 Z0 C" ~5 z$ ^; m W+ d5 ~) V3 S# V$ k- static int acnt = 512;1 P+ N/ x5 ?1 p; M
- static int bcnt = 8;
/ y) X3 R( g1 a - static int ccnt = 8;. ]; U- p7 e9 j. R0 l* i
( O) c1 l. p5 M% W8 B# W5 c8 P0 y ^) ~- module_param(acnt, int, S_IRUGO);8 {! \( @' V9 F
- module_param(bcnt, int, S_IRUGO);
2 y. L/ Q4 S7 Y* ? P6 N - module_param(ccnt, int, S_IRUGO);
复制代码
1 Z; Q0 f0 r- j, ?. E6 u
8 |! E$ T( N: a; _ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 V. c K: S* d, J! p8 U
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& @) \7 u4 W" Z) ], X: c V 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( u! b5 @0 T$ O. X: u1 z
5 R: s& C' i" I P, |4 ]+ }9 w; n5 [+ q
|
|