STM32Cube BSP FW for STM32F769I-Discovery
Dependents: mbed-os-example-blinky-5 DISCO-F769NI_TOUCHSCREEN_demo_custom_1 Datarecorder2 DISCO-F769NI_TOUCHSCREEN_demo ... more
Diff: Drivers/BSP/Components/wm8994/wm8994.c
- Revision:
- 4:72a949940ad6
- Parent:
- 0:c0f3bbab73d2
- Child:
- 5:60b59d223214
diff -r 145e714557cf -r 72a949940ad6 Drivers/BSP/Components/wm8994/wm8994.c --- a/Drivers/BSP/Components/wm8994/wm8994.c Thu Jul 06 16:48:52 2017 +0200 +++ b/Drivers/BSP/Components/wm8994/wm8994.c Fri Nov 15 11:20:11 2019 +0100 @@ -2,9 +2,7 @@ ****************************************************************************** * @file wm8994.c * @author MCD Application Team - * @version V2.1.0 - * @date 22-February-2016 - * @brief This file provides the WM8994 Audio Codec driver. + * @brief This file provides the WM8994 Audio Codec driver. ****************************************************************************** * @attention * @@ -106,6 +104,8 @@ static uint32_t outputEnabled = 0; static uint32_t inputEnabled = 0; +static uint8_t ColdStartup = 1; + /** * @} */ @@ -118,6 +118,7 @@ * @} */ + /** @defgroup WM8994_Private_Functions * @{ */ @@ -146,10 +147,10 @@ counter += CODEC_IO_Write(DeviceAddr, 0x102, 0x0003); counter += CODEC_IO_Write(DeviceAddr, 0x817, 0x0000); counter += CODEC_IO_Write(DeviceAddr, 0x102, 0x0000); - + /* Enable VMID soft start (fast), Start-up Bias Current Enabled */ counter += CODEC_IO_Write(DeviceAddr, 0x39, 0x006C); - + /* Enable bias generator, Enable VMID */ if (input_device > 0) { @@ -167,6 +168,7 @@ if (output_device > 0) { outputEnabled = 1; + switch (output_device) { case OUTPUT_DEVICE_SPEAKER: @@ -465,6 +467,33 @@ if (output_device > 0) /* Audio output selected */ { + if (output_device == OUTPUT_DEVICE_HEADPHONE) + { + /* Select DAC1 (Left) to Left Headphone Output PGA (HPOUT1LVOL) path */ + counter += CODEC_IO_Write(DeviceAddr, 0x2D, 0x0100); + + /* Select DAC1 (Right) to Right Headphone Output PGA (HPOUT1RVOL) path */ + counter += CODEC_IO_Write(DeviceAddr, 0x2E, 0x0100); + + /* Startup sequence for Headphone */ + if(ColdStartup) + { + counter += CODEC_IO_Write(DeviceAddr,0x110,0x8100); + + ColdStartup=0; + /* Add Delay */ + AUDIO_IO_Delay(300); + } + else /* Headphone Warm Start-Up */ + { + counter += CODEC_IO_Write(DeviceAddr,0x110,0x8108); + /* Add Delay */ + AUDIO_IO_Delay(50); + } + + /* Soft un-Mute the AIF1 Timeslot 0 DAC1 path L&R */ + counter += CODEC_IO_Write(DeviceAddr, 0x420, 0x0000); + } /* Analog Output Configuration */ /* Enable SPKRVOL PGA, Enable SPKMIXR, Enable SPKLVOL PGA, Enable SPKMIXL */ @@ -524,7 +553,7 @@ counter += CODEC_IO_Write(DeviceAddr, 0x54, 0x0033); /* Add Delay */ - AUDIO_IO_Delay(250); + AUDIO_IO_Delay(257); /* Enable HPOUT1 (Left) and HPOUT1 (Right) intermediate and output stages. Remove clamps */ counter += CODEC_IO_Write(DeviceAddr, 0x60, 0x00EE); @@ -538,7 +567,7 @@ counter += CODEC_IO_Write(DeviceAddr, 0x611, 0x00C0); /* Unmute the AIF1 Timeslot 0 DAC path */ - counter += CODEC_IO_Write(DeviceAddr, 0x420, 0x0000); + counter += CODEC_IO_Write(DeviceAddr, 0x420, 0x0010); /* Unmute DAC 2 (Left) */ counter += CODEC_IO_Write(DeviceAddr, 0x612, 0x00C0); @@ -547,7 +576,7 @@ counter += CODEC_IO_Write(DeviceAddr, 0x613, 0x00C0); /* Unmute the AIF1 Timeslot 1 DAC2 path */ - counter += CODEC_IO_Write(DeviceAddr, 0x422, 0x0000); + counter += CODEC_IO_Write(DeviceAddr, 0x422, 0x0010); /* Volume Control */ wm8994_SetVolume(DeviceAddr, Volume); @@ -701,7 +730,7 @@ if (CodecPdwnMode == CODEC_PDWN_SW) { - /* Only output mute required*/ + /* Only output mute required*/ } else /* CODEC_PDWN_HW */ { @@ -830,10 +859,10 @@ else /* AUDIO_MUTE_OFF Disable the Mute */ { /* Unmute the AIF1 Timeslot 0 DAC1 path L&R */ - counter += CODEC_IO_Write(DeviceAddr, 0x420, 0x0000); + counter += CODEC_IO_Write(DeviceAddr, 0x420, 0x0010); /* Unmute the AIF1 Timeslot 1 DAC2 path L&R */ - counter += CODEC_IO_Write(DeviceAddr, 0x422, 0x0000); + counter += CODEC_IO_Write(DeviceAddr, 0x422, 0x0010); } } return counter; @@ -950,6 +979,11 @@ /* AIF1 Sample Rate = 16 (KHz), ratio=256 */ counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0033); break; + + case AUDIO_FREQUENCY_32K: + /* AIF1 Sample Rate = 32 (KHz), ratio=256 */ + counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0063); + break; case AUDIO_FREQUENCY_48K: /* AIF1 Sample Rate = 48 (KHz), ratio=256 */