I have an unsigned char buffer which is being read in and working fine. I need to be able to select a number of bits within the main buffer and copy them to another variable to convert from hex data (little endian) into an integer to be displayed. I cannot for the life of me get this working. The following code prints the values I need in hex (in reverse order due to endianness) but I can't figure out how to use it.
void printFromBuffer(unsigned char *buffer, int block, int offset, int size){
unsigned char *ptr = buffer;
ptr += block * 0x10 + offset;
for(int i=0;i<size;i++){
printf("%X \n",ptr[i]);
}
}
printFromBuffer(buffer, 0x08, 0x03, 0x02);
Thanks