unsigned char BitReverse(unsigned char In)
{
int Loop = 0;
unsigned char Out = 0;
while (1)
{
Out |= (In & 1); //AND In with 00000001, and OR the result with Out
if (Loop > 6) //if we did all 8 bits then break
break;
In >>= 1; //shift bits in In 1 position to the right
Out <<= 1; //shift bits in Out 1 pos to the left
Loop++; //increase loop for next pass
}
return Out; //return the result
}