Rev 89 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 89 | Rev 121 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | #include "CAENV288.h" |
2 | #include "CAENV288.h" |
3 | #include "CAENV288_DEF.h" |
3 | #include "CAENV288_DEF.h" |
4 | 4 | ||
5 | 5 | ||
6 | #include "vme.h" |
6 | #include "vme.h" |
7 | - | ||
8 | #include <utility.h> |
7 | #include <utility.h> |
9 | 8 | ||
10 | static unsigned long ModuleAddress[10]; |
9 | static unsigned long ModuleAddress[10]; |
- | 10 | static float timeout = 0.01; |
|
11 | 11 | ||
12 | void _VI_FUNC V288_Map (int ModuleNumber, unsigned long ModuleOffset) |
12 | void _VI_FUNC V288_Map (int ModuleNumber, unsigned long ModuleOffset) |
13 | { |
13 | { |
14 | ModuleAddress[ModuleNumber] = ModuleOffset; |
14 | ModuleAddress[ModuleNumber] = ModuleOffset; |
15 | 15 | ||
16 | return; |
16 | return; |
17 | } |
17 | } |
18 | 18 | ||
19 | void _VI_FUNC V288_Reset(int ModuleNumber) |
19 | void _VI_FUNC V288_Reset(int ModuleNumber) |
20 | { |
20 | { |
21 |
|
21 | uint32_t ultmp=0; |
22 | 22 | ||
23 | VME_A24D16_W(ModuleAddress[ModuleNumber]+V288_RST, |
23 | VME_A24D16_W(ModuleAddress[ModuleNumber]+V288_RST, ultmp); |
24 | 24 | ||
25 | return; |
25 | return; |
26 | }; |
26 | }; |
27 | 27 | ||
28 | void _VI_FUNC V288_Init (int ModuleNumber) |
28 | void _VI_FUNC V288_Init (int ModuleNumber) |
29 | { |
29 | { |
30 | V288_Reset(ModuleNumber); |
30 | V288_Reset(ModuleNumber); |
31 | 31 | ||
32 | return; |
32 | return; |
33 | } |
33 | } |
34 | 34 | ||
35 | int _VI_FUNC V288_Send (int ModuleNumber,int slaveid,int nbuf,unsigned short *buf) |
35 | int _VI_FUNC V288_Send (int ModuleNumber,int slaveid,int nbuf,unsigned short *buf) |
36 | { |
36 | { |
37 | int i; |
37 | int i; |
38 |
|
38 | uint32_t ultmp,ulstat; |
39 | 39 | ||
40 | ultmp= |
40 | ultmp=0x00000001; |
41 | while (1){ |
41 | while (1){ |
42 | VME_A24D16_W(ModuleAddress[ModuleNumber]+V288_BUF, |
42 | VME_A24D16_W(ModuleAddress[ModuleNumber]+V288_BUF, ultmp); |
43 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
43 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
44 | if (ulstat & 1) Delay(0.1); else break; |
44 | if (ulstat & 1) Delay(0.1); else break; |
45 | } |
45 | } |
46 | 46 | ||
47 | ultmp=slaveid; |
47 | ultmp=slaveid; |
48 | while (1){ |
48 | while (1){ |
49 | VME_A24D16_W(ModuleAddress[ModuleNumber]+V288_BUF, |
49 | VME_A24D16_W(ModuleAddress[ModuleNumber]+V288_BUF, ultmp); |
50 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
50 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
51 | if (ulstat & 1) Delay(0.1); else break; |
51 | if (ulstat & 1) Delay(0.1); else break; |
52 | } |
52 | } |
53 | 53 | ||
54 | for (i=0;i<nbuf;i++){ |
54 | for (i=0;i<nbuf;i++){ |
55 | ultmp=buf[i]; |
55 | ultmp=buf[i]; |
56 | while (1){ |
56 | while (1){ |
57 | VME_A24D16_W(ModuleAddress[ModuleNumber]+V288_BUF, |
57 | VME_A24D16_W(ModuleAddress[ModuleNumber]+V288_BUF, ultmp); |
58 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
58 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
59 | if (ulstat & 1) Delay(0.1); else break; |
59 | if (ulstat & 1) Delay(0.1); else break; |
60 | } |
60 | } |
61 | } |
61 | } |
62 | 62 | ||
63 | while (1){ |
63 | while (1){ |
64 | VME_A24D16_W(ModuleAddress[ModuleNumber]+V288_TX, |
64 | VME_A24D16_W(ModuleAddress[ModuleNumber]+V288_TX, ultmp); |
65 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
65 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
66 | if (ulstat & 1) Delay(0.1); else break; |
66 | if (ulstat & 1) Delay(0.1); else break; |
67 | } |
67 | } |
68 | 68 | ||
69 | return 0; |
69 | return 0; |
70 | } |
70 | } |
71 | 71 | ||
72 | int _VI_FUNC V288_Receive(int ModuleNumber,int nbuf,unsigned short *buf) |
72 | int _VI_FUNC V288_Receive(int ModuleNumber,int nbuf,unsigned short *buf) |
73 | { |
73 | { |
74 | int i; |
74 | int i; |
75 |
|
75 | uint32_t ecode,ulstat; |
76 | 76 | ||
77 | while (1){ |
77 | while (1){ |
78 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_BUF, &ecode); |
78 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_BUF, &ecode); |
79 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
79 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
80 | if (ulstat & 1) Delay(0.1); else break; |
80 | if (ulstat & 1) Delay(0.1); else break; |
81 | } |
81 | } |
82 | if (ecode) return 1; |
82 | if (ecode) return 1; |
83 | 83 | ||
84 | i=0; |
84 | i=0; |
85 | while (i<nbuf){ |
85 | while (i<nbuf){ |
86 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_BUF, & |
86 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_BUF, &ecode); |
- | 87 | buf[i]=(unsigned short) ecode; |
|
87 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
88 | VME_A24D16_R(ModuleAddress[ModuleNumber]+V288_STATUS, &ulstat); |
88 | if (ulstat & 1) break; |
89 | if (ulstat & 1) break; |
89 | i++; |
90 | i++; |
90 | } |
91 | } |
91 | 92 |