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.
Fork of BSP_DISCO_F746NG by
wm8994.h
00001 /** 00002 ****************************************************************************** 00003 * @file wm8994.h 00004 * @author MCD Application Team 00005 * @version V2.0.0 00006 * @date 24-June-2015 00007 * @brief This file contains all the functions prototypes for the 00008 * wm8994.c driver. 00009 ****************************************************************************** 00010 * @attention 00011 * 00012 * <h2><center>© COPYRIGHT(c) 2015 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 "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 00083 /* Volume Levels values */ 00084 #define DEFAULT_VOLMIN 0x00 00085 #define DEFAULT_VOLMAX 0xFF 00086 #define DEFAULT_VOLSTEP 0x04 00087 00088 #define AUDIO_PAUSE 0 00089 #define AUDIO_RESUME 1 00090 00091 /* Codec POWER DOWN modes */ 00092 #define CODEC_PDWN_HW 1 00093 #define CODEC_PDWN_SW 2 00094 00095 /* MUTE commands */ 00096 #define AUDIO_MUTE_ON 1 00097 #define AUDIO_MUTE_OFF 0 00098 00099 /* AUDIO FREQUENCY */ 00100 #define AUDIO_FREQUENCY_192K ((uint32_t)192000) 00101 #define AUDIO_FREQUENCY_96K ((uint32_t)96000) 00102 #define AUDIO_FREQUENCY_48K ((uint32_t)48000) 00103 #define AUDIO_FREQUENCY_44K ((uint32_t)44100) 00104 #define AUDIO_FREQUENCY_32K ((uint32_t)32000) 00105 #define AUDIO_FREQUENCY_22K ((uint32_t)22050) 00106 #define AUDIO_FREQUENCY_16K ((uint32_t)16000) 00107 #define AUDIO_FREQUENCY_11K ((uint32_t)11025) 00108 #define AUDIO_FREQUENCY_8K ((uint32_t)8000) 00109 00110 #define VOLUME_CONVERT(Volume) (((Volume) > 100)? 100:((uint8_t)(((Volume) * 63) / 100))) 00111 #define VOLUME_IN_CONVERT(Volume) (((Volume) >= 100)? 239:((uint8_t)(((Volume) * 240) / 100))) 00112 00113 /******************************************************************************/ 00114 /****************************** REGISTER MAPPING ******************************/ 00115 /******************************************************************************/ 00116 /** 00117 * @brief WM8994 ID 00118 */ 00119 #define WM8994_ID 0x8994 00120 00121 /** 00122 * @brief Device ID Register: Reading from this register will indicate device 00123 * family ID 8994h 00124 */ 00125 #define WM8994_CHIPID_ADDR 0x00 00126 00127 /** 00128 * @} 00129 */ 00130 00131 /** @defgroup WM8994_Exported_Macros 00132 * @{ 00133 */ 00134 /** 00135 * @} 00136 */ 00137 00138 /** @defgroup WM8994_Exported_Functions 00139 * @{ 00140 */ 00141 00142 /*------------------------------------------------------------------------------ 00143 Audio Codec functions 00144 ------------------------------------------------------------------------------*/ 00145 /* High Layer codec functions */ 00146 uint32_t wm8994_Init(uint16_t DeviceAddr, uint16_t OutputInputDevice, uint8_t Volume, uint32_t AudioFreq); 00147 void wm8994_DeInit(void); 00148 uint32_t wm8994_ReadID(uint16_t DeviceAddr); 00149 uint32_t wm8994_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size); 00150 uint32_t wm8994_Pause(uint16_t DeviceAddr); 00151 uint32_t wm8994_Resume(uint16_t DeviceAddr); 00152 uint32_t wm8994_Stop(uint16_t DeviceAddr, uint32_t Cmd); 00153 uint32_t wm8994_SetVolume(uint16_t DeviceAddr, uint8_t Volume); 00154 uint32_t wm8994_SetMute(uint16_t DeviceAddr, uint32_t Cmd); 00155 uint32_t wm8994_SetOutputMode(uint16_t DeviceAddr, uint8_t Output); 00156 uint32_t wm8994_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq); 00157 uint32_t wm8994_Reset(uint16_t DeviceAddr); 00158 00159 /* AUDIO IO functions */ 00160 void AUDIO_IO_Init(void); 00161 void AUDIO_IO_DeInit(void); 00162 void AUDIO_IO_Write(uint8_t Addr, uint16_t Reg, uint16_t Value); 00163 uint8_t AUDIO_IO_Read(uint8_t Addr, uint16_t Reg); 00164 void AUDIO_IO_Delay(uint32_t Delay); 00165 00166 /* Audio driver structure */ 00167 extern AUDIO_DrvTypeDef wm8994_drv; 00168 00169 #endif /* __WM8994_H */ 00170 00171 /** 00172 * @} 00173 */ 00174 00175 /** 00176 * @} 00177 */ 00178 00179 /** 00180 * @} 00181 */ 00182 00183 /** 00184 * @} 00185 */ 00186 00187 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Wed Jul 13 2022 13:25:21 by
1.7.2
