- UID
- 856476
|
#include
union
{
struct
{
unsigned char bit0 : 1;
unsigned char bit1 : 1;
unsigned char bit2 : 1;
unsigned char bit3 : 1;
unsigned char bit4 : 1;
unsigned char bit5 : 1;
unsigned char bit6 : 1;
unsigned char bit7 : 1;
}bits;
unsigned char ucOne8Byte;
}uData8;
void DataChange(unsigned char *upByte)
{
unsigned char bTemp;
uData8.ucOne8Byte = *upByte;
bTemp = uData8.bits.bit0;
uData8.bits.bit0 = uData8.bits.bit7;
uData8.bits.bit7 = bTemp;
bTemp = uData8.bits.bit1;
uData8.bits.bit1 = uData8.bits.bit6;
uData8.bits.bit6 = bTemp;
bTemp = uData8.bits.bit2;
uData8.bits.bit2 = uData8.bits.bit5;
uData8.bits.bit5 = bTemp;
bTemp = uData8.bits.bit3;
uData8.bits.bit3 = uData8.bits.bit4;
uData8.bits.bit4 = bTemp;
*upByte = uData8.ucOne8Byte;
}
int main()
{
unsigned char a = 0xfe;
DataChange(&a);
printf("0x%x\n", a);
} |
|