1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #12789 from maribu/bmx280_endianess

drivers/bmx280: Fix incorrect endian conversion
This commit is contained in:
benpicco 2019-11-28 14:04:41 +01:00 committed by GitHub
commit f4876013cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,20 +123,12 @@ static int _read_burst(const bmx280_t *dev, uint8_t reg, void *buf, size_t len)
static uint16_t _to_u16_le(const uint8_t *buffer, size_t offset)
{
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
return (((uint16_t)buffer[offset + 1]) << 8) + buffer[offset];
#else
return (((uint16_t)buffer[offset]) << 8) + buffer[offset + 1];
#endif
return (((uint16_t)buffer[offset + 1]) << 8) | buffer[offset];
}
static int16_t _to_i16_le(const uint8_t *buffer, size_t offset)
{
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
return (((int16_t)buffer[offset + 1]) << 8) + buffer[offset];
#else
return (((int16_t)buffer[offset]) << 8) + buffer[offset + 1];
#endif
return (((int16_t)buffer[offset + 1]) << 8) | buffer[offset];
}
/**