Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
190 | f9daq | 1 | #include <ansi_c.h> |
2 | #include "CAENV462.h" |
||
3 | #include "CAENV462_DEF.h" |
||
4 | |||
5 | #ifdef SISVME |
||
6 | #include "sisvme_dll.h" |
||
7 | #endif |
||
8 | #ifdef WIENVME |
||
9 | #include "wienvme_dll.h" |
||
10 | #endif |
||
11 | |||
12 | static unsigned long ModuleAddress[10]; |
||
13 | |||
14 | int _VI_FUNC V462_map (int ModuleNumber, |
||
15 | unsigned long ModuleOffset, int print) |
||
16 | { |
||
17 | unsigned short vsr, mmt, fix; |
||
18 | |||
19 | ModuleAddress[ModuleNumber] = ModuleOffset; |
||
20 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV462_FIX,&fix); |
||
21 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV462_MMT,&mmt); |
||
22 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV462_VSR,&vsr); |
||
23 | if (print) { |
||
24 | printf("fixed code = 0x%04x\n", fix); |
||
25 | printf("manufacturer number = %i\n", MANUFACTURER(mmt)); |
||
26 | printf("module type = %i\n", MODULE_TYPE(mmt)); |
||
27 | printf("version = %i\n", VERSION(vsr)); |
||
28 | printf("serial no. = %i\n", SERIAL(vsr)); |
||
29 | } |
||
30 | if ((fix != FIX_CODE) || (mmt != CAENV462_MMT_VALUE)) return 1; |
||
31 | return 0; |
||
32 | } |
||
33 | |||
34 | int _VI_FUNC V462_set0 (int ModuleNumber, int time) |
||
35 | { |
||
36 | int i; |
||
37 | unsigned int status; |
||
38 | union { |
||
39 | unsigned short lsbmsb[2]; |
||
40 | unsigned long bcd; |
||
41 | } set; |
||
42 | |||
43 | if ((time > 99999999) || (time < 0)) time = 0; |
||
44 | set.bcd = 0; |
||
45 | for (i=0;i<32;i+=4) { |
||
46 | set.bcd |= (time % 10) << i; |
||
47 | time = time / 10; |
||
48 | } |
||
49 | |||
50 | |||
51 | VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV462_MSB0, &set.lsbmsb[1]); |
||
52 | VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV462_LSB0, &set.lsbmsb[0]); |
||
53 | |||
54 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV462_CSR, &status); |
||
55 | return (status & CAENV462_STATUS); |
||
56 | } |
||
57 | |||
58 | int _VI_FUNC V462_set1 (int ModuleNumber, int time) |
||
59 | { |
||
60 | int i; |
||
61 | unsigned int status; |
||
62 | union { |
||
63 | unsigned short lsbmsb[2]; |
||
64 | unsigned long bcd; |
||
65 | } set; |
||
66 | |||
67 | if ((time > 99999999) || (time < 0)) time = 0; |
||
68 | set.bcd = 0; |
||
69 | for (i=0;i<32;i+=4) { |
||
70 | set.bcd |= (time % 10) << i; |
||
71 | time = time / 10; |
||
72 | } |
||
73 | |||
74 | VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV462_MSB1, &set.lsbmsb[1]); |
||
75 | VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV462_LSB1, &set.lsbmsb[0]); |
||
76 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV462_CSR, &status); |
||
77 | return ( status & CAENV462_STATUS ); |
||
78 | |||
79 | } |
||
80 | |||
81 | int _VI_FUNC V462_start0 (int ModuleNumber) |
||
82 | { |
||
83 | unsigned int status; |
||
84 | unsigned short dum16= CAENV462_START0; |
||
85 | VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV462_CSR, &dum16 ); |
||
86 | |||
87 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV462_CSR, &status); |
||
88 | return ( status & CAENV462_STATUS ); |
||
89 | } |
||
90 | |||
91 | |||
92 | int _VI_FUNC V462_start1 (int ModuleNumber) |
||
93 | { |
||
94 | unsigned int status; |
||
95 | unsigned short dum16= CAENV462_START1; |
||
96 | VME_A24D16_W(ModuleAddress[ModuleNumber] + CAENV462_CSR, &dum16 ); |
||
97 | |||
98 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV462_CSR, &status); |
||
99 | return ( status & CAENV462_STATUS ); |
||
100 | } |
||
101 | |||
102 | |||
103 | |||
104 | |||
105 | int _VI_FUNC V462_status (int ModuleNumber) |
||
106 | { |
||
107 | unsigned int status; |
||
108 | VME_A24D16_R(ModuleAddress[ModuleNumber] + CAENV462_CSR, &status); |
||
109 | return (status & CAENV462_STATUS ); |
||
110 | } |