source: drsdaq/VME/struck/sis1100/V2.02/test/synctest.c@ 22

Last change on this file since 22 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
File size: 1.1 KB
Line 
1#include <stdio.h>
2#include <errno.h>
3#include <string.h>
4#include <sys/types.h>
5#include <fcntl.h>
6#include <sys/ioctl.h>
7
8#include <dev/pci/sis1100_var.h>
9
10static u_int32_t read_local_register(int p, u_int32_t offs)
11{
12 struct sis1100_ctrl_reg reg;
13
14 reg.offset=offs;
15 if (ioctl(p, SIS1100_CONTROL_READ, &reg)<0) {
16 fprintf(stderr, "ioctl(SIS1100_CONTROL_READ, offs=0x%x): %s\n",
17 offs, strerror(errno));
18 return -1;
19 }
20 return reg.val;
21}
22
23int main(int argc, char* argv[])
24{
25 int p, count;
26 u_int32_t status, old_status;
27
28 if (argc<2)
29 {
30 fprintf(stderr, "usage: %s path\n", argv[0]);
31 return 1;
32 }
33
34 if ((p=open(argv[1], O_RDWR, 0))<0)
35 {
36 fprintf(stderr, "open(\"%s\"): %s\n", argv[1], strerror(errno));
37 return 1;
38 }
39
40 old_status=read_local_register(p, 4);
41 printf("status=0x%08x\n", old_status);
42 count=0;
43 while (count++<1000000) {
44 status=read_local_register(p, 4);
45 if (status!=old_status) {
46 printf(" 0x%08x\n", status);
47 old_status=status;
48 }
49 }
50
51 close(p);
52 return 0;
53}
Note: See TracBrowser for help on using the repository browser.