Skip to content

Commit a7bdddd

Browse files
araneusdiademakartben
authored andcommitted
drivers: sensor: max31855: fixed sign bit positions
MAX31855 driver had a wrong position of sign bits causing invalid reading of negative temperature values. Fixed by shifting position of sign bit by one bit. Signed-off-by: Petr Vilím <petr.vilim@proton.me>
1 parent 7e1bc39 commit a7bdddd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/sensor/maxim/max31855/max31855.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2020 Christian Hirsch
3+
* Copyright (c) 2025 Petr Vilím
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
@@ -72,7 +73,7 @@ static int max31855_channel_get(const struct device *dev, enum sensor_channel ch
7273
temp = (temp >> THERMOCOUPLE_TEMPERATURE_POS) & 0x3fff;
7374

7475
/* if sign bit is set, make value negative */
75-
if (temp & BIT(14)) {
76+
if (temp & BIT(13)) {
7677
temp |= THERMOCOUPLE_SIGN_BITS;
7778
}
7879

@@ -86,7 +87,7 @@ static int max31855_channel_get(const struct device *dev, enum sensor_channel ch
8687
temp = (temp >> INTERNAL_TEMPERATURE_POS) & 0xfff;
8788

8889
/* if sign bit is set, make value negative */
89-
if (temp & BIT(12)) {
90+
if (temp & BIT(11)) {
9091
temp |= INTERNAL_SIGN_BITS;
9192
}
9293

0 commit comments

Comments
 (0)