This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Input : bitReverseMasked(0x9, 1, 3) | |
// Output : 0x3 [ Reversing bit between low and high] | |
uint32_t bitReverseMasked(uint32_t val, uint8_t low, uint8_t high) | |
{ | |
uint32_t mask; | |
uint32_t rev_val; | |
uint8_t i; | |
mask = ((1UL<<(high - low + 1)) - 1) << low; | |
rev_val = val & ~mask; |