STM32Cube BSP FW for STM32F769I-Discovery

Dependents:   mbed-os-example-blinky-5 DISCO-F769NI_TOUCHSCREEN_demo_custom_1 Datarecorder2 DISCO-F769NI_TOUCHSCREEN_demo ... more

Committer:
Jerome Coutant
Date:
Fri Feb 10 13:08:21 2017 +0100
Revision:
0:c0f3bbab73d2
Child:
4:72a949940ad6
STM32Cube_FW_F7_V1.5.1 BSP STM32F769I-Discovery

Who changed what in which revision?

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