From: Keith Packard Date: Tue, 8 May 2012 06:14:14 +0000 (-0700) Subject: altos: Conditional byte swapping in mpu6000 driver X-Git-Tag: 1.0.9.5~24 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=6a62edd4a1f01a6ee380c3aabaff3f437e8d6f1e altos: Conditional byte swapping in mpu6000 driver Only needed on LSB machines. Signed-off-by: Keith Packard --- diff --git a/src/drivers/ao_mpu6000.c b/src/drivers/ao_mpu6000.c index d27c42b0..eb4044be 100644 --- a/src/drivers/ao_mpu6000.c +++ b/src/drivers/ao_mpu6000.c @@ -73,11 +73,13 @@ ao_mpu6000_sample(struct ao_mpu6000_sample *sample) int i = sizeof (*sample) / 2; ao_mpu6000_read(MPU6000_ACCEL_XOUT_H, sample, sizeof (*sample)); - /* byte swap (sigh) */ +#if __BYTE_ORDER == __LITTLE_ENDIAN + /* byte swap */ while (i--) { uint16_t t = *d; *d++ = (t >> 8) | (t << 8); } +#endif } #define G 981 /* in cm/s² */