diff --git a/Kconfig b/Kconfig index 56def76b1d..74dd7cfc00 100644 --- a/Kconfig +++ b/Kconfig @@ -1081,14 +1081,40 @@ config DEBUG_GPIO_INFO endif # DEBUG_GPIO config DEBUG_I2C - bool "I2C Debug Output" + bool "I2C Debug Features" default n depends on I2C ---help--- - Enable I2C driver debug SYSLOG output (disabled by default). + Enable I2C debug features. + Support for this debug option is architecture-specific and may not be available for some MCUs. +if DEBUG_I2C + +config DEBUG_I2C_ERROR + bool "I2C Error Output" + default n + depends on DEBUG_ERROR + ---help--- + Enable I2C driver error output to SYSLOG. + +config DEBUG_I2C_WARN + bool "I2C Warnings Output" + default n + depends on DEBUG_WARN + ---help--- + Enable I2C drive warning output to SYSLOG. + +config DEBUG_I2C_INFO + bool "I2C Informational Output" + default n + depends on DEBUG_INFO + ---help--- + Enable I2C drive informational output to SYSLOG. + +endif # DEBUG_I2C + config DEBUG_I2S bool "I2S Debug Output" default n diff --git a/arch/arm/src/efm32/efm32_i2c.c b/arch/arm/src/efm32/efm32_i2c.c index f12118f512..c139ea012a 100644 --- a/arch/arm/src/efm32/efm32_i2c.c +++ b/arch/arm/src/efm32/efm32_i2c.c @@ -134,16 +134,6 @@ /* Debug ****************************************************************************/ -/* CONFIG_DEBUG_I2C + CONFIG_DEBUG_FEATURES enables general I2C debug output. */ - -#ifdef CONFIG_DEBUG_I2C -# define i2cerr err -# define i2cinfo info -#else -# define i2cerr(x...) -# define i2cinfo(x...) -#endif - /* I2C event trace logic. NOTE: trace uses the internal, non-standard, * low-level debug interface syslog() but does not require that any other debug * is enabled. diff --git a/arch/arm/src/sam34/sam_twi.c b/arch/arm/src/sam34/sam_twi.c index dcf324770b..a91d9af815 100644 --- a/arch/arm/src/sam34/sam_twi.c +++ b/arch/arm/src/sam34/sam_twi.c @@ -95,21 +95,6 @@ #define TWI_MAX_FREQUENCY 66000000 /* Maximum TWI frequency */ -/* Debug ***********************************************************************/ -/* CONFIG_DEBUG_I2C + CONFIG_DEBUG_FEATURES enables general I2C debug output. */ - -#ifdef CONFIG_DEBUG_I2C -# define i2cerr err -# define i2cinfo info -# define i2cllerr llerr -# define i2cllinfo llinfo -#else -# define i2cerr(x...) -# define i2cinfo(x...) -# define i2cllerr(x...) -# define i2cllinfo(x...) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ diff --git a/arch/arm/src/sama5/sam_twi.c b/arch/arm/src/sama5/sam_twi.c index c08135a1ce..aae56067bb 100644 --- a/arch/arm/src/sama5/sam_twi.c +++ b/arch/arm/src/sama5/sam_twi.c @@ -96,14 +96,14 @@ #endif /* Driver internal definitions *************************************************/ -/* If verbose I2C debug output is enable, then allow more time before we declare +/* If verbose I2C debug output is enabled, then allow more time before we declare * a timeout. The debug output from twi_interrupt will really slow things down! * * With a very slow clock (say 100,000 Hz), less than 100 usec would be required * to transfer on byte. So these define a "long" timeout. */ -#if defined(CONFIG_DEBUG_I2C) && defined(CONFIG_DEBUG_INFO) +#ifdef CONFIG_DEBUG_I2C_INFO # define TWI_TIMEOUT_MSPB (50) /* 50 msec/byte */ #else # define TWI_TIMEOUT_MSPB (5) /* 5 msec/byte */ @@ -123,21 +123,6 @@ #define MKI2C_INPUT(p) (((p) & (PIO_PORT_MASK | PIO_PIN_MASK)) | I2C_INPUT) #define MKI2C_OUTPUT(p) (((p) & (PIO_PORT_MASK | PIO_PIN_MASK)) | I2C_OUTPUT) -/* Debug ***********************************************************************/ -/* CONFIG_DEBUG_I2C + CONFIG_DEBUG_FEATURES enables general I2C debug output. */ - -#ifdef CONFIG_DEBUG_I2C -# define i2cerr err -# define i2cinfo info -# define i2cllerr llerr -# define i2cllinfo llinfo -#else -# define i2cerr(x...) -# define i2cinfo(x...) -# define i2cllerr(x...) -# define i2cllinfo(x...) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ diff --git a/arch/arm/src/samv7/sam_twihs.c b/arch/arm/src/samv7/sam_twihs.c index 67f989d842..b57662cc18 100644 --- a/arch/arm/src/samv7/sam_twihs.c +++ b/arch/arm/src/samv7/sam_twihs.c @@ -99,7 +99,7 @@ * to transfer on byte. So these define a "long" timeout. */ -#if defined(CONFIG_DEBUG_I2C) && defined(CONFIG_DEBUG_INFO) +#ifdef CONFIG_DEBUG_I2C_INFO # define TWIHS_TIMEOUT_MSPB (50) /* 50 msec/byte */ #else # define TWIHS_TIMEOUT_MSPB (5) /* 5 msec/byte */ @@ -120,21 +120,6 @@ #define MKI2C_INPUT(p) (((p) & (PIO_PORT_MASK | PIO_PIN_MASK)) | I2C_INPUT) #define MKI2C_OUTPUT(p) (((p) & (PIO_PORT_MASK | PIO_PIN_MASK)) | I2C_OUTPUT) -/* Debug ***********************************************************************/ -/* CONFIG_DEBUG_I2C + CONFIG_DEBUG_FEATURES enables general I2C debug output. */ - -#ifdef CONFIG_DEBUG_I2C -# define i2cerr err -# define i2cinfo info -# define i2cllerr llerr -# define i2cllinfo llinfo -#else -# define i2cerr(x...) -# define i2cinfo(x...) -# define i2cllerr(x...) -# define i2cllinfo(x...) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_i2c.c b/arch/arm/src/stm32/stm32_i2c.c index 0b81465f4a..97e6ccc682 100644 --- a/arch/arm/src/stm32/stm32_i2c.c +++ b/arch/arm/src/stm32/stm32_i2c.c @@ -162,15 +162,6 @@ #define MKI2C_OUTPUT(p) (((p) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | I2C_OUTPUT) /* Debug ****************************************************************************/ -/* CONFIG_DEBUG_I2C + CONFIG_DEBUG_FEATURES enables general I2C debug output. */ - -#ifdef CONFIG_DEBUG_I2C -# define i2cerr err -# define i2cinfo info -#else -# define i2cerr(x...) -# define i2cinfo(x...) -#endif /* I2C event trace logic. NOTE: trace uses the internal, non-standard, low-level * debug interface syslog() but does not require that any other debug diff --git a/arch/arm/src/stm32/stm32_i2c_alt.c b/arch/arm/src/stm32/stm32_i2c_alt.c index 4ea697320a..1419bfc81f 100644 --- a/arch/arm/src/stm32/stm32_i2c_alt.c +++ b/arch/arm/src/stm32/stm32_i2c_alt.c @@ -169,15 +169,6 @@ #define MKI2C_OUTPUT(p) (((p) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | I2C_OUTPUT) /* Debug ****************************************************************************/ -/* CONFIG_DEBUG_I2C + CONFIG_DEBUG_FEATURES enables general I2C debug output. */ - -#ifdef CONFIG_DEBUG_I2C -# define i2cerr err -# define i2cinfo info -#else -# define i2cerr(x...) -# define i2cinfo(x...) -#endif /* I2C event trace logic. NOTE: trace uses the internal, non-standard, low-level * debug interface syslog() but does not require that any other debug diff --git a/arch/arm/src/stm32/stm32f30xxx_i2c.c b/arch/arm/src/stm32/stm32f30xxx_i2c.c index 5f989bf0cd..de9d9241cb 100644 --- a/arch/arm/src/stm32/stm32f30xxx_i2c.c +++ b/arch/arm/src/stm32/stm32f30xxx_i2c.c @@ -154,15 +154,6 @@ #define STATUS_BUSY(status) (status & I2C_ISR_BUSY) /* Debug ****************************************************************************/ -/* CONFIG_DEBUG_I2C + CONFIG_DEBUG_FEATURES enables general I2C debug output. */ - -#ifdef CONFIG_DEBUG_I2C -# define i2cerr err -# define i2cinfo info -#else -# define i2cerr(x...) -# define i2cinfo(x...) -#endif /* I2C event trace logic. NOTE: trace uses the internal, non-standard, low-level * debug interface syslog() but does not require that any other debug diff --git a/arch/arm/src/stm32f7/stm32_i2c.c b/arch/arm/src/stm32f7/stm32_i2c.c index 71edf919fd..bc34aa25aa 100644 --- a/arch/arm/src/stm32f7/stm32_i2c.c +++ b/arch/arm/src/stm32f7/stm32_i2c.c @@ -178,7 +178,7 @@ * * Debugging output enabled with: * - * CONFIG_DEBUG and CONFIG_DEBUG_I2C + * CONFIG_DEBUG_I2C_INFO * * ISR Debugging output may be enabled with: * @@ -287,16 +287,6 @@ #define I2C_CR1_ALLINTS \ (I2C_CR1_TXRX | I2C_CR1_TCIE | I2C_CR1_ERRIE) -/* I2C Debugging */ - -#ifdef CONFIG_DEBUG_I2C -# define i2cerr err -# define i2cinfo info -#else -# define i2cerr(x...) -# define i2cinfo(x...) -#endif - /* I2C event tracing * * To enable tracing statements which show the details of the state machine diff --git a/arch/arm/src/stm32l4/stm32l4_i2c.c b/arch/arm/src/stm32l4/stm32l4_i2c.c index 49088d947b..63b0f5b048 100644 --- a/arch/arm/src/stm32l4/stm32l4_i2c.c +++ b/arch/arm/src/stm32l4/stm32l4_i2c.c @@ -146,15 +146,6 @@ #define STATUS_BUSY(status) (status & I2C_ISR_BUSY) /* Debug ****************************************************************************/ -/* CONFIG_DEBUG_I2C + CONFIG_DEBUG_FEATURES enables general I2C debug output. */ - -#ifdef CONFIG_DEBUG_I2C -# define i2cerr err -# define i2cinfo info -#else -# define i2cerr(x...) -# define i2cinfo(x...) -#endif /* I2C event trace logic. NOTE: trace uses the internal, non-standard, low-level * debug interface syslog() but does not require that any other debug diff --git a/arch/arm/src/tiva/Kconfig b/arch/arm/src/tiva/Kconfig index ceca1c5c30..fc61ea26c3 100644 --- a/arch/arm/src/tiva/Kconfig +++ b/arch/arm/src/tiva/Kconfig @@ -783,7 +783,7 @@ config TIVA_I2C_HIGHSPEED config TIVA_I2C_REGDEBUG bool "Register level debug" default n - depends on DEBUG_INFO + depends on DEBUG_I2C_INFO ---help--- Enables extremely detailed register access debug output. diff --git a/arch/arm/src/tiva/tiva_i2c.c b/arch/arm/src/tiva/tiva_i2c.c index 375f52ff4a..f3e47ac795 100644 --- a/arch/arm/src/tiva/tiva_i2c.c +++ b/arch/arm/src/tiva/tiva_i2c.c @@ -119,17 +119,8 @@ #define MKI2C_OUTPUT(p) (((p) & (GPIO_PORT_MASK | GPIO_PIN_MASK)) | I2C_OUTPUT) /* Debug ****************************************************************************/ -/* CONFIG_DEBUG_I2C + CONFIG_DEBUG_FEATURES enables general I2C debug output. */ -#ifdef CONFIG_DEBUG_I2C -# define i2cerr err -# define i2cinfo info -#else -# define i2cerr(x...) -# define i2cinfo(x...) -#endif - -#ifndef CONFIG_DEBUG_FEATURES +#ifndef CONFIG_DEBUG_I2C_INFO # undef CONFIG_TIVA_I2C_REGDEBUG #endif @@ -609,7 +600,7 @@ static bool tiva_i2c_checkreg(struct tiva_i2c_priv_s *priv, bool wr, { /* Yes... show how many times we did it */ - llerr("...[Repeats %d times]...\n", priv->ntimes); + i2cinfo("...[Repeats %d times]...\n", priv->ntimes); } /* Save information about the new access */ @@ -642,7 +633,7 @@ static uint32_t tiva_i2c_getreg(struct tiva_i2c_priv_s *priv, unsigned int offse if (tiva_i2c_checkreg(priv, false, regval, regaddr)) { - llerr("%08x->%08x\n", regaddr, regval); + i2cinfo("%08x->%08x\n", regaddr, regval); } return regval; @@ -671,7 +662,7 @@ static void tiva_i2c_putreg(struct tiva_i2c_priv_s *priv, unsigned int offset, if (tiva_i2c_checkreg(priv, true, regval, regaddr)) { - llerr("%08x<-%08x\n", regaddr, regval); + i2cinfo("%08x<-%08x\n", regaddr, regval); } putreg32(regval, regaddr); diff --git a/drivers/i2c/i2c_driver.c b/drivers/i2c/i2c_driver.c index 83b8aa37e3..1e5024b3ec 100644 --- a/drivers/i2c/i2c_driver.c +++ b/drivers/i2c/i2c_driver.c @@ -62,17 +62,6 @@ #define DEVNAME_FMT "/dev/i2c%d" #define DEVNAME_FMTLEN (8 + 3 + 1) -/* Debug ********************************************************************/ -/* CONFIG_DEBUG_I2C + CONFIG_DEBUG_FEATURES enables general I2C debug output. */ - -#ifdef CONFIG_DEBUG_I2C -# define i2cerr err -# define i2cinfo info -#else -# define i2cerr(x...) -# define i2cinfo(x...) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ @@ -435,4 +424,4 @@ int i2c_register(FAR struct i2c_master_s *i2c, int bus) return -ENOMEM; } -#endif /* CONFIG_I2C_DRIVER */ \ No newline at end of file +#endif /* CONFIG_I2C_DRIVER */ diff --git a/include/debug.h b/include/debug.h index 8bdd2c260e..c86ad7e39f 100644 --- a/include/debug.h +++ b/include/debug.h @@ -645,6 +645,30 @@ # define gpiollinfo(x...) #endif +#ifdef CONFIG_DEBUG_I2C_ERROR +# define i2cerr(format, ...) err(format, ##__VA_ARGS__) +# define i2cllerr(format, ...) llerr(format, ##__VA_ARGS__) +#else +# define i2cerr(x...) +# define i2cllerr(x...) +#endif + +#ifdef CONFIG_DEBUG_I2C_WARN +# define i2cwarn(format, ...) warn(format, ##__VA_ARGS__) +# define i2cllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +#else +# define i2cwarn(x...) +# define i2cllwarn(x...) +#endif + +#ifdef CONFIG_DEBUG_I2C_INFO +# define i2cinfo(format, ...) info(format, ##__VA_ARGS__) +# define i2cllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +#else +# define i2cinfo(x...) +# define i2cllinfo(x...) +#endif + #ifdef CONFIG_DEBUG_SENSORS_ERROR # define snerr(format, ...) err(format, ##__VA_ARGS__) # define snllerr(format, ...) llerr(format, ##__VA_ARGS__) @@ -1186,6 +1210,30 @@ # define gpiollinfo (void) #endif +#ifdef CONFIG_DEBUG_I2C_ERROR +# define i2cerr err +# define i2cllerr llerr +#else +# define i2cerr (void) +# define i2cllerr (void) +#endif + +#ifdef CONFIG_DEBUG_I2C_WARN +# define i2cwarn warn +# define i2cllwarn llwarn +#else +# define i2cwarn (void) +# define i2cllwarn (void) +#endif + +#ifdef CONFIG_DEBUG_I2C_INFO +# define i2cinfo info +# define i2cllinfo llinfo +#else +# define i2cinfo (void) +# define i2cllinfo (void) +#endif + #ifdef CONFIG_DEBUG_SENSORS_ERROR # define snerr err # define snllerr llerr @@ -1396,6 +1444,14 @@ # define gpioinfodumpbuffer(m,b,n) #endif +#ifdef CONFIG_DEBUG_I2C +# define i2cerrdumpbuffer(m,b,n) errdumpbuffer(m,b,n) +# define i2cinfodumpbuffer(m,b,n) infodumpbuffer(m,b,n) +#else +# define i2cerrdumpbuffer(m,b,n) +# define i2cinfodumpbuffer(m,b,n) +#endif + #ifdef CONFIG_DEBUG_SENSORS # define snerrdumpbuffer(m,b,n) errdumpbuffer(m,b,n) # define sninfodumpbuffer(m,b,n) infodumpbuffer(m,b,n)