mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 05:08:41 +08:00
Unify sensor debug. ADX driver was using input debug; LM75 and QENCODE that their own custom debug. Now all use CONFIG_DEBUG_SENSOR, sndbg()
This commit is contained in:
parent
10863af628
commit
ae18f9dacd
16 changed files with 114 additions and 216 deletions
9
Kconfig
9
Kconfig
|
@ -630,6 +630,15 @@ config DEBUG_SDIO
|
|||
Support for this debug option is architecture-specific and may not
|
||||
be available for some MCUs.
|
||||
|
||||
config DEBUG_SENSORS
|
||||
bool "Sensor Debug Output"
|
||||
default n
|
||||
depends on SENSORS
|
||||
---help---
|
||||
Enable sensor driver debug SYSLOG output (disabled by default).
|
||||
Support for this debug option is architecture-specific and may not
|
||||
be available for some MCUs.
|
||||
|
||||
config DEBUG_SPI
|
||||
bool "SPI Debug Output"
|
||||
default n
|
||||
|
|
|
@ -65,7 +65,7 @@
|
|||
# undef CONFIG_DEBUG_I2C
|
||||
# undef CONFIG_DEBUG_CAN
|
||||
# undef CONFIG_DEBUG_PWM
|
||||
# undef CONFIG_DEBUG_QENCODER
|
||||
# undef CONFIG_DEBUG_SENSORS
|
||||
#endif
|
||||
|
||||
/* Peripherals **********************************************************************/
|
||||
|
|
|
@ -149,26 +149,16 @@
|
|||
/* Non-standard debug that may be enabled just for testing the quadrature encoder */
|
||||
|
||||
#ifndef CONFIG_DEBUG
|
||||
# undef CONFIG_DEBUG_QENCODER
|
||||
# undef CONFIG_DEBUG_SENSORS
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_QENCODER
|
||||
# define qedbg dbg
|
||||
# define qelldbg lldbg
|
||||
#ifdef CONFIG_DEBUG_SENSORS
|
||||
# ifdef CONFIG_DEBUG_VERBOSE
|
||||
# define qevdbg vdbg
|
||||
# define qellvdbg llvdbg
|
||||
# define qe_dumpgpio(p,m) stm32_dumpgpio(p,m)
|
||||
# else
|
||||
# define qevdbg(x...)
|
||||
# define qellvdbg(x...)
|
||||
# define qe_dumpgpio(p,m)
|
||||
# endif
|
||||
#else
|
||||
# define qedbg(x...)
|
||||
# define qelldbg(x...)
|
||||
# define qevdbg(x...)
|
||||
# define qellvdbg(x...)
|
||||
# define qe_dumpgpio(p,m)
|
||||
#endif
|
||||
|
||||
|
@ -228,7 +218,7 @@ static void stm32_putreg16(struct stm32_lowerhalf_s *priv, int offset, uint16_t
|
|||
static uint32_t stm32_getreg32(FAR struct stm32_lowerhalf_s *priv, int offset);
|
||||
static void stm32_putreg32(FAR struct stm32_lowerhalf_s *priv, int offset, uint32_t value);
|
||||
|
||||
#if defined(CONFIG_DEBUG_QENCODER) && defined(CONFIG_DEBUG_VERBOSE)
|
||||
#if defined(CONFIG_DEBUG_SENSORS) && defined(CONFIG_DEBUG_VERBOSE)
|
||||
static void stm32_dumpregs(struct stm32_lowerhalf_s *priv, FAR const char *msg);
|
||||
#else
|
||||
# define stm32_dumpregs(priv,msg)
|
||||
|
@ -542,26 +532,26 @@ static void stm32_putreg32(FAR struct stm32_lowerhalf_s *priv, int offset, uint3
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_DEBUG_QENCODER) && defined(CONFIG_DEBUG_VERBOSE)
|
||||
#if defined(CONFIG_DEBUG_SENSORS) && defined(CONFIG_DEBUG_VERBOSE)
|
||||
static void stm32_dumpregs(struct stm32_lowerhalf_s *priv, FAR const char *msg)
|
||||
{
|
||||
qevdbg("%s:\n", msg);
|
||||
qevdbg(" CR1: %04x CR2: %04x SMCR: %04x DIER: %04x\n",
|
||||
snvdbg("%s:\n", msg);
|
||||
snvdbg(" CR1: %04x CR2: %04x SMCR: %04x DIER: %04x\n",
|
||||
stm32_getreg16(priv, STM32_GTIM_CR1_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_CR2_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_SMCR_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_DIER_OFFSET));
|
||||
qevdbg(" SR: %04x EGR: %04x CCMR1: %04x CCMR2: %04x\n",
|
||||
snvdbg(" SR: %04x EGR: %04x CCMR1: %04x CCMR2: %04x\n",
|
||||
stm32_getreg16(priv, STM32_GTIM_SR_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_EGR_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_CCMR1_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_CCMR2_OFFSET));
|
||||
qevdbg(" CCER: %04x CNT: %04x PSC: %04x ARR: %04x\n",
|
||||
snvdbg(" CCER: %04x CNT: %04x PSC: %04x ARR: %04x\n",
|
||||
stm32_getreg16(priv, STM32_GTIM_CCER_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_CNT_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_PSC_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_ARR_OFFSET));
|
||||
qevdbg(" CCR1: %04x CCR2: %04x CCR3: %04x CCR4: %04x\n",
|
||||
snvdbg(" CCR1: %04x CCR2: %04x CCR3: %04x CCR4: %04x\n",
|
||||
stm32_getreg16(priv, STM32_GTIM_CCR1_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_CCR2_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_CCR3_OFFSET),
|
||||
|
@ -569,7 +559,7 @@ static void stm32_dumpregs(struct stm32_lowerhalf_s *priv, FAR const char *msg)
|
|||
#if defined(CONFIG_STM32_TIM1_QENCODER) || defined(CONFIG_STM32_TIM8_QENCODER)
|
||||
if (priv->timtype == TIMTYPE_ADVANCED)
|
||||
{
|
||||
qevdbg(" RCR: %04x BDTR: %04x DCR: %04x DMAR: %04x\n",
|
||||
snvdbg(" RCR: %04x BDTR: %04x DCR: %04x DMAR: %04x\n",
|
||||
stm32_getreg16(priv, STM32_ATIM_RCR_OFFSET),
|
||||
stm32_getreg16(priv, STM32_ATIM_BDTR_OFFSET),
|
||||
stm32_getreg16(priv, STM32_ATIM_DCR_OFFSET),
|
||||
|
@ -578,7 +568,7 @@ static void stm32_dumpregs(struct stm32_lowerhalf_s *priv, FAR const char *msg)
|
|||
else
|
||||
#endif
|
||||
{
|
||||
qevdbg(" DCR: %04x DMAR: %04x\n",
|
||||
snvdbg(" DCR: %04x DMAR: %04x\n",
|
||||
stm32_getreg16(priv, STM32_GTIM_DCR_OFFSET),
|
||||
stm32_getreg16(priv, STM32_GTIM_DMAR_OFFSET));
|
||||
}
|
||||
|
@ -1036,7 +1026,7 @@ static int stm32_shutdown(FAR struct qe_lowerhalf_s *lower)
|
|||
putreg32(regval, regaddr);
|
||||
irqrestore(flags);
|
||||
|
||||
qevdbg("regaddr: %08x resetbit: %08x\n", regaddr, resetbit);
|
||||
snvdbg("regaddr: %08x resetbit: %08x\n", regaddr, resetbit);
|
||||
stm32_dumpregs(priv, "After stop");
|
||||
|
||||
/* Put the TI1 GPIO pin back to its default state */
|
||||
|
@ -1128,7 +1118,7 @@ static int stm32_reset(FAR struct qe_lowerhalf_s *lower)
|
|||
#ifdef HAVE_16BIT_TIMERS
|
||||
irqstate_t flags;
|
||||
|
||||
qevdbg("Resetting position to zero\n");
|
||||
snvdbg("Resetting position to zero\n");
|
||||
DEBUGASSERT(lower && priv->inuse);
|
||||
|
||||
/* Reset the timer and the counter. Interrupts are disabled to make this atomic
|
||||
|
@ -1140,7 +1130,7 @@ static int stm32_reset(FAR struct qe_lowerhalf_s *lower)
|
|||
priv->position = 0;
|
||||
irqrestore(flags);
|
||||
#else
|
||||
qevdbg("Resetting position to zero\n");
|
||||
snvdbg("Resetting position to zero\n");
|
||||
DEBUGASSERT(lower && priv->inuse);
|
||||
|
||||
/* Reset the counter to zero */
|
||||
|
@ -1195,7 +1185,7 @@ int stm32_qeinitialize(FAR const char *devpath, int tim)
|
|||
priv = stm32_tim2lower(tim);
|
||||
if (!priv)
|
||||
{
|
||||
qedbg("TIM%d support not configured\n", tim);
|
||||
sndbg("TIM%d support not configured\n", tim);
|
||||
return -ENXIO;
|
||||
}
|
||||
|
||||
|
@ -1203,7 +1193,7 @@ int stm32_qeinitialize(FAR const char *devpath, int tim)
|
|||
|
||||
if (priv->inuse)
|
||||
{
|
||||
qedbg("TIM%d is in-used\n", tim);
|
||||
sndbg("TIM%d is in-used\n", tim);
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
|
@ -1212,7 +1202,7 @@ int stm32_qeinitialize(FAR const char *devpath, int tim)
|
|||
ret = qe_register(devpath, (FAR struct qe_lowerhalf_s *)priv);
|
||||
if (ret < 0)
|
||||
{
|
||||
qedbg("qe_register failed: %d\n", ret);
|
||||
sndbg("qe_register failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,30 +118,6 @@
|
|||
|
||||
#ifdef HAVE_QENCODER
|
||||
|
||||
/* Debug ***************************************************************************/
|
||||
/* Non-standard debug that may be enabled just for testing the quadrature encoder */
|
||||
|
||||
#ifndef CONFIG_DEBUG
|
||||
# undef CONFIG_DEBUG_QENCODER
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_QENCODER
|
||||
# define qedbg dbg
|
||||
# define qelldbg lldbg
|
||||
# ifdef CONFIG_DEBUG_VERBOSE
|
||||
# define qevdbg vdbg
|
||||
# define qellvdbg llvdbg
|
||||
# else
|
||||
# define qevdbg(x...)
|
||||
# define qellvdbg(x...)
|
||||
# endif
|
||||
#else
|
||||
# define qedbg(x...)
|
||||
# define qelldbg(x...)
|
||||
# define qevdbg(x...)
|
||||
# define qellvdbg(x...)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
@ -170,11 +146,11 @@ int qe_devinit(void)
|
|||
{
|
||||
/* Initialize a quadrature encoder interface. */
|
||||
|
||||
qevdbg("Initializing the quadrature encoder using TIM%d\n", TIMID);
|
||||
snvdbg("Initializing the quadrature encoder using TIM%d\n", TIMID);
|
||||
ret = stm32_qeinitialize("/dev/qe0", TIMID);
|
||||
if (ret < 0)
|
||||
{
|
||||
qedbg("stm32_qeinitialize failed: %d\n", ret);
|
||||
sndbg("stm32_qeinitialize failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,30 +118,6 @@
|
|||
|
||||
#ifdef HAVE_QENCODER
|
||||
|
||||
/* Debug ***************************************************************************/
|
||||
/* Non-standard debug that may be enabled just for testing the quadrature encoder */
|
||||
|
||||
#ifndef CONFIG_DEBUG
|
||||
# undef CONFIG_DEBUG_QENCODER
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_QENCODER
|
||||
# define qedbg dbg
|
||||
# define qelldbg lldbg
|
||||
# ifdef CONFIG_DEBUG_VERBOSE
|
||||
# define qevdbg vdbg
|
||||
# define qellvdbg llvdbg
|
||||
# else
|
||||
# define qevdbg(x...)
|
||||
# define qellvdbg(x...)
|
||||
# endif
|
||||
#else
|
||||
# define qedbg(x...)
|
||||
# define qelldbg(x...)
|
||||
# define qevdbg(x...)
|
||||
# define qellvdbg(x...)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
@ -170,11 +146,11 @@ int qe_devinit(void)
|
|||
{
|
||||
/* Initialize a quadrature encoder interface. */
|
||||
|
||||
qevdbg("Initializing the quadrature encoder using TIM%d\n", TIMID);
|
||||
snvdbg("Initializing the quadrature encoder using TIM%d\n", TIMID);
|
||||
ret = stm32_qeinitialize("/dev/qe0", TIMID);
|
||||
if (ret < 0)
|
||||
{
|
||||
qedbg("stm32_qeinitialize failed: %d\n", ret);
|
||||
sndbg("stm32_qeinitialize failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -651,9 +651,9 @@ Where <subdir> is one of the following:
|
|||
CONFIG_STM32_TIM8_QE=y : Use TIM8 as the quadrature encoder
|
||||
CONFIG_STM32_TIM2_QE=y : (Or optionally TIM2)
|
||||
|
||||
See also apps/examples/README.tx. Special PWM-only debug options:
|
||||
See also apps/examples/README.txt. Special debug options:
|
||||
|
||||
CONFIG_DEBUG_QENCODER
|
||||
CONFIG_DEBUG_SENSORS
|
||||
|
||||
6. This example supports the watchdog timer test (apps/examples/watchdog)
|
||||
but this must be manually enabled by selecting:
|
||||
|
|
|
@ -1438,9 +1438,9 @@ Where <subdir> is one of the following:
|
|||
CONFIG_STM32_TIM8_QE=y : Use TIM8 as the quadrature encoder
|
||||
CONFIG_STM32_TIM2_QE=y : (Or optionally TIM2)
|
||||
|
||||
See also apps/examples/README.tx. Special PWM-only debug options:
|
||||
See also apps/examples/README.tx. Special debug options:
|
||||
|
||||
CONFIG_DEBUG_QENCODER
|
||||
CONFIG_DEBUG_SENSORS
|
||||
|
||||
6. This example supports the watchdog timer test (apps/examples/watchdog)
|
||||
but this must be manually enabled by selecting:
|
||||
|
|
|
@ -117,30 +117,6 @@
|
|||
|
||||
#ifdef HAVE_QENCODER
|
||||
|
||||
/* Debug ***************************************************************************/
|
||||
/* Non-standard debug that may be enabled just for testing the quadrature encoder */
|
||||
|
||||
#ifndef CONFIG_DEBUG
|
||||
# undef CONFIG_DEBUG_QENCODER
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_QENCODER
|
||||
# define qedbg dbg
|
||||
# define qelldbg lldbg
|
||||
# ifdef CONFIG_DEBUG_VERBOSE
|
||||
# define qevdbg vdbg
|
||||
# define qellvdbg llvdbg
|
||||
# else
|
||||
# define qevdbg(x...)
|
||||
# define qellvdbg(x...)
|
||||
# endif
|
||||
#else
|
||||
# define qedbg(x...)
|
||||
# define qelldbg(x...)
|
||||
# define qevdbg(x...)
|
||||
# define qellvdbg(x...)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
@ -169,11 +145,11 @@ int qe_devinit(void)
|
|||
{
|
||||
/* Initialize a quadrature encoder interface. */
|
||||
|
||||
qevdbg("Initializing the quadrature encoder using TIM%d\n", TIMID);
|
||||
snvdbg("Initializing the quadrature encoder using TIM%d\n", TIMID);
|
||||
ret = stm32_qeinitialize("/dev/qe0", TIMID);
|
||||
if (ret < 0)
|
||||
{
|
||||
qedbg("stm32_qeinitialize failed: %d\n", ret);
|
||||
sndbg("stm32_qeinitialize failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -118,30 +118,6 @@
|
|||
|
||||
#ifdef HAVE_QENCODER
|
||||
|
||||
/* Debug ***************************************************************************/
|
||||
/* Non-standard debug that may be enabled just for testing the quadrature encoder */
|
||||
|
||||
#ifndef CONFIG_DEBUG
|
||||
# undef CONFIG_DEBUG_QENCODER
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_QENCODER
|
||||
# define qedbg dbg
|
||||
# define qelldbg lldbg
|
||||
# ifdef CONFIG_DEBUG_VERBOSE
|
||||
# define qevdbg vdbg
|
||||
# define qellvdbg llvdbg
|
||||
# else
|
||||
# define qevdbg(x...)
|
||||
# define qellvdbg(x...)
|
||||
# endif
|
||||
#else
|
||||
# define qedbg(x...)
|
||||
# define qelldbg(x...)
|
||||
# define qevdbg(x...)
|
||||
# define qellvdbg(x...)
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Private Functions
|
||||
************************************************************************************/
|
||||
|
@ -170,11 +146,11 @@ int qe_devinit(void)
|
|||
{
|
||||
/* Initialize a quadrature encoder interface. */
|
||||
|
||||
qevdbg("Initializing the quadrature encoder using TIM%d\n", TIMID);
|
||||
snvdbg("Initializing the quadrature encoder using TIM%d\n", TIMID);
|
||||
ret = stm32_qeinitialize("/dev/qe0", TIMID);
|
||||
if (ret < 0)
|
||||
{
|
||||
qedbg("stm32_qeinitialize failed: %d\n", ret);
|
||||
sndbg("stm32_qeinitialize failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,17 +61,6 @@ config LM75
|
|||
select I2C
|
||||
select I2C_LM75
|
||||
|
||||
config DEBUG_LM75
|
||||
bool "Enable LM-75 debug"
|
||||
default n
|
||||
depends on LM75
|
||||
|
||||
config QENCODER
|
||||
bool "Qencoder"
|
||||
default n
|
||||
|
||||
config DEBUG_QENCODER
|
||||
bool "Enable Qencoder Debug"
|
||||
default n
|
||||
depends on QENCODER
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
|
||||
# Include sensor drivers
|
||||
|
||||
ifeq ($(CONFIG_SENSORS),y)
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_ADXL345),y)
|
||||
CSRCS += adxl345_base.c
|
||||
endif
|
||||
|
@ -75,3 +77,5 @@ endif
|
|||
DEPPATH += --dep-path sensors
|
||||
VPATH += :sensors
|
||||
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)sensors}
|
||||
|
||||
endif # CONFIG_SENSORS
|
|
@ -127,7 +127,7 @@ static ssize_t adxl345_read(FAR struct file *filep, FAR char *buffer, size_t len
|
|||
struct adxl345_sample_s sample;
|
||||
int ret;
|
||||
|
||||
ivdbg("len=%d\n", len);
|
||||
snvdbg("len=%d\n", len);
|
||||
DEBUGASSERT(filep);
|
||||
inode = filep->f_inode;
|
||||
|
||||
|
@ -198,7 +198,7 @@ int adxl345_register(ADXL345_HANDLE handle, int minor)
|
|||
char devname[DEV_NAMELEN];
|
||||
int ret;
|
||||
|
||||
ivdbg("handle=%p minor=%d\n", handle, minor);
|
||||
snvdbg("handle=%p minor=%d\n", handle, minor);
|
||||
DEBUGASSERT(priv);
|
||||
|
||||
/* Get exclusive access to the device structure */
|
||||
|
@ -207,7 +207,7 @@ int adxl345_register(ADXL345_HANDLE handle, int minor)
|
|||
if (ret < 0)
|
||||
{
|
||||
int errval = errno;
|
||||
idbg("ERROR: sem_wait failed: %d\n", errval);
|
||||
sndbg("ERROR: sem_wait failed: %d\n", errval);
|
||||
return -errval;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ int adxl345_register(ADXL345_HANDLE handle, int minor)
|
|||
ret = register_driver(devname, &g_adxl345fops, 0666, priv);
|
||||
if (ret < 0)
|
||||
{
|
||||
idbg("ERROR: Failed to register driver %s: %d\n", devname, ret);
|
||||
sndbg("ERROR: Failed to register driver %s: %d\n", devname, ret);
|
||||
sem_post(&priv->exclsem);
|
||||
return ret;
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ static int adxl345_interrupt(int irq, FAR void *context)
|
|||
ret = work_queue(HPWORK, &priv->work, adxl345_worker, priv, 0);
|
||||
if (ret != 0)
|
||||
{
|
||||
illdbg("Failed to queue work: %d\n", ret);
|
||||
snlldbg("Failed to queue work: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ static int adxl345_checkid(FAR struct adxl345_dev_s *priv)
|
|||
/* Read device ID */
|
||||
|
||||
devid = adxl345_getreg8(priv, ADXL345_DEVID);
|
||||
ivdbg("devid: %04x\n", devid);
|
||||
snvdbg("devid: %04x\n", devid);
|
||||
|
||||
if (devid != (uint16_t) DEVID)
|
||||
{
|
||||
|
@ -444,7 +444,7 @@ ADXL345_HANDLE adxl345_instantiate(FAR struct i2c_dev_s *dev,
|
|||
ret = adxl345_checkid(priv);
|
||||
if (ret < 0)
|
||||
{
|
||||
illdbg("Wrong Device ID!\n");
|
||||
snlldbg("Wrong Device ID!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ uint8_t adxl345_getreg8(FAR struct adxl345_dev_s *priv, uint8_t regaddr)
|
|||
ret = I2C_TRANSFER(priv->i2c, msg, 2);
|
||||
if (ret < 0)
|
||||
{
|
||||
idbg("I2C_TRANSFER failed: %d\n", ret);
|
||||
sndbg("I2C_TRANSFER failed: %d\n", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ void adxl345_putreg8(FAR struct adxl345_dev_s *priv,
|
|||
ret = I2C_TRANSFER(priv->i2c, &msg, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
idbg("I2C_TRANSFER failed: %d\n", ret);
|
||||
sndbg("I2C_TRANSFER failed: %d\n", ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -198,7 +198,7 @@ uint16_t adxl345_getreg16(FAR struct adxl345_dev_s *priv, uint8_t regaddr)
|
|||
ret = I2C_TRANSFER(priv->i2c, msg, 2);
|
||||
if (ret < 0)
|
||||
{
|
||||
idbg("I2C_TRANSFER failed: %d\n", ret);
|
||||
sndbg("I2C_TRANSFER failed: %d\n", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,18 +61,6 @@
|
|||
#define B16_9DIV5 (9 * 65536 / 5)
|
||||
#define B16_32 (32 * 65536)
|
||||
|
||||
/* Debug for this file only */
|
||||
|
||||
#ifdef CONFIG_DEBUG_LM75
|
||||
# define lm75dbg dbg
|
||||
#else
|
||||
# ifdef CONFIG_CPP_HAVE_VARARGS
|
||||
# define lm75dbg(x...)
|
||||
# else
|
||||
# define lm75dbg (void)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private
|
||||
****************************************************************************/
|
||||
|
@ -145,7 +133,7 @@ static int lm75_readb16(FAR struct lm75_dev_s *priv, uint8_t regaddr,
|
|||
ret = I2C_WRITE(priv->i2c, ®addr, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
lm75dbg("I2C_WRITE failed: %d\n", ret);
|
||||
sndbg("I2C_WRITE failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -154,7 +142,7 @@ static int lm75_readb16(FAR struct lm75_dev_s *priv, uint8_t regaddr,
|
|||
ret = I2C_READ(priv->i2c, buffer, 2);
|
||||
if (ret < 0)
|
||||
{
|
||||
lm75dbg("I2C_READ failed: %d\n", ret);
|
||||
sndbg("I2C_READ failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -164,7 +152,7 @@ static int lm75_readb16(FAR struct lm75_dev_s *priv, uint8_t regaddr,
|
|||
*/
|
||||
|
||||
*regvalue = b8tob16((b8_t)buffer[0] << 8 | (b8_t)buffer[1]);
|
||||
lm75dbg("addr: %02x value: %08x ret: %d\n", regaddr, *regvalue, ret);
|
||||
sndbg("addr: %02x value: %08x ret: %d\n", regaddr, *regvalue, ret);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -182,7 +170,7 @@ static int lm75_writeb16(FAR struct lm75_dev_s *priv, uint8_t regaddr,
|
|||
uint8_t buffer[3];
|
||||
b8_t regb8;
|
||||
|
||||
lm75dbg("addr: %02x value: %08x\n", regaddr, regval);
|
||||
sndbg("addr: %02x value: %08x\n", regaddr, regval);
|
||||
|
||||
/* Set up a 3 byte message to send */
|
||||
|
||||
|
@ -216,10 +204,11 @@ static int lm75_readtemp(FAR struct lm75_dev_s *priv, FAR b16_t *temp)
|
|||
ret = lm75_readb16(priv, LM75_TEMP_REG, &temp16);
|
||||
if (ret < 0)
|
||||
{
|
||||
lm75dbg("lm75_readb16 failed: %d\n", ret);
|
||||
sndbg("lm75_readb16 failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
lm75dbg("Centigrade: %08x\n", temp16);
|
||||
|
||||
sndbg("Centigrade: %08x\n", temp16);
|
||||
|
||||
/* Was fahrenheit requested? */
|
||||
|
||||
|
@ -228,7 +217,7 @@ static int lm75_readtemp(FAR struct lm75_dev_s *priv, FAR b16_t *temp)
|
|||
/* Centigrade to Fahrenheit conversion: F = 9*C/5 + 32 */
|
||||
|
||||
temp16 = b16mulb16(temp16, B16_9DIV5) + B16_32;
|
||||
lm75dbg("Fahrenheit: %08x\n", temp16);
|
||||
sndbg("Fahrenheit: %08x\n", temp16);
|
||||
}
|
||||
|
||||
*temp = temp16;
|
||||
|
@ -256,14 +245,14 @@ static int lm75_readconf(FAR struct lm75_dev_s *priv, FAR uint8_t *conf)
|
|||
ret = I2C_WRITE(priv->i2c, &buffer, 1);
|
||||
if (ret < 0)
|
||||
{
|
||||
lm75dbg("I2C_WRITE failed: %d\n", ret);
|
||||
sndbg("I2C_WRITE failed: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Restart and read 8-bits from the register */
|
||||
|
||||
ret = I2C_READ(priv->i2c, conf, 1);
|
||||
lm75dbg("conf: %02x ret: %d\n", *conf, ret);
|
||||
sndbg("conf: %02x ret: %d\n", *conf, ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -279,7 +268,7 @@ static int lm75_writeconf(FAR struct lm75_dev_s *priv, uint8_t conf)
|
|||
{
|
||||
uint8_t buffer[2];
|
||||
|
||||
lm75dbg("conf: %02x\n", conf);
|
||||
sndbg("conf: %02x\n", conf);
|
||||
|
||||
/* Set up a 2 byte message to send */
|
||||
|
||||
|
@ -336,7 +325,7 @@ static ssize_t lm75_read(FAR struct file *filep, FAR char *buffer, size_t buflen
|
|||
nsamples = buflen / sizeof(b16_t);
|
||||
ptr = (FAR b16_t *)buffer;
|
||||
|
||||
lm75dbg("buflen: %d nsamples: %d\n", buflen, nsamples);
|
||||
sndbg("buflen: %d nsamples: %d\n", buflen, nsamples);
|
||||
|
||||
/* Get the requested number of samples */
|
||||
|
||||
|
@ -349,7 +338,7 @@ static ssize_t lm75_read(FAR struct file *filep, FAR char *buffer, size_t buflen
|
|||
ret = lm75_readtemp(priv, &temp);
|
||||
if (ret < 0)
|
||||
{
|
||||
lm75dbg("lm75_readtemp failed: %d\n",ret);
|
||||
sndbg("lm75_readtemp failed: %d\n",ret);
|
||||
return (ssize_t)ret;
|
||||
}
|
||||
|
||||
|
@ -389,7 +378,7 @@ static int lm75_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
{
|
||||
FAR uint8_t *ptr = (FAR uint8_t *)((uintptr_t)arg);
|
||||
ret = lm75_readconf(priv, ptr);
|
||||
lm75dbg("conf: %02x ret: %d\n", *ptr, ret);
|
||||
sndbg("conf: %02x ret: %d\n", *ptr, ret);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -397,7 +386,7 @@ static int lm75_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
|
||||
case SNIOC_WRITECONF:
|
||||
ret = lm75_writeconf(priv, (uint8_t)arg);
|
||||
lm75dbg("conf: %02x ret: %d\n", *(uint8_t*)arg, ret);
|
||||
sndbg("conf: %02x ret: %d\n", *(uint8_t*)arg, ret);
|
||||
break;
|
||||
|
||||
/* Shutdown the LM75, Arg: None */
|
||||
|
@ -410,7 +399,8 @@ static int lm75_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
{
|
||||
ret = lm75_writeconf(priv, conf | LM75_CONF_SHUTDOWN);
|
||||
}
|
||||
lm75dbg("conf: %02x ret: %d\n", conf | LM75_CONF_SHUTDOWN, ret);
|
||||
|
||||
sndbg("conf: %02x ret: %d\n", conf | LM75_CONF_SHUTDOWN, ret);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -424,7 +414,8 @@ static int lm75_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
{
|
||||
ret = lm75_writeconf(priv, conf & ~LM75_CONF_SHUTDOWN);
|
||||
}
|
||||
lm75dbg("conf: %02x ret: %d\n", conf & ~LM75_CONF_SHUTDOWN, ret);
|
||||
|
||||
sndbg("conf: %02x ret: %d\n", conf & ~LM75_CONF_SHUTDOWN, ret);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -432,14 +423,14 @@ static int lm75_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
|
||||
case SNIOC_FAHRENHEIT:
|
||||
priv->fahrenheit = true;
|
||||
lm75dbg("Fahrenheit\n");
|
||||
sndbg("Fahrenheit\n");
|
||||
break;
|
||||
|
||||
/* Report Samples in Centigrade */
|
||||
|
||||
case SNIOC_CENTIGRADE:
|
||||
priv->fahrenheit = false;
|
||||
lm75dbg("Centigrade\n");
|
||||
sndbg("Centigrade\n");
|
||||
break;
|
||||
|
||||
/* Read THYS temperature register. Arg: b16_t* pointer */
|
||||
|
@ -448,7 +439,7 @@ static int lm75_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
{
|
||||
FAR b16_t *ptr = (FAR b16_t *)((uintptr_t)arg);
|
||||
ret = lm75_readb16(priv, LM75_THYS_REG, ptr);
|
||||
lm75dbg("THYS: %08x ret: %d\n", *ptr, ret);
|
||||
sndbg("THYS: %08x ret: %d\n", *ptr, ret);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -456,7 +447,7 @@ static int lm75_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
|
||||
case SNIOC_WRITETHYS:
|
||||
ret = lm75_writeb16(priv, LM75_THYS_REG, (b16_t)arg);
|
||||
lm75dbg("THYS: %08x ret: %d\n", (b16_t)arg, ret);
|
||||
sndbg("THYS: %08x ret: %d\n", (b16_t)arg, ret);
|
||||
break;
|
||||
|
||||
/* Read TOS (Over-temp Shutdown Threshold) Register. Arg: b16_t* pointer */
|
||||
|
@ -465,7 +456,7 @@ static int lm75_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
{
|
||||
FAR b16_t *ptr = (FAR b16_t *)((uintptr_t)arg);
|
||||
ret = lm75_readb16(priv, LM75_TOS_REG, ptr);
|
||||
lm75dbg("TOS: %08x ret: %d\n", *ptr, ret);
|
||||
sndbg("TOS: %08x ret: %d\n", *ptr, ret);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -473,11 +464,11 @@ static int lm75_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
|
||||
case SNIOC_WRITRETOS:
|
||||
ret = lm75_writeb16(priv, LM75_TOS_REG, (b16_t)arg);
|
||||
lm75dbg("TOS: %08x ret: %d\n", (b16_t)arg, ret);
|
||||
sndbg("TOS: %08x ret: %d\n", (b16_t)arg, ret);
|
||||
break;
|
||||
|
||||
default:
|
||||
lm75dbg("Unrecognized cmd: %d\n", cmd);
|
||||
sndbg("Unrecognized cmd: %d\n", cmd);
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
@ -517,7 +508,7 @@ int lm75_register(FAR const char *devpath, FAR struct i2c_dev_s *i2c, uint8_t ad
|
|||
priv = (FAR struct lm75_dev_s *)kmm_malloc(sizeof(struct lm75_dev_s));
|
||||
if (!priv)
|
||||
{
|
||||
lm75dbg("Failed to allocate instance\n");
|
||||
sndbg("Failed to allocate instance\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -530,7 +521,7 @@ int lm75_register(FAR const char *devpath, FAR struct i2c_dev_s *i2c, uint8_t ad
|
|||
ret = register_driver(devpath, &g_lm75fops, 0666, priv);
|
||||
if (ret < 0)
|
||||
{
|
||||
lm75dbg("Failed to register driver: %d\n", ret);
|
||||
sndbg("Failed to register driver: %d\n", ret);
|
||||
kmm_free(priv);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,19 +68,6 @@
|
|||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Debug ********************************************************************/
|
||||
/* Non-standard debug that may be enabled just for testing PWM */
|
||||
|
||||
#ifdef CONFIG_DEBUG_QENCODER
|
||||
# define qedbg dbg
|
||||
# define qevdbg vdbg
|
||||
# define qelldbg lldbg
|
||||
# define qellvdbg llvdbg
|
||||
#else
|
||||
# define qedbg(x...)
|
||||
# define qevdbg(x...)
|
||||
# define qelldbg(x...)
|
||||
# define qellvdbg(x...)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Type Definitions
|
||||
|
@ -141,7 +128,7 @@ static int qe_open(FAR struct file *filep)
|
|||
uint8_t tmp;
|
||||
int ret;
|
||||
|
||||
qevdbg("crefs: %d\n", upper->crefs);
|
||||
snvdbg("crefs: %d\n", upper->crefs);
|
||||
|
||||
/* Get exclusive access to the device structures */
|
||||
|
||||
|
@ -175,7 +162,7 @@ static int qe_open(FAR struct file *filep)
|
|||
/* Yes.. perform one time hardware initialization. */
|
||||
|
||||
DEBUGASSERT(lower->ops->setup != NULL);
|
||||
qevdbg("calling setup\n");
|
||||
snvdbg("calling setup\n");
|
||||
|
||||
ret = lower->ops->setup(lower);
|
||||
if (ret < 0)
|
||||
|
@ -210,7 +197,7 @@ static int qe_close(FAR struct file *filep)
|
|||
FAR struct qe_upperhalf_s *upper = inode->i_private;
|
||||
int ret;
|
||||
|
||||
qevdbg("crefs: %d\n", upper->crefs);
|
||||
snvdbg("crefs: %d\n", upper->crefs);
|
||||
|
||||
/* Get exclusive access to the device structures */
|
||||
|
||||
|
@ -240,7 +227,7 @@ static int qe_close(FAR struct file *filep)
|
|||
/* Disable the PWM device */
|
||||
|
||||
DEBUGASSERT(lower->ops->shutdown != NULL);
|
||||
qevdbg("calling shutdown: %d\n");
|
||||
snvdbg("calling shutdown: %d\n");
|
||||
|
||||
lower->ops->shutdown(lower);
|
||||
}
|
||||
|
@ -298,7 +285,7 @@ static int qe_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
FAR struct qe_lowerhalf_s *lower = upper->lower;
|
||||
int ret;
|
||||
|
||||
qevdbg("cmd: %d arg: %ld\n", cmd, arg);
|
||||
snvdbg("cmd: %d arg: %ld\n", cmd, arg);
|
||||
DEBUGASSERT(upper && lower);
|
||||
|
||||
/* Get exclusive access to the device structures */
|
||||
|
@ -340,7 +327,7 @@ static int qe_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||
|
||||
default:
|
||||
{
|
||||
qevdbg("Forwarding unrecognized cmd: %d arg: %ld\n", cmd, arg);
|
||||
snvdbg("Forwarding unrecognized cmd: %d arg: %ld\n", cmd, arg);
|
||||
DEBUGASSERT(lower->ops->ioctl != NULL);
|
||||
ret = lower->ops->ioctl(lower, cmd, arg);
|
||||
}
|
||||
|
@ -385,7 +372,7 @@ int qe_register(FAR const char *devpath, FAR struct qe_lowerhalf_s *lower)
|
|||
upper = (FAR struct qe_upperhalf_s *)kmm_zalloc(sizeof(struct qe_upperhalf_s));
|
||||
if (!upper)
|
||||
{
|
||||
qedbg("Allocation failed\n");
|
||||
sndbg("Allocation failed\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
|
@ -396,7 +383,7 @@ int qe_register(FAR const char *devpath, FAR struct qe_lowerhalf_s *lower)
|
|||
|
||||
/* Register the PWM device */
|
||||
|
||||
qevdbg("Registering %s\n", devpath);
|
||||
snvdbg("Registering %s\n", devpath);
|
||||
return register_driver(devpath, &g_qeops, 0666, upper);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* include/debug.h
|
||||
*
|
||||
* Copyright (C) 2007-2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2011, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -248,6 +248,18 @@
|
|||
# define illvdbg(x...)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_SENSORS
|
||||
# define sndbg(format, ...) dbg(format, ##__VA_ARGS__)
|
||||
# define snlldbg(format, ...) lldbg(format, ##__VA_ARGS__)
|
||||
# define snvdbg(format, ...) vdbg(format, ##__VA_ARGS__)
|
||||
# define snllvdbg(format, ...) llvdbg(format, ##__VA_ARGS__)
|
||||
#else
|
||||
# define sndbg(x...)
|
||||
# define snlldbg(x...)
|
||||
# define snvdbg(x...)
|
||||
# define snllvdbg(x...)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_ANALOG
|
||||
# define adbg(format, ...) dbg(format, ##__VA_ARGS__)
|
||||
# define alldbg(format, ...) lldbg(format, ##__VA_ARGS__)
|
||||
|
@ -441,6 +453,18 @@
|
|||
# define illvdbg (void)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_SENSORS
|
||||
# define sndbg dbg
|
||||
# define snlldbg lldbg
|
||||
# define snvdbg vdbg
|
||||
# define snllvdbg llvdbg
|
||||
#else
|
||||
# define sndbg (void)
|
||||
# define snlldbg (void)
|
||||
# define snvdbg (void)
|
||||
# define snllvdbg (void)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_ANALOG
|
||||
# define adbg dbg
|
||||
# define alldbg lldbg
|
||||
|
|
Loading…
Reference in a new issue