ST / BSP_DISCO_F413ZH

Dependents:   DISCO_F413ZH-LCD-demo DISCO_F413ZH-touch-screen-demo DISCO_F413ZH-SD-demo DISCO_F413ZH-PSRAM-demo ... more

Committer:
Jerome Coutant
Date:
Wed Feb 28 14:35:04 2018 +0100
Revision:
3:42b354f5069c
Parent:
0:4af3ca173992
STM32Cube_FW_F4_V1.19.0 BSP_DISCO_F413ZH

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arostm 0:4af3ca173992 1 /**
arostm 0:4af3ca173992 2 ******************************************************************************
arostm 0:4af3ca173992 3 * @file wm8994.h
arostm 0:4af3ca173992 4 * @author MCD Application Team
arostm 0:4af3ca173992 5 * @version V2.1.0
arostm 0:4af3ca173992 6 * @date 22-February-2016
arostm 0:4af3ca173992 7 * @brief This file contains all the functions prototypes for the
arostm 0:4af3ca173992 8 * wm8994.c driver.
arostm 0:4af3ca173992 9 ******************************************************************************
arostm 0:4af3ca173992 10 * @attention
arostm 0:4af3ca173992 11 *
arostm 0:4af3ca173992 12 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
arostm 0:4af3ca173992 13 *
arostm 0:4af3ca173992 14 * Redistribution and use in source and binary forms, with or without modification,
arostm 0:4af3ca173992 15 * are permitted provided that the following conditions are met:
arostm 0:4af3ca173992 16 * 1. Redistributions of source code must retain the above copyright notice,
arostm 0:4af3ca173992 17 * this list of conditions and the following disclaimer.
arostm 0:4af3ca173992 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
arostm 0:4af3ca173992 19 * this list of conditions and the following disclaimer in the documentation
arostm 0:4af3ca173992 20 * and/or other materials provided with the distribution.
arostm 0:4af3ca173992 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
arostm 0:4af3ca173992 22 * may be used to endorse or promote products derived from this software
arostm 0:4af3ca173992 23 * without specific prior written permission.
arostm 0:4af3ca173992 24 *
arostm 0:4af3ca173992 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
arostm 0:4af3ca173992 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
arostm 0:4af3ca173992 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
arostm 0:4af3ca173992 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
arostm 0:4af3ca173992 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
arostm 0:4af3ca173992 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
arostm 0:4af3ca173992 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
arostm 0:4af3ca173992 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
arostm 0:4af3ca173992 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
arostm 0:4af3ca173992 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
arostm 0:4af3ca173992 35 *
arostm 0:4af3ca173992 36 ******************************************************************************
arostm 0:4af3ca173992 37 */
arostm 0:4af3ca173992 38
arostm 0:4af3ca173992 39 /* Define to prevent recursive inclusion -------------------------------------*/
arostm 0:4af3ca173992 40 #ifndef __WM8994_H
arostm 0:4af3ca173992 41 #define __WM8994_H
arostm 0:4af3ca173992 42
arostm 0:4af3ca173992 43 /* Includes ------------------------------------------------------------------*/
arostm 0:4af3ca173992 44 #include "../Common/audio.h"
arostm 0:4af3ca173992 45
arostm 0:4af3ca173992 46 /** @addtogroup BSP
arostm 0:4af3ca173992 47 * @{
arostm 0:4af3ca173992 48 */
arostm 0:4af3ca173992 49
arostm 0:4af3ca173992 50 /** @addtogroup Component
arostm 0:4af3ca173992 51 * @{
arostm 0:4af3ca173992 52 */
arostm 0:4af3ca173992 53
arostm 0:4af3ca173992 54 /** @addtogroup WM8994
arostm 0:4af3ca173992 55 * @{
arostm 0:4af3ca173992 56 */
arostm 0:4af3ca173992 57
arostm 0:4af3ca173992 58 /** @defgroup WM8994_Exported_Types
arostm 0:4af3ca173992 59 * @{
arostm 0:4af3ca173992 60 */
arostm 0:4af3ca173992 61
arostm 0:4af3ca173992 62 /**
arostm 0:4af3ca173992 63 * @}
arostm 0:4af3ca173992 64 */
arostm 0:4af3ca173992 65
arostm 0:4af3ca173992 66 /** @defgroup WM8994_Exported_Constants
arostm 0:4af3ca173992 67 * @{
arostm 0:4af3ca173992 68 */
arostm 0:4af3ca173992 69
arostm 0:4af3ca173992 70 /******************************************************************************/
arostm 0:4af3ca173992 71 /*************************** Codec User defines ******************************/
arostm 0:4af3ca173992 72 /******************************************************************************/
arostm 0:4af3ca173992 73 /* Codec output DEVICE */
arostm 0:4af3ca173992 74 #define OUTPUT_DEVICE_SPEAKER ((uint16_t)0x0001)
arostm 0:4af3ca173992 75 #define OUTPUT_DEVICE_HEADPHONE ((uint16_t)0x0002)
arostm 0:4af3ca173992 76 #define OUTPUT_DEVICE_BOTH ((uint16_t)0x0003)
arostm 0:4af3ca173992 77 #define OUTPUT_DEVICE_AUTO ((uint16_t)0x0004)
arostm 0:4af3ca173992 78 #define INPUT_DEVICE_DIGITAL_MICROPHONE_1 ((uint16_t)0x0100)
arostm 0:4af3ca173992 79 #define INPUT_DEVICE_DIGITAL_MICROPHONE_2 ((uint16_t)0x0200)
arostm 0:4af3ca173992 80 #define INPUT_DEVICE_INPUT_LINE_1 ((uint16_t)0x0300)
arostm 0:4af3ca173992 81 #define INPUT_DEVICE_INPUT_LINE_2 ((uint16_t)0x0400)
arostm 0:4af3ca173992 82 #define INPUT_DEVICE_DIGITAL_MIC1_MIC2 ((uint16_t)0x0800)
arostm 0:4af3ca173992 83
arostm 0:4af3ca173992 84 /* Volume Levels values */
arostm 0:4af3ca173992 85 #define DEFAULT_VOLMIN 0x00
arostm 0:4af3ca173992 86 #define DEFAULT_VOLMAX 0xFF
arostm 0:4af3ca173992 87 #define DEFAULT_VOLSTEP 0x04
arostm 0:4af3ca173992 88
arostm 0:4af3ca173992 89 #define AUDIO_PAUSE 0
arostm 0:4af3ca173992 90 #define AUDIO_RESUME 1
arostm 0:4af3ca173992 91
arostm 0:4af3ca173992 92 /* Codec POWER DOWN modes */
arostm 0:4af3ca173992 93 #define CODEC_PDWN_HW 1
arostm 0:4af3ca173992 94 #define CODEC_PDWN_SW 2
arostm 0:4af3ca173992 95
arostm 0:4af3ca173992 96 /* MUTE commands */
arostm 0:4af3ca173992 97 #define AUDIO_MUTE_ON 1
arostm 0:4af3ca173992 98 #define AUDIO_MUTE_OFF 0
arostm 0:4af3ca173992 99
arostm 0:4af3ca173992 100 /* AUDIO FREQUENCY */
arostm 0:4af3ca173992 101 #define AUDIO_FREQUENCY_192K ((uint32_t)192000)
arostm 0:4af3ca173992 102 #define AUDIO_FREQUENCY_96K ((uint32_t)96000)
arostm 0:4af3ca173992 103 #define AUDIO_FREQUENCY_48K ((uint32_t)48000)
arostm 0:4af3ca173992 104 #define AUDIO_FREQUENCY_44K ((uint32_t)44100)
arostm 0:4af3ca173992 105 #define AUDIO_FREQUENCY_32K ((uint32_t)32000)
arostm 0:4af3ca173992 106 #define AUDIO_FREQUENCY_22K ((uint32_t)22050)
arostm 0:4af3ca173992 107 #define AUDIO_FREQUENCY_16K ((uint32_t)16000)
arostm 0:4af3ca173992 108 #define AUDIO_FREQUENCY_11K ((uint32_t)11025)
arostm 0:4af3ca173992 109 #define AUDIO_FREQUENCY_8K ((uint32_t)8000)
arostm 0:4af3ca173992 110
arostm 0:4af3ca173992 111 #define VOLUME_CONVERT(Volume) (((Volume) > 100)? 100:((uint8_t)(((Volume) * 63) / 100)))
arostm 0:4af3ca173992 112 #define VOLUME_IN_CONVERT(Volume) (((Volume) >= 100)? 239:((uint8_t)(((Volume) * 240) / 100)))
arostm 0:4af3ca173992 113
arostm 0:4af3ca173992 114 /******************************************************************************/
arostm 0:4af3ca173992 115 /****************************** REGISTER MAPPING ******************************/
arostm 0:4af3ca173992 116 /******************************************************************************/
arostm 0:4af3ca173992 117 /**
arostm 0:4af3ca173992 118 * @brief WM8994 ID
arostm 0:4af3ca173992 119 */
arostm 0:4af3ca173992 120 #define WM8994_ID 0x8994
arostm 0:4af3ca173992 121
arostm 0:4af3ca173992 122 /**
arostm 0:4af3ca173992 123 * @brief Device ID Register: Reading from this register will indicate device
arostm 0:4af3ca173992 124 * family ID 8994h
arostm 0:4af3ca173992 125 */
arostm 0:4af3ca173992 126 #define WM8994_CHIPID_ADDR 0x00
arostm 0:4af3ca173992 127
arostm 0:4af3ca173992 128 /**
arostm 0:4af3ca173992 129 * @}
arostm 0:4af3ca173992 130 */
arostm 0:4af3ca173992 131
arostm 0:4af3ca173992 132 /** @defgroup WM8994_Exported_Macros
arostm 0:4af3ca173992 133 * @{
arostm 0:4af3ca173992 134 */
arostm 0:4af3ca173992 135 /**
arostm 0:4af3ca173992 136 * @}
arostm 0:4af3ca173992 137 */
arostm 0:4af3ca173992 138
arostm 0:4af3ca173992 139 /** @defgroup WM8994_Exported_Functions
arostm 0:4af3ca173992 140 * @{
arostm 0:4af3ca173992 141 */
arostm 0:4af3ca173992 142
arostm 0:4af3ca173992 143 /*------------------------------------------------------------------------------
arostm 0:4af3ca173992 144 Audio Codec functions
arostm 0:4af3ca173992 145 ------------------------------------------------------------------------------*/
arostm 0:4af3ca173992 146 /* High Layer codec functions */
arostm 0:4af3ca173992 147 uint32_t wm8994_Init(uint16_t DeviceAddr, uint16_t OutputInputDevice, uint8_t Volume, uint32_t AudioFreq);
arostm 0:4af3ca173992 148 void wm8994_DeInit(void);
arostm 0:4af3ca173992 149 uint32_t wm8994_ReadID(uint16_t DeviceAddr);
arostm 0:4af3ca173992 150 uint32_t wm8994_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size);
arostm 0:4af3ca173992 151 uint32_t wm8994_Pause(uint16_t DeviceAddr);
arostm 0:4af3ca173992 152 uint32_t wm8994_Resume(uint16_t DeviceAddr);
arostm 0:4af3ca173992 153 uint32_t wm8994_Stop(uint16_t DeviceAddr, uint32_t Cmd);
arostm 0:4af3ca173992 154 uint32_t wm8994_SetVolume(uint16_t DeviceAddr, uint8_t Volume);
arostm 0:4af3ca173992 155 uint32_t wm8994_SetMute(uint16_t DeviceAddr, uint32_t Cmd);
arostm 0:4af3ca173992 156 uint32_t wm8994_SetOutputMode(uint16_t DeviceAddr, uint8_t Output);
arostm 0:4af3ca173992 157 uint32_t wm8994_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq);
arostm 0:4af3ca173992 158 uint32_t wm8994_Reset(uint16_t DeviceAddr);
arostm 0:4af3ca173992 159
arostm 0:4af3ca173992 160 /* AUDIO IO functions */
arostm 0:4af3ca173992 161 void AUDIO_IO_Init(void);
arostm 0:4af3ca173992 162 void AUDIO_IO_DeInit(void);
arostm 0:4af3ca173992 163 void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value);
arostm 0:4af3ca173992 164 uint8_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg);
arostm 0:4af3ca173992 165 void AUDIO_IO_Delay(uint32_t Delay);
arostm 0:4af3ca173992 166
arostm 0:4af3ca173992 167 /* Audio driver structure */
arostm 0:4af3ca173992 168 extern AUDIO_DrvTypeDef wm8994_drv;
arostm 0:4af3ca173992 169
arostm 0:4af3ca173992 170 #endif /* __WM8994_H */
arostm 0:4af3ca173992 171
arostm 0:4af3ca173992 172 /**
arostm 0:4af3ca173992 173 * @}
arostm 0:4af3ca173992 174 */
arostm 0:4af3ca173992 175
arostm 0:4af3ca173992 176 /**
arostm 0:4af3ca173992 177 * @}
arostm 0:4af3ca173992 178 */
arostm 0:4af3ca173992 179
arostm 0:4af3ca173992 180 /**
arostm 0:4af3ca173992 181 * @}
arostm 0:4af3ca173992 182 */
arostm 0:4af3ca173992 183
arostm 0:4af3ca173992 184 /**
arostm 0:4af3ca173992 185 * @}
arostm 0:4af3ca173992 186 */
arostm 0:4af3ca173992 187
arostm 0:4af3ca173992 188 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/