No changes made
Fork of BSP_DISCO_F746NG by
Embed:
(wiki syntax)
Show/hide line numbers
wm8994.h
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file wm8994.h 00004 * @author MCD Application Team 00005 * @version V2.1.0 00006 * @date 22-February-2016 00007 * @brief This file contains all the functions prototypes for the 00008 * wm8994.c driver. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without modification, 00015 * are permitted provided that the following conditions are met: 00016 * 1. Redistributions of source code must retain the above copyright notice, 00017 * this list of conditions and the following disclaimer. 00018 * 2. Redistributions in binary form must reproduce the above copyright notice, 00019 * this list of conditions and the following disclaimer in the documentation 00020 * and/or other materials provided with the distribution. 00021 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00022 * may be used to endorse or promote products derived from this software 00023 * without specific prior written permission. 00024 * 00025 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00026 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00027 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00028 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00029 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00030 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00031 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00032 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00033 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00034 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 ****************************************************************************** 00037 */ 00038 00039 /* Define to prevent recursive inclusion -------------------------------------*/ 00040 #ifndef __WM8994_H 00041 #define __WM8994_H 00042 00043 /* Includes ------------------------------------------------------------------*/ 00044 #include "../Common/audio.h" 00045 00046 /** @addtogroup BSP 00047 * @{ 00048 */ 00049 00050 /** @addtogroup Component 00051 * @{ 00052 */ 00053 00054 /** @addtogroup WM8994 00055 * @{ 00056 */ 00057 00058 /** @defgroup WM8994_Exported_Types 00059 * @{ 00060 */ 00061 00062 /** 00063 * @} 00064 */ 00065 00066 /** @defgroup WM8994_Exported_Constants 00067 * @{ 00068 */ 00069 00070 /******************************************************************************/ 00071 /*************************** Codec User defines ******************************/ 00072 /******************************************************************************/ 00073 /* Codec output DEVICE */ 00074 #define OUTPUT_DEVICE_SPEAKER ((uint16_t)0x0001) 00075 #define OUTPUT_DEVICE_HEADPHONE ((uint16_t)0x0002) 00076 #define OUTPUT_DEVICE_BOTH ((uint16_t)0x0003) 00077 #define OUTPUT_DEVICE_AUTO ((uint16_t)0x0004) 00078 #define INPUT_DEVICE_DIGITAL_MICROPHONE_1 ((uint16_t)0x0100) 00079 #define INPUT_DEVICE_DIGITAL_MICROPHONE_2 ((uint16_t)0x0200) 00080 #define INPUT_DEVICE_INPUT_LINE_1 ((uint16_t)0x0300) 00081 #define INPUT_DEVICE_INPUT_LINE_2 ((uint16_t)0x0400) 00082 #define INPUT_DEVICE_DIGITAL_MIC1_MIC2 ((uint16_t)0x0800) 00083 00084 /* Volume Levels values */ 00085 #define DEFAULT_VOLMIN 0x00 00086 #define DEFAULT_VOLMAX 0xFF 00087 #define DEFAULT_VOLSTEP 0x04 00088 00089 #define AUDIO_PAUSE 0 00090 #define AUDIO_RESUME 1 00091 00092 /* Codec POWER DOWN modes */ 00093 #define CODEC_PDWN_HW 1 00094 #define CODEC_PDWN_SW 2 00095 00096 /* MUTE commands */ 00097 #define AUDIO_MUTE_ON 1 00098 #define AUDIO_MUTE_OFF 0 00099 00100 /* AUDIO FREQUENCY */ 00101 #define AUDIO_FREQUENCY_192K ((uint32_t)192000) 00102 #define AUDIO_FREQUENCY_96K ((uint32_t)96000) 00103 #define AUDIO_FREQUENCY_48K ((uint32_t)48000) 00104 #define AUDIO_FREQUENCY_44K ((uint32_t)44100) 00105 #define AUDIO_FREQUENCY_32K ((uint32_t)32000) 00106 #define AUDIO_FREQUENCY_22K ((uint32_t)22050) 00107 #define AUDIO_FREQUENCY_16K ((uint32_t)16000) 00108 #define AUDIO_FREQUENCY_11K ((uint32_t)11025) 00109 #define AUDIO_FREQUENCY_8K ((uint32_t)8000) 00110 00111 #define VOLUME_CONVERT(Volume) (((Volume) > 100)? 100:((uint8_t)(((Volume) * 63) / 100))) 00112 #define VOLUME_IN_CONVERT(Volume) (((Volume) >= 100)? 239:((uint8_t)(((Volume) * 240) / 100))) 00113 00114 /******************************************************************************/ 00115 /****************************** REGISTER MAPPING ******************************/ 00116 /******************************************************************************/ 00117 /** 00118 * @brief WM8994 ID 00119 */ 00120 #define WM8994_ID 0x8994 00121 00122 /** 00123 * @brief Device ID Register: Reading from this register will indicate device 00124 * family ID 8994h 00125 */ 00126 #define WM8994_CHIPID_ADDR 0x00 00127 00128 /** 00129 * @} 00130 */ 00131 00132 /** @defgroup WM8994_Exported_Macros 00133 * @{ 00134 */ 00135 /** 00136 * @} 00137 */ 00138 00139 /** @defgroup WM8994_Exported_Functions 00140 * @{ 00141 */ 00142 00143 /*------------------------------------------------------------------------------ 00144 Audio Codec functions 00145 ------------------------------------------------------------------------------*/ 00146 /* High Layer codec functions */ 00147 uint32_t wm8994_Init(uint16_t DeviceAddr, uint16_t OutputInputDevice, uint8_t Volume, uint32_t AudioFreq); 00148 void wm8994_DeInit(void); 00149 uint32_t wm8994_ReadID(uint16_t DeviceAddr); 00150 uint32_t wm8994_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size); 00151 uint32_t wm8994_Pause(uint16_t DeviceAddr); 00152 uint32_t wm8994_Resume(uint16_t DeviceAddr); 00153 uint32_t wm8994_Stop(uint16_t DeviceAddr, uint32_t Cmd); 00154 uint32_t wm8994_SetVolume(uint16_t DeviceAddr, uint8_t Volume); 00155 uint32_t wm8994_SetMute(uint16_t DeviceAddr, uint32_t Cmd); 00156 uint32_t wm8994_SetOutputMode(uint16_t DeviceAddr, uint8_t Output); 00157 uint32_t wm8994_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq); 00158 uint32_t wm8994_Reset(uint16_t DeviceAddr); 00159 00160 /* AUDIO IO functions */ 00161 void AUDIO_IO_Init(void); 00162 void AUDIO_IO_DeInit(void); 00163 void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value); 00164 uint8_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg); 00165 void AUDIO_IO_Delay(uint32_t Delay); 00166 00167 /* Audio driver structure */ 00168 extern AUDIO_DrvTypeDef wm8994_drv; 00169 00170 #endif /* __WM8994_H */ 00171 00172 /** 00173 * @} 00174 */ 00175 00176 /** 00177 * @} 00178 */ 00179 00180 /** 00181 * @} 00182 */ 00183 00184 /** 00185 * @} 00186 */ 00187 00188 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 19:15:26 by 1.7.2