/* @cfg: NTC Thermistor configuration @sample_mv: Measured voltage in mV  */
uint32_t ntc_get_ohm_of_thermistor(const struct ntc_config *cfg, int sample_mv)
/* @cfg: NTC Thermistor configuration @sample_mv: Measured voltage in mV  */
uint32_t ntc_get_ohm_of_thermistor(const struct ntc_config *cfg, int sample_mv)
{
	int pullup_mv = cfg->pullup_uv / 1000;
	uint32_t ohm;
	if (sample_mv <= 0) {
		return cfg->connected_positive ? INT_MAX : 0;
	}
	if (sample_mv >= pullup_mv) {
		return cfg->connected_positive ? 0 : INT_MAX;
	}
	if (cfg->connected_positive) {
		ohm = cfg->pulldown_ohm * (pullup_mv - sample_mv) / sample_mv;
	} else {
		ohm = cfg->pullup_ohm * sample_mv / (pullup_mv - sample_mv);
	}
	return ohm;
}