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

masayuki 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 77bc1d1  power/battery: Move the enumurate to the common place
77bc1d1 is described below

commit 77bc1d1bdfd1312270d3b4f556bbe08cfb151c27
Author: Xiang Xiao <[email protected]>
AuthorDate: Wed Sep 29 12:03:20 2021 +0800

    power/battery: Move the enumurate to the common place
    
    so the userspace program can handle the different battery driver equally
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 arch/arm/src/cxd56xx/cxd56_charger.c  | 16 ++++++-------
 arch/arm/src/cxd56xx/cxd56_gauge.c    |  6 ++---
 include/nuttx/power/battery_charger.h | 44 ++++-------------------------------
 include/nuttx/power/battery_gauge.h   | 15 ++----------
 include/nuttx/power/battery_ioctl.h   | 39 +++++++++++++++++++++++++++++++
 include/nuttx/power/battery_monitor.h | 44 ++++-------------------------------
 6 files changed, 61 insertions(+), 103 deletions(-)

diff --git a/arch/arm/src/cxd56xx/cxd56_charger.c 
b/arch/arm/src/cxd56xx/cxd56_charger.c
index 1bd3970..b853ff2 100644
--- a/arch/arm/src/cxd56xx/cxd56_charger.c
+++ b/arch/arm/src/cxd56xx/cxd56_charger.c
@@ -79,8 +79,8 @@ struct charger_dev_s
  * Private Function Prototypes
  ****************************************************************************/
 
-static int charger_get_status(FAR enum battery_charger_status_e *status);
-static int charger_get_health(FAR enum battery_charger_health_e *health);
+static int charger_get_status(FAR enum battery_status_e *status);
+static int charger_get_health(FAR enum battery_health_e *health);
 static int charger_online(FAR bool *online);
 static int charger_get_temptable(FAR struct battery_temp_table_s *table);
 static int charger_set_temptable(FAR struct battery_temp_table_s *table);
@@ -210,7 +210,7 @@ static int charger_therm2temp(int val)
  * Name: charger_get_status
  ****************************************************************************/
 
-static int charger_get_status(FAR enum battery_charger_status_e *status)
+static int charger_get_status(FAR enum battery_status_e *status)
 {
   uint8_t state;
   int ret;
@@ -269,7 +269,7 @@ static int charger_get_status(FAR enum 
battery_charger_status_e *status)
  * Name: charger_get_health
  ****************************************************************************/
 
-static int charger_get_health(FAR enum battery_charger_health_e *health)
+static int charger_get_health(FAR enum battery_health_e *health)
 {
   FAR struct pmic_gauge_s gauge;
   uint8_t state;
@@ -495,16 +495,16 @@ static int charger_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
     {
       case BATIOC_STATE:
         {
-          FAR enum battery_charger_status_e *status =
-            (FAR enum battery_charger_status_e *)(uintptr_t)arg;
+          FAR enum battery_status_e *status =
+            (FAR enum battery_status_e *)(uintptr_t)arg;
           ret = charger_get_status(status);
         }
         break;
 
       case BATIOC_HEALTH:
         {
-          FAR enum battery_charger_health_e *health =
-            (FAR enum battery_charger_health_e *)(uintptr_t)arg;
+          FAR enum battery_health_e *health =
+            (FAR enum battery_health_e *)(uintptr_t)arg;
           ret = charger_get_health(health);
         }
         break;
diff --git a/arch/arm/src/cxd56xx/cxd56_gauge.c 
b/arch/arm/src/cxd56xx/cxd56_gauge.c
index 769838a..683b7fa 100644
--- a/arch/arm/src/cxd56xx/cxd56_gauge.c
+++ b/arch/arm/src/cxd56xx/cxd56_gauge.c
@@ -111,7 +111,7 @@ static struct bat_gauge_dev_s g_gaugedev;
  * Name: gauge_get_status
  ****************************************************************************/
 
-static int gauge_get_status(FAR enum battery_gauge_status_e *status)
+static int gauge_get_status(FAR enum battery_status_e *status)
 {
   uint8_t state;
   int ret;
@@ -325,8 +325,8 @@ static int gauge_ioctl(FAR struct file *filep, int cmd, 
unsigned long arg)
     {
       case BATIOC_STATE:
         {
-          FAR enum battery_gauge_status_e *status =
-            (FAR enum battery_gauge_status_e *)(uintptr_t)arg;
+          FAR enum battery_status_e *status =
+            (FAR enum battery_status_e *)(uintptr_t)arg;
           ret = gauge_get_status(status);
         }
         break;
diff --git a/include/nuttx/power/battery_charger.h 
b/include/nuttx/power/battery_charger.h
index 692f3ab..bd841b1 100644
--- a/include/nuttx/power/battery_charger.h
+++ b/include/nuttx/power/battery_charger.h
@@ -61,10 +61,10 @@
  * lower half as summarized below:
  *
  * BATIOC_STATE - Return the current state of the battery (see
- *   enum battery_charger_status_e).
+ *   enum battery_status_e).
  *   Input value:  A pointer to type int.
  * BATIOC_HEALTH - Return the current health of the battery (see
- *   enum battery_charger_health_e).
+ *   enum battery_health_e).
  *   Input value:  A pointer to type int.
  * BATIOC_ONLINE - Return 1 if the battery is online; 0 if offline.
  *   Input value:  A pointer to type bool.
@@ -79,54 +79,20 @@
  *                 batio_operate_msg_s.
  */
 
-/* Special input values for BATIOC_INPUT_CURRENT that may optionally
- * be supported by lower-half driver:
- */
-
-#define BATTERY_INPUT_CURRENT_EXT_LIM   (-1) /* External input current limit */
-
 /****************************************************************************
  * Public Types
  ****************************************************************************/
 
-/* Battery status */
-
-enum battery_charger_status_e
-{
-  BATTERY_UNKNOWN = 0, /* Battery state is not known */
-  BATTERY_FAULT,       /* Charger reported a fault, get health for more info */
-  BATTERY_IDLE,        /* Not full, not charging, not discharging */
-  BATTERY_FULL,        /* Full, not discharging */
-  BATTERY_CHARGING,    /* Not full, charging */
-  BATTERY_DISCHARGING  /* Probably not full, discharging */
-};
-
-/* Battery Health status */
-
-enum battery_charger_health_e
-{
-  BATTERY_HEALTH_UNKNOWN = 0,  /* Battery health state is not known */
-  BATTERY_HEALTH_GOOD,         /* Battery is in good condiction */
-  BATTERY_HEALTH_DEAD,         /* Battery is dead, nothing we can do */
-  BATTERY_HEALTH_OVERHEAT,     /* Battery is over recommended temperature */
-  BATTERY_HEALTH_OVERVOLTAGE,  /* Battery voltage is over recommended level */
-  BATTERY_HEALTH_UNSPEC_FAIL,  /* Battery charger reported an unspected 
failure */
-  BATTERY_HEALTH_COLD,         /* Battery is under recommended temperature */
-  BATTERY_HEALTH_WD_TMR_EXP,   /* Battery WatchDog Timer Expired */
-  BATTERY_HEALTH_SAFE_TMR_EXP, /* Battery Safety Timer Expired */
-  BATTERY_HEALTH_DISCONNECTED  /* Battery is not connected */
-};
-
-  /* This structure defines the lower half battery interface */
+/* This structure defines the lower half battery interface */
 
 struct battery_charger_dev_s;
 struct battery_charger_operations_s
 {
-  /* Return the current battery state (see enum battery_charger_status_e) */
+  /* Return the current battery state (see enum battery_status_e) */
 
   int (*state)(struct battery_charger_dev_s *dev, int *status);
 
-  /* Return the current battery health (see enum battery_charger_health_e) */
+  /* Return the current battery health (see enum battery_health_e) */
 
   int (*health)(struct battery_charger_dev_s *dev, int *health);
 
diff --git a/include/nuttx/power/battery_gauge.h 
b/include/nuttx/power/battery_gauge.h
index de76252..f03ce6c 100644
--- a/include/nuttx/power/battery_gauge.h
+++ b/include/nuttx/power/battery_gauge.h
@@ -61,7 +61,7 @@
  * lower half as summarized below:
  *
  * BATIOC_STATE - Return the current state of the battery (see
- *   enum battery_gauge_status_e).
+ *   enum battery_status_e).
  *   Input value:  A pointer to type int.
  * BATIOC_ONLINE - Return 1 if the battery is online; 0 if offline.
  *   Input value:  A pointer to type bool.
@@ -78,23 +78,12 @@
  * Public Types
  ****************************************************************************/
 
-/* Battery status */
-
-enum battery_gauge_status_e
-{
-  BATTERY_UNKNOWN = 0, /* Battery state is not known */
-  BATTERY_IDLE,        /* Not full, not charging, not discharging */
-  BATTERY_FULL,        /* Full, not discharging */
-  BATTERY_CHARGING,    /* Not full, charging */
-  BATTERY_DISCHARGING  /* Probably not full, discharging */
-};
-
 /* This structure defines the lower half battery interface */
 
 struct battery_gauge_dev_s;
 struct battery_gauge_operations_s
 {
-  /* Return the current battery state (see enum battery_gauge_status_e) */
+  /* Return the current battery state (see enum battery_status_e) */
 
   int (*state)(struct battery_gauge_dev_s *dev, int *status);
 
diff --git a/include/nuttx/power/battery_ioctl.h 
b/include/nuttx/power/battery_ioctl.h
index 380b864..df91d56 100644
--- a/include/nuttx/power/battery_ioctl.h
+++ b/include/nuttx/power/battery_ioctl.h
@@ -55,10 +55,49 @@
 #define BATIOC_CLEARFAULTS   _BATIOC(0x000F)
 #define BATIOC_COULOMBS      _BATIOC(0x0010)
 
+/* Special input values for BATIOC_INPUT_CURRENT that may optionally
+ * be supported by lower-half driver:
+ */
+
+#define BATTERY_INPUT_CURRENT_EXT_LIM   (-1) /* External input current limit */
+
 /****************************************************************************
  * Public Types
  ****************************************************************************/
 
+/* Battery status */
+
+enum battery_status_e
+{
+  BATTERY_UNKNOWN = 0, /* Battery state is not known */
+  BATTERY_FAULT,       /* Charger reported a fault, get health for more info */
+  BATTERY_IDLE,        /* Not full, not charging, not discharging */
+  BATTERY_FULL,        /* Full, not discharging */
+  BATTERY_CHARGING,    /* Not full, charging */
+  BATTERY_DISCHARGING  /* Probably not full, discharging */
+};
+
+/* Battery Health status */
+
+enum battery_health_e
+{
+  BATTERY_HEALTH_UNKNOWN = 0,   /* Battery health state is not known */
+  BATTERY_HEALTH_GOOD,          /* Battery is in good condiction */
+  BATTERY_HEALTH_DEAD,          /* Battery is dead, nothing we can do */
+  BATTERY_HEALTH_OVERHEAT,      /* Battery is over recommended temperature */
+  BATTERY_HEALTH_OVERVOLTAGE,   /* Battery voltage is over recommended level */
+  BATTERY_HEALTH_UNDERVOLTAGE,  /* Battery monitor reported an unspecified 
failure */
+  BATTERY_HEALTH_OVERCURRENT,   /* Battery monitor reported an overcurrent 
event */
+  BATTERY_HEALTH_SHORT_CIRCUIT, /* Battery monitor reported a short circuit 
event */
+  BATTERY_HEALTH_UNSPEC_FAIL,   /* Battery charger reported an unspected 
failure */
+  BATTERY_HEALTH_COLD,          /* Battery is under recommended temperature */
+  BATTERY_HEALTH_WD_TMR_EXP,    /* Battery WatchDog Timer Expired */
+  BATTERY_HEALTH_SAFE_TMR_EXP,  /* Battery Safety Timer Expired */
+  BATTERY_HEALTH_DISCONNECTED   /* Battery is not connected */
+};
+
+/* Battery operation message */
+
 struct batio_operate_msg_s
 {
   uint8_t operate_type; /* Really enum batio_operate_e */
diff --git a/include/nuttx/power/battery_monitor.h 
b/include/nuttx/power/battery_monitor.h
index c6f0e7c..8239c6c 100644
--- a/include/nuttx/power/battery_monitor.h
+++ b/include/nuttx/power/battery_monitor.h
@@ -62,10 +62,10 @@
  * lower half as summarized below:
  *
  * BATIOC_STATE - Return the current state of the battery (see
- *   enum battery_monitor_status_e).
+ *   enum battery_status_e).
  *   Input value:  A pointer to type int.
  * BATIOC_HEALTH - Return the current health of the battery (see
- *   enum battery_monitor_health_e).
+ *   enum battery_health_e).
  *   Input value:  A pointer to type int.
  * BATIOC_ONLINE - Return 1 if the battery is online; 0 if offline.
  *   Input value:  A pointer to type bool.
@@ -101,46 +101,10 @@
  *   batio_operate_msg_s.
  */
 
-/* Special input values for BATIOC_INPUT_CURRENT that may optionally
- * be supported by lower-half driver:
- */
-
-#define BATTERY_INPUT_CURRENT_EXT_LIM   (-1) /* External input current limit */
-
 /****************************************************************************
  * Public Types
  ****************************************************************************/
 
-/* Battery status */
-
-enum battery_monitor_status_e
-{
-  BATTERY_UNKNOWN = 0, /* Battery state is not known */
-  BATTERY_FAULT,       /* Charger reported a fault, get health for more info */
-  BATTERY_IDLE,        /* Not full, not charging, not discharging */
-  BATTERY_FULL,        /* Full, not discharging */
-  BATTERY_CHARGING,    /* Not full, charging */
-  BATTERY_DISCHARGING  /* Probably not full, discharging */
-};
-
-/* Battery Health status */
-
-enum battery_monitor_health_e
-{
-  BATTERY_HEALTH_UNKNOWN = 0,   /* Battery health state is not known */
-  BATTERY_HEALTH_GOOD,          /* Battery is in good condition */
-  BATTERY_HEALTH_DEAD,          /* Battery is dead, nothing we can do */
-  BATTERY_HEALTH_OVERHEAT,      /* Battery is over recommended temperature */
-  BATTERY_HEALTH_OVERVOLTAGE,   /* Battery voltage is over recommended level */
-  BATTERY_HEALTH_UNDERVOLTAGE,  /* Battery monitor reported an unspecified 
failure */
-  BATTERY_HEALTH_OVERCURRENT,   /* Battery monitor reported an overcurrent 
event */
-  BATTERY_HEALTH_SHORT_CIRCUIT, /* Battery monitor reported a short circuit 
event */
-  BATTERY_HEALTH_UNSPEC_FAIL,   /* Battery monitor reported an unspecified 
failure */
-  BATTERY_HEALTH_COLD,          /* Battery is under recommended temperature */
-  BATTERY_HEALTH_WD_TMR_EXP,    /* Battery WatchDog Timer Expired */
-  BATTERY_HEALTH_DISCONNECTED   /* Battery is not connected */
-};
-
 struct battery_monitor_voltage_s
 {
   /* Before call, contains the desired number of cells to read.
@@ -254,11 +218,11 @@ struct battery_monitor_dev_s;
 
 struct battery_monitor_operations_s
 {
-  /* Return the current battery state (see enum battery_monitor_status_e) */
+  /* Return the current battery state (see enum battery_status_e) */
 
   int (*state)(struct battery_monitor_dev_s *dev, int *status);
 
-  /* Return the current battery health (see enum battery_monitor_health_e) */
+  /* Return the current battery health (see enum battery_health_e) */
 
   int (*health)(struct battery_monitor_dev_s *dev, int *health);
 

Reply via email to