Skip to content

Commit 7497b8b

Browse files
maxmclaukartben
authored andcommitted
drivers: sensor: max31865: fix compilation warning -Wdouble-promotion
Fixes type mix-match for rtd temperature calculation. Also changes coefficient array name for clarity. Signed-off-by: Maxmillion McLaughlin <max@sorcerer.earth>
1 parent 303c674 commit 7497b8b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/sensor/maxim/max31865/max31865.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ static double calculate_temperature(double resistance, double resistance_0)
9999
}
100100
resistance /= resistance_0;
101101
resistance *= 100.0;
102-
temperature = A[0] + A[1] * resistance + A[2] * pow(resistance, 2) -
103-
A[3] * pow(resistance, 3) - A[4] * pow(resistance, 4) +
104-
A[5] * pow(resistance, 5);
102+
temperature = RTD_C[0] + RTD_C[1] * resistance + RTD_C[2] * pow(resistance, 2) -
103+
RTD_C[3] * pow(resistance, 3) - RTD_C[4] * pow(resistance, 4) +
104+
RTD_C[5] * pow(resistance, 5);
105105
return temperature;
106106
}
107107

drivers/sensor/maxim/max31865/max31865.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ LOG_MODULE_REGISTER(MAX31865, CONFIG_SENSOR_LOG_LEVEL);
7171
* For under zero, taken from
7272
* https://www.analog.com/media/en/technical-documentation/application-notes/AN709_0.pdf
7373
*/
74-
static const float A[6] = {-242.02, 2.2228, 2.5859e-3, 4.8260e-6, 2.8183e-8, 1.5243e-10};
74+
static const double RTD_C[6] = {-242.02, 2.2228, 2.5859e-3, 4.8260e-6, 2.8183e-8, 1.5243e-10};
7575

7676
struct max31865_data {
7777
double temperature;

0 commit comments

Comments
 (0)