You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2021/11/26 10:17:03 UTC

[incubator-nuttx] 02/02: feat: charger: add operation to get out voltage

This is an automated email from the ASF dual-hosted git repository.

aguettouche pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit b16eea4f14a50ff178baf6043a6f9d6d34f906b7
Author: zhangguoliang <zh...@xiaomi.com>
AuthorDate: Mon Nov 8 19:46:56 2021 +0800

    feat: charger: add operation to get out voltage
    
    Signed-off-by: zhangguoliang <zh...@xiaomi.com>
---
 drivers/power/battery_charger.c       | 10 ++++++++++
 include/nuttx/power/battery_charger.h |  4 ++++
 include/nuttx/power/battery_ioctl.h   |  1 +
 3 files changed, 15 insertions(+)

diff --git a/drivers/power/battery_charger.c b/drivers/power/battery_charger.c
index 35e883a..ea62a10 100644
--- a/drivers/power/battery_charger.c
+++ b/drivers/power/battery_charger.c
@@ -370,6 +370,16 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd,
         }
         break;
 
+      case BATIOC_GET_VOLTAGE:
+        {
+          FAR int *outvoltsp = (FAR int *)((uintptr_t)arg);
+          if (outvoltsp)
+            {
+              ret = dev->ops->get_voltage(dev, outvoltsp);
+            }
+        }
+        break;
+
       default:
         _err("ERROR: Unrecognized cmd: %d\n", cmd);
         ret = -ENOTTY;
diff --git a/include/nuttx/power/battery_charger.h b/include/nuttx/power/battery_charger.h
index 6829925..eee6348 100644
--- a/include/nuttx/power/battery_charger.h
+++ b/include/nuttx/power/battery_charger.h
@@ -122,6 +122,10 @@ struct battery_charger_operations_s
   /* Get chip id */
 
   int (*chipid)(struct battery_charger_dev_s *dev, unsigned int *value);
+
+  /* Get the actual output voltage for charging */
+
+  int (*get_voltage)(struct battery_charger_dev_s *dev, int *value);
 };
 
 /* This structure defines the battery driver state structure */
diff --git a/include/nuttx/power/battery_ioctl.h b/include/nuttx/power/battery_ioctl.h
index 6aa9b7d..90be461 100644
--- a/include/nuttx/power/battery_ioctl.h
+++ b/include/nuttx/power/battery_ioctl.h
@@ -55,6 +55,7 @@
 #define BATIOC_CLEARFAULTS   _BATIOC(0x000F)
 #define BATIOC_COULOMBS      _BATIOC(0x0010)
 #define BATIOC_CHIPID        _BATIOC(0x0011)
+#define BATIOC_GET_VOLTAGE   _BATIOC(0x0012)
 
 /* Special input values for BATIOC_INPUT_CURRENT that may optionally
  * be supported by lower-half driver: