mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 13:18:50 +08:00
Add debug logic to dump WM8904 registers
This commit is contained in:
parent
83dab03576
commit
e59bb45b33
6 changed files with 283 additions and 17 deletions
|
@ -2697,20 +2697,21 @@ I2S Audio Support
|
|||
WM8904 Audio CODEC Interface
|
||||
----------------------------
|
||||
|
||||
------------- ---------------- -----------------
|
||||
WM8904 SAMA5D3 NuttX Pin Name
|
||||
------------- ---------------- -----------------
|
||||
3 SDA PA30 TWD0 PIO_TWI0_D
|
||||
2 SCLK PA31 TWCK0 PIO_TWI0_CK
|
||||
28 MCLK PD30 PCK0 PIO_PMC_PCK0
|
||||
29 BCLK/GPIO4 PC16 TK PIO_SSC0_TK
|
||||
"" " " PC19 RK PIO_SSC0_RK
|
||||
30 LRCLK PC17 TF PIO_SSC0_TF
|
||||
"" " " PC20 RF PIO_SSC0_RF
|
||||
31 ADCDAT PC21 RD PIO_SSC0_RD
|
||||
32 DACDAT PC18 TD PIO_SSC0_TD
|
||||
1 IRQ/GPIO1 PD16 INT_AUDIO N/A
|
||||
------------- ---------------- -----------------
|
||||
------------- ---------------- ----------------- ----------------------
|
||||
WM8904 SAMA5D3 NuttX Pin Name External Access
|
||||
------------- ---------------- ----------------- ----------------------
|
||||
3 SDA PA30 TWD0 PIO_TWI0_D J1 Pin 34
|
||||
2 SCLK PA31 TWCK0 PIO_TWI0_CK J1 Pin 36
|
||||
28 MCLK PD30 PCK0 PIO_PMC_PCK0 (Not available)
|
||||
29 BCLK/GPIO4 PC16 TK PIO_SSC0_TK J2 Pin 6
|
||||
"" " " PC19 RK PIO_SSC0_RK J2 Pin 12
|
||||
30 LRCLK PC17 TF PIO_SSC0_TF J2 Pin 8
|
||||
"" " " PC20 RF PIO_SSC0_RF J2 Pin 14
|
||||
31 ADCDAT PC21 RD PIO_SSC0_RD J2 Pin 16
|
||||
32 DACDAT PC18 TD PIO_SSC0_TD J2 Pin 10
|
||||
1 IRQ/GPIO1 PD16 INT_AUDIO N/A (Not available)
|
||||
------------- ---------------- ----------------- ----------------------
|
||||
Ground at Pins 3,4,37,38
|
||||
|
||||
WM8904 Configuration
|
||||
--------------------
|
||||
|
|
|
@ -45,6 +45,9 @@ endif
|
|||
|
||||
ifeq ($(CONFIG_AUDIO_WM8904),y)
|
||||
CSRCS += wm8904.c
|
||||
ifeq ($(CONFIG_DEBUG_AUDIO),y)
|
||||
CSRCS += wm8904_debug.c
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_AUDIO_NULL),y)
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
#include "wm8904.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Definitions
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
#define WM8904_DUMMY 0xff
|
||||
|
@ -132,7 +132,10 @@ struct wm8904_dev_s
|
|||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
static uint16_t wm8904_readreg(FAR struct wm8904_dev_s *priv,
|
||||
#ifndef CONFIG_DEBUG_AUDIO
|
||||
static
|
||||
#endif
|
||||
uint16_t wm8904_readreg(FAR struct wm8904_dev_s *priv,
|
||||
uint8_t regaddr);
|
||||
static void wm8904_writereg(FAR struct wm8904_dev_s *priv,
|
||||
uint8_t regaddr, uint16_t regval);
|
||||
|
@ -256,7 +259,10 @@ static const struct audio_ops_s g_audioops =
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
static uint16_t wm8904_readreg(FAR struct wm8904_dev_s *priv, uint8_t regaddr)
|
||||
#ifndef CONFIG_DEBUG_AUDIO
|
||||
static
|
||||
#endif
|
||||
uint16_t wm8904_readreg(FAR struct wm8904_dev_s *priv, uint8_t regaddr)
|
||||
{
|
||||
int retries;
|
||||
|
||||
|
@ -1914,6 +1920,7 @@ FAR struct audio_lowerhalf_s *
|
|||
*/
|
||||
|
||||
wm8904_writereg(priv, WM8904_SWRST, 0);
|
||||
wm8904_dump_registers(&priv->dev, "After reset");
|
||||
|
||||
/* Verify that WM8904 is present and available on this I2C */
|
||||
|
||||
|
@ -1927,6 +1934,7 @@ FAR struct audio_lowerhalf_s *
|
|||
/* Configure the WM8904 hardware as an audio input device */
|
||||
|
||||
wm8904_audio_output(priv);
|
||||
wm8904_dump_registers(&priv->dev, "After configuration");
|
||||
|
||||
/* Attach our ISR to this device */
|
||||
|
||||
|
|
|
@ -983,5 +983,18 @@
|
|||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wm8904_readreg
|
||||
*
|
||||
* Description
|
||||
* Read the specified 16-bit register from the WM8904 device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_AUDIO
|
||||
struct wm8904_dev_s;
|
||||
uint16_t wm8904_readreg(FAR struct wm8904_dev_s *priv, uint8_t regaddr);
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_AUDIO */
|
||||
#endif /* __DRIVERS_AUDIO_WM8904_H */
|
||||
|
|
220
drivers/audio/wm8904_debug.c
Normal file
220
drivers/audio/wm8904_debug.c
Normal file
|
@ -0,0 +1,220 @@
|
|||
/****************************************************************************
|
||||
* drivers/audio/wm8904_debug.c
|
||||
*
|
||||
* Audio device driver for Wolfson Microelectronics WM8904 Audio codec.
|
||||
*
|
||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* References:
|
||||
* - "WM8904 Ultra Low Power CODEC for Portable Audio Applications, Pre-
|
||||
* Production", September 2012, Rev 3.3, Wolfson Microelectronics
|
||||
*
|
||||
* - The framework for this driver is based on Ken Pettit's VS1053 driver.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <nuttx/audio/audio.h>
|
||||
|
||||
#include "wm8904.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
struct wm8904_debug_s
|
||||
{
|
||||
FAR const char *regname;
|
||||
uint8_t regaddr;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static const struct wm8904_debug_s g_wm8904_debug[] =
|
||||
{
|
||||
{"ID", WM8904_ID },
|
||||
{"BIAS_CTRL", WM8904_BIAS_CTRL },
|
||||
{"VMID_CTRL", WM8904_VMID_CTRL },
|
||||
{"MIC_BIAS_CTRL0", WM8904_MIC_BIAS_CTRL0 },
|
||||
{"MIC_BIAS_CTRL1", WM8904_MIC_BIAS_CTRL1 },
|
||||
{"ANALOG_ADC", WM8904_ANALOG_ADC },
|
||||
{"PM0", WM8904_PM0 },
|
||||
{"PM2", WM8904_PM2 },
|
||||
{"PM3", WM8904_PM3 },
|
||||
{"PM6", WM8904_PM6 },
|
||||
{"CLKRATE0", WM8904_CLKRATE0 },
|
||||
{"CLKRATE1", WM8904_CLKRATE1 },
|
||||
{"CLKRATE2", WM8904_CLKRATE2 },
|
||||
{"AIF0", WM8904_AIF0 },
|
||||
{"AIF1", WM8904_AIF1 },
|
||||
{"AIF2", WM8904_AIF2 },
|
||||
{"AIF3", WM8904_AIF3 },
|
||||
{"DAC_VOL_LEFT", WM8904_DAC_VOL_LEFT },
|
||||
{"DAC_VOL_RIGHT", WM8904_DAC_VOL_RIGHT },
|
||||
{"DAC_DIGI0", WM8904_DAC_DIGI0 },
|
||||
{"DAC_DIGI1", WM8904_DAC_DIGI1 },
|
||||
{"ADC_VOL_LEFT", WM8904_ADC_VOL_LEFT },
|
||||
{"ADC_VOL_RIGHT", WM8904_ADC_VOL_RIGHT },
|
||||
{"ADC_DIGI", WM8904_ADC_DIGI },
|
||||
{"MIC_DIGI", WM8904_MIC_DIGI },
|
||||
{"DRC0", WM8904_DRC0 },
|
||||
{"DRC1", WM8904_DRC1 },
|
||||
{"DRC2", WM8904_DRC2 },
|
||||
{"DRC3", WM8904_DRC3 },
|
||||
{"ANA_LEFT_IN0", WM8904_ANA_LEFT_IN0 },
|
||||
{"ANA_RIGHT_IN0", WM8904_ANA_RIGHT_IN0 },
|
||||
{"ANA_LEFT_IN1", WM8904_ANA_LEFT_IN1 },
|
||||
{"ANA_RIGHT_IN1", WM8904_ANA_RIGHT_IN1 },
|
||||
{"ANA_LEFT_OUT1", WM8904_ANA_LEFT_OUT1 },
|
||||
{"ANA_RIGHT_OUT1", WM8904_ANA_RIGHT_OUT1 },
|
||||
{"ANA_LEFT_OUT2", WM8904_ANA_LEFT_OUT2 },
|
||||
{"ANA_RIGHT_OUT2", WM8904_ANA_RIGHT_OUT2 },
|
||||
{"ANA_OUT12_ZC", WM8904_ANA_OUT12_ZC },
|
||||
{"DC_SERVO0", WM8904_DC_SERVO0 },
|
||||
{"DC_SERVO1", WM8904_DC_SERVO1 },
|
||||
{"DC_SERVO2", WM8904_DC_SERVO2 },
|
||||
{"DC_SERVO4", WM8904_DC_SERVO4 },
|
||||
{"DC_SERVO5", WM8904_DC_SERVO5 },
|
||||
{"DC_SERVO6", WM8904_DC_SERVO6 },
|
||||
{"DC_SERVO7", WM8904_DC_SERVO7 },
|
||||
{"DC_SERVO8", WM8904_DC_SERVO8 },
|
||||
{"DC_SERVO9", WM8904_DC_SERVO9 },
|
||||
{"DC_SERVO_RDBACK", WM8904_DC_SERVO_RDBACK },
|
||||
{"ANA_HP0", WM8904_ANA_HP0 },
|
||||
{"ANA_LINEOUT0", WM8904_ANA_LINEOUT0 },
|
||||
{"CHG_PUMP0", WM8904_CHG_PUMP0 },
|
||||
{"CLASS_W0", WM8904_CLASS_W0 },
|
||||
{"WR_SEQ0", WM8904_WR_SEQ0 },
|
||||
{"WR_SEQ1", WM8904_WR_SEQ1 },
|
||||
{"WR_SEQ2", WM8904_WR_SEQ2 },
|
||||
{"WR_SEQ3", WM8904_WR_SEQ3 },
|
||||
{"WR_SEQ4", WM8904_WR_SEQ4 },
|
||||
{"FLL_CTRL1", WM8904_FLL_CTRL1 },
|
||||
{"FLL_CTRL2", WM8904_FLL_CTRL2 },
|
||||
{"FLL_CTRL3", WM8904_FLL_CTRL3 },
|
||||
{"FLL_CTRL4", WM8904_FLL_CTRL4 },
|
||||
{"FLL_CTRL5", WM8904_FLL_CTRL5 },
|
||||
{"GPIO_CTRL1", WM8904_GPIO_CTRL1 },
|
||||
{"GPIO_CTRL2", WM8904_GPIO_CTRL2 },
|
||||
{"GPIO_CTRL3", WM8904_GPIO_CTRL3 },
|
||||
{"GPIO_CTRL4", WM8904_GPIO_CTRL4 },
|
||||
{"DIGI_PULLS", WM8904_DIGI_PULLS },
|
||||
{"INT_STATUS", WM8904_INT_STATUS },
|
||||
{"INT_MASK", WM8904_INT_MASK },
|
||||
{"INT_POL", WM8904_INT_POL },
|
||||
{"INT_DEBOUNCE", WM8904_INT_DEBOUNCE },
|
||||
{"EQ1", WM8904_EQ1 },
|
||||
{"EQ2", WM8904_EQ2 },
|
||||
{"EQ3", WM8904_EQ3 },
|
||||
{"EQ4", WM8904_EQ4 },
|
||||
{"EQ5", WM8904_EQ5 },
|
||||
{"EQ6", WM8904_EQ6 },
|
||||
{"EQ7", WM8904_EQ7 },
|
||||
{"EQ8", WM8904_EQ8 },
|
||||
{"EQ9", WM8904_EQ9 },
|
||||
{"EQ10", WM8904_EQ10 },
|
||||
{"EQ11", WM8904_EQ11 },
|
||||
{"EQ12", WM8904_EQ12 },
|
||||
{"EQ13", WM8904_EQ13 },
|
||||
{"EQ14", WM8904_EQ14 },
|
||||
{"EQ15", WM8904_EQ15 },
|
||||
{"EQ16", WM8904_EQ16 },
|
||||
{"EQ17", WM8904_EQ17 },
|
||||
{"EQ18", WM8904_EQ18 },
|
||||
{"EQ19", WM8904_EQ19 },
|
||||
{"EQ20", WM8904_EQ20 },
|
||||
{"EQ21", WM8904_EQ21 },
|
||||
{"EQ22", WM8904_EQ22 },
|
||||
{"EQ23", WM8904_EQ23 },
|
||||
{"EQ24", WM8904_EQ24 },
|
||||
{"ADC_TEST", WM8904_ADC_TEST },
|
||||
{"FLL_NCO_TEST0", WM8904_FLL_NCO_TEST0 },
|
||||
{"FLL_NCO_TEST1", WM8904_FLL_NCO_TEST1 }
|
||||
};
|
||||
|
||||
#define WM8904_NREGISTERS (sizeof(g_wm8904_debug)/sizeof(struct wm8904_debug_s))
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wm8904_dump_registers
|
||||
*
|
||||
* Description:
|
||||
* Dump the contents of all WM8904 registers to the syslog device
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - The device instance returned by wm8904_initialize
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_AUDIO
|
||||
void wm8904_dump_registers(FAR struct audio_lowerhalf_s *dev,
|
||||
FAR const char *msg)
|
||||
{
|
||||
int i;
|
||||
|
||||
syslog("WM8904 Registers: %s\n", msg);
|
||||
for (i = 0; i < WM8904_NREGISTERS; i++)
|
||||
{
|
||||
syslog("%16s[%02x]: %04x\n",
|
||||
g_wm8904_debug[i].regname, g_wm8904_debug[i].regaddr,
|
||||
wm8904_readreg((FAR struct wm8904_dev_s *)dev,
|
||||
g_wm8904_debug[i].regaddr));
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -212,6 +212,27 @@ FAR struct audio_lowerhalf_s *
|
|||
wm8904_initialize(FAR struct i2c_dev_s *i2c, FAR struct i2s_dev_s *i2s,
|
||||
FAR const struct wm8904_lower_s *lower);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: wm8904_dump_registers
|
||||
*
|
||||
* Description:
|
||||
* Dump the contents of all WM8904 registers to the syslog device
|
||||
*
|
||||
* Input Parameters:
|
||||
* dev - The device instance returned by wm8904_initialize
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_AUDIO
|
||||
void wm8904_dump_registers(FAR struct audio_lowerhalf_s *dev,
|
||||
FAR const char *msg);
|
||||
#else
|
||||
# define wm8904_dump_registers(d)
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue