I'm reading the outputs of an accelerometer as a MSB (8 bits) and LSB (8 bits). i'm new to spin programming and i need to combine the two numbers into one. the two numbers are given in two's complement.
PRI combine_unsigned(MSB, LSB)
result.byte[0] := LSB
result.byte[1] := MSB
PRI combine_signed(MSB, LSB)
result.byte[0] := LSB
result.byte[1] := MSB
return ~~result ' sign-extend word to long
Comments
If the value is signed:
This removes two LSB bits from the value while preserving the sign.