You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/09/28 03:25:26 UTC
(nuttx) 03/04: feature: charge: Add battery operate
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 5238f2c200211171283c33be031130551e98d247
Author: liangdongdong <li...@xiaomi.com>
AuthorDate: Wed Oct 25 19:40:54 2023 +0800
feature: charge: Add battery operate
Signed-off-by: liangdongdong<li...@xiaomi.com>
---
drivers/power/battery/battery_gauge.c | 10 ++++++++++
include/nuttx/power/battery_gauge.h | 4 ++++
include/nuttx/power/battery_ioctl.h | 2 ++
3 files changed, 16 insertions(+)
diff --git a/drivers/power/battery/battery_gauge.c b/drivers/power/battery/battery_gauge.c
index 498654a404..442e29f133 100644
--- a/drivers/power/battery/battery_gauge.c
+++ b/drivers/power/battery/battery_gauge.c
@@ -354,6 +354,16 @@ static int bat_gauge_ioctl(FAR struct file *filep,
}
break;
+ case BATIOC_OPERATE:
+ {
+ FAR int *ptr = (FAR int *)((uintptr_t)arg);
+ if (ptr)
+ {
+ ret = dev->ops->operate(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 e0d9db905e..ee5a62d267 100644
--- a/include/nuttx/power/battery_gauge.h
+++ b/include/nuttx/power/battery_gauge.h
@@ -120,6 +120,10 @@ struct battery_gauge_operations_s
CODE int (*chipid)(FAR struct battery_gauge_dev_s *dev,
FAR unsigned int *value);
+
+ /* Do device specific operation */
+
+ CODE int (*operate)(FAR struct battery_gauge_dev_s *dev, FAR int *param);
};
/* 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 45dc694daa..0d9f71005e 100644
--- a/include/nuttx/power/battery_ioctl.h
+++ b/include/nuttx/power/battery_ioctl.h
@@ -146,6 +146,8 @@ enum batio_operate_e
BATIO_OPRTN_WDOG,
BATIO_OPRTN_SHIPMODE,
BATIO_OPRTN_CUTOFF_CURRENT,
+ BATIO_OPRTN_VBUS_STATE,
+ BATIO_OPRTN_CAPACITY,
BATIO_OPRTN_END
};