zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.89k stars 6.63k forks source link

driver: sensor: ina23x: driver lacks critical rshunt value resolution when set in milliohms. #59862

Closed bperseghetti closed 1 year ago

bperseghetti commented 1 year ago

Describe the bug The INA23x driver does not allow setting of a rshunt value less than 1mOhm.

To Reproduce

  1. Try to set the rshunt-milliohms to <0.5> in an overlay for MIMXRT1062_FMURT6 board ex:

    &lpi2c1 {
    status = "okay";
    pinctrl-0 = <&pinmux_lpi2c1>;
    pinctrl-names = "default";
    clock-frequency = <I2C_BITRATE_FAST>;
    
    ina230: ina230@41 {
        compatible = "ti,ina230";
        reg = <0x41>;
        config = <INA230_CONFIG(INA230_OPER_MODE_SHUNT_BUS_VOLTAGE_CONT,
                                INA230_CONV_TIME_2116, 
                                INA230_CONV_TIME_2116, 
                                INA230_AVG_MODE_64)>;
        current-lsb-microamps = <5000>;
        rshunt-milliohms = <0.5>;
    };
    };
  2. Fails to compile as it is not an integer and milliohms does not have enough resolution.

Expected behavior Should allow setting value below 1 mOhm

Impact The driver eliminates the ability to use many standard VMU/FMU modules that range in 100-500 uOhm range. The lack of resolution on the rshunt Ohm value also eliminates the ability to "tune" to a resistors variance when using the TI documents example of 1mOhm.

henrikbrixandersen commented 1 year ago

Please use our bug template when reporting bugs. You need to edit this issue to include the information requested in https://github.com/zephyrproject-rtos/zephyr/blob/main/.github/ISSUE_TEMPLATE/001_bug_report.md

bperseghetti commented 1 year ago

Updated it, thanks.