黄金会员
主题
回帖0
积分5089
阅读权限40
注册时间2008-12-13
最后登录1970-1-1
在线时间 小时
|
本帖最后由 desertsailor 于 2014-5-27 21:35 编辑 6 x$ f w! @0 }& H& `8 ?2 r
* V0 F1 I- K& P
想了一下,查表可以这样:
" Q+ J# r, C7 j. x6 e2 J9 h- x Q$ B' H! d/ t/ u+ j
unsigned char Tab[16]={0x00,0x08,0x04,0x0C,0x02,0x0A,0x06,0x0E,0x01,0x09,0x05,0x0D,0x03,0x0B,0x07,0x0F}; //四位数据的反转,分别对应0-15的反转后的数据
5 j9 a; O3 W6 L) T8 e& L$ H1 b2 o0 W M6 B4 s* u
//8位数据的反转
4 Y+ |1 k D9 nunsigned char Reverse_8Bits(unsigned char Data)3 f! U6 G+ M8 J, b4 z% V
{$ g `2 z2 u7 q% I+ O# u
unsigned char temp;6 o- \8 y2 `+ N G+ `# `# z; C
temp=(Tab[Data&0x0f]<<4) | Tab[Data>>4];1 w. r0 V8 l5 m5 Q( Y( H/ D
return temp;# d9 c% i0 j% P
}
& }' x7 }3 B8 B7 {
. |6 }2 t& e/ H9 E
1 u: @; A# i9 S2 ?" T/ u//16位数据的反转# m( J4 M4 n4 e) {7 F- s
unsigned int Reverse_16Bits(unsigned int Data)
2 @3 b* Q, A- Q/ _1 b2 s& K{
2 e, W% u& H* V: n unsigned int temp;/ G$ \% L) y" ]; c7 {; k9 P# E
temp=(Reverse_8Bits((unsigned char)(Data&0x00FF))<<8) | Reverse_8Bits((unsigned char)(Data>>8));
8 `) ^& g9 U# o6 ]3 N* s: z return temp; R( R7 d, ^& i# A* W$ f7 w% v
} |
|