What is reason behind multiplying the val[1] by 256 in the following function?
I was working ISM330DLC sensor which I have interfaced with the my dev board nucleo 144 STM32F446. I'm using SPI protocol to get the raw data and also I'm able to read who am I register using following example codes "ism330dlc_read_data_polling.c". After reading getting raw data I was using MOTION GC library to get the calibrated data but I observed that "gyro_bias" parameter which will give the calibrated value of the accelerator as well as variable "bias update" was always zero
void MotionGC_Update ( MGC_input_t * data_in,
MGC_output_t * gyro_bias,
int * bias_update
)So while debugging this issue, I came across the following function where I found the following function
int32_t ism330dlc_mag_calibrated_raw_get(stmdev_ctx_t *ctx,
int16_t *val)
{
uint8_t buff[6];
int32_t ret;
ret = ism330dlc_read_reg(ctx, ISM330DLC_OUT_MAG_RAW_X_L, buff, 6);
val[0] = (int16_t)buff[1];
val[0] = (val[0] * 256) + (int16_t)buff[0];
val[1] = (int16_t)buff[3];
val[1] = (val[1] * 256) + (int16_t)buff[2];
val[2] = (int16_t)buff[5];
val[2] = (val[2] * 256) + (int16_t)buff[4];
return ret;
}As we can able to see that in the above function input value is multiplied by 256 so my doubt is what will be reason of multiplying by the 256??
