X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Fwm8731.c;h=e96ce6f1614d76eb2d4949a9ede95074619f808b;hb=a9ebbfb868ccabfbaa3f012484ea4f0a651ebc5e;hp=340ca817c4f353473ada885a0eb63b9d9341132d;hpb=58d88967207425fd0fc11e5b9ca2f98b6745e01f;p=bertos.git 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 */