From a9ebbfb868ccabfbaa3f012484ea4f0a651ebc5e Mon Sep 17 00:00:00 2001 From: asterix Date: Fri, 16 Sep 2011 16:55:40 +0000 Subject: [PATCH] Fix initialization. Use macro for sampling rate. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@5064 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/drv/wm8731.c | 21 +++++++++++++------ .../examples/sam3x-ek_codec/cfg/cfg_wm8731.h | 5 +++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/bertos/drv/wm8731.c b/bertos/drv/wm8731.c index 340ca817..e96ce6f1 100644 --- a/bertos/drv/wm8731.c +++ b/bertos/drv/wm8731.c @@ -137,12 +137,21 @@ void wm8731_init(Wm8731 *ctx, I2c *i2c, uint8_t codec_addr) /* Configure the codec */ - wm8731_write(ctx, WM8731_REG_DIGITAL_PATH_CTRL, CONFIG_WM8731_DEEMP | CONFIG_WM8731_DAPC | - (CONFIG_WM8731_DACMU << WM8731_DACMU)); - wm8731_write(ctx, WM8731_REG_ANALOGUE_PATH_CTRL, (CONFIG_WM8731_MICBOOST ? BV(WM8731_MICBOOST) : ~BV(WM8731_MICBOOST)) | - CONFIG_WM8731_INSEL | CONFIG_WM8731_BYPASS | CONFIG_WM8731_SIDEATT); - wm8731_write(ctx, WM8731_REG_DA_INTERFACE_FORMAT, CONFIG_WM8731_INTERFACE_FORMAT | CONFIG_WM8731_IWL_BITS | - (CONFIG_WM8731_MS ? BV(WM8731_MS_BIT) : ~BV(WM8731_MS_BIT))); + wm8731_write(ctx, WM8731_REG_DIGITAL_PATH_CTRL, CONFIG_WM8731_DEEMP | CONFIG_WM8731_DAPC | (CONFIG_WM8731_DACMU << WM8731_DACMU)); + + #if CONFIG_WM8731_MICBOOST + wm8731_write(ctx, WM8731_REG_ANALOGUE_PATH_CTRL, BV(WM8731_MICBOOST) | CONFIG_WM8731_INSEL | CONFIG_WM8731_BYPASS | CONFIG_WM8731_SIDEATT); + #else + wm8731_write(ctx, WM8731_REG_ANALOGUE_PATH_CTRL, (CONFIG_WM8731_INSEL | CONFIG_WM8731_BYPASS | CONFIG_WM8731_SIDEATT) & ~BV(WM8731_MICBOOST)); + #endif + + #if CONFIG_WM8731_MS + wm8731_write(ctx, WM8731_REG_DA_INTERFACE_FORMAT, CONFIG_WM8731_INTERFACE_FORMAT | CONFIG_WM8731_IWL_BITS | BV(WM8731_MS_BIT)); + #else + wm8731_write(ctx, WM8731_REG_DA_INTERFACE_FORMAT, + (CONFIG_WM8731_INTERFACE_FORMAT | CONFIG_WM8731_IWL_BITS | BV(WM8731_MS_BIT)) & ~BV(WM8731_MS_BIT)); + #endif + wm8731_write(ctx, WM8731_REG_SAMPLECTRL, CONFIG_WM8731_SAMPLING_RATES); /* By default we turn on all devices and disable only the outclock */ diff --git a/boards/sam3x-ek/examples/sam3x-ek_codec/cfg/cfg_wm8731.h b/boards/sam3x-ek/examples/sam3x-ek_codec/cfg/cfg_wm8731.h index e268b801..b90815b1 100644 --- a/boards/sam3x-ek/examples/sam3x-ek_codec/cfg/cfg_wm8731.h +++ b/boards/sam3x-ek/examples/sam3x-ek_codec/cfg/cfg_wm8731.h @@ -126,8 +126,9 @@ /** * Data sampling rate, refer to datasheet for this value. - * $WIZ$ type = "hex" + * $WIZ$ type = "enum" + * $WIZ$ value_list = "wm8731_sample_rate" */ -#define CONFIG_WM8731_SAMPLING_RATES 0x6 +#define CONFIG_WM8731_SAMPLING_RATES WM8731_NORMAL_256FS_44_1KHZ #endif /* CFG_WM8731_H */ -- 2.25.1