|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 q2 _" [3 [ N) x R) p/ G- [code]EDMA sample test application
/ u8 ~0 \ L: b* N, N - /*
/ R K8 U9 P& C - * edma_test.c
; t& D" E6 m- V1 m0 R - *
" r& U4 B" @, N: H+ n+ n - * brief EDMA3 Test Application
: n* {: |+ s, m3 s - *
2 ?1 E# q5 x/ d! h- }& J' n - * This file contains EDMA3 Test code.
. F* H1 v" v) L+ F - *) y b2 d8 E! l' s$ ]3 Q: |: {: h
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 W) Q. j! \8 r2 ?( |0 a' e
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* b. g( k; a4 A" v
- * TO CHANGE.
9 S! h& Y. ` m+ N; i; Y' E - *& D" A, {4 V! M
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& ^* u) I1 K |6 }- m
- *& A2 Y# \7 G/ ?: N
- * This program is free software; you can redistribute it and/or
# O8 j7 G; H# v3 X/ a2 J - * modify it under the terms of the GNU General Public License as
' Y! ]0 U" m# x: U7 I# C' @ - * published by the Free Software Foundation version 2., }* F" {- r; A* H8 T
- *; s. k" k- U1 V) f: o. D5 a
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any! ~. F0 j6 Y$ {, k; m8 u i
- * kind, whether express or implied; without even the implied warranty
; ]( r1 R. b2 ~( q0 r) o0 {% n9 g - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. X7 u& K( N" x4 @, Q/ j/ B - * GNU General Public License for more details.
" X! }! `. J1 }# H2 t" | - */
# _6 J L) f6 C - 2 V) F' ^; V. h" H0 C, l
- #include <linux/module.h>; d. j3 f! ^) m& C" d5 S
- #include <linux/init.h>( m; r# ^6 \5 f P1 N9 D1 Q" f
- #include <linux/errno.h>
1 H$ K7 S+ a [% E4 a - #include <linux/types.h>: y! j: b+ B8 @: x; Z
- #include <linux/interrupt.h>7 J- _" P8 H7 s: {
- #include <asm/io.h>/ W0 |1 e1 A& ]- ~
- #include <linux/moduleparam.h>- N b) P9 V5 r, i
- #include <linux/sysctl.h>) ~" f# W4 l5 Q5 |
- #include <linux/mm.h> a9 `4 c0 S& |" ^& O9 E
- #include <linux/dma-mapping.h>
$ S0 B4 a: j! U* ^6 V
) F* o% K% ^2 t0 q0 S- #include <mach/memory.h>3 B8 B8 R0 Q9 j4 J9 N7 X9 c
- #include <mach/hardware.h>
9 j3 w$ l5 y- ~! S8 S/ R - #include <mach/irqs.h>1 h4 V( ]# D4 n% b) S: t# v% ?
- #include <asm/hardware/edma.h>
3 b6 w. Y7 p0 ~! f) N' e
, \/ {' L" A. A: Y7 d* m) I- #undef EDMA3_DEBUG4 l. Y T; _. l
- /*#define EDMA3_DEBUG*/
, @% X/ E- }1 O' u& n( o9 s - ! j# `+ h- i$ o' A2 X9 Q* V
- #ifdef EDMA3_DEBUG
D6 P( I9 m& T: R- r1 c - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 B4 b: F9 ?3 d- C% m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)8 ?, S) |8 c( I- J& h* S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! ]4 I9 C3 ~2 Z0 y3 g/ m' w3 q
- #else2 i2 x& \9 X" O {
- #define DMA_PRINTK( x... )
8 X4 L6 k2 A% L- b5 |! I- W' q: _ - #define DMA_FN_IN
' R( e$ l' `. v1 n - #define DMA_FN_OUT
5 u& m1 l" U0 m - #endif
. _9 \7 j( |+ H _
: g4 k% F+ R3 p" K* k x- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: }2 P" g; R9 w% `5 m: P - #define STATIC_SHIFT 3/ o* n7 q) l, m& H; @
- #define TCINTEN_SHIFT 20
4 p4 d* e! `3 [6 L4 b6 k - #define ITCINTEN_SHIFT 21* i+ i' Z4 ?2 K4 k( b, u+ U [
- #define TCCHEN_SHIFT 229 S' j5 _2 s- C
- #define ITCCHEN_SHIFT 23
0 h0 K9 ]) F$ [8 ?
! G( T* f- w0 P. k6 z8 H; j! n- static volatile int irqraised1 = 0;
5 H$ e& _" i# w# X; g - static volatile int irqraised2 = 0;$ T5 H! {8 r0 S6 c( G
- % a6 x& T4 w t7 O' j
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- T/ W. V d) c* @9 X, o+ a
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. @- P$ l5 C8 F! F% ?2 m9 `* W7 H* S - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* X. l3 L5 n6 e( j; {( ]: A
$ V* |0 W) C$ n, r- dma_addr_t dmaphyssrc1 = 0;
0 D0 M+ B* i' G3 D+ _ - dma_addr_t dmaphyssrc2 = 0;* V: |& P- A8 T4 p. h9 W4 h; Z
- dma_addr_t dmaphysdest1 = 0;
1 E; L A9 z2 i - dma_addr_t dmaphysdest2 = 0;4 ~4 ^- [0 a( Y: Y
* g( Q" X$ E0 m! k- char *dmabufsrc1 = NULL;8 p2 r2 N& I4 h7 S( J3 V
- char *dmabufsrc2 = NULL;$ k, [6 u0 h+ U6 |; g
- char *dmabufdest1 = NULL;
+ C: D. H/ p3 {0 H5 d; Y - char *dmabufdest2 = NULL;
; N- O+ u" C2 G8 ]+ u& `
* H7 ]2 a" G1 Z/ p3 u, v. ]: Z0 {# ~- static int acnt = 512;0 ?6 x4 N4 @6 R/ I; [: N5 c/ q& r5 x
- static int bcnt = 8;' V: m- W, ~0 F: L: k& ?% V
- static int ccnt = 8;
- F$ k g: X$ l0 {! M) J - 5 l: [( e4 o0 \, H. D: f* H
- module_param(acnt, int, S_IRUGO);
' A. B, {4 C& k) r! r( J - module_param(bcnt, int, S_IRUGO);! \1 J$ |; n+ t" S
- module_param(ccnt, int, S_IRUGO);
复制代码
! G: Y5 Q4 I) }! F1 n+ V3 Y+ _8 C8 X4 F' }2 n7 [
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 }$ h9 z4 O( D9 @& c- e) V2 c8 O
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
8 B% X2 j: b# U9 Z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. ^* M3 T+ ~+ T' R* P* t
6 b9 L! d1 x# c, q
3 H( `. z3 v, W% F |
|