|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & ]2 e" y$ p7 E) ~
- [code]EDMA sample test application
b9 T4 {2 `7 ]; n. y - /*
` ?+ S) r: l6 ~, ]- ^ - * edma_test.c' ~" s1 ?) E' W3 U: \1 Z0 x
- *9 x& `9 P# r1 ^! o
- * brief EDMA3 Test Application
6 Q/ ?9 r9 r8 b. C* t8 k$ r - *
; H |# N" A& F: g2 l& Y j - * This file contains EDMA3 Test code.
$ @0 C# r8 @0 @1 ~ - *$ h5 o+ N" a+ g! B3 d
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 d9 @0 g7 `+ U( M - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. T, d& ?$ [; I$ x - * TO CHANGE.: b% d) E- r$ f2 l3 g
- *
/ r5 t7 L4 c; c. z; W, m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- c3 D. e! E: e" x; R% r - ** A* h; C0 ^0 l Z: n# V/ J
- * This program is free software; you can redistribute it and/or
* E6 W5 t- [7 p0 `& E - * modify it under the terms of the GNU General Public License as. d' S; h5 R) f* P: R9 g! C
- * published by the Free Software Foundation version 2.
% E+ b& I. V5 B, R - *
1 n2 _- J9 b" E, b- {" ^; O - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% a4 v2 m- E V. n. f. T - * kind, whether express or implied; without even the implied warranty
6 a7 O+ Q- Y2 a$ c, t6 n9 ] - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 G1 r8 J) ~, i- I+ L+ j
- * GNU General Public License for more details.( T. X( d; |: ]/ Y/ V8 B; {. `: g
- */0 I8 q: ]# c6 E9 O6 N( a5 P: g
- 4 F- j, D$ @9 Q8 j5 `
- #include <linux/module.h>
% C5 o0 H6 K9 Z; f5 |. ]) i - #include <linux/init.h>: C, W3 |4 y) E; j8 q8 C
- #include <linux/errno.h>
) M$ e" [+ f4 J - #include <linux/types.h> q! _8 c3 s9 U x
- #include <linux/interrupt.h>
: c) {3 v1 l' e4 A2 B" f% u - #include <asm/io.h>
8 D0 f- T, A% W- F, t+ O# y( T - #include <linux/moduleparam.h>2 P' h V% y; ^; }
- #include <linux/sysctl.h>
7 \- I4 @4 M5 }! i; v+ l% m - #include <linux/mm.h>+ y) I l( S2 H! e+ e8 B0 L; R8 a: ~
- #include <linux/dma-mapping.h>+ X0 u) N; q$ R; A$ P6 q
3 p" |; O9 t$ D0 Q0 [. P- #include <mach/memory.h>
/ g' X1 s$ D# p* m - #include <mach/hardware.h>6 o$ \ U( `/ A
- #include <mach/irqs.h>, p3 a; O: R$ P) t' K6 y
- #include <asm/hardware/edma.h>3 x: h* D/ O" y4 d5 ?, f
1 R" x- o* w( t1 R+ ]$ P4 y- #undef EDMA3_DEBUG/ V0 Q6 G. H7 i
- /*#define EDMA3_DEBUG*/
8 y# G4 I# A, G# h8 r, g# X0 a1 M - 1 Z# o; d; Y/ ^. O6 l
- #ifdef EDMA3_DEBUG
m2 i* c+ }% b1 \( c4 @ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: c- ~( f' N% {" q6 E2 v1 l5 i4 \7 Q - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
: U3 r% q! {, {% d; X- m - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 U) S5 d. `# ]9 N# w - #else
4 f$ x' V) [ @1 ~ - #define DMA_PRINTK( x... )
) G Y2 t: q- R) G4 x - #define DMA_FN_IN
9 \; u, ^( p( a2 v# n: n - #define DMA_FN_OUT
. z, {) X& T; G1 v# D1 j0 O - #endif
4 i, a1 ?8 A7 @( c& w/ K - ) ^6 a% @. T( T4 O2 H" q* i' p% M
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 A" Q- X5 _' _- W D - #define STATIC_SHIFT 3
# \5 u' [8 _$ o; o) z. } - #define TCINTEN_SHIFT 20" k4 x% W0 U. d+ r% ]
- #define ITCINTEN_SHIFT 21
: x% f5 Y0 F0 t" W0 X. U - #define TCCHEN_SHIFT 22
- e. k' W" v5 \ L' ? - #define ITCCHEN_SHIFT 23
8 W, `/ L, _; `7 ]- T3 n _ - $ [, k* Z& q0 q* I5 h: V2 L7 @. L9 d
- static volatile int irqraised1 = 0;
% L" N3 Y6 C. a4 k+ ?1 l - static volatile int irqraised2 = 0;
% m) L; e' \; ]
2 B* C3 X; ^4 A2 L* _3 E- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* Q }, _' h4 K - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( h! O. x1 O r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* F. y- P0 a; b# ^. t& m3 Y
9 K# B5 _# ^8 m1 S" D# c; w- dma_addr_t dmaphyssrc1 = 0;1 E5 ~# c) ~' E% \
- dma_addr_t dmaphyssrc2 = 0;' P t: G+ o. R! W0 j! v s( P, y, M
- dma_addr_t dmaphysdest1 = 0;
2 s! i% }8 W- a& R, _. l - dma_addr_t dmaphysdest2 = 0;6 \% c/ D7 O3 N7 J1 q
- ( O9 K6 l, j# i& j3 X
- char *dmabufsrc1 = NULL;
, w. F" G0 e4 ]0 S. h" q: ?$ S' l r - char *dmabufsrc2 = NULL;7 I- a* V$ P1 g! o) P% b2 Q5 z
- char *dmabufdest1 = NULL;4 s: F$ h1 n5 x5 T2 S
- char *dmabufdest2 = NULL;
! t+ z$ `5 S% r. G3 V/ j
% l3 d4 A# \& N3 [- static int acnt = 512;3 w+ S2 D: A9 G) s, {2 \3 {
- static int bcnt = 8;
& P6 L4 F0 V( Z3 J$ M4 o* I& [ - static int ccnt = 8;
\. {5 \7 Y+ ?2 |! [/ \
8 O" A2 m' `# r0 h6 A$ w* q- module_param(acnt, int, S_IRUGO);0 U: O& j! _. M
- module_param(bcnt, int, S_IRUGO);6 R( A! ~& a2 B5 U+ {( w3 T
- module_param(ccnt, int, S_IRUGO);
复制代码
3 h' `* a+ Y w1 T; |0 t
: Z" R/ v g1 H 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 s4 H! V' F: t) darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
+ o4 j. Z4 M8 Q5 n+ ?8 i! a. ] 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) I# @7 z8 t3 q0 G7 x. V/ V& @5 z0 ?: j" n3 c5 E9 l3 e( F1 m7 X
) ~+ H% J1 F( c; {1 { |
|