source: drsdaq/VME/struck/sis1100/V2.02/examples/vme_simple_routines/test.c@ 23

Last change on this file since 23 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
  • Property svn:executable set to *
File size: 2.7 KB
Line 
1#define _GNU_SOURCE
2#include <stdio.h>
3#include <errno.h>
4#include <string.h>
5#include <sys/types.h>
6#include <unistd.h>
7#include <stdlib.h>
8#include <fcntl.h>
9#include <sys/ioctl.h>
10
11
12#include "dev/pci/sis1100_var.h"
13#include "sis3100_vme_calls.h"
14
15
16
17/*
18int soll_data ;
19int max_lword_cnt ;
20int loop_cnt ;
21
22int error_cnt ;
23*/
24
25
26
27
28static int getopts(int iargc, char* iargv[])
29{
30
31 extern char *optarg ;
32 extern int optind ;
33
34 const char* optstring="a:f:p";
35 int c, errflag = 0 ;
36 int return_code ;
37
38 printf("iargc = 0x%08x\n", iargc );
39 printf(" \n") ;
40
41 return_code = -1 ;
42
43while (!errflag && ((c = getopt(iargc, iargv, optstring)) != -1)) {
44 switch (c) {
45 case 'a':
46 printf("-a iargc = 0x%08x\n", iargc );
47 printf("-a c = 0x%08x\n", c );
48 printf("-a = 0x%08x\n", (strtoul(optarg,NULL,0)) );
49 return_code = 0 ;
50 printf(" \n") ;
51 break ;
52 case 'f':
53 printf("-f iargc = 0x%08x\n", iargc );
54 printf("-f c = 0x%08x\n", c );
55 printf("-f = 0x%08x\n", (strtoul(optarg,NULL,0)) );
56 return_code = 0 ;
57 printf(" \n") ;
58 break ;
59 }
60}
61return return_code ;
62
63}
64
65
66/****************************************************************************/
67
68int main(int argc, char* argv[])
69{
70
71#define MAX_NUMBER_LWORDS 0x100000
72
73int i;
74
75int mod_base;
76int no_of_lwords ;
77int p;
78u_int32_t blt_data[MAX_NUMBER_LWORDS] ;
79u_int32_t put_lwords ;
80u_int32_t start_data ;
81
82int return_code ;
83int loop_counter ;
84
85 getopts(argc,argv) ;
86
87if (argc<4)
88 {
89 fprintf(stderr, "usage: %s VME_BASE_ADDR NO_OF_LWORDS START_DATA [LOOP_COUNTER] \n", argv[0]);
90 return 1;
91 }
92
93/* open VME */
94 if ((p=open("/tmp/sis1100", O_RDWR, 0))<0) {
95 printf("error on opening VME environment\n");
96 return -1;
97 }
98
99mod_base = strtoul(argv[1],NULL,0) ;
100no_of_lwords = strtoul(argv[2],NULL,0) ;
101start_data = strtoul(argv[3],NULL,0) ;
102
103
104loop_counter = 1 ;
105if (argc>3) loop_counter = strtoul(argv[4],NULL,0) ;
106
107
108if (no_of_lwords > MAX_NUMBER_LWORDS)
109 {
110 printf("no_of_lwords (0x%08x) must be lower then MAX_NUMBER_LWORDS (0x%08x)\n",no_of_lwords, MAX_NUMBER_LWORDS);
111 return -1;
112 }
113
114
115
116/* test pattern (increment ) */
117 for (i=0; i<no_of_lwords; i++) blt_data[i] = start_data + i ;
118
119 for (i=0; i < loop_counter; i++) {
120 return_code = vme_A32BLT32_write(p, mod_base, blt_data, no_of_lwords, &put_lwords) ;
121 }
122
123 printf("vme_A32BLT32_write: return_code = 0x%08x\n", return_code );
124 printf("vme_A32BLT32_write: put_lwords = 0x%08x\n", put_lwords );
125
126
127
128close(p);
129return 0;
130}
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
Note: See TracBrowser for help on using the repository browser.