Skip to content

Instantly share code, notes, and snippets.

@mshafeeqkn
Last active March 29, 2024 03:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mshafeeqkn/3597c9eeda0a4a24917d6bc870dddafa to your computer and use it in GitHub Desktop.
Save mshafeeqkn/3597c9eeda0a4a24917d6bc870dddafa to your computer and use it in GitHub Desktop.
uint8_t reverse_byte(uint8_t byte) {
byte = ((byte & 0x55) << 1) | ((byte & 0xAA) >> 1);
byte = ((byte & 0x33) << 2) | ((byte & 0xCC) >> 2);
byte = ((byte & 0x0F) << 4) | ((byte & 0xF0) >> 4);
return byte;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment