|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* x y( C7 w. K6 B- [code]EDMA sample test application
( o- M0 @. o( J - /*
4 c- |; @5 m: V$ U1 v7 J; A - * edma_test.c
! k6 S( F- N+ U( D7 Z& P: ] - *
3 P% I3 S) y+ {- ^- i. g/ {+ |7 F - * brief EDMA3 Test Application# o5 h+ x# F; L* \( l, e
- *
4 }4 M/ G& v5 D, Z: \ - * This file contains EDMA3 Test code.
. N: g. F& R- r! F) T* ?4 n - *
5 J9 Q) A( b8 U. F/ s q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' x" ~+ {. e# Q, L# T5 x M
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
2 k( F. M8 P+ H$ e - * TO CHANGE.
/ ]% b2 Z6 c3 U& z7 B - *
. |' C- o; Q' M) U' t: I - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/1 `" Q* O6 Y: @# E. c1 L+ Z
- *2 o* n2 Z. ?6 ~
- * This program is free software; you can redistribute it and/or: S5 _+ c$ V, W( f/ i$ M
- * modify it under the terms of the GNU General Public License as- @( Q% B1 T* Q9 m" _( l( y7 d( m
- * published by the Free Software Foundation version 2.
9 p3 ?8 q. m: {) J3 s& f: {4 U- j - *
% [" S8 j! d5 R& z4 b$ s0 } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" {6 @0 `+ m6 u- m" @ - * kind, whether express or implied; without even the implied warranty) d- Q4 G: o$ g6 Q& k* Q4 K- X
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 W/ z& ]& z7 J+ c& Z' H" G
- * GNU General Public License for more details.& h+ _) Y; x4 ]. g, E. N
- */7 x; O2 K6 r; Y( \
- 0 \* H5 j Y- s6 E
- #include <linux/module.h>4 J" i. j& W( h) ?
- #include <linux/init.h>; t3 m; R) F/ N/ L$ q# j2 o
- #include <linux/errno.h>: C% P3 N2 E, W \8 x6 W
- #include <linux/types.h> M0 i- Y4 @6 y9 r# H/ w4 u8 D
- #include <linux/interrupt.h>
' P3 d9 W" P% @. G! \ - #include <asm/io.h>
' x a! p5 _, ] - #include <linux/moduleparam.h>
6 `6 k1 H w2 X) u8 ?9 v - #include <linux/sysctl.h>
& P2 ] P2 }% Y! d% D8 P' p/ s - #include <linux/mm.h>$ ^6 G* ]0 z. M- k* o, a8 N
- #include <linux/dma-mapping.h>" S. V( C: E7 y/ V" V
- " d; Q8 A0 ~7 r) o8 X# b5 P8 G
- #include <mach/memory.h>
& L5 _: {8 j/ X5 p - #include <mach/hardware.h>
8 Y U8 n5 t! ` - #include <mach/irqs.h>
1 p/ {9 V4 j0 Z$ B+ w - #include <asm/hardware/edma.h>
$ v. q9 a$ b R
% T) X: c( A. [' {" t- #undef EDMA3_DEBUG6 ?! C$ r+ r! U1 H0 B7 C
- /*#define EDMA3_DEBUG*/
9 S- r, b( x! E5 U( X3 i, G1 `
8 X7 I6 S2 w. ]! W, F3 R+ t" C; c- #ifdef EDMA3_DEBUG. b2 r0 M. s) W6 W2 U9 J! o
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); S& O9 c$ o9 V* F
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 q' e" {: a9 R% ^, P) ` - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
w) _0 G" D6 E$ b3 R - #else
/ ]: w) X! r, o/ {, H% ]0 F - #define DMA_PRINTK( x... )
2 ]; P+ x1 n4 f3 S. N4 ?6 \0 B - #define DMA_FN_IN, J. ^% g# C( n
- #define DMA_FN_OUT
4 L: M: `7 \0 O f$ w1 a - #endif
' M. J% f( k/ G. |% ~ - & v$ }3 v# I, b3 ^- |( C% _# X
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ ?# F" E6 r7 w H
- #define STATIC_SHIFT 3" v) m& m% w( l# a ^
- #define TCINTEN_SHIFT 20
; d; d+ P- S/ C3 n1 Q - #define ITCINTEN_SHIFT 21
2 C' `4 o: d0 H3 m7 M - #define TCCHEN_SHIFT 22
6 x, \6 @4 h4 o& i# [ - #define ITCCHEN_SHIFT 23
+ v8 M' o5 X7 h
/ E9 o2 F, w: U% N/ X* Q; a- static volatile int irqraised1 = 0;
/ i1 F* _$ V% y% r6 J* ` - static volatile int irqraised2 = 0;
) U, P# X) I G - . o# R/ ?: J1 G# K! p' y* v
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 \7 E3 w) P* U2 d* ~* M* K5 v7 @, T - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ a% {( Z8 v1 o) I - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 j! [3 y/ X8 h+ ^. t* G
! q$ x- }" q3 J* B2 \6 ~7 S% F# V% [- dma_addr_t dmaphyssrc1 = 0;- X1 G1 ~* a( b" c. N5 g t! Y
- dma_addr_t dmaphyssrc2 = 0;( s( d. s+ H/ v. d" V
- dma_addr_t dmaphysdest1 = 0;1 C( p% Q- t3 o" Z8 w
- dma_addr_t dmaphysdest2 = 0;
* [5 @" g+ k; U; P# E
( Y3 Z% F* ~! d/ O+ C2 G. ]- char *dmabufsrc1 = NULL;
& Z3 l2 [- [8 n - char *dmabufsrc2 = NULL;
' e0 N6 K) P" O - char *dmabufdest1 = NULL;/ N) P$ X1 v( W2 O
- char *dmabufdest2 = NULL;
, ^. q0 O5 v8 ?3 L" I9 m9 u! @
% j, A: a/ `9 o/ B6 J- static int acnt = 512;- R( A1 H' E+ Z2 u
- static int bcnt = 8;
) F2 e8 _1 }# O" L/ M3 v - static int ccnt = 8;! E; v1 @2 E' |+ ]- I- _
- 4 }6 d/ r. V e d# U& w2 _: [
- module_param(acnt, int, S_IRUGO);
5 J! w6 K' l1 R) c1 N# v4 C0 | - module_param(bcnt, int, S_IRUGO);
: K, @9 m$ M' \7 M0 R - module_param(ccnt, int, S_IRUGO);
复制代码
9 v' Y$ l* H- A* ]( l' u5 o
+ ?: {( q) l( h% V4 H 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 f9 _& e' x6 z) N
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
^) K7 x0 ^3 b$ l D 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
. `+ N3 R* r( t
" q- F8 D7 P( d; n6 K# W4 \! b) ]( K8 ^5 I
|
|