- Notifications
You must be signed in to change notification settings - Fork 8.2k
Description
Describe the bug
#87988 introduced a zero-current-offset, useful for hall sensors.
#95588 then rewrote the conversion algorithm from milliamps to microamps and forgot to include said zero-current-offset, breaking all peripherals that use said offset.
For my device, I use a CC6920BSO-5A, which has a sensitivity of 264 mA/V.
I use the following device tree node:
curr_sens: curr_sens { compatible = "current-sense-amplifier"; io-channels = <&adc1 0>; sense-resistor-milli-ohms = <1>; sense-gain-mult = <264>; zero-current-voltage-mv = <1650>; }; I consume about 1.1A and get the following debug output:
[00:00:05.420,000] <inf> current_amp: 1667/4095, 1343041 uV, current:5087276 uA u I then patched current_sense_amplifier_scale_ua_dt and added:
temp = temp - 1000 * (int64_t)(spec->zero_current_voltage_mv);... and now it works:
[00:00:21.368,000] <inf> current_amp: 1664/4095, 1340625 uV, current:-1171875 uA Regression
- This is a regression.
Steps to reproduce
Not that easy, I don't know of a dev board with a built in hall sensor. It's very trivial to reproduce logically, the offset calculation in current_sense_amplifier_scale_dt is simply missing in current_sense_amplifier_scale_ua_dt.
Relevant log output
Impact
Functional Limitation – Some features not working as expected, but system usable.
Environment
Zephyr v4.3.0
Additional Context
No response