diff options
author | Keith Packard <keithp@keithp.com> | 2012-05-07 23:14:14 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-05-18 20:19:00 -0700 |
commit | 6a62edd4a1f01a6ee380c3aabaff3f437e8d6f1e (patch) | |
tree | fd4f009d7bd641c17901c42966df91e982d1cfb8 /src/drivers/ao_mpu6000.c | |
parent | 6a973f788563ccc66b01cc7557a004dabef18d09 (diff) |
altos: Conditional byte swapping in mpu6000 driver
Only needed on LSB machines.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/drivers/ao_mpu6000.c')
-rw-r--r-- | src/drivers/ao_mpu6000.c | 4 |
1 files changed, 3 insertions, 1 deletions
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² */ |