|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & m: V: s, Z. w+ r8 V
- [code]EDMA sample test application
: K$ [$ w) K, q# ?! `2 q# C3 _ - /*
x/ t5 d; j6 H$ S0 X - * edma_test.c) J" n2 A, u2 V
- *0 b: F. u+ i' N3 {, {
- * brief EDMA3 Test Application
2 w9 }6 @9 y' s- j - *
8 L3 L9 X: V3 k) ]( p2 z# Q - * This file contains EDMA3 Test code.
- e R" \9 Y' l3 b+ O - *4 e! J% z5 q% g1 p3 t$ `
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
]) u, {, H9 w- H - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( r+ j" T3 e1 A: E( o7 Q) I- }! ? - * TO CHANGE.2 h% f! M/ a; l) t% S7 R
- *9 E ~. R% a4 ]5 Z
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 j# f# g; |9 w+ u" r# Y( e - *
" w. f4 [! c* a - * This program is free software; you can redistribute it and/or: I2 k; f! T# J0 U; x. n6 e
- * modify it under the terms of the GNU General Public License as8 H6 X5 e6 A+ \, l% |
- * published by the Free Software Foundation version 2.
6 Y6 e7 n' M+ c1 a- W$ r' i - *
" Q' k8 f2 H7 c. } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any. N/ d% H0 Y4 R
- * kind, whether express or implied; without even the implied warranty
5 I- a5 z, g) i p3 @* o5 z - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ v& d L2 Z9 A9 @ - * GNU General Public License for more details., X- r4 @$ ^1 o m- g
- */
5 ^5 I. K u6 c2 b8 A - ; H, i+ h- m4 v R+ E8 h4 r
- #include <linux/module.h>
2 @* I! b) _& @: ? - #include <linux/init.h> ^# g$ k8 z3 W# }+ y; f
- #include <linux/errno.h>
3 O0 |! k3 F8 F* q; m+ @7 r1 e! s3 P - #include <linux/types.h>
' U+ V/ p# }+ M - #include <linux/interrupt.h>% x1 Q: G1 G/ D j: j
- #include <asm/io.h>
2 \5 ?& q# `! `1 s( `# n8 I. H - #include <linux/moduleparam.h>7 w/ [' s- h8 v) R
- #include <linux/sysctl.h>! G( ]1 `3 w! I5 v6 U
- #include <linux/mm.h>5 [: t' g# l" Z. H6 D$ l
- #include <linux/dma-mapping.h>
* j) ~& R: |' G/ ~ - 4 x) K. g2 v, S3 u$ g
- #include <mach/memory.h>
4 L" z% A' }1 A* i+ `# F - #include <mach/hardware.h>
& L- G, H: c D4 T - #include <mach/irqs.h>8 K M7 B& h4 y' U5 v1 a
- #include <asm/hardware/edma.h># V3 u4 c4 P2 ~3 t& H3 o
- ( X$ S: E! N1 q) a2 U
- #undef EDMA3_DEBUG4 M+ N$ _5 R! u& q9 O* P. t4 ^
- /*#define EDMA3_DEBUG*/% G9 h9 ^9 Y6 y
6 X$ y0 P: ? ~- #ifdef EDMA3_DEBUG& R# @& a/ K& E& G
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' }+ p. w8 R+ E2 p, r - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! {" h& X2 g8 H, d! t - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ @2 y4 T g" U# D; S4 x - #else
& w+ `0 X) Q/ z. e# W4 N1 x - #define DMA_PRINTK( x... )
% L( w. [7 m4 }9 g/ X# |& _8 l - #define DMA_FN_IN2 a9 c4 M. P5 T4 x
- #define DMA_FN_OUT
( P+ }& {2 e; ]" j - #endif
/ Q. q2 o. Y; q/ M# @4 ]
3 y( c! c. P' }/ }9 f- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) ~8 u5 R" K7 }" T - #define STATIC_SHIFT 3
% X$ L* t4 F9 _$ O - #define TCINTEN_SHIFT 20
" E9 M% j7 o3 q3 p s - #define ITCINTEN_SHIFT 21( w8 N W; ^/ G4 Y
- #define TCCHEN_SHIFT 22
! {/ W) n l6 K3 h. V7 ? - #define ITCCHEN_SHIFT 23
3 V8 Y& P4 _) `) V' ], R0 e' h1 b% [, Z
: P R5 U) S+ @0 p- z4 G9 ]- static volatile int irqraised1 = 0;# R1 {4 p1 t; m) P i
- static volatile int irqraised2 = 0;
" Q7 n( X K# @- V+ @ }: v( b - 3 e0 L$ _/ l- q3 k: E
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' V) e1 N7 Q( q4 ]! \5 Y - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* b: D T7 l% C7 s2 l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) P8 [5 Z y: i% d1 O* B& w% F - 6 ?$ o+ f% Y; j* e' { g
- dma_addr_t dmaphyssrc1 = 0;4 U" k8 M, Q$ j0 |3 r9 ]& z
- dma_addr_t dmaphyssrc2 = 0;' F; j: c. O2 y3 K9 V; K1 `
- dma_addr_t dmaphysdest1 = 0;
5 R% S: r; j0 {+ v: q4 W/ [1 ^ - dma_addr_t dmaphysdest2 = 0;
. u$ k# Y2 ^3 U4 K( [
5 u2 a8 w/ h% o( p' D* W. j- char *dmabufsrc1 = NULL;
& @; g0 }0 P2 K% J- n - char *dmabufsrc2 = NULL;
0 k# J/ C, e" P3 L) {0 F0 ^ - char *dmabufdest1 = NULL;
, m0 t- ]. ]/ R7 _0 l/ |+ d - char *dmabufdest2 = NULL;
" H5 a9 p6 O2 `/ P' r) ^2 T
: E3 N( _, |! A, d! f: W- static int acnt = 512;0 p- h3 r. N# [ R0 n. E, }9 R& m
- static int bcnt = 8;
1 l+ F( ^4 {6 Z# w p& K) X h! j - static int ccnt = 8;
7 o4 d8 H9 s0 g6 x2 }
+ P! O: ^+ j& I- module_param(acnt, int, S_IRUGO);7 K3 y7 K% z7 R+ j; h# c
- module_param(bcnt, int, S_IRUGO);
4 @# v1 b2 K' i- C9 L6 i - module_param(ccnt, int, S_IRUGO);
复制代码
1 ]) [( B6 U2 V2 G( M. K: R1 O: Q8 v! E$ W* k/ D
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- l1 E8 F: D1 [% Harm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 ~9 }% |+ D1 ^4 J. v9 b$ }
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 E8 s3 k; f1 t# q
4 q' W% ~, Z m) |* ]/ g ^) a
|
|