|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: |7 @8 {8 q, l2 Z+ Y4 t- [code]EDMA sample test application
8 p3 ]" M/ m8 z3 Q8 B3 v6 b" L - /*+ U: s! U S0 p+ c4 l5 H3 H
- * edma_test.c/ Z- `2 Y" L: Y: j5 l% p% K) V6 Y$ {
- *
" j% H& m5 B; C5 W" { - * brief EDMA3 Test Application
* x0 N+ [1 M5 D2 ^0 ^ - *. ?2 J* M: `& A* O5 \ H
- * This file contains EDMA3 Test code.. s; q/ s) }/ V! B
- *
" Z8 ]( B9 q, g" X1 Y0 r - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* R* \0 Q# G1 ^. U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT& U$ Z, y- \. s' X9 q$ Z9 J6 G0 G
- * TO CHANGE.& m W, {0 W, E. P& R0 A( a: q: D, W
- *& s9 @8 Y, y" h: r; F6 I
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ E7 [- \+ X- ^6 D
- *' f7 t4 s) Y, n x; @% g7 Y' ^8 J
- * This program is free software; you can redistribute it and/or1 l+ }* T& J( e4 V/ U
- * modify it under the terms of the GNU General Public License as
7 ^. ]5 D/ M5 J0 l$ N - * published by the Free Software Foundation version 2.- L) h9 X. w/ M
- *+ A3 \* n) r3 y% i
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any) B& q- [7 d1 R5 ~
- * kind, whether express or implied; without even the implied warranty; w% x; G' }9 l2 A+ B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the6 `) s, Z) t! x0 a, P
- * GNU General Public License for more details.+ I( V( m1 S9 {( e, C& v
- */
- F8 D; C# `# E2 `% I - " z, `: O$ E( j ]) I
- #include <linux/module.h>5 j! t1 e& L* z( |
- #include <linux/init.h>
; o6 K: v' _7 E# e1 F1 J - #include <linux/errno.h>
+ p# Z* d9 |- M - #include <linux/types.h>
& z7 B# f3 r, a5 Y; V - #include <linux/interrupt.h>8 f2 X L& x& `8 N$ t
- #include <asm/io.h>5 e% c6 k* Z! |6 h, S
- #include <linux/moduleparam.h>
" F& I& W+ ~2 Q9 B. ? - #include <linux/sysctl.h>5 C [/ ?/ i8 t1 j U
- #include <linux/mm.h>
" L# \9 c$ t7 r/ `. s - #include <linux/dma-mapping.h>
) E) m& ?$ W5 M
! k `8 A( n/ d6 S+ g- #include <mach/memory.h>" K! o/ v/ ~7 {7 T! t" y0 p- U
- #include <mach/hardware.h>
: ]# R' b1 Y: R" b+ ?' F - #include <mach/irqs.h>
* q+ H, {' o2 x7 K! V* B, s! B" k5 M - #include <asm/hardware/edma.h>6 T" b! c/ a Z! |% a2 f
) h6 S' h8 m7 x- C- U- #undef EDMA3_DEBUG
! A' s% s r1 K1 D0 _ - /*#define EDMA3_DEBUG*/3 C. ]/ D! t# u& k8 p; n$ j
- 6 g; T# D- \9 w- w, }
- #ifdef EDMA3_DEBUG5 O1 L9 e) o9 X8 E c- C7 M8 O
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) D& O' M' W# ^, Z( _- x2 ]
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, v- p0 x7 ~/ E - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& c& t; [/ D& w+ m: P7 g! Q6 s
- #else* F) N1 E$ A, G, V
- #define DMA_PRINTK( x... )
6 r2 _& {2 g1 ^ D7 r0 _* f! C - #define DMA_FN_IN' `+ ~. `5 _2 `# n7 G$ g3 K! t8 d# N
- #define DMA_FN_OUT. F+ \. W* T, ?7 z
- #endif k* `/ M4 Q. s3 o7 t
2 Q5 X$ E7 [+ O7 }( u. U- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 ^% ^+ @1 g7 j N0 L - #define STATIC_SHIFT 3% D* b$ T; U/ ~
- #define TCINTEN_SHIFT 20) ?! W- q! Q& ^* I* ~/ t" X
- #define ITCINTEN_SHIFT 21/ Q5 ]2 _. L5 u7 Z& W4 {5 ]1 v
- #define TCCHEN_SHIFT 22
9 A, t# `# d0 n: g - #define ITCCHEN_SHIFT 23
, c: O8 w8 N8 D! s! r; S+ e. F - $ R6 r5 t4 ^) ?
- static volatile int irqraised1 = 0;
, g$ S- s% h z5 L8 [ - static volatile int irqraised2 = 0;; T8 i# |: f1 j3 {
- G) Z% \- y2 w- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ M5 g/ ~2 f/ `7 ~, w* s+ n# b9 J
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 T. `+ ^6 z+ x3 a. n$ B! l1 h! l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' B. R' G& T5 v& T9 R( `
- 9 A: D E4 w4 B: t
- dma_addr_t dmaphyssrc1 = 0;* g9 R7 c- ^2 \- S5 N4 L
- dma_addr_t dmaphyssrc2 = 0;
9 k! q8 d6 G$ l7 t# M - dma_addr_t dmaphysdest1 = 0;- a$ w, i9 A/ m5 v) `8 l
- dma_addr_t dmaphysdest2 = 0;! f L1 h" @. L5 H. C* j4 P
: V& d- H" C4 O. y! q$ N7 u- char *dmabufsrc1 = NULL;
' O) Y8 q6 q& H. {$ u - char *dmabufsrc2 = NULL;& X; e2 d/ c3 A8 w1 ]3 H
- char *dmabufdest1 = NULL;% L j i; n, _2 s* _+ ?6 T6 g
- char *dmabufdest2 = NULL;
. ? ?5 h* a9 o( r1 T0 G6 L& y2 y: { - : U. W; r$ H5 @9 ^' j
- static int acnt = 512;
, `$ d" D$ y9 v - static int bcnt = 8;+ i: F+ S9 H* t3 A. x+ {
- static int ccnt = 8;% K* ~1 B6 a" [
- ; I# {) D0 b9 D9 z) f/ N& h
- module_param(acnt, int, S_IRUGO);
- e" q R9 [# s1 S# `$ Z- |0 q - module_param(bcnt, int, S_IRUGO);
& z( G3 F1 r( Y# | - module_param(ccnt, int, S_IRUGO);
复制代码 - S2 D2 D* i' C! A
?8 t# X6 J& w3 g# r2 m5 z1 i
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用0 j4 N; d* O. v6 h
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ D' |% G1 Z% ?6 O* s& ~5 q! I 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) r! m2 r, J5 g* ?) G6 L E, Q" y, n& _" Z
* |+ j; j5 l7 b A( M$ @3 S; c! \5 y2 P) f
|
|