source: drsdaq/VME/struck/sis1100/V2.02/examples/camac_simple_routines/sis5100_ios.c@ 22

Last change on this file since 22 was 22, checked in by ogrimm, 16 years ago
First commit of drsdaq program
  • Property svn:executable set to *
File size: 1.7 KB
Line 
1/***************/
2/* SIS5100 IOS */
3/***************/
4
5#define _GNU_SOURCE
6#include <stdio.h>
7#include <errno.h>
8#include <string.h>
9#include <sys/types.h>
10#include <unistd.h>
11#include <stdlib.h>
12#include <fcntl.h>
13#include <sys/ioctl.h>
14
15
16#include "dev/pci/sis1100_var.h"
17#include "sis5100_camac_calls.h"
18
19
20/****************************************************************************/
21int main(int argc, char* argv[])
22{
23
24int p;
25int res;
26int datum;
27
28
29if (argc<2) {
30 fprintf(stderr, "usage: %s path\n", argv[0]);
31 return 1;
32}
33
34if ((p=open(argv[1], O_RDWR, 0))<0) {
35 perror("open");
36 return 1;
37}
38
39
40while(1){
41 /* enable LAM station N1-N4 */
42 res=s5100_control_write(p,0x108,0xF);
43 if (res!=0) {
44 printf("error: %x\n",res);
45 return -1;
46 }
47 /* read input status */
48 res=s5100_control_read(p,0x84,&datum);
49 printf("OPT-IN register contents: %8.8x\n",datum);
50 sleep(1);
51 res=s5100_control_write(p,0x80,0x70);
52 /* read latched inputs */
53 res=s5100_control_read(p,0x84,&datum);
54 printf("OPT-IN IRQ register contents: %8.8x\n",datum);
55 /* clear latched bits */
56 res=s5100_control_write(p,0x84,datum);
57 /* and read again */
58 res=s5100_control_read(p,0x84,&datum);
59 printf("OPT-IN IRQ register contents after clear: %8.8x\n",datum);
60 res=s5100_control_read(p,0x80,&datum);
61 printf("OPT-IN register contents: %8.8x\n",datum);
62 sleep(1);
63 res=s5100_control_write(p,0x80,0x700000);
64 res=s5100_control_read(p,0x80,&datum);
65 printf("OPT-IN register contents: %8.8x\n",datum);
66 /* one shot IRQ LAM update */
67 res=s5100_control_write(p,0x104,0x8000);
68 /* read LAM status register */
69 res=s5100_control_read(p,0x104,&datum);
70 printf("LAM register contents: %8.8x\n",datum);
71
72}
73
74close(p);
75return 0;
76}
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
Note: See TracBrowser for help on using the repository browser.