here is the function code
unsigned char reverse_bit(unsigned char normalbit)
{
uint8_t reversed;
reversed = (((normalbit&0b00000001)>>0)<<7)|(((normalbit&0b00000010)>>1)<<6)|(((normalbit&0b00000100)>>2)<<5)|(((normalbit&0b00001000)>>3)<<4)|
(((normalbit&0b00010000)>>4)<<3)|(((normalbit&0b00100000)>>5)<<2)|(((normalbit&0b01000000)>>6)<<1)|(((normalbit&0b10000000)>>7)<<0);
return reversed;
}
this code will reverse bit from bit 7,6,5,4,3,2,1,0 into 0,1,2,3,4,5,6,7 or from bit 0,1,2,3,4,5,6,7 into 7,6,5,4,3,2,1,0.
for example :
//start here
unsigned char reverse_bit(unsigned char normalbit)
{
uint8_t reversed;
reversed =
(((normalbit
...
Read more »