X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=bertos%2Fdrv%2Fwm8731.h;h=3404d0286bfa1e8fb52ba6ff8ab60a010a7d7236;hb=15810459b8f5fb09b12cef6f8e4d4e64d167087b;hp=244b80eab6604268d251c5bf52aa330df1f5d2fc;hpb=a3c8fd5c3fca6e0bad57e6b554442e6efb88fcdf;p=bertos.git diff --git a/bertos/drv/wm8731.h b/bertos/drv/wm8731.h index 244b80ea..3404d028 100644 --- a/bertos/drv/wm8731.h +++ b/bertos/drv/wm8731.h @@ -53,31 +53,31 @@ /* Left Line in register */ #define WM8731_REG_LEFT_LINEIN 0x0 -#define WM8731_LINVOL_BITS_MASK 0xF // Left line input volume control +#define WM8731_LINVOL_BITS_MASK 0x1F // Left line input volume control #define WM8731_LINMUTE_BIT 7 // Left line input mute to ADC #define WM8731_LRINBOTH_BIT 8 // Left to right channel line input volume and mute data load control /* Right Line in register */ #define WM8731_REG_RIGHT_LINEIN 0x1 -#define WM8731_RINVOL_BITS_MASK 0xF // Right line input volume control +#define WM8731_RINVOL_BITS_MASK 0x1F // Right line input volume control #define WM8731_RINMUTE_BIT 7 // Right line input mute to ADC #define WM8731_RLINBOTH_BIT 8 // Right to right channel line input volume and mute data load control /* Left Headphone out register*/ #define WM8731_REG_LEFT_HPOUT 0x2 -#define WM8731_LHPVOL_BITS_MASK 0x7 // Left channel headphone output volume control +#define WM8731_LHPVOL_BITS_MASK 0x7F // Left channel headphone output volume control #define WM8731_LZCEN_BIT 7 // Left channel zero cross detect enable #define WM8731_LRHPBOTH_BIT 8 // Left to right channel headphone volume, mute and zero cross data load control /* Right Headphone out register*/ #define WM8731_REG_RIGHT_HPOUT 0x3 -#define WM8731_RHPVOL_BITS_MASK 0x7 // Right channel headphone output volume control +#define WM8731_RHPVOL_BITS_MASK 0x7F // Right channel headphone output volume control #define WM8731_RZCEN_BIT 7 // Right channel zero cross detect enable #define WM8731_RLHPBOTH_BIT 8 // Right to right channel headphone volume, mute and zero cross data load control /* 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 @@ -131,11 +131,19 @@ /* 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 @@ -153,6 +161,14 @@ #define WM8731_SR_BITS_MASK 0x3C // Sample rate control #define WM8731_CLKIDIV2_BIT 6 // Core clock divider select #define WM8731_CLKODIV2_BIT 7 // CLKOUT divider select +/** + * Sampling rate control + * $WIZ$ wm8731_sample_rate = "WM8731_NORMAL_256FS_48KHZ", "WM8731_NORMAL_256FS_44_1KHZ", "WM8731_NORMAL_384FS_44_1KHZ" + */ +#define WM8731_NORMAL_256FS_48KHZ 0 +#define WM8731_NORMAL_256FS_44_1KHZ 0x20 +#define WM8731_NORMAL_384FS_44_1KHZ 0x22 +#define WM8731_NORMAL_128FS_44_1KHZ 0x3E /* Active control register*/ #define WM8731_REG_ACTIVE_CTRL 0x9 @@ -166,14 +182,16 @@ typedef struct Wm8731 } Wm8731; - -#define WM8731_LINE_IN_RX BV(0) -#define WM8731_LINE_IN_LX BV(1) -#define WM8731_HEADPHONE_RX BV(2) -#define WM8731_HEADPHONE_LX BV(3) +/** + * Devices which is possible to set volume + * \} + */ +#define WM8731_LINE_IN BV(0) +#define WM8731_HEADPHONE BV(1) +/* \} */ /** - * Set the volume of select device (line in Rx/Lx, Headphone Rx/Lx). + * Set the volume of select device line in or Headphone. * The volume is express in %, and the volume range is 0-100%. */ void wm8731_setVolume(Wm8731 *ctx, uint16_t device, uint8_t volume);