Move some settings into cfg file.
authorasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 18 Jul 2011 13:37:21 +0000 (13:37 +0000)
committerasterix <asterix@38d2e660-2303-0410-9eaa-f027e97ec537>
Mon, 18 Jul 2011 13:37:21 +0000 (13:37 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4973 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/cfg/cfg_wm8731.h
bertos/drv/wm8731.c
bertos/drv/wm8731.h

index 59651315eb3a40dad4e01ce781d205848a0a39c7..76280b6541b2aa9c7e92494d86ad33f7ffd8fc36 100644 (file)
@@ -93,7 +93,7 @@
  * $WIZ$ type = "enum"
  * $WIZ$ value_list = "wm8731_bypass"
  */
-#define CONFIG_WM8731_BYPASS     WM8731_BYPASS
+#define CONFIG_WM8731_BYPASS     WM8731_DACSEL
 
 /**
  * Analog control: Side tone attenuation
  */
 #define CONFIG_WM8731_SIDEATT     WM8731_SIDEATT_6dB
 
+
+/**
+ * Digital Audio interface format.
+ * $WIZ$ type = "enum"
+ * $WIZ$ value_list = "wm8731_fmt"
+ */
+#define CONFIG_WM8731_INTERFACE_FORMAT    WM8731_FORMAT_I2S
+
+/**
+ * Digital Audio data bit length.
+ * $WIZ$ type = "enum"
+ * $WIZ$ value_list = "wm8731_databit"
+ */
+#define CONFIG_WM8731_IWL_BITS            WM8731_IWL_16_BIT
+
+/**
+ * Enable Master mode.
+ * $WIZ$ type = "boolean"
+ */
+#define CONFIG_WM8731_MS     0
+
+
+/**
+ * Data sampling rate, refer to datasheet for this value.
+ * $WIZ$ type = "hex"
+ */
+#define CONFIG_WM8731_SAMPLING_RATES     0x6
+
 #endif /* CFG_WM8731_H */
index 2a921792e49e3ed65278a9b4c4bf0d249bfdf61a..3bb09f28dcc88f2777c63d8028ad755399d24537 100644 (file)
@@ -153,14 +153,13 @@ 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 ? WM8731_MICBOOST : ~WM8731_MICBOOST) |
+       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, 0x2);
-       wm8731_write(ctx, WM8731_REG_SAMPLECTRL, 0x6);
-
-       wm8731_write(ctx, WM8731_REG_ACTIVE_CTRL, 1);
+       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_SAMPLECTRL, CONFIG_WM8731_SAMPLING_RATES);
 
        /* By default we turn on all devices and disable only the outclock */
+       wm8731_write(ctx, WM8731_REG_ACTIVE_CTRL, 1);
        wm8731_write(ctx, WM8731_REG_PWDOWN_CTRL, 0x47);
 }
index 244b80eab6604268d251c5bf52aa330df1f5d2fc..2cccc691d04a20a642640feacd322a71e055cbcf 100644 (file)
@@ -77,7 +77,7 @@
 
 /* Analogue audio path control register*/
 #define WM8731_REG_ANALOGUE_PATH_CTRL              0x4
-#define WM8731_MICBOOST                          BV(0) // Microphone Input Level Boost
+#define WM8731_MICBOOST                              0 // Microphone Input Level Boost
 #define WM8731_MUTEMIC                               1 // Line input Mute to ADC
 /**
  * Input selector
 
 /* Interface format register*/
 #define WM8731_REG_DA_INTERFACE_FORMAT             0x7
+/**
+ * Audio format
+ * $WIZ$ wm8731_fmt = "WM8731_FORMAT_MSB_LEFT_JUSTIFIED", "WM8731_FORMAT_MSB_RIGHT_JUSTIFIED", "WM8731_FORMAT_I2S", "WM8731_FORMAT_DSP"
+ */
 #define WM8731_FORMAT_BITS_MASK                    0x3 // Format
 #define WM8731_FORMAT_MSB_LEFT_JUSTIFIED           0x0 // MSB-First, left justified
 #define WM8731_FORMAT_MSB_RIGHT_JUSTIFIED          0x1 // MSB-First, right justified
 #define WM8731_FORMAT_I2S                          0x2 //I2S Format, MSB-First left-1 justified
 #define WM8731_FORMAT_DSP                          0x3 //DSP Mode, frame sync + 2 data packed words
+/**
+ * Audio format
+ * $WIZ$ wm8731_databit = "WM8731_IWL_16_BIT", "WM8731_IWL_20_BIT", "WM8731_IWL_24_BIT", "WM8731_IWL_32_BIT"
+ */
 #define WM8731_IWL_BITS                            0xC // Input audio data bit length select
 #define WM8731_IWL_16_BIT                          0x0 // 16 bit
 #define WM8731_IWL_20_BIT                          0x4 // 20 bit