--- name: wm8731 author: Jason Berger created: 01/30/2020 category: Device description: Aduio codec datasheet: https://statics.cirrus.com/pubs/proDatasheet/WM8731_v4.9.pdf mfr: STMicroelectronics mfr_pn: WM8731CLSEFL digikey_pn: WM8731CSEFL-ND prefix: wm bus: I2C, SPI i2c_addr: 0x34 ########################################################################################################### # REGISTERS # ########################################################################################################### registers: - LEFT_IN: { addr: 0x00 , type: uint16_t, default: 0x097, perm: W, desc: Left line in control} - RIGHT_IN: { addr: 0x01 , type: uint16_t, default: 0x097, perm: W, desc: Right line in control} - LEFT_OUT: { addr: 0x02 , type: uint16_t, default: 0x079, perm: W, desc: Left Headphone Out control} - RIGHT_OUT: { addr: 0x03 , type: uint16_t, default: 0x079, perm: W, desc: Right Headphone Out control} - AN_PATH: { addr: 0x04 , type: uint16_t, default: 0x00A, perm: W, desc: analog audio path control} - DIG_PATH: { addr: 0x05 , type: uint16_t, default: 0x008, perm: W, desc: Digital audio path control} - POWER_DWN: { addr: 0x06 , type: uint16_t, default: 0x09F, perm: W, desc: Power Down control} - DIG_IFACE: { addr: 0x07 , type: uint16_t, default: 0x09F, perm: W, desc: Digital audio interface format} - SAMPLE: { addr: 0x08 , type: uint16_t, default: 0x000, perm: W, desc: Sampling control} - ACTIVE: { addr: 0x09 , type: uint16_t, default: 0x000, perm: W, desc: Active Control} - RESET: { addr: 0x0F , type: uint16_t, default: 0xfff, perm: W, desc: Reset control} ########################################################################################################### # VALUES # ########################################################################################################### fields: - LEFT_IN: - MUTE: {mask: 0x080, desc: Mutes Left input} - LRINBOTH: {mask: 0x100, desc: Left to Right Channel Line Input Volume and Mute Data Load Control} - VOLUME: mask: 0x01F desc: Volume control for Left input in 1.5dB steps range -34.5dB -> +12dB values: - MIN: { val: 0, desc: -34.5dB} - 0dB: {val: 21, desc: 0db Gain} - MAX: {val: 31, desc: +12dB} - STEP: { val: 1, desc: 1.5dB Step} - RIGHT_IN: - MUTE: {mask: 0x080, desc: Mutes Right input} - LRINBOTH: {mask: 0x100, desc: Left to Right Channel Line Input Volume and Mute Data Load Control} - VOLUME: mask: 0x01F desc: Volume control for right input in 1.5dB steps range -34.5dB -> +12dB values: - MIN: { val: 0, desc: minimum -34.5dB} - 0dB: {val: 21, desc: 0db Gain} - MAX: {val: 31, desc: maximum +12dB} - STEP: { val: 1, desc: 1.5dB Step} - AN_PATH: - MICBOOST: { bit: 0, desc: Microphone Input Level Boost } - MUTEMIC: { bit: 1, desc: Mute Mic input to ADC } - INSEL: bit: 2 desc: Selects input between Mic and Line-in values: - MIC: {val: 1, desc: Selects Microphone} - LINE: {val: 0, desc: Selects Line-in} - BYPASS: { bit: 3, desc: Combines Line-in signal to Output} - DACSEL: { bit: 4, desc: DAC Select } - SIDETONE: { bit: 5, desc: Combines Mic signal to Output} - SIDEATT: mask: 0xC0 desc: Side Tone attenuation values: - 6dB: {val: 0b00, desc: 6dB of attenuation} - 9dB: {val: 0b01, desc: 9dB of attenuation} - 12dB: {val: 0b10, desc: 12dB of attenuation} - 15dB: {val: 0b11, desc: 15dB of attenuation} - DIG_PATH: - ADCHPD: { bit: 0, desc: ADC High Pass Filter } - DEEMP: mask: 0x06 desc: De-emphasis Control values: - DIS: {val: 0b00, desc: Disable} - 32kHz: {val: 0b01, desc: 32 kHz } - 44_1kHz: {val: 0b10, desc: 44.1 kHz } - 48kHz: {val: 0b11, desc: 48 kHz } - DACMU: { bit: 3, desc: DAC Soft Mute } - HPOR: { bit: 4, desc: Store dc offset when High Pass Filter disabled } - POWER_DWN: - LINEINPD: { bit: 0, desc: Line Input Power Down } - MICPD: { bit: 1, desc: Microphone Input an Bias PowerDown } - ADCPD: { bit: 2, desc: ADC Power Dow } - DACPD: { bit: 3, desc: DAC Power Down } - OUTPD: { bit: 4, desc: Powers down ALL outputs including digital } - OSCPD: { bit: 5, desc: Oscillator Power Down } - CLKOUTPD: { bit: 6, desc: CLKOUT power down } - POWEROFF: { bit: 7, desc: POWEROFF mode } - DIG_IFACE: - BLCKINV: {bit: 7, desc: Inverts the bit clock} - MASTER_MODE: {bit: 6, desc: Enables Master mode} - LRSWAP: {bit: 5, desc: Swaps LR clock polarity} - LRP: bit: 4 desc: DACLRC phase control (in left, right or I2S modes) values: - HIGH: {val: 1, Right Channel DAC DACLRC high} - LOW: {val: 1, Right Channel DAC DACLRC low} - IWL: mask: 0x00C desc: Word Length. Audio data size values: - 32BIT: {val: 0b11 , desc: 32 bit sample size } - 24BIT: {val: 0b10 , desc: 24 bit sample size } - 20BIT: {val: 0b01 , desc: 20 bit sample size } - 16BIT: {val: 0b00 , desc: 16 bit sample size } - FORMAT: mask: 0x03 desc: Selects digital audio format values: - RIGHT_JUST: {val: 0b00, desc: MSB-First right justified} - LEFT_JUST: {val: 0b01, desc: MSB-first left justified} - I2S: {val: 0b10, desc: I2S format. MSB-First left -1 justified} - DSP: {val: 0b11, desc: DSP Mode. frame sync + 2 data packed words } - RESET: - RESET: {mask: 0xFF, desc: Setting to 0 resets the device} - ACTIVE: - Enable: {bit: 0, desc: Enables Digital Audio interface} ########################################################################################################### # PRESET CONFIGS # ########################################################################################################### configs: - 16bit_line_in: desc: Device configured for stereo input with 16bit data registers: - RESET: {RESET: 0, delay: 100} - LEFT_IN: {MUTE: OFF, LRINBOTH: OFF, VOLUME: 0dB } - RIGHT_IN: {MUTE: OFF, LRINBOTH: OFF, VOLUME: 0dB } - DIG_PATH: {ADCHPD: OFF} - AN_PATH: {BYPASS: ON, INSEL: LINE, MUTEMIC: ON } - POWER_DWN: {MICPD: ON, DACPD: ON, OUTPD: OFF } - DIG_IFACE: {IWL: 16BIT, FORMAT: I2S} - ACTIVE: {Enable: ON} ########################################################################################################### # HW (experimental) # ########################################################################################################### package: QFN-28 pins: - XTI/MCLK: {pad: 1, type: digital , dir: i, desc: Crystal Input or Master Clock Input (MCLK)} - XTO: {pad: 2, type: digital , dir: o, desc: Crystal Output} - DCVDD: {pad: 3, type: Supply, desc: Digital Core VDD} - DGND: {pad: 4, type: Ground, desc: Digital GND } - DBVDD: {pad: 5, type: Supply, desc: Digital Buffers VDD} - CLKOUT: {pad: 6, type: digital , dir: o, desc: Buffered Clock Output} - BCLK: {pad: 7, type: digital , dir: io, desc: Digital Audio Bit Clock, Pull Down, (see Note 1)} - DACDAT: {pad: 8, type: digital , dir: i, desc: DAC Digital Audio Data Input} - DACLRC: {pad: 9, type: digital , dir: io, desc: DAC Sample Rate Left/Right Clock, Pull Down (see Note 1)} - ADCDAT: {pad: 10, type: digital , dir: o, desc: ADC Digital Audio Data Output} - ADCLRC: {pad: 11, type: digital , dir: io, desc: ADC Sample Rate Left/Right Clock, Pull Down (see Note 1)} - HPVDD: {pad: 12, type: Supply, desc: Headphone VDD} - LHPOUT: {pad: 13, type: analog , dir: o, desc: Left Channel Headphone Output} - RHPOUT: {pad: 14, type: analog , dir: o, desc: Right Channel Headphone Output} - HPGND: {pad: 15, type: Ground, desc: Headphone GND} - LOUT: {pad: 16, type: analog , dir: o, desc: Left Channel Line Output} - ROUT: {pad: 17, type: analog , dir: o, desc: Right Channel Line Output} - AVDD: {pad: 18, type: Supply, desc: analog VDD} - AGND: {pad: 19, type: Ground, desc: analog GND} - VMID: {pad: 20, type: analog , dir: o, desc: Mid-rail reference decoupling point} - MICBIAS: {pad: 21, type: analog , dir: o, desc: Electret Microphone Bias} - MICIN: {pad: 22, type: analog , dir: i, desc: Microphone Input (AC coupled)} - RLINEIN: {pad: 23, type: analog , dir: i, desc: Right Channel Line Input (AC coupled)} - LLINEIN: {pad: 24, type: analog , dir: i, desc: Left Channel Line Input (AC coupled)} - MODE: {pad: 25, type: digital , dir: i, desc: Control Interface Selection, Pull Up (see Note 1)} - CSB: {pad: 26, type: digital , dir: i, desc: 3-Wire MPU Chip Select/ 2-Wire MPU interface addressselection, active low, Pull up (see Note 1)} - SDIN: {pad: 27, type: digital , dir: io, desc: 3-Wire MPU Data Input / 2-Wire MPU Data Input} - SCLK: {pad: 28, type: digital , dir: i, desc: 3-Wire MPU Clock Input / 2-Wire MPU Clock Input} variants: - SSOP28: package: SSOP-28 pins: - 1: DBVDD - 2: CLKOUT - 3: BCLK - 4: DACDAT - 5: DACLRC - 6: ADCDAT - 7: ADCLRC - 8: HPVDD - 9: LHPOUT - 10: RHPOUT - 11: HPGND - 12: LOUT - 13: ROUT - 14: AVDD - 15: AGND - 16: VMID - 17: MICBIAS - 18: MICIN - 19: RLINEIN - 20: LLINEIN - 21: MODE - 22: CSB - 23: SDIN - 24: SCLK - 25: XTI/MCLK - 26: XTO - 27: DCVDD - 28: DGND