Skip to content
Commit 88649dad authored by Trent Piepho's avatar Trent Piepho Committed by Anas Nashif
Browse files

drivers/sensor: si7006: Mask off low two bits of data reads



The low two bits are not part of the data, but rather "status" bits that
should be masked off.

This is documented in the HTU21D datasheet Edition 8, date 05/2017, pp.
15, and Sensirion SHT21 datasheet version 6, date 10/2022, §6 (wording
exactly the same):

"The two status bits, the last bits of LSB, must be set to ‘0’ before
calculating physical values."

Also Silicon Labs Si7006 example driver code:
        /* Swap the bytes and clear the status bits */
        return ((data.byte[0] * 256) + data.byte[1]) & ~3;

Since these are the LSBs, it has only a small effect and might not have
been noticed despite being wrong.

While editing this code, switch to using the Zephyr endian conversion
functions intead of a written out conversion.

Add error code to error log message.

Signed-off-by: default avatarTrent Piepho <tpiepho@gmail.com>
parent c7b3b131
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment