mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
feature: charge: modify battery_gauge code
CHAMPION-137 1.add temperature and current ioctl api Signed-off-by: weizhifang <weizhifang@xiaomi.com> Change-Id: I958f37aa385d942b24a44c696a7b8d5c45d3b9c5
This commit is contained in:
@@ -201,6 +201,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;
|
||||
|
||||
@@ -109,6 +109,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 */
|
||||
|
||||
Reference in New Issue
Block a user