|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - o# {- \0 k, D
- [code]EDMA sample test application
( h: { z" C7 W7 D5 ~3 X1 A' T - /*, J4 q9 S2 ~; ]+ w
- * edma_test.c9 e T: V( V. g9 [6 }' z" A
- *
; u+ |1 h2 P) v" r& S! A# ? - * brief EDMA3 Test Application7 @: H7 b% M1 J( X
- *# {: u: ?! V# D) S
- * This file contains EDMA3 Test code.7 G; w/ r8 g5 `, A1 T# u
- *
8 t4 U0 k+ i5 N i - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE9 {8 [3 M6 t: k3 ]
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT Z1 S( K' V+ ~. `3 P/ v
- * TO CHANGE.
1 v* l. M0 t8 f* j! P - *: i' \& [8 Q3 C0 D% d
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; R* M, b3 `! v2 U
- *: {# O/ G5 K( M" s+ Y
- * This program is free software; you can redistribute it and/or
* r% k$ r' S4 O - * modify it under the terms of the GNU General Public License as' U8 k1 l: f8 C [' f5 Y; E
- * published by the Free Software Foundation version 2.
. [0 C# f6 Y0 W% W - *! U# ^" j0 R# [& D$ d+ |
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 [- J. h* M" V |7 _; m, c4 m - * kind, whether express or implied; without even the implied warranty
, I7 i8 X! U+ f4 j% M4 f5 K - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 M7 k; b+ d2 J \- h0 D
- * GNU General Public License for more details.. R: E. I+ I" T# X
- */
% w; N8 n. k) j/ h
3 n5 D, ]* l' F6 Z7 J- #include <linux/module.h>
% F v7 G! [* K, o$ ` - #include <linux/init.h>
& k* z, R1 z; Y5 t4 j - #include <linux/errno.h>" W' J! R Q: X
- #include <linux/types.h>4 o7 \* J9 W9 C6 u
- #include <linux/interrupt.h>
2 v9 W. }8 |- W5 u - #include <asm/io.h>
, }$ w- W0 `4 U) U5 |7 z - #include <linux/moduleparam.h>
" @( v: D# ~) Y. c, b4 H - #include <linux/sysctl.h>7 d$ s5 |% q5 b- o% `2 z3 b- S4 m8 E
- #include <linux/mm.h>; r( v2 t0 T3 y0 O) ~
- #include <linux/dma-mapping.h>
3 j: r/ o1 u! f; a+ s6 Q1 V8 t
. f0 \$ {) ~" n( w; I' t6 l- #include <mach/memory.h>
* Q4 ?) E) z6 ^- a - #include <mach/hardware.h>4 r% y7 z0 f. T) Y
- #include <mach/irqs.h>
+ s1 G- ~; n6 i - #include <asm/hardware/edma.h>6 }) W/ J8 }, M
' v" z) a0 d& [- #undef EDMA3_DEBUG5 ^2 {0 C- X. D4 |
- /*#define EDMA3_DEBUG*/
9 o& l w. e" E - $ e6 [6 v% u \7 V
- #ifdef EDMA3_DEBUG
8 m1 t$ T0 M; g2 X; Q4 o% Q9 n, T' `: \ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): a+ c, V! u+ K% l3 ^0 I9 k
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. Z, _9 `; s! w - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) l4 |0 v8 R/ `4 T3 {2 w1 w& z8 s2 U
- #else
- B! v2 B. K r1 [' m5 S - #define DMA_PRINTK( x... )% M1 N/ }8 p1 ~
- #define DMA_FN_IN+ x# l" \! m" R/ p' \% y
- #define DMA_FN_OUT4 s; M6 u, c: R: Y/ e$ P
- #endif- z! t, W f! R1 y+ K& L( h; S, k" ?7 \
- ; d" a& y+ J% n/ l C6 v, r
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" K* B7 t5 p, M j% |9 f" w; ^ - #define STATIC_SHIFT 3
1 w7 w* ~" [- A4 x* y2 X - #define TCINTEN_SHIFT 20
' h4 H, B3 W) i" {2 b8 X - #define ITCINTEN_SHIFT 21
1 d7 W3 [8 t, U' t - #define TCCHEN_SHIFT 22
7 d: C% Z* q1 w" X5 O - #define ITCCHEN_SHIFT 23
: e- s1 O) X$ \, x
6 c q; H+ J1 t0 B- static volatile int irqraised1 = 0;
. ~0 z9 w: O# }2 X# h) F - static volatile int irqraised2 = 0;, U4 Z, a/ f# J' E
( f, Q4 B1 Y8 C9 r, F7 @0 F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 V1 @) e" ~+ I- M9 w - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, F0 O. J% @4 v. V9 S
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 A; h% m4 L) W2 v. W( _9 E
6 p9 i M# X: n: r- c/ ?- dma_addr_t dmaphyssrc1 = 0; g3 V8 p* ?2 i
- dma_addr_t dmaphyssrc2 = 0;
9 T* D Y9 y3 t. B, { - dma_addr_t dmaphysdest1 = 0;
8 e, F, }( J T) J, o - dma_addr_t dmaphysdest2 = 0;
) V7 ~5 r0 G. t# M% _! e - : M4 J2 p \( Y2 W6 I
- char *dmabufsrc1 = NULL;- i) w5 \0 s0 s3 L! S; `0 r
- char *dmabufsrc2 = NULL;, ?. y: D* Z2 G, I: j7 z: J
- char *dmabufdest1 = NULL;9 z( f! N1 y; K2 ]3 r9 X' l; `
- char *dmabufdest2 = NULL;. W- M9 t3 Z9 f+ S* L2 r
- " m5 f, L) w# J9 r# [( ^' r0 @9 ]3 m
- static int acnt = 512;% f2 f: |+ `5 p6 m0 L4 @! N. i
- static int bcnt = 8;
9 _& y: e) m1 I) Y4 i) n! s$ h4 U - static int ccnt = 8;
3 O6 S: T! m' Y# U9 l4 c/ C - & F# |1 z4 `$ N3 V
- module_param(acnt, int, S_IRUGO);
% \1 x* w; ?0 v4 Y3 N! } - module_param(bcnt, int, S_IRUGO);3 h. z" P! y) J- m6 j$ R
- module_param(ccnt, int, S_IRUGO);
复制代码 4 ?- j+ p* W h" Y' q3 F
$ S! ?- q- V8 G
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 t6 k' G+ T5 g4 U6 \& q/ m) Oarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
5 }3 M! |. @4 r) b o 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 ^' e ^) d" s5 l: Q p2 @4 D
, i5 o1 n6 j( K0 q, b" j# J% [; f( g8 |, b; C8 q8 z
|
|