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