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

[incubator-nuttx] branch master updated: power/battery: add baterr, batinfo, batwarn for debug log

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

gustavonihei 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 1ed4118  power/battery: add baterr, batinfo, batwarn for debug log
1ed4118 is described below

commit 1ed41183781aa818fac1835853ff584278915d7f
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Mon Oct 25 22:43:10 2021 +0800

    power/battery: add baterr, batinfo, batwarn for debug log
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 Kconfig                              | 31 +++++++++++++++++++++
 arch/arm/src/cxd56xx/Kconfig         | 17 ------------
 arch/arm/src/cxd56xx/cxd56_charger.c |  8 ------
 arch/arm/src/cxd56xx/cxd56_gauge.c   | 10 -------
 drivers/power/Kconfig                | 14 ----------
 drivers/power/bq2425x.c              | 12 +-------
 drivers/power/bq2429x.c              | 53 ++++++++++++++----------------------
 drivers/power/bq27426.c              | 18 ------------
 drivers/power/bq769x0.c              | 16 ++---------
 drivers/power/max1704x.c             |  8 ------
 drivers/power/mcp73871.c             | 10 -------
 include/debug.h                      | 18 ++++++++++++
 12 files changed, 73 insertions(+), 142 deletions(-)

diff --git a/Kconfig b/Kconfig
index b58deb8..126139e 100644
--- a/Kconfig
+++ b/Kconfig
@@ -931,6 +931,37 @@ config DEBUG_POWER_INFO
 
 endif # DEBUG_POWER
 
+config DEBUG_BATTERY
+	bool "Battery-related Debug Features"
+	default n
+	---help---
+		Enable Battery-related debug features.
+
+if DEBUG_BATTERY
+
+config DEBUG_BATTERY_ERROR
+	bool "Battery-related Error Output"
+	default n
+	depends on DEBUG_ERROR
+	---help---
+		Enable battery-related error output to SYSLOG.
+
+config DEBUG_BATTERY_WARN
+	bool "Battery-related Warnings Output"
+	default n
+	depends on DEBUG_WARN
+	---help---
+		Enable battery-related warning output to SYSLOG.
+
+config DEBUG_BATTERY_INFO
+	bool "Battery-related Informational Output"
+	default n
+	depends on DEBUG_INFO
+	---help---
+		Enable battery-related informational output to SYSLOG.
+
+endif # DEBUG_BATTERY
+
 config DEBUG_WIRELESS
 	bool "Wireless Debug Features"
 	default n
diff --git a/arch/arm/src/cxd56xx/Kconfig b/arch/arm/src/cxd56xx/Kconfig
index ef9b7e1..bc8d12b 100644
--- a/arch/arm/src/cxd56xx/Kconfig
+++ b/arch/arm/src/cxd56xx/Kconfig
@@ -276,16 +276,6 @@ config CXD56_GAUGE
 		Enable battery gauge driver.
 		This is not a lower half of power driver, but compatible with NuttX gauge driver.
 
-if CXD56_GAUGE
-
-config CXD56_GAUGE_DEBUG
-	bool "Battery Gauge Debug"
-	default n
-	---help---
-		Enable battery driver debug messages and debug IO command.
-
-endif
-
 config CXD56_CHARGER
 	bool "CXD5247 battery charger"
 	default n
@@ -303,13 +293,6 @@ config CXD56_CHARGER_TEMP_PRECISE
 		Get temperature precisely. If this option is enabled, driver calculate precisely
 		from register value to degrees Celsius.
 		This option requires libm.
-
-config CXD56_CHARGER_DEBUG
-	bool "Battery Charger Debug"
-	default n
-	---help---
-		Enable battery charger driver debug messages.
-
 endif
 
 comment "Peripheral Support"
diff --git a/arch/arm/src/cxd56xx/cxd56_charger.c b/arch/arm/src/cxd56xx/cxd56_charger.c
index b853ff2..2b5d74e 100644
--- a/arch/arm/src/cxd56xx/cxd56_charger.c
+++ b/arch/arm/src/cxd56xx/cxd56_charger.c
@@ -52,14 +52,6 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* Debug ********************************************************************/
-
-#ifdef CONFIG_CXD56_CHARGER_DEBUG
-#define baterr(fmt, ...) _err(fmt, ## __VA_ARGS__)
-#else
-#define baterr(fmt, ...)
-#endif
-
 /* Configuration */
 
 #ifdef CONFIG_CXD56_CHARGER_TEMP_PRECISE
