I'm reading x-axis accelerometer data from an IC via the I2C bus using I2C-Tools ( specifically i2cget
) in Linux. Here is the code that is reading these values:
$OUT_X_L_A = shell_exec( 'i2cget -y 1 0x19 0x28' ) ... eg. returns 0x20
$OUT_X_H_A = shell_exec( 'i2cget -y 1 0x19 0x29' ) ... eg. returns 0xfc
The documentation for this accelerometer states that these values ( 0x20 and 0xfc ) are expressed in 2's compliment. This accelerometer has 16 bit resolution.
From another application I'm running that is reading this data in C, I believe that these values, when converted to a decimal value, should equal ~65,475 ( essentially no acceleration as the device is sitting on my desk ). Some other documentation I've found suggests that $OUT_X_L_A is the Least Significant Register and $OUT_X_H_A is the Most Significant Register.
I've done some research, but am generally unfamiliar with Two's Complement and LSB and MSB. How do I calculate the full decimal value ( 16 bit resolution ) from the two hex values returned by the device? How am I supposed to tell from the documentation which register is the most significant?