/* If INA233 skips current/power, shunt-resistor and current-lsb aren't needed. */ /* read rshunt value (uOhm) */
ret = device_property_read_u32(dev, "shunt-resistor", &rshunt); if (ret) { if (ret != -EINVAL) return dev_err_probe(dev, ret, "Shunt resistor property read fail.\n");
rshunt = INA233_RSHUNT_DEFAULT;
} if (!rshunt) return dev_err_probe(dev, -EINVAL, "Shunt resistor cannot be zero.\n");
/* read Maximum expected current value (uA) */
ret = device_property_read_u32(dev, "ti,maximum-expected-current-microamp", &max_current); if (ret) { if (ret != -EINVAL) return dev_err_probe(dev, ret, "Maximum expected current property read fail.\n");
max_current = INA233_MAX_CURRENT_DEFAULT;
} if (max_current < 32768) return dev_err_probe(dev, -EINVAL, "Maximum expected current cannot less then 32768.\n");
/* Calculate Current_LSB according to the spec formula */
current_lsb = max_current / 32768;
/* calculate current coefficient */
calculate_coef(&m, &R, current_lsb, 1);
info->m[PSC_CURRENT_OUT] = m;
info->R[PSC_CURRENT_OUT] = R;
/* calculate power coefficient */
calculate_coef(&m, &R, current_lsb, 25);
info->m[PSC_POWER] = m;
info->R[PSC_POWER] = R;
/* write MFR_CALIBRATION register, Apply formula from spec with unit scaling. */
calibration = div64_u64(5120000000ULL, (u64)rshunt * current_lsb); if (calibration > 0x7FFF) return dev_err_probe(dev, -EINVAL, "Product of Current_LSB %u and shunt resistor %u too small, MFR_CALIBRATION reg exceeds 0x7FFF.\n",
current_lsb, rshunt);
ret = i2c_smbus_write_word_data(client, MFR_CALIBRATION, calibration); if (ret < 0) return dev_err_probe(dev, ret, "Unable to write calibration.\n");
MODULE_AUTHOR("Leo Yang <leo.yang.sy0@gmail.com>");
MODULE_DESCRIPTION("PMBus driver for INA233 and compatible chips");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS("PMBUS");
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.