-
Notifications
You must be signed in to change notification settings - Fork 1
/
testV513.cpp
128 lines (109 loc) · 3.1 KB
/
testV513.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include <iostream>
#include "myV513.h"
using namespace std;
inline bool isT1T2Trig(v513& xio) { return (xio.readInputRegister() & 1<<7); }
inline bool isHWBusy(v513& xio) { return (xio.readInputRegister() & 1<<4); }
inline bool isInSpill(v513& xio) { return (xio.readInputRegister() & 1<<5); }
inline bool isPedTrig(v513& xio) { return (xio.readInputRegister() & 1<<6); }
uint32_t checkRW (uint32_t k, v513& xio, uint16_t w )
{
uint16_t z;
std::cout << dec << k << " W " << hex << w;
xio.write16phys(0x04, w);
usleep(1);
xio.read16phys(0x04, &z);
std::cout << " -> R " << z << endl;
usleep(1);
return z;
}
int32_t main( int32_t argc, char** argv )
{
uint32_t ads;
ads = 0xa00000;
if (argc == 2)
{
int result = sscanf (argv[1], "%x", &ads);
if (result != 1) return -1;
}
cout << hex << " V513 addres is " << ads << endl;
v513 xio(ads,"/V2718/cvA24_U_DATA/0"); // Desy setup // roberto 15.06.2021
uint16_t z;
xio.print();
xio.reset();
xio.read16phys(0x04, &z);
cout << hex << " V513 0x4 " << z << endl;
cout << "isT1T2Trig: " << isT1T2Trig(xio) << " - isPedTrig: " << isPedTrig(xio) << " - isInSpill " << isInSpill(xio) << " - isHWBusy " << isHWBusy(xio) << endl;
// exit(0);
sleep(1);
do
{
uint16_t w;
xio.read16phys(0xFE, &w);
cout << hex << " V513 FE " << w << endl;
sleep(1);
xio.read16phys(0xFC, &w);
cout << hex << " V513 FC " << w << endl;
sleep(1);
xio.read16phys(0xFA, &w);
cout << hex << " V513 FA " << w << endl;
usleep(1);
w=0;
xio.write16phys(0x48, w);
usleep(1);
xio.write16phys(0x46, w);
usleep(1);
xio.write16phys(0x42, w);
usleep(1);
xio.read16phys(0x04, &w);
cout << hex << " V513 0x4 " << w << endl;
usleep(1);
for (int i=0; i<8; i++)
{
int reg07 = 0x10+i*2;
// xio.write16phys(reg07, 7);
xio.setChannelInput(i);
usleep(1);
xio.read16phys(reg07, &w);
cout << hex << " V513 " << reg07 << " " << w << " ------- ";
usleep(1);
int reg8f = 0x20+i*2;
// xio.write16phys(reg8f, 6);
xio.setChannelOutput(8+i);
usleep(1);
xio.read16phys(reg8f, &w);
cout << hex << " V513 " << reg8f << " " << w << endl;
usleep(1);
}
for (int i=0; i<8; i++) xio.setChannelInput(i);
for (int i=8; i<16; i++) xio.setChannelOutput(i);
usleep(1);
}
while(0);
uint32_t i(0);
while(0)
{
uint16_t w, z;
i ++;
w = 0xff00;
z = checkRW(i, xio, w);
if (z != (w|4)) { cout << " ******** ERROR w != z " << w << " " << z << endl; break; }
w = 0xf000;
z = checkRW(i, xio, w);
if (z != (w|4)) { cout << " ******** ERROR w != z " << w << " " << z << endl; break; }
w = 0x0f00;
z = checkRW(i, xio, w);
if (z != (w|4)) { cout << " ******** ERROR w != z " << w << " " << z << endl; break; }
w = 0x0300;
z = checkRW(i, xio, w);
if (z != (w|4)) { cout << " ******** ERROR w != z " << w << " " << z << endl; break; }
}
while (1)
{
uint16_t w;
xio.write16phys(0x04, 0x8000);
if (0) for (int i=0; i<1; i++) xio.read16phys(0x04, &w);
xio.write16phys(0x04, 0x0);
if (0) for (int i=0; i<1; i++) xio.read16phys(0x04, &w);
}
return 0;
}