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