From 6a62edd4a1f01a6ee380c3aabaff3f437e8d6f1e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 7 May 2012 23:14:14 -0700 Subject: [PATCH] altos: Conditional byte swapping in mpu6000 driver Only needed on LSB machines. Signed-off-by: Keith Packard --- src/drivers/ao_mpu6000.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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² */ -- 2.30.2