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