|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! {& c. M0 a! S, ]$ {5 w- f- [code]EDMA sample test application
1 [' E, J3 H1 \3 s - /*
* d7 \( \! T# U7 E - * edma_test.c
. @0 g0 r& i9 D- D - *0 s# f1 M+ O# z2 u4 n# v/ B
- * brief EDMA3 Test Application5 _3 A* ~# U- ^
- *
5 m$ l- l8 ` e5 V" C - * This file contains EDMA3 Test code.
# v% n( U5 G, z5 R( m# b6 b - *
4 t/ |' n9 R& m7 [# |" N - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% h8 x( h9 c3 x6 T; n1 @& l& G
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
1 e( Y) \ c$ d" A9 s - * TO CHANGE.$ f: C1 |* C: Q1 p) ?7 r l0 z% i
- *% {/ `& V% x9 F# L
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) b! J4 U6 S( K4 F, `6 J5 J
- *1 m# j* b6 [+ G. ]4 c6 X
- * This program is free software; you can redistribute it and/or
4 {% l5 G0 K, q$ l. Y - * modify it under the terms of the GNU General Public License as9 R: f9 e6 T- P5 M# y; x
- * published by the Free Software Foundation version 2.; R; @& _' v; M$ s! u g
- *
1 ]6 ~$ n" ?3 ]/ n# t; O: J - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; B* `( j, t' |( t/ B6 n - * kind, whether express or implied; without even the implied warranty
( ~$ |! f9 K9 q1 z% D' r/ ~) c - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! d- @( J! P# o
- * GNU General Public License for more details.' a) W8 t {8 f! w: e
- */! G5 m+ d& B2 ^/ {
- + L5 F8 U9 f, I6 h
- #include <linux/module.h>) X; ?" c" k8 ?0 Q
- #include <linux/init.h>
; L( ~8 m- X) }% g7 J" n - #include <linux/errno.h>
" n$ @6 d! s5 F1 a, o1 i - #include <linux/types.h>/ P+ \; U: @2 T* N8 [
- #include <linux/interrupt.h>
3 W6 \. V2 Q) j% k% O; H* t f- K$ D - #include <asm/io.h>
8 B' {) S0 S' i( S u5 r) { - #include <linux/moduleparam.h> ^6 C' M( y. V z2 N5 t7 e
- #include <linux/sysctl.h>
# z" I, s5 u T9 J# U! r |1 W9 f( ~* d - #include <linux/mm.h>
# y, N7 o) X' u( }1 L - #include <linux/dma-mapping.h>. f3 c( L5 ~9 S! A( `
- ! b w i9 ?' I5 ^ N7 s
- #include <mach/memory.h>6 w( v; [& k; j) R
- #include <mach/hardware.h>. n9 n5 w" P, K0 K) `
- #include <mach/irqs.h>! p7 S' s& ^! E5 I
- #include <asm/hardware/edma.h>6 h: _) }* S* a! d" Z
- : o* a4 @* k" M& @; V
- #undef EDMA3_DEBUG! v3 F/ F! P, L$ U! j1 r8 y
- /*#define EDMA3_DEBUG*/; n6 q+ P3 p0 l+ ] O- L* A
) a/ x7 \% X7 I* k1 Y1 w3 x- #ifdef EDMA3_DEBUG
! Y, c* @9 ~6 j+ b- l b - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' l& S. a; P* ^- J: f; t% ` - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 a, z# W1 | g: c( h! m3 M; L
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) ^2 f! c \. U% R2 R
- #else
1 n# q/ v" n( n2 H, [" i1 w - #define DMA_PRINTK( x... )
: v3 U8 L( j3 r3 v; a - #define DMA_FN_IN, A( p. y# V/ V; V# @1 ~
- #define DMA_FN_OUT
/ V4 f9 P4 b2 k, m& F4 p+ _" a - #endif
6 T. Z6 L/ z d- i1 m - " U% Y- f. Q; J
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# w( [) {# O, H0 Z
- #define STATIC_SHIFT 3
9 N7 t" l; ~0 j - #define TCINTEN_SHIFT 20
0 l) e' Z; v, ^/ Z! v! T - #define ITCINTEN_SHIFT 216 Y& Q& U+ S+ b+ o, ^) {
- #define TCCHEN_SHIFT 22
5 H& \! ]% t) V# t7 A* k/ V - #define ITCCHEN_SHIFT 23
" S. q6 W5 z- I7 x4 o( y* ^ - 2 W8 `: J$ |2 `7 o) X9 x
- static volatile int irqraised1 = 0;
* M& ]9 {: F6 L5 z0 r - static volatile int irqraised2 = 0;
) v9 `+ J( S1 f, X+ q0 c% @
; f- g4 z0 M4 p N. A4 c- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! e) {( x1 [1 w
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 `- R7 w, w( [* f - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 j# ^5 f/ N; [; w8 P
4 ^. `, |( X3 i4 c. X4 Z- dma_addr_t dmaphyssrc1 = 0;+ W6 n) J5 a! t5 J* Z4 s, l8 }2 q
- dma_addr_t dmaphyssrc2 = 0;
7 b* y% J# s5 e8 r) ?0 \4 g! M - dma_addr_t dmaphysdest1 = 0;6 U9 D* Z, f% ], D) Q( F& r
- dma_addr_t dmaphysdest2 = 0;) a8 } G% P! M7 t
; @2 ^- t1 K+ S, d- char *dmabufsrc1 = NULL;
; x. i) \! g7 m+ _( R - char *dmabufsrc2 = NULL;1 E6 p" ], O" s9 k9 `. f3 F
- char *dmabufdest1 = NULL;
4 j7 N+ G M! j' v1 I4 R - char *dmabufdest2 = NULL;$ ]4 B6 m8 j! [8 r
- 1 H. M/ O" g7 G) J( O& l
- static int acnt = 512;
* K/ r( O7 ~- y) U" \) O - static int bcnt = 8;$ C' a" s3 J, h( J9 c
- static int ccnt = 8;
$ e/ F4 A% Z* N* q+ P& u1 k7 y - # l0 l9 `+ E$ |. ~
- module_param(acnt, int, S_IRUGO);6 n; i0 N1 a5 N: N" T6 t
- module_param(bcnt, int, S_IRUGO);2 `+ [5 C! ?1 C X2 }1 E. M( J
- module_param(ccnt, int, S_IRUGO);
复制代码
5 e6 N4 g4 t" Y' a; m
# @' z* O. _; t4 W- |9 g 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 z, h: Y: Q6 `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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ s: Y6 ?% e" h& ]) X* |; U/ ] 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 u, u3 L3 V; I# y8 @% h2 p9 k
# u' @5 T' C! P# @7 F6 Z- Q Y& T& D7 q
|
|