I have a 16-byte array, and am trying to left-shift the number of bits - where the number to shift can vary from 1 to 10. I tried the code below, but it only works with a 4 bit shift:
Rx_Table[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0A, 0xBC};
if (byteezy == 0x00 && byteezy1 == 0x10) {
int i;
uint8_t shifted = 0x00;
uint8_t overflow = (0xF0 & RxTable[0]) >> 4;
for (i = (16 - 1); i >= 0; i--) {
shifted = (RxTable[i] << 4) | overflow;
overflow = (0xF0 & RxTable[i]) >> 4;
RxTable1[i] = shifted;
}
I am stuck: how to make this work when the number of bits to shift is variable?