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