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


The following commit(s) were added to refs/heads/master by this push:
     new 2a6673bc feature: charge: modify battery_gauge code
2a6673bc is described below

commit 2a6673bcddb5c0f51aef933c3bf8c5f84bc0bd3b
Author: weizhifang <weizhif...@xiaomi.com>
AuthorDate: Sat Sep 18 14:06:16 2021 +0800

    feature: charge: modify battery_gauge code
    
    add temperature and current ioctl api
    
    Signed-off-by: weizhifang <weizhif...@xiaomi.com>
---
 drivers/power/battery_gauge.c       | 20 ++++++++++++++++++++
 include/nuttx/power/battery_gauge.h |  8 ++++++++
 2 files changed, 28 insertions(+)

diff --git a/drivers/power/battery_gauge.c b/drivers/power/battery_gauge.c
index 66fe97b..2f6ea83 100644
--- a/drivers/power/battery_gauge.c
+++ b/drivers/power/battery_gauge.c
@@ -328,6 +328,26 @@ static int bat_gauge_ioctl(FAR struct file *filep,
         }
         break;
 
+        case BATIOC_CURRENT:
+        {
+          FAR b16_t *ptr = (FAR b16_t *)((uintptr_t)arg);
+          if (ptr)
+            {
+              ret = dev->ops->current(dev, ptr);
+            }
+        }
+        break;
+
+        case BATIOC_TEMPERATURE:
+        {
+          FAR b8_t *ptr = (FAR b8_t *)((uintptr_t)arg);
+          if (ptr)
+            {
+              ret = dev->ops->temp(dev, ptr);
+            }
+        }
+        break;
+
       default:
         _err("ERROR: Unrecognized cmd: %d\n", cmd);
         ret = -ENOTTY;
diff --git a/include/nuttx/power/battery_gauge.h 
b/include/nuttx/power/battery_gauge.h
index c1e074f..5fa2fd4 100644
--- a/include/nuttx/power/battery_gauge.h
+++ b/include/nuttx/power/battery_gauge.h
@@ -99,6 +99,14 @@ struct battery_gauge_operations_s
   /* Battery capacity */
 
   int (*capacity)(struct battery_gauge_dev_s *dev, b16_t *value);
+
+  /* Battery current */
+
+  int (*current)(struct battery_gauge_dev_s *dev, b16_t *value);
+
+  /* Battery temp */
+
+  int (*temp)(struct battery_gauge_dev_s *dev, b8_t *value);
 };
 
 /* This structure defines the battery driver state structure */

Reply via email to