|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , V+ j& M/ \0 Y2 ^2 ^) n; s
- [code]EDMA sample test application
! E3 ?& M3 O! q - /*1 c1 p. d O- t
- * edma_test.c# d, q0 N! x+ D
- *0 V' Z( J$ S9 k' X
- * brief EDMA3 Test Application
2 d9 q" W; Q/ A* {2 r - *7 f# D9 W& w# e( |+ R2 `% s8 u" ]
- * This file contains EDMA3 Test code.
2 ?( I; M& z- E- W" V+ z, s: S, S - *; S O; V0 \1 w! B T/ U7 v
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) ]1 N: I& z+ H$ N
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* h9 d* e0 H! d, l5 p) [
- * TO CHANGE.2 `2 J- v) A- ^& x! ~& F) x
- *
1 R8 w* H- c) V% _ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/9 T+ k3 |5 Q Q
- *
, F$ |0 Z. i O, y+ ~ - * This program is free software; you can redistribute it and/or ~% S7 f8 j' V8 J: F1 e
- * modify it under the terms of the GNU General Public License as
' [% ?( d0 o: U% J+ W5 i# r - * published by the Free Software Foundation version 2.
8 J. ]3 w* I4 c/ O - *
; {6 E" F( P8 `; D8 F' [( `0 Q* P - * This program is distributed "as is" WITHOUT ANY WARRANTY of any. D8 [6 I: y; e# s
- * kind, whether express or implied; without even the implied warranty
+ h- T; F s8 C. i7 p2 G1 b4 i) _ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! i4 }! Q4 H& K1 c5 z# J - * GNU General Public License for more details.2 x# J! ], I. e+ c+ e2 |
- */! B6 E$ f. \8 X G' [: n( z
- 6 o7 L6 f. \- p4 o q& }+ ~
- #include <linux/module.h>% K; P1 n# o* m
- #include <linux/init.h>0 q; l1 u- M1 V. C
- #include <linux/errno.h>
3 V- Y5 W9 I7 Y4 Q0 {* f - #include <linux/types.h>4 A. }2 U) h" S( w
- #include <linux/interrupt.h>
8 z. T4 o! l1 v/ V9 P% s d - #include <asm/io.h>
, p0 o9 l" W! L9 X2 k2 X* `+ k - #include <linux/moduleparam.h>
( L6 Q: N1 F2 l" w - #include <linux/sysctl.h>
" c- j6 G0 g$ v$ n, E; W1 W8 \' p; d* a - #include <linux/mm.h>8 a3 T }* M$ k2 c4 o
- #include <linux/dma-mapping.h>- \/ g8 ~# l; U! [! n
- . j8 _2 [/ } V8 i+ ?9 y: [
- #include <mach/memory.h>* U, o6 V4 ?8 p6 z/ b
- #include <mach/hardware.h>- K: v# p5 L1 Y: V" C0 S/ e: C8 r
- #include <mach/irqs.h>
! x1 O @$ E( l/ s - #include <asm/hardware/edma.h>
( M* f( j n8 K( ]' |/ Z8 Z - 1 m. I- t6 v: f
- #undef EDMA3_DEBUG0 p) K; B1 [; A
- /*#define EDMA3_DEBUG*/) b) B# r/ _' l8 ~' A$ P
- " w& Z7 p7 s( C5 H% P
- #ifdef EDMA3_DEBUG, K; ^) |# `# w. X+ y o$ u
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
0 T3 ~$ v9 c/ J+ \! C, z, |/ C - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 L& A4 {, H3 H% r' r
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
) ^9 L6 D6 A/ z+ ?1 {8 T - #else
! K; g; R; }% a - #define DMA_PRINTK( x... )
. t& l/ j; L3 Z6 { - #define DMA_FN_IN
2 e7 e7 J% c! i - #define DMA_FN_OUT
! ~) s) l, K: H: _5 } - #endif
4 ~3 E% u2 H9 T: J
" M! ^* Z5 ?6 s# i) r$ I8 ?- }' v- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ g' l* q1 U% i. ?7 k - #define STATIC_SHIFT 3$ U- N2 q- A! @( }2 C; L
- #define TCINTEN_SHIFT 206 i% K/ `, ^0 R7 I; {: X- ]8 P- B
- #define ITCINTEN_SHIFT 21) W1 F: v$ G* d; V& R, Z' S
- #define TCCHEN_SHIFT 22
. I1 s F3 q; |. a7 V - #define ITCCHEN_SHIFT 23
! s/ ~0 S7 o: v& S* V9 t2 p8 E6 t0 D7 ?
/ q6 M( y2 \0 |/ [% y- static volatile int irqraised1 = 0;
. }' Y6 ]# |, i) z8 m& ^: j2 h - static volatile int irqraised2 = 0;' C4 {, X$ k5 s+ \
1 y* C, x& P4 O% V V- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: H9 d; u+ n8 L! D% [/ A& E* {4 U3 c - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 N' ^+ o7 Q3 s- n% d" m8 z
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ [# q5 n: H+ R U/ }8 ^* `
3 ]# L" Y9 f; P( v$ g* F& W- dma_addr_t dmaphyssrc1 = 0;
' T- `; @, L5 l, V8 u1 K - dma_addr_t dmaphyssrc2 = 0;
8 u- Q5 a/ e. q6 \1 i8 ] - dma_addr_t dmaphysdest1 = 0;
. J4 B& h) M$ Z( s - dma_addr_t dmaphysdest2 = 0;* S% T: y" _& x' O9 q- Y
- ) ~, Q+ t% T& T
- char *dmabufsrc1 = NULL;
" s: ` e! K( M - char *dmabufsrc2 = NULL;% r* v" C2 u1 N K( j" w, J
- char *dmabufdest1 = NULL;
5 n& x5 T j) m: ~6 n$ q6 g. n- | - char *dmabufdest2 = NULL; a1 C# m* o2 F! c) i, `6 A
0 f$ g0 q/ T* G3 f- static int acnt = 512;( |( o) g; c% z( f8 h
- static int bcnt = 8;
% x8 m4 m* `$ Y - static int ccnt = 8;7 x) x1 @- k) U- M
. ^. G0 b( Z& G+ t2 t- module_param(acnt, int, S_IRUGO);; `$ f/ P, l# |$ `
- module_param(bcnt, int, S_IRUGO); F0 P! S z* _& V
- module_param(ccnt, int, S_IRUGO);
复制代码
! V4 B4 S4 e. C+ w9 M1 `* n/ t6 U, S( d
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 Q# k! F' l1 w
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. ~ m. O9 C& @' `; p* A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; S5 K3 {0 |* D3 I/ q
$ n5 G; Y$ `6 a: i9 L( L1 S3 D3 \: k( L: G- m. a' i
|
|