www.vxitech.com
SVM2608 Appendix A
55
A
PPENDIX
A
A
PPENDIX
A
D
ATA
S
WAPPING
E
XAMPLE
An example is provided below detailing how data might be swapped in to get a REAL number
when the data is read “swapped”. In order to make the code easier to understand, only the portion
that shuffles the data is presented here. The VME functions that actually perform the reading of
the data are the responsibility of the user.
byte tempData[16];
int regRdata[16];
doublerealData;
union
{ char
data[8];
doublevalue;
}dblData;
// read results
data = VmeRead16(channel, Vme0x28, &Api_Result);
printf("MSB1: %02x\n", data);
regRdata[0] = data;
data = VmeRead16(channel, Vme0x2a, &Api_Result);
printf("MSB0: %02x\n", data);
regRdata[1] = data;
data = VmeRead16(channel, Vme0x2c, &Api_Result);
printf("LSB1: %02x\n", data);
regRdata[2] = data;
data = VmeRead16(channel, Vme0x2e, &Api_Result);
printf("LSB0: %02x\n", data);
regRdata[3] = data;
//
now shuffle the bytes
dblData.data[0] = (byte)((regRdata[3] & 0xff00) >> 8);
dblData.data[1] = (byte)((regRdata[3] & 0x00ff) >> 0);
dblData.data[2] = (byte)((regRdata[2] & 0xff00) >> 8);
dblData.data[3] = (byte)((regRdata[2] & 0x00ff) >> 0);
dblData.data[4] = (byte)((regRdata[1] & 0xff00) >> 8);
dblData.data[5] = (byte)((regRdata[1] & 0x00ff) >> 0);
dblData.data[6] = (byte)((regRdata[0] & 0xff00) >> 8);
dblData.data[7] = (byte)((regRdata[0] & 0x00ff) >> 0);
realData = dblData.value;
Содержание SVM2608
Страница 2: ...VXI Technology Inc 2 ...
Страница 10: ...VXI Technology Inc 10 SVM2608 Preface ...
Страница 22: ...VXI Technology Inc 22 SVM2608 Introduction ...
Страница 54: ...VXI Technology Inc 54 SVM2608 Programming ...
Страница 56: ...VXI Technology Inc 56 SVM2608 Appendix A ...