Reverse all bits from entire byte(uint8)
| 110 | |
| 111 | // Reverse all bits from entire byte(uint8) |
| 112 | uint8_t ReverseUint8(uint8_t num) { |
| 113 | num = ((num & 0xf0) >> 4) | ((num & 0x0f) << 4); |
| 114 | num = ((num & 0xcc) >> 2) | ((num & 0x33) << 2); |
| 115 | num = ((num & 0xaa) >> 1) | ((num & 0x55) << 1); |
| 116 | return num; |
| 117 | } |
| 118 | |
| 119 | // Get a reverse block of byte(uint8) using offsets, the result can be |
| 120 | // part of a left block and right block, length indicates the number of bits |