BSP files for STM32H747I-Discovery Copy from ST Cube delivery

Dependents:   DISCO_H747I_LCD_demo DISCO_H747I_AUDIO_demo

Committer:
Jerome Coutant
Date:
Wed Nov 06 11:32:01 2019 +0100
Revision:
3:bc403474b366
Parent:
0:146cf26a9bbb
Add PDM lib

Who changed what in which revision?

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