diff options
-rw-r--r-- | driver/temp_sensor/thermistor.c | 39 | ||||
-rw-r--r-- | driver/temp_sensor/thermistor.h | 18 | ||||
-rw-r--r-- | include/config.h | 1 |
3 files changed, 57 insertions, 1 deletions
diff --git a/driver/temp_sensor/thermistor.c b/driver/temp_sensor/thermistor.c index 15295a00ea..25ff819321 100644 --- a/driver/temp_sensor/thermistor.c +++ b/driver/temp_sensor/thermistor.c @@ -65,7 +65,8 @@ int thermistor_linear_interpolate(uint16_t mv, #if defined(CONFIG_STEINHART_HART_3V3_51K1_47K_4050B) || \ defined(CONFIG_STEINHART_HART_3V3_13K7_47K_4050B) || \ - defined(CONFIG_STEINHART_HART_6V0_51K1_47K_4050B) + defined(CONFIG_STEINHART_HART_6V0_51K1_47K_4050B) || \ + defined(CONFIG_STEINHART_HART_3V0_22K6_47K_4050B) static int thermistor_get_temperature(int idx_adc, int *temp_ptr, const struct thermistor_info *info) { @@ -196,3 +197,39 @@ int get_temp_6v0_51k1_47k_4050b(int idx_adc, int *temp_ptr) &thermistor_info_6v0_51_47); } #endif /* CONFIG_STEINHART_HART_6V0_51K1_47K_4050B */ + +#ifdef CONFIG_STEINHART_HART_3V0_22K6_47K_4050B +/* + * Data derived from Steinhart-Hart equation in a resistor divider circuit with + * Vdd=3000mV, R = 22.6Kohm, and thermistor (B = 4050, T0 = 298.15 K, nominal + * resistance (R0) = 47Kohm). + */ +#define THERMISTOR_SCALING_FACTOR_22_47 11 +static const struct thermistor_data_pair thermistor_data_22_47[] = { + { 2625 / THERMISTOR_SCALING_FACTOR_22_47, 0 }, + { 2425 / THERMISTOR_SCALING_FACTOR_22_47, 10 }, + { 2170 / THERMISTOR_SCALING_FACTOR_22_47, 20 }, + { 1875 / THERMISTOR_SCALING_FACTOR_22_47, 30 }, + { 1563 / THERMISTOR_SCALING_FACTOR_22_47, 40 }, + { 1263 / THERMISTOR_SCALING_FACTOR_22_47, 50 }, + { 995 / THERMISTOR_SCALING_FACTOR_22_47, 60 }, + { 770 / THERMISTOR_SCALING_FACTOR_22_47, 70 }, + { 589 / THERMISTOR_SCALING_FACTOR_22_47, 80 }, + { 514 / THERMISTOR_SCALING_FACTOR_22_47, 85 }, + { 448 / THERMISTOR_SCALING_FACTOR_22_47, 90 }, + { 391 / THERMISTOR_SCALING_FACTOR_22_47, 95 }, + { 341 / THERMISTOR_SCALING_FACTOR_22_47, 100 }, +}; + +static const struct thermistor_info thermistor_info_22_47 = { + .scaling_factor = THERMISTOR_SCALING_FACTOR_22_47, + .num_pairs = ARRAY_SIZE(thermistor_data_22_47), + .data = thermistor_data_22_47, +}; + +int get_temp_3v0_22k6_47k_4050b(int idx_adc, int *temp_ptr) +{ + return thermistor_get_temperature(idx_adc, temp_ptr, + &thermistor_info_22_47); +} +#endif /* CONFIG_STEINHART_HART_3V0_22K6_47K_4050B */ diff --git a/driver/temp_sensor/thermistor.h b/driver/temp_sensor/thermistor.h index 1874188b60..5ba338f40f 100644 --- a/driver/temp_sensor/thermistor.h +++ b/driver/temp_sensor/thermistor.h @@ -111,4 +111,22 @@ int get_temp_3v3_51k1_47k_4050b(int idx_adc, int *temp_ptr); int get_temp_6v0_51k1_47k_4050b(int idx_adc, int *temp_ptr); #endif +#ifdef CONFIG_STEINHART_HART_3V0_22K6_47K_4050B +/** + * Reads the specified ADC channel and uses a lookup table and interpolation to + * return a temperature in degrees K. + * + * The lookup table is based off of a resistor divider circuit on 3V with a + * 22.6K resistor in series with a thermistor with nominal value of 47K (at 25C) + * and a B (25/100) value of 4050. + * + * @param idx_adc The idx value from the temp_sensor_t struct, which is + * the ADC channel to read and convert to degrees K + * @param temp_ptr Destination for temperature (in degrees K) + * + * @return EC_SUCCESS, or non-zero if error. + */ +int get_temp_3v0_22k6_47k_4050b(int idx_adc, int *temp_ptr); +#endif + #endif /* __CROS_EC_TEMP_SENSOR_THERMISTOR_NCP15WB_H */ diff --git a/include/config.h b/include/config.h index 67b1b7a1dd..e7dc4e8da2 100644 --- a/include/config.h +++ b/include/config.h @@ -3148,6 +3148,7 @@ * thermistor ADC readings into degrees K based off of various circuit * configurations. */ +#undef CONFIG_STEINHART_HART_3V0_22K6_47K_4050B #undef CONFIG_STEINHART_HART_3V3_13K7_47K_4050B #undef CONFIG_STEINHART_HART_3V3_51K1_47K_4050B #undef CONFIG_STEINHART_HART_6V0_51K1_47K_4050B |