diff --git a/arch/arm/src/cxd56xx/cxd56_gauge.c b/arch/arm/src/cxd56xx/cxd56_gauge.c
index 683b7fa..51b0bce 100644
--- a/arch/arm/src/cxd56xx/cxd56_gauge.c
+++ b/arch/arm/src/cxd56xx/cxd56_gauge.c
@@ -49,16 +49,6 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* Debug ********************************************************************/
-
-#ifdef CONFIG_CXD56_GAUGE_DEBUG
-#define baterr(fmt, ...)  _err(fmt, ## __VA_ARGS__)
-#define batinfo(fmt, ...) _info(fmt, ## __VA_ARGS__)
-#else
-#define baterr(fmt, ...)
-#define batinfo(fmt, ...)
-#endif
-
 /****************************************************************************
  * Private Types
  ****************************************************************************/
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index f71ca39..d45abb5 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -454,16 +454,6 @@ config BQ27426
 		It can be interrogated by a system processor to provide cell information,
 		such as state-of-charge (SOC).
 
-if BQ27426
-
-config DEBUG_BQ27426
-	bool "BQ27426 Debug Features"
-	default n
-	---help---
-		Enable BQ27426 battery management debug features.
-
-endif # BQ27426
-
 config I2C_BQ2425X
 	bool
 	default y if BQ2425X
@@ -499,10 +489,6 @@ config I2C_BQ769X0
 	default y if BQ769X0
 
 if BQ769X0
-	config DEBUG_BQ769X0
-		bool "BQ769X0 debug features"
-		default n
-
 	config BQ769X0_USE_INTERNAL_TS
 		bool "Use internal temperature sensor on BQ769X0"
 		default n
diff --git a/drivers/power/bq2425x.c b/drivers/power/bq2425x.c
index 6c2015b..38f7c83 100644
--- a/drivers/power/bq2425x.c
+++ b/drivers/power/bq2425x.c
@@ -59,16 +59,6 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* Debug ********************************************************************/
-
-#ifdef CONFIG_DEBUG_BQ2425X
-#  define baterr  _err
-#  define batreg  _err
-#else
-#  define baterr  _none
-#  define batreg  _none
-#endif
-
 /****************************************************************************
  * Private
  ****************************************************************************/
