itshusky01 opened a new issue, #20094:
URL: https://github.com/apache/nuttx/issues/20094

   ### Is your feature request related to a problem? Please describe.
   
   The uORB sensor framework has no topic types for electrical
   measurements (voltage, current, power). Power monitors such as INA219,
   INA226, INA3221 and LTC4151 can therefore only use the legacy drivers,
   which are marked deprecated ("WARNING for developers" in the source
   tree).
   
   Practical bug hit while using INA226 on a bitbanged I2C bus: the
   legacy `ina226_access()` leaves `msg[].frequency` uninitialized on
   the second message; the bitbang controller derives its timing from
   `msg->frequency`, stalling the boot with ~121 ms per SCL edge.
   Hardware I2C controllers ignore per-message frequency, which is why
   it was never caught. The legacy driver is deprecated and frozen,
   so instead of patching it we propose a replacement written against
   the current sensor framework.
   
   This RFC requests feedback before implementation, since it touches
   the framework type space (`include/nuttx/uorb.h`).
   
   ### Describe the solution you'd like
   
   1. `include/nuttx/uorb.h`: add `SENSOR_TYPE_VOLTAGE`,
      `SENSOR_TYPE_CURRENT` and `SENSOR_TYPE_POWER`, bump
      `SENSOR_TYPE_COUNT`, and add message structs following the
      `struct sensor_temp` pattern, e.g.:
   
      ```c
      struct sensor_voltage
      {
        float value;      /* Bus voltage, unit: V */
        uint64_t timestamp;
      };
   
      struct sensor_current
      {
        float value;      /* Current, unit: A */
        uint64_t timestamp;
      };
   
      struct sensor_power
      {
        float value;      /* Power, unit: W */
        uint64_t timestamp;
      };
   
   2. drivers/sensors/ina226_uorb.c: implement sensor_lowerhalf_s
   (activate / fetch / set_interval / selftest), one instance per
   device, publishing bus voltage, current and power.
   
   3. Kconfig option (SENSORS_INA226_UORB), build wiring and docs.
   
   ### Describe alternatives you've considered
   
   Open questions — maintainer feedback requested before implementation:
   
   1. One topic per quantity vs. a single combined power-monitor topic?
      (PX4 uses a combined `battery_status` carrying voltage + current.)
   
   2. Type namespace: `SENSOR_TYPE_*` already includes electrical
      parameters such as `SENSOR_TYPE_CAP` and `SENSOR_TYPE_IMPEDANCE`.
      Default proposal is to extend `SENSOR_TYPE_*`; a separate
      power-monitoring topic family is possible but more invasive.
   
   3. Include shunt voltage as well, or only V/I/P?
   
   4. Alternative: keep using the legacy char device and fix the I2C
      frequency bug in place. Rejected because the legacy driver is
      already marked deprecated and frozen.
   
   ### Verification
   
   - [x] I have verified before submitting the report.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to