I need to convert 112 bits (16 Bytes) of 7-bit value variables (They are received in bytes but the MSb have to be discarded) into 14 bytes the fastest way possible in C.
So basically, what I need to do is to take the first 7 bits of the first byte received and shift them to the left and then take the 7th bit of the the second byte put it in the first byte to store in the bit position 0 so I would get in the first byte the 7 bits of the first byte received plus the 7th bit of the second byte. Then I would have to do the same with the rest.
The first way I can think of to that would be this:
byteToStore [0] = 1 << byteReceived[0] + byteReceived[1] & 1;
byteToStore [1] = 2 << byteReceived[1] + byteReceived[2] & 3;
byteToStore [2] = 3 << byteReceived[2] + byteReceived[3] & 7;
And so on.
Also, it would be great if it could be made easily with a for loop. I could it with a for loop with my method but it wouldn't be so "clean".
Thank you.