|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 P8 a: G9 _, f
- [code]EDMA sample test application
: d+ n2 W# C2 V - /*
1 ^& { L/ A5 y3 _5 R - * edma_test.c
. C8 J+ b% e( B4 C* u - *3 ]/ d6 i; y0 x* q4 d, \
- * brief EDMA3 Test Application
1 g9 t5 H, i3 p1 t& K+ m - *
8 G* U4 J) f7 \$ K - * This file contains EDMA3 Test code.
Q' O# R$ R1 P" f: m* R+ @9 z/ d - *
! N# Y- \' G4 i: t! Y/ @7 P - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; n6 N- H6 M3 V# H; @4 u
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT: v' p' q& h* f2 p
- * TO CHANGE.6 I- R b8 c/ g& B8 F( y
- *' ?# R# c" Y1 q9 {! } U
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ l( q; u0 H( U- d0 O! s
- *
0 o$ }4 @2 g0 a# R2 d3 H - * This program is free software; you can redistribute it and/or
) n- \# @1 C9 T. [+ F - * modify it under the terms of the GNU General Public License as
# f0 d* _. Y3 W3 i9 ~ - * published by the Free Software Foundation version 2.
: k3 Q" n/ c7 ?6 y+ q - *7 p* C( l3 l& T
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 f- H# t4 {! s, O+ ? - * kind, whether express or implied; without even the implied warranty, E7 W8 u- N2 p5 [
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the/ J- I- n# V6 t4 f8 x2 n
- * GNU General Public License for more details.% J% o7 I; n& [: a! c5 A! b
- */* R9 L A8 W2 ?* {% X' P
$ f( [: B- @$ R1 f: a4 Y- #include <linux/module.h>
$ d0 s3 t* b; |7 A - #include <linux/init.h>5 b2 |9 K4 ?/ b" A# y! X
- #include <linux/errno.h>8 {# k# Y) O1 Q2 \2 y: L& r4 c
- #include <linux/types.h>9 D; f; T+ [; _3 L, b e& Z
- #include <linux/interrupt.h>
5 _$ I4 B" D, B$ `9 `5 W- K - #include <asm/io.h>
! ]! G$ w% L4 Q* O* D0 x5 b( @ O - #include <linux/moduleparam.h>
1 O7 ` Z# {( X% `# ? - #include <linux/sysctl.h>6 ?" g+ U, V# c+ e8 m
- #include <linux/mm.h>
/ _3 K, N! h) p1 B9 e; h$ `# a# I% G- \ - #include <linux/dma-mapping.h>+ K6 G9 l; N# B! K; |
- " q& q- l# O, m, f
- #include <mach/memory.h>& F n1 `+ T" \. Z9 p( w. o$ l
- #include <mach/hardware.h>
[* c5 o$ m! v7 E& Y - #include <mach/irqs.h>
3 ^" `+ I: {/ `& w - #include <asm/hardware/edma.h>0 ~: a- ~, n' V+ k" f
, H; T0 v; Y8 u7 j2 Z6 ]- #undef EDMA3_DEBUG
1 X3 W7 L/ V; z - /*#define EDMA3_DEBUG*/
( v( t, u. M: I$ k - 4 L7 _' @% ]: r- A) j$ K
- #ifdef EDMA3_DEBUG
; f: x/ |/ w# i) N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 v: P5 I |, |- w1 q3 f
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ ^) t5 a$ b; Y: A. r+ O9 T2 I - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% O9 B7 m! m% f, N" e
- #else, v' o+ a% u8 y( y* Y0 B8 d. ]" B
- #define DMA_PRINTK( x... ), \# m( x+ p' b8 n
- #define DMA_FN_IN# a9 R& ?+ Y& C% x5 Q3 V8 }
- #define DMA_FN_OUT
) h5 @' j4 U4 k# M+ D - #endif
+ O- m' q5 A5 O) K" l5 O4 S" G
]1 c7 s" e: l) o# p9 j7 Y" X5 D3 h- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 T5 i& l- z* Y8 [ - #define STATIC_SHIFT 3
0 l4 ]4 M; H- f2 H. J! e - #define TCINTEN_SHIFT 20
# r; A& s) ^- n5 b( C8 w7 ^1 F9 S - #define ITCINTEN_SHIFT 21
6 w- `& Q8 x; S* S! a' [ - #define TCCHEN_SHIFT 22
% q2 i0 Q* S! {8 o* Y7 O: H - #define ITCCHEN_SHIFT 23
- z. c5 e( M% U7 w' ?
/ P* B3 g. y# f9 C- static volatile int irqraised1 = 0;
8 ~8 Y" o; N2 `0 e1 ~( V7 T - static volatile int irqraised2 = 0;! L- j V# K6 b
. Q# ?7 d2 r1 X" n4 N* M, T% q" ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ `. @* A, A8 l h& A4 g
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( ^% X2 i; J( M i# h; ] - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 T- |/ B; m( s0 {4 _. [) d
! g% u0 Q* C: R" |# ]0 G5 u' f- dma_addr_t dmaphyssrc1 = 0;) m+ ^* Y2 f# E' F' P2 c8 f& Z( G
- dma_addr_t dmaphyssrc2 = 0;
: l- t6 u$ J4 f - dma_addr_t dmaphysdest1 = 0;9 G3 U2 p- j3 T, e* H/ J; b
- dma_addr_t dmaphysdest2 = 0;& X; d+ e0 b# }+ j: o! l6 O
- / M h: U9 ?% s6 g
- char *dmabufsrc1 = NULL;
0 j0 Z+ f$ ?! X, ^ - char *dmabufsrc2 = NULL;
2 |- n0 [# Z) f% }. ?+ G8 V+ K! y - char *dmabufdest1 = NULL;
( Z/ N" b' X" {& c9 a$ U: V - char *dmabufdest2 = NULL;& Y9 O) ` g C- f" \' p8 ]
, Q& P$ ]5 w( U; Y( D& M- static int acnt = 512;
! V( C; f# n' Y- r! R9 |/ c - static int bcnt = 8;* s& @* x2 g+ r& f, r
- static int ccnt = 8;
0 Z! |% Y: q) F2 X. Q8 R; X - " \! r% F1 ? g4 t: @5 u0 ^
- module_param(acnt, int, S_IRUGO);
; |2 f4 @9 k7 L6 ?: D$ G - module_param(bcnt, int, S_IRUGO);( l8 m( C* [% Q0 t5 T0 B& n
- module_param(ccnt, int, S_IRUGO);
复制代码 ) s" W4 Z0 n( h X$ ?
. y: X( D O+ Y- t
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% n1 v- X( m7 Y7 L$ Z. X
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" `- ?8 P2 y8 h4 y" O# V 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。 U0 q6 V z+ a9 ~0 q, U _! |
' N5 B7 p5 S& V
. U* g% }4 g6 q6 U3 O3 R e |
|