|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* U! b" {& s5 |' C, U; X Y1 F- [code]EDMA sample test application; ?- j7 p( D9 G8 A. c
- /*
% `, w2 e) y' o9 M. F - * edma_test.c
- `" U7 K( z* T' a( l - * t* [+ r% k* e# u( x; p/ u+ d
- * brief EDMA3 Test Application1 z) e( V! x+ p. a* g- |
- *
" e/ s8 y+ o o - * This file contains EDMA3 Test code.6 T$ k2 `; e; `9 {% k* }
- *
: C2 B, [5 C7 l- d1 ?: G: v7 i2 S8 m - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 }0 i- g! \( y+ n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 A6 I- G1 D! q, A" I4 H; K I
- * TO CHANGE.9 [/ O! Y. J" ^7 l* B, |7 R
- *
- t+ B3 z; p1 E% C! m# `, a/ j& h - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ k3 a" @) w3 z: _+ J - *+ n/ C5 c% A: H9 j/ k2 Y9 L( i8 `0 q
- * This program is free software; you can redistribute it and/or
S) X7 o( \7 P1 D5 F/ L - * modify it under the terms of the GNU General Public License as
; r, ^% i6 G5 }, _- u$ A - * published by the Free Software Foundation version 2.3 g1 R7 b W5 G* @0 r; S
- *8 D+ Q' t5 t7 U, P+ `) Z
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 ?# m5 A$ N! G2 s' _
- * kind, whether express or implied; without even the implied warranty. S6 G: X8 `* m& a U
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the5 K# ? \; A7 h. C
- * GNU General Public License for more details.
1 J+ M) _! j" Q0 Z6 c - */% i) h5 w9 |6 g) M* V8 L
- 3 X/ k* ]* ~& W6 W- L3 y
- #include <linux/module.h>, U e; d. i. ^' m2 K/ T! \
- #include <linux/init.h>! e% ^, k7 w1 U3 I6 d
- #include <linux/errno.h>
7 ^ O' F5 x+ S4 u4 j y) E - #include <linux/types.h>* t. u/ _! s/ ?7 }; u5 F
- #include <linux/interrupt.h>
! c9 G/ ~- P ^' x) e, U; B - #include <asm/io.h> E" k J7 f9 C
- #include <linux/moduleparam.h>
Q3 Z& D7 A/ v - #include <linux/sysctl.h>
& |4 ?$ `" x+ J: }8 O - #include <linux/mm.h>
* {; k G: W/ ^6 ] - #include <linux/dma-mapping.h>
0 \: v) B" N% r- m2 T4 c j- R: | - 3 N1 c; m1 a$ ]& L* D4 w1 q
- #include <mach/memory.h>* E& A3 e1 C& y3 p# H; J; w
- #include <mach/hardware.h>* I" ]. m/ o7 Z. L
- #include <mach/irqs.h>
3 s9 S" V" I4 f' @+ i) N3 p9 L - #include <asm/hardware/edma.h>
; [/ o- P; z- K% {) a
/ \8 X5 P8 j$ G* a q4 \; i9 Y- #undef EDMA3_DEBUG1 E' M/ z$ s6 ~+ b% f
- /*#define EDMA3_DEBUG*/
, e0 a. \. W. j# S0 H - 7 s5 x) x3 q" I% P
- #ifdef EDMA3_DEBUG
: a# F V( m9 h1 X8 f - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& Z( E1 o: }$ a) I
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)) J3 i* r- G1 b3 R8 L/ Y& ?1 h
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! {2 c' N* j7 r6 [, s( M
- #else5 c& \. c9 C7 J, E
- #define DMA_PRINTK( x... )
9 Z& q2 C/ L5 } P( n& w6 t- |2 c - #define DMA_FN_IN
3 C1 N/ i% V% F: ?& X - #define DMA_FN_OUT
: P& @& p+ u5 c) X5 l) H$ J - #endif
. d3 v0 }: m% t - $ v. w' f/ } R+ X6 }8 w
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* N1 H" H# n0 { - #define STATIC_SHIFT 3# Q8 U3 l8 s- c3 ~$ W$ I; H( u
- #define TCINTEN_SHIFT 20
; k8 ]# y2 n* ^; j - #define ITCINTEN_SHIFT 21
. T- F7 U3 }3 j0 d7 R1 x9 y - #define TCCHEN_SHIFT 22
, |0 |2 T, t$ a - #define ITCCHEN_SHIFT 230 r+ h! w2 O# s( ?1 X, L# X! k
- / B$ Z( {0 U- T7 v2 T
- static volatile int irqraised1 = 0;) t0 \& Y2 `) i% [6 x
- static volatile int irqraised2 = 0;* v7 r g- D1 X) i/ P% M Z
- ( k* F! | R3 V( i
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# F7 U- r7 _2 s- w+ \5 t1 c - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' u/ j, F0 H2 I, [3 {
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 d1 i! n H" b0 l" Y
' n% L8 `$ i* \) Y, v: F9 a- dma_addr_t dmaphyssrc1 = 0;& O4 S6 L' t2 `$ a6 z
- dma_addr_t dmaphyssrc2 = 0;) F" U: ~' X/ O9 h. I
- dma_addr_t dmaphysdest1 = 0;
% y5 V) B2 H/ Y* c3 x) _0 i - dma_addr_t dmaphysdest2 = 0;9 Y# H- u4 x |( L( F' v
- ; R& U* \1 \/ a7 d2 a0 ]8 w
- char *dmabufsrc1 = NULL;
/ q- Z% s0 ^( v- y, i) p: p. { - char *dmabufsrc2 = NULL;9 Q9 y+ K# f& B5 P6 [# j3 a
- char *dmabufdest1 = NULL;
- B7 m0 M9 ]0 w8 v9 Y - char *dmabufdest2 = NULL;+ b8 M$ }1 ]. f5 v
9 q/ d+ C6 D8 U1 d- static int acnt = 512;
- @0 L2 i& p7 e. O7 o. I5 N - static int bcnt = 8;
/ r0 V+ v+ u* u8 ~3 j: b - static int ccnt = 8;
1 }7 V: r0 E3 I5 o - 2 \! Q! m; p( x6 s' {
- module_param(acnt, int, S_IRUGO);
5 h# K0 ?8 W3 W - module_param(bcnt, int, S_IRUGO);
& s3 o$ [0 t9 ?2 l - module_param(ccnt, int, S_IRUGO);
复制代码
N$ n" u Q* c9 ]2 V; i2 N
; U! Y @7 q4 K1 [ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
Q7 @0 }2 s7 ~$ iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* g: _* W) y0 V+ G2 z( a% r, f/ }
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- U3 \. O; @( y* d& Q( |7 ~6 C$ D' @, [1 Q/ x# U2 h
5 P: F" y) T. F- ] |
|