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