00001 #ifndef TRGUTIL_H
00002 #define TRGUTIL_H
00003
00004 inline unsigned int swapI(unsigned int var)
00005 {
00006 volatile unsigned int x = var ;
00007
00008 return
00009 (x&0xff000000) >> 24 |
00010 (x&0x00ff0000) >> 8 |
00011 (x&0x0000ff00) << 8 |
00012 (x&0x000000ff) << 24;
00013 }
00014
00015 inline unsigned int swapSCC(unsigned int var)
00016 {
00017 volatile unsigned int x = var ;
00018
00019 return
00020 (x&0x0000ff00) >> 8 |
00021 (x&0x000000ff) << 8 |
00022 (x&0xffff0000);
00023 }
00024
00025 inline unsigned int swapSS(unsigned int var)
00026 {
00027 volatile unsigned int x = var ;
00028
00029 return
00030 (x&0xff000000) >> 8 |
00031 (x&0x00ff0000) << 8 |
00032 (x&0x0000ff00) >> 8 |
00033 (x&0x000000ff) << 8;
00034 }
00035
00036 inline float swapF(float *var)
00037 {
00038 unsigned char *cs, tmp;
00039 cs = (unsigned char *)var;
00040 tmp = cs[0];
00041 cs[0] = cs[3];
00042 cs[3] = tmp;
00043 tmp = cs[1];
00044 cs[1] = cs[2];
00045 cs[2] = tmp;
00046 return(*var);
00047 }
00048
00049 inline TrgDataType *swapDescSum( TrgDataType *trgD )
00050 {
00051 int ii;
00052 volatile unsigned int *x;
00053
00054 x = (volatile unsigned int*)&trgD->EvtDesc.TCUdataBytes;
00055
00056
00057
00058 *x++ = swapSCC(*x);
00059 *x++ = swapI(*x);
00060 *x++ = swapI(*x);
00061 *x++ = swapSCC(*x);
00062 for (ii=0; ii<6; ii++) {
00063 *x++ = swapSS(*x);
00064 }
00065
00066
00067
00068 *x++ = swapSS(*x);
00069 for (ii=0; ii<4; ii++ ) {
00070 *x++ = swapI(*x);
00071 }
00072 *x++ = swapSS(*x);
00073 for (ii=0; ii<48; ii++) {
00074 *x++ = swapSS(*x);
00075 }
00076 *x++ = swapSS(*x);
00077 for (ii=0; ii<32; ii++) {
00078 *x++ = swapI(*x);
00079 }
00080 *x++ = swapSS(*x);
00081 for (ii=0; ii<32; ii++) {
00082 *x++ = swapI(*x);
00083 }
00084 return(trgD);
00085 }
00086
00087 inline TrgDataType *swapTrg( TrgDataType *trgD, int pre, int post )
00088 {
00089 int ii, jj;
00090 volatile unsigned int *x;
00091
00092 x = (volatile unsigned int*)&trgD->EvtDesc.TCUdataBytes;
00093
00094
00095
00096 *x++ = swapSCC(*x);
00097 *x++ = swapI(*x);
00098 *x++ = swapI(*x);
00099 *x++ = swapSCC(*x);
00100 for (ii=0; ii<6; ii++) {
00101 *x++ = swapSS(*x);
00102 }
00103 pre = trgD->EvtDesc.npre;
00104 post = trgD->EvtDesc.npost;
00105
00106
00107
00108 *x++ = swapSS(*x);
00109 for (ii=0; ii<4; ii++ ) {
00110 *x++ = swapI(*x);
00111 }
00112 *x++ = swapSS(*x);
00113 for (ii=0; ii<48; ii++) {
00114 *x++ = swapSS(*x);
00115 }
00116 *x++ = swapSS(*x);
00117 for (ii=0; ii<32; ii++) {
00118 *x++ = swapI(*x);
00119 }
00120 *x++ = swapSS(*x);
00121 for (ii=0; ii<32; ii++) {
00122 *x++ = swapI(*x);
00123 }
00124
00125 for ( jj = 0; jj < (pre+post+1); jj++ ) {
00126 *x++ = swapSCC(*x);
00127 *x++ = swapSCC(*x);
00128 for (ii=0; ii<64; ii++) *x++;
00129 *x++ = swapSCC(*x);
00130 *x++ = swapI(*x);
00131 for (ii=0; ii<32; ii++) *x++;
00132 *x++ = swapSCC(*x);
00133 *x++ = swapI(*x);
00134 for (ii=0; ii<120; ii++) *x++;
00135 for (ii=0; ii<24; ii++) {
00136 *x++ = swapSS(*x);
00137 }
00138 *x++ = swapSCC(*x);
00139 *x++ = swapI(*x);
00140 for (ii=0; ii<8; ii++) {
00141 *x++ = swapSS(*x);
00142 }
00143 for (ii=0; ii<36; ii++) *x++;
00144 *x++ = swapSCC(*x);
00145 *x++ = swapI(*x);
00146 for (ii=0; ii<28; ii++) *x++;
00147 for (ii=0; ii<4; ii++) {
00148 *x++ = swapSS(*x);
00149 }
00150 for (ii=0; ii<16; ii++) *x++;
00151 for (ii=0; ii<4; ii++) {
00152 *x++ = swapSS(*x);
00153 }
00154 for (ii=0; ii<28; ii++) *x++;
00155 for (ii=0; ii<4; ii++) {
00156 *x++ = swapSS(*x);
00157 }
00158 for (ii=0; ii<16; ii++) *x++;
00159 for (ii=0; ii<4; ii++) {
00160 *x++ = swapSS(*x);
00161 }
00162 *x++ = swapSCC(*x);
00163 *x++ = swapI(*x);
00164 for (ii=0; ii<24; ii++) *x++;
00165 for (ii=0; ii<8; ii++) {
00166 *x++ = swapSS(*x);
00167 }
00168 for (ii=0; ii<8; ii++) *x++;
00169 for (ii=0; ii<4; ii++) *x++;
00170 for (ii=0; ii<4; ii++) {
00171 *x++ = swapSS(*x);
00172 }
00173 }
00174 return (trgD);
00175 }
00176
00177
00178
00179 #endif
00180