Reverse all bits from entire byte(uint8)
| 120 | |
| 121 | // Reverse all bits from entire byte(uint8) |
| 122 | uint8_t ReverseUint8(uint8_t num) { |
| 123 | num = ((num & 0xf0) >> 4) | ((num & 0x0f) << 4); |
| 124 | num = ((num & 0xcc) >> 2) | ((num & 0x33) << 2); |
| 125 | num = ((num & 0xaa) >> 1) | ((num & 0x55) << 1); |
| 126 | return num; |
| 127 | } |
| 128 | |
| 129 | // Get a reverse block of byte(uint8) using offsets, the result can be |
| 130 | // part of a left block and right block, length indicates the number of bits |