@@ -215,7 +205,7 @@ static int bq2425x_putreg8(FAR struct bq2425x_dev_s *priv, uint8_t regaddr,
   config.address   = priv->addr;
   config.addrlen   = 7;
 
-  batreg("addr: %02x regval: %08x\n", regaddr, regval);
+  batinfo("addr: %02x regval: %08x\n", regaddr, regval);
 
   /* Set up a 3 byte message to send */
 
diff --git a/drivers/power/bq2429x.c b/drivers/power/bq2429x.c
index d4d9523..418f883 100644
--- a/drivers/power/bq2429x.c
+++ b/drivers/power/bq2429x.c
@@ -97,18 +97,6 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* Debug ********************************************************************/
-
-#ifdef CONFIG_DEBUG_BQ2429X
-#  define baterr  _err
-#  define batdbg  _info
-#  define batinfo _info
-#else
-#  define baterr  _none
-#  define batdbg  _none
-#  define batinfo _none
-#endif
-
 /****************************************************************************
  * Private
  ****************************************************************************/
@@ -259,7 +247,7 @@ static int bq2429x_putreg8(FAR struct bq2429x_dev_s *priv, uint8_t regaddr,
   config.address   = priv->addr;
   config.addrlen   = 7;
 
-  batdbg("addr: %02x regval: %08x\n", regaddr, regval);
+  batinfo("addr: %02x regval: %08x\n", regaddr, regval);
 
   /* Set up a message to send */
 
@@ -278,28 +266,28 @@ static int (bq2429x_dump_regs) (FAR struct bq2429x_dev_s * priv)
   uint8_t value = 0;
 
   ret  = bq2429x_getreg8(priv, BQ2429X_REG00, &value, 1);
-  batdbg("REG#0: 0x%08X\n", value);
+  batinfo("REG#0: 0x%08X\n", value);
   ret |= bq2429x_getreg8(priv, BQ2429X_REG01, &value, 1);
-  batdbg("REG#1: 0x%08X\n", value);
+  batinfo("REG#1: 0x%08X\n", value);
   ret |= bq2429x_getreg8(priv, BQ2429X_REG02, &value, 1);
-  batdbg("REG#2: 0x%08X\n", value);
+  batinfo("REG#2: 0x%08X\n", value);
   ret |= bq2429x_getreg8(priv, BQ2429X_REG03, &value, 1);
-  batdbg("REG#3: 0x%08X\n", value);
+  batinfo("REG#3: 0x%08X\n", value);
   ret |= bq2429x_getreg8(priv, BQ2429X_REG04, &value, 1);
-  batdbg("REG#4: 0x%08X\n", value);
+  batinfo("REG#4: 0x%08X\n", value);
   ret |= bq2429x_getreg8(priv, BQ2429X_REG05, &value, 1);
-  batdbg("REG#5: 0x%08X\n", value);
+  batinfo("REG#5: 0x%08X\n", value);
   ret |= bq2429x_getreg8(priv, BQ2429X_REG06, &value, 1);
-  batdbg("REG#6: 0x%08X\n", value);
+  batinfo("REG#6: 0x%08X\n", value);
   ret |= bq2429x_getreg8(priv, BQ2429X_REG07, &value, 1);
-  batdbg("REG#7: 0x%08X\n", value);
+  batinfo("REG#7: 0x%08X\n", value);
   ret |= bq2429x_getreg8(priv, BQ2429X_REG08, &value, 1);
-  batdbg("REG#8: 0x%08X\n", value);
+  batinfo("REG#8: 0x%08X\n", value);
 
   /* Not reading fault register. */
 
   ret |= bq2429x_getreg8(priv, BQ2429X_REG0A, &value, 1);
-  batdbg("REG#10: 0x%08X\n", value);
+  batinfo("REG#10: 0x%08X\n", value);
 
   return ret;
 }
@@ -415,7 +403,7 @@ static int bq2429x_sysoff(FAR struct bq2429x_dev_s *priv)
   uint8_t value = 0;
 
   ret = bq2429x_getreg8(priv, BQ2429X_REG07, &value, 1);
-  batdbg("REG7 read value: 0x%08X\n", value);
+  batinfo("REG7 read value: 0x%08X\n", value);
   value |= BQ2429XR7_BATFET_DISABLE;
   ret |= bq2429x_putreg8(priv, BQ2429X_REG07, value);
 
@@ -436,7 +424,7 @@ static int bq2429x_syson(FAR struct bq2429x_dev_s *priv)
   uint8_t value = 0;
 
   ret = bq2429x_getreg8(priv, BQ2429X_REG07, &value, 1);
-  batdbg("REG7 read value: 0x%08X\n", value);
+  batinfo("REG7 read value: 0x%08X\n", value);
   value &= ~BQ2429XR7_BATFET_DISABLE;
   ret |= bq2429x_putreg8(priv, BQ2429X_REG07, value);
 
@@ -464,7 +452,7 @@ static int bq2429x_en_term(FAR struct bq2429x_dev_s *priv, bool state)
       return ret;
     }
 
-  batdbg("en_term: REG05 %02X EN_TERM=%d\n",
+  batinfo("en_term: REG05 %02X EN_TERM=%d\n",
          regval, !!(regval & BQ2429XR5_EN_TERM));
 
   /* Clear previous and set new value */
@@ -509,8 +497,8 @@ static int bq2429x_en_hiz(FAR struct bq2429x_dev_s *priv, bool state)
       return ret;
     }
 
-  batdbg("en_hiz: REG00 %02X EN_HIZ=%d\n",
-         regval, !!(regval & BQ2429XR1_EN_HIZ));
+  batinfo("en_hiz: REG00 %02X EN_HIZ=%d\n",
+          regval, !!(regval & BQ2429XR1_EN_HIZ));
 
   /* Clear previous and set new value */
 
@@ -553,8 +541,9 @@ static int bq2429x_en_stat(FAR struct bq2429x_dev_s *priv, bool state)
       return ret;
     }
 
-  batdbg("int stat: REG07 %02X INT_MASK1=%d INT_MASK0=%d\n", regval,
-         !!(regval & BQ2429XR7_INT_MASK1), !!(regval & BQ2429XR7_INT_MASK0));
+  batinfo("int stat: REG07 %02X INT_MASK1=%d INT_MASK0=%d\n", regval,
+          !!(regval & BQ2429XR7_INT_MASK1),
+          !!(regval & BQ2429XR7_INT_MASK0));
 
   /* We always set or clear both interrupts together. */
 
@@ -621,8 +610,8 @@ static int bq2429x_setboost_otg_config(FAR struct bq2429x_dev_s *priv,
     }
 
 #define BST_CONFIG_MASK (BQ2429XR1_CHG_CONFIG | BQ2429XR1_OTG_CONFIG)
-  batdbg("otg_config: REG01 %02X Boost=%d\n", regval,
-      ((BQ2429XR1_OTG_CONFIG == (regval & BST_CONFIG_MASK)) ? 1 : 0));
+  batinfo("otg_config: REG01 %02X Boost=%d\n", regval,
+          ((BQ2429XR1_OTG_CONFIG == (regval & BST_CONFIG_MASK)) ? 1 : 0));
 
   return OK;
 }
diff --git a/drivers/power/bq27426.c b/drivers/power/bq27426.c
index ce63008..f98ead0 100644
--- a/drivers/power/bq27426.c
+++ b/drivers/power/bq27426.c
@@ -55,24 +55,6 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* Debug ********************************************************************/
-
-#ifdef CONFIG_DEBUG_BQ27426
-#  define baterr  _err
-#  define batdbg  _info
-#  define batinfo _info
-#else
-#  ifdef CONFIG_CPP_HAVE_VARARGS
-#    define baterr(x...)
-#    define batdbg(x...)
-#    define batinfo(x...)
-#  else
-#    define baterr (void)
-#    define batdbg (void)
-#    define batinfo(void)
-#  endif
-#endif
-
 /****************************************************************************
  * Private
  ****************************************************************************/
diff --git a/drivers/power/bq769x0.c b/drivers/power/bq769x0.c
index 18eb773..145bdcc 100644
--- a/drivers/power/bq769x0.c
+++ b/drivers/power/bq769x0.c
@@ -74,18 +74,6 @@
 #define WR_ADDR(a)  ((a) << 1)
 #define RD_ADDR(a)  (((a) << 1) | 1)
 
-/* Debug ********************************************************************/
-
-#ifdef CONFIG_DEBUG_BQ769X0
-#  define baterr    _err
-#  define batreg    _err
-#  define batinfo   _info
-#else
-#  define baterr    _none
-#  define batreg    _none
-#  define batinfo   _none
-#endif
-
 /****************************************************************************
  * Private
  ****************************************************************************/
@@ -424,7 +412,7 @@ static int bq769x0_putreg8(FAR struct bq769x0_dev_s *priv, uint8_t regaddr,
   config.address   = priv->addr;
   config.addrlen   = 7;
 
-  batreg("addr: %02x regval: %02x\n", regaddr, regval);
+  batinfo("addr: %02x regval: %02x\n", regaddr, regval);
 
   /* Set up a 3 byte message to send */
 
@@ -440,7 +428,7 @@ static int bq769x0_putreg8(FAR struct bq769x0_dev_s *priv, uint8_t regaddr,
       crc = crc8ccittpart(&sl_addr, 1, 0);
       crc = crc8ccittpart(buffer, 2, crc);
       buffer[2] = crc;
-      batreg("write crc: %02x\n", crc);
+      batinfo("write crc: %02x\n", crc);
     }
   else
     {
diff --git a/drivers/power/max1704x.c b/drivers/power/max1704x.c
index a859b4a..42c2ccd 100644
--- a/drivers/power/max1704x.c
+++ b/drivers/power/max1704x.c
@@ -146,14 +146,6 @@
 
 #define MAX1407X_COMMAND_POR     0x5400
 
-/* Debug ********************************************************************/
-
-#ifdef CONFIG_DEBUG_MAX1704X
-#  define baterr  _err
-#else
-#  define baterr  _none
-#endif
-
 /****************************************************************************
  * Private
  ****************************************************************************/
diff --git a/drivers/power/mcp73871.c b/drivers/power/mcp73871.c
index 01b5dd8..d0fec76 100644
--- a/drivers/power/mcp73871.c
+++ b/drivers/power/mcp73871.c
@@ -55,16 +55,6 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* Debug ********************************************************************/
-
-#ifdef CONFIG_DEBUG_MCP73871
-#  define baterr  _err
-#  define batreg  _err
-#else
-#  define baterr  _none
-#  define batreg  _none
-#endif
-
 /****************************************************************************
  * Private
  ****************************************************************************/
diff --git a/include/debug.h b/include/debug.h
index 995020b..67660b3 100644
--- a/include/debug.h
+++ b/include/debug.h
@@ -250,6 +250,24 @@
 #  define pwrinfo      _none
 #endif
 
+#ifdef CONFIG_DEBUG_BATTERY_ERROR
+#  define baterr       _err
+#else
+#  define baterr       _none
+#endif
+
+#ifdef CONFIG_DEBUG_BATTERY_WARN
+#  define batwarn      _warn
+#else
+#  define batwarn      _none
+#endif
+
+#ifdef CONFIG_DEBUG_BATTERY_INFO
+#  define batinfo      _info
+#else
+#  define batinfo      _none
+#endif
+
 #ifdef CONFIG_DEBUG_WIRELESS_ERROR
 #  define wlerr       _err
 #else