STM32L476G-Discovery board drivers V1.0.0
Dependents: DiscoLogger DISCO_L476VG_GlassLCD DISCO_L476VG_MicrophoneRecorder DISCO_L476VG_UART ... more
Drivers/BSP/Components/cs43l22/cs43l22.c@1:917af0ca86df, 2017-07-05 (annotated)
- Committer:
- Jerome Coutant
- Date:
- Wed Jul 05 10:51:49 2017 +0200
- Revision:
- 1:917af0ca86df
- Child:
- 5:4943b15cce9f
Update with STM32Cube_FW_L4_V1.8.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jerome Coutant
1:917af0ca86df
|
1
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
2
|
******************************************************************************
|
|
Jerome Coutant
1:917af0ca86df
|
3
|
* @file cs43l22.c
|
|
Jerome Coutant
1:917af0ca86df
|
4
|
* @author MCD Application Team
|
|
Jerome Coutant
1:917af0ca86df
|
5
|
* @version V2.0.2
|
|
Jerome Coutant
1:917af0ca86df
|
6
|
* @date 06-October-2015
|
|
Jerome Coutant
1:917af0ca86df
|
7
|
* @brief This file provides the CS43L22 Audio Codec driver.
|
|
Jerome Coutant
1:917af0ca86df
|
8
|
******************************************************************************
|
|
Jerome Coutant
1:917af0ca86df
|
9
|
* @attention
|
|
Jerome Coutant
1:917af0ca86df
|
10
|
*
|
|
Jerome Coutant
1:917af0ca86df
|
11
|
* <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
|
|
Jerome Coutant
1:917af0ca86df
|
12
|
*
|
|
Jerome Coutant
1:917af0ca86df
|
13
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
Jerome Coutant
1:917af0ca86df
|
14
|
* are permitted provided that the following conditions are met:
|
|
Jerome Coutant
1:917af0ca86df
|
15
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
Jerome Coutant
1:917af0ca86df
|
16
|
* this list of conditions and the following disclaimer.
|
|
Jerome Coutant
1:917af0ca86df
|
17
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
Jerome Coutant
1:917af0ca86df
|
18
|
* this list of conditions and the following disclaimer in the documentation
|
|
Jerome Coutant
1:917af0ca86df
|
19
|
* and/or other materials provided with the distribution.
|
|
Jerome Coutant
1:917af0ca86df
|
20
|
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
|
Jerome Coutant
1:917af0ca86df
|
21
|
* may be used to endorse or promote products derived from this software
|
|
Jerome Coutant
1:917af0ca86df
|
22
|
* without specific prior written permission.
|
|
Jerome Coutant
1:917af0ca86df
|
23
|
*
|
|
Jerome Coutant
1:917af0ca86df
|
24
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Jerome Coutant
1:917af0ca86df
|
25
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Jerome Coutant
1:917af0ca86df
|
26
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
Jerome Coutant
1:917af0ca86df
|
27
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
Jerome Coutant
1:917af0ca86df
|
28
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Jerome Coutant
1:917af0ca86df
|
29
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Jerome Coutant
1:917af0ca86df
|
30
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
Jerome Coutant
1:917af0ca86df
|
31
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
Jerome Coutant
1:917af0ca86df
|
32
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Jerome Coutant
1:917af0ca86df
|
33
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Jerome Coutant
1:917af0ca86df
|
34
|
*
|
|
Jerome Coutant
1:917af0ca86df
|
35
|
******************************************************************************
|
|
Jerome Coutant
1:917af0ca86df
|
36
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
37
|
|
|
Jerome Coutant
1:917af0ca86df
|
38
|
/* Includes ------------------------------------------------------------------*/
|
|
Jerome Coutant
1:917af0ca86df
|
39
|
#include "cs43l22.h"
|
|
Jerome Coutant
1:917af0ca86df
|
40
|
|
|
Jerome Coutant
1:917af0ca86df
|
41
|
/** @addtogroup BSP
|
|
Jerome Coutant
1:917af0ca86df
|
42
|
* @{
|
|
Jerome Coutant
1:917af0ca86df
|
43
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
44
|
|
|
Jerome Coutant
1:917af0ca86df
|
45
|
/** @addtogroup Components
|
|
Jerome Coutant
1:917af0ca86df
|
46
|
* @{
|
|
Jerome Coutant
1:917af0ca86df
|
47
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
48
|
|
|
Jerome Coutant
1:917af0ca86df
|
49
|
/** @addtogroup CS43L22
|
|
Jerome Coutant
1:917af0ca86df
|
50
|
* @brief This file provides a set of functions needed to drive the
|
|
Jerome Coutant
1:917af0ca86df
|
51
|
* CS43L22 audio codec.
|
|
Jerome Coutant
1:917af0ca86df
|
52
|
* @{
|
|
Jerome Coutant
1:917af0ca86df
|
53
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
54
|
|
|
Jerome Coutant
1:917af0ca86df
|
55
|
/** @defgroup CS43L22_Private_Types
|
|
Jerome Coutant
1:917af0ca86df
|
56
|
* @{
|
|
Jerome Coutant
1:917af0ca86df
|
57
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
58
|
|
|
Jerome Coutant
1:917af0ca86df
|
59
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
60
|
* @}
|
|
Jerome Coutant
1:917af0ca86df
|
61
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
62
|
|
|
Jerome Coutant
1:917af0ca86df
|
63
|
/** @defgroup CS43L22_Private_Defines
|
|
Jerome Coutant
1:917af0ca86df
|
64
|
* @{
|
|
Jerome Coutant
1:917af0ca86df
|
65
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
66
|
#define VOLUME_CONVERT(Volume) (((Volume) > 100)? 100:((uint8_t)(((Volume) * 255) / 100)))
|
|
Jerome Coutant
1:917af0ca86df
|
67
|
/* Uncomment this line to enable verifying data sent to codec after each write
|
|
Jerome Coutant
1:917af0ca86df
|
68
|
operation (for debug purpose) */
|
|
Jerome Coutant
1:917af0ca86df
|
69
|
#if !defined (VERIFY_WRITTENDATA)
|
|
Jerome Coutant
1:917af0ca86df
|
70
|
/* #define VERIFY_WRITTENDATA */
|
|
Jerome Coutant
1:917af0ca86df
|
71
|
#endif /* VERIFY_WRITTENDATA */
|
|
Jerome Coutant
1:917af0ca86df
|
72
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
73
|
* @}
|
|
Jerome Coutant
1:917af0ca86df
|
74
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
75
|
|
|
Jerome Coutant
1:917af0ca86df
|
76
|
/** @defgroup CS43L22_Private_Macros
|
|
Jerome Coutant
1:917af0ca86df
|
77
|
* @{
|
|
Jerome Coutant
1:917af0ca86df
|
78
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
79
|
|
|
Jerome Coutant
1:917af0ca86df
|
80
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
81
|
* @}
|
|
Jerome Coutant
1:917af0ca86df
|
82
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
83
|
|
|
Jerome Coutant
1:917af0ca86df
|
84
|
/** @defgroup CS43L22_Private_Variables
|
|
Jerome Coutant
1:917af0ca86df
|
85
|
* @{
|
|
Jerome Coutant
1:917af0ca86df
|
86
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
87
|
|
|
Jerome Coutant
1:917af0ca86df
|
88
|
/* Audio codec driver structure initialization */
|
|
Jerome Coutant
1:917af0ca86df
|
89
|
AUDIO_DrvTypeDef cs43l22_drv =
|
|
Jerome Coutant
1:917af0ca86df
|
90
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
91
|
cs43l22_Init,
|
|
Jerome Coutant
1:917af0ca86df
|
92
|
cs43l22_DeInit,
|
|
Jerome Coutant
1:917af0ca86df
|
93
|
cs43l22_ReadID,
|
|
Jerome Coutant
1:917af0ca86df
|
94
|
|
|
Jerome Coutant
1:917af0ca86df
|
95
|
cs43l22_Play,
|
|
Jerome Coutant
1:917af0ca86df
|
96
|
cs43l22_Pause,
|
|
Jerome Coutant
1:917af0ca86df
|
97
|
cs43l22_Resume,
|
|
Jerome Coutant
1:917af0ca86df
|
98
|
cs43l22_Stop,
|
|
Jerome Coutant
1:917af0ca86df
|
99
|
|
|
Jerome Coutant
1:917af0ca86df
|
100
|
cs43l22_SetFrequency,
|
|
Jerome Coutant
1:917af0ca86df
|
101
|
cs43l22_SetVolume,
|
|
Jerome Coutant
1:917af0ca86df
|
102
|
cs43l22_SetMute,
|
|
Jerome Coutant
1:917af0ca86df
|
103
|
cs43l22_SetOutputMode,
|
|
Jerome Coutant
1:917af0ca86df
|
104
|
cs43l22_Reset,
|
|
Jerome Coutant
1:917af0ca86df
|
105
|
};
|
|
Jerome Coutant
1:917af0ca86df
|
106
|
|
|
Jerome Coutant
1:917af0ca86df
|
107
|
static uint8_t Is_cs43l22_Stop = 1;
|
|
Jerome Coutant
1:917af0ca86df
|
108
|
|
|
Jerome Coutant
1:917af0ca86df
|
109
|
volatile uint8_t OutputDev = 0;
|
|
Jerome Coutant
1:917af0ca86df
|
110
|
|
|
Jerome Coutant
1:917af0ca86df
|
111
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
112
|
* @}
|
|
Jerome Coutant
1:917af0ca86df
|
113
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
114
|
|
|
Jerome Coutant
1:917af0ca86df
|
115
|
/** @defgroup CS43L22_Function_Prototypes
|
|
Jerome Coutant
1:917af0ca86df
|
116
|
* @{
|
|
Jerome Coutant
1:917af0ca86df
|
117
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
118
|
static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value);
|
|
Jerome Coutant
1:917af0ca86df
|
119
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
120
|
* @}
|
|
Jerome Coutant
1:917af0ca86df
|
121
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
122
|
|
|
Jerome Coutant
1:917af0ca86df
|
123
|
/** @defgroup CS43L22_Private_Functions
|
|
Jerome Coutant
1:917af0ca86df
|
124
|
* @{
|
|
Jerome Coutant
1:917af0ca86df
|
125
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
126
|
|
|
Jerome Coutant
1:917af0ca86df
|
127
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
128
|
* @brief Initializes the audio codec and the control interface.
|
|
Jerome Coutant
1:917af0ca86df
|
129
|
* @param DeviceAddr: Device address on communication Bus.
|
|
Jerome Coutant
1:917af0ca86df
|
130
|
* @param OutputDevice: can be OUTPUT_DEVICE_SPEAKER, OUTPUT_DEVICE_HEADPHONE,
|
|
Jerome Coutant
1:917af0ca86df
|
131
|
* OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO .
|
|
Jerome Coutant
1:917af0ca86df
|
132
|
* @param Volume: Initial volume level (from 0 (Mute) to 100 (Max))
|
|
Jerome Coutant
1:917af0ca86df
|
133
|
* @retval 0 if correct communication, else wrong communication
|
|
Jerome Coutant
1:917af0ca86df
|
134
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
135
|
uint32_t cs43l22_Init(uint16_t DeviceAddr, uint16_t OutputDevice, uint8_t Volume, uint32_t AudioFreq)
|
|
Jerome Coutant
1:917af0ca86df
|
136
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
137
|
uint32_t counter = 0;
|
|
Jerome Coutant
1:917af0ca86df
|
138
|
|
|
Jerome Coutant
1:917af0ca86df
|
139
|
/* Initialize the Control interface of the Audio Codec */
|
|
Jerome Coutant
1:917af0ca86df
|
140
|
AUDIO_IO_Init();
|
|
Jerome Coutant
1:917af0ca86df
|
141
|
|
|
Jerome Coutant
1:917af0ca86df
|
142
|
/* Keep Codec powered OFF */
|
|
Jerome Coutant
1:917af0ca86df
|
143
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x01);
|
|
Jerome Coutant
1:917af0ca86df
|
144
|
|
|
Jerome Coutant
1:917af0ca86df
|
145
|
/*Save Output device for mute ON/OFF procedure*/
|
|
Jerome Coutant
1:917af0ca86df
|
146
|
switch (OutputDevice)
|
|
Jerome Coutant
1:917af0ca86df
|
147
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
148
|
case OUTPUT_DEVICE_SPEAKER:
|
|
Jerome Coutant
1:917af0ca86df
|
149
|
OutputDev = 0xFA;
|
|
Jerome Coutant
1:917af0ca86df
|
150
|
break;
|
|
Jerome Coutant
1:917af0ca86df
|
151
|
|
|
Jerome Coutant
1:917af0ca86df
|
152
|
case OUTPUT_DEVICE_HEADPHONE:
|
|
Jerome Coutant
1:917af0ca86df
|
153
|
OutputDev = 0xAF;
|
|
Jerome Coutant
1:917af0ca86df
|
154
|
break;
|
|
Jerome Coutant
1:917af0ca86df
|
155
|
|
|
Jerome Coutant
1:917af0ca86df
|
156
|
case OUTPUT_DEVICE_BOTH:
|
|
Jerome Coutant
1:917af0ca86df
|
157
|
OutputDev = 0xAA;
|
|
Jerome Coutant
1:917af0ca86df
|
158
|
break;
|
|
Jerome Coutant
1:917af0ca86df
|
159
|
|
|
Jerome Coutant
1:917af0ca86df
|
160
|
case OUTPUT_DEVICE_AUTO:
|
|
Jerome Coutant
1:917af0ca86df
|
161
|
OutputDev = 0x05;
|
|
Jerome Coutant
1:917af0ca86df
|
162
|
break;
|
|
Jerome Coutant
1:917af0ca86df
|
163
|
|
|
Jerome Coutant
1:917af0ca86df
|
164
|
default:
|
|
Jerome Coutant
1:917af0ca86df
|
165
|
OutputDev = 0x05;
|
|
Jerome Coutant
1:917af0ca86df
|
166
|
break;
|
|
Jerome Coutant
1:917af0ca86df
|
167
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
168
|
|
|
Jerome Coutant
1:917af0ca86df
|
169
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev);
|
|
Jerome Coutant
1:917af0ca86df
|
170
|
|
|
Jerome Coutant
1:917af0ca86df
|
171
|
/* Clock configuration: Auto detection */
|
|
Jerome Coutant
1:917af0ca86df
|
172
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_CLOCKING_CTL, 0x81);
|
|
Jerome Coutant
1:917af0ca86df
|
173
|
|
|
Jerome Coutant
1:917af0ca86df
|
174
|
/* Set the Slave Mode and the audio Standard */
|
|
Jerome Coutant
1:917af0ca86df
|
175
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_INTERFACE_CTL1, CODEC_STANDARD);
|
|
Jerome Coutant
1:917af0ca86df
|
176
|
|
|
Jerome Coutant
1:917af0ca86df
|
177
|
/* Set the Master volume */
|
|
Jerome Coutant
1:917af0ca86df
|
178
|
counter += cs43l22_SetVolume(DeviceAddr, Volume);
|
|
Jerome Coutant
1:917af0ca86df
|
179
|
|
|
Jerome Coutant
1:917af0ca86df
|
180
|
/* If the Speaker is enabled, set the Mono mode and volume attenuation level */
|
|
Jerome Coutant
1:917af0ca86df
|
181
|
if(OutputDevice != OUTPUT_DEVICE_HEADPHONE)
|
|
Jerome Coutant
1:917af0ca86df
|
182
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
183
|
/* Set the Speaker Mono mode */
|
|
Jerome Coutant
1:917af0ca86df
|
184
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PLAYBACK_CTL2, 0x06);
|
|
Jerome Coutant
1:917af0ca86df
|
185
|
|
|
Jerome Coutant
1:917af0ca86df
|
186
|
/* Set the Speaker attenuation level */
|
|
Jerome Coutant
1:917af0ca86df
|
187
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_SPEAKER_A_VOL, 0x00);
|
|
Jerome Coutant
1:917af0ca86df
|
188
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_SPEAKER_B_VOL, 0x00);
|
|
Jerome Coutant
1:917af0ca86df
|
189
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
190
|
|
|
Jerome Coutant
1:917af0ca86df
|
191
|
/* Additional configuration for the CODEC. These configurations are done to reduce
|
|
Jerome Coutant
1:917af0ca86df
|
192
|
the time needed for the Codec to power off. If these configurations are removed,
|
|
Jerome Coutant
1:917af0ca86df
|
193
|
then a long delay should be added between powering off the Codec and switching
|
|
Jerome Coutant
1:917af0ca86df
|
194
|
off the I2S peripheral MCLK clock (which is the operating clock for Codec).
|
|
Jerome Coutant
1:917af0ca86df
|
195
|
If this delay is not inserted, then the codec will not shut down properly and
|
|
Jerome Coutant
1:917af0ca86df
|
196
|
it results in high noise after shut down. */
|
|
Jerome Coutant
1:917af0ca86df
|
197
|
|
|
Jerome Coutant
1:917af0ca86df
|
198
|
/* Disable the analog soft ramp */
|
|
Jerome Coutant
1:917af0ca86df
|
199
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_ANALOG_ZC_SR_SETT, 0x00);
|
|
Jerome Coutant
1:917af0ca86df
|
200
|
/* Disable the digital soft ramp */
|
|
Jerome Coutant
1:917af0ca86df
|
201
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x04);
|
|
Jerome Coutant
1:917af0ca86df
|
202
|
/* Disable the limiter attack level */
|
|
Jerome Coutant
1:917af0ca86df
|
203
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_LIMIT_CTL1, 0x00);
|
|
Jerome Coutant
1:917af0ca86df
|
204
|
/* Adjust Bass and Treble levels */
|
|
Jerome Coutant
1:917af0ca86df
|
205
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_TONE_CTL, 0x0F);
|
|
Jerome Coutant
1:917af0ca86df
|
206
|
/* Adjust PCM volume level */
|
|
Jerome Coutant
1:917af0ca86df
|
207
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PCMA_VOL, 0x0A);
|
|
Jerome Coutant
1:917af0ca86df
|
208
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_PCMB_VOL, 0x0A);
|
|
Jerome Coutant
1:917af0ca86df
|
209
|
|
|
Jerome Coutant
1:917af0ca86df
|
210
|
/* Return communication control value */
|
|
Jerome Coutant
1:917af0ca86df
|
211
|
return counter;
|
|
Jerome Coutant
1:917af0ca86df
|
212
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
213
|
|
|
Jerome Coutant
1:917af0ca86df
|
214
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
215
|
* @brief Deinitializes the audio codec.
|
|
Jerome Coutant
1:917af0ca86df
|
216
|
* @param None
|
|
Jerome Coutant
1:917af0ca86df
|
217
|
* @retval None
|
|
Jerome Coutant
1:917af0ca86df
|
218
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
219
|
void cs43l22_DeInit(void)
|
|
Jerome Coutant
1:917af0ca86df
|
220
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
221
|
/* Deinitialize Audio Codec interface */
|
|
Jerome Coutant
1:917af0ca86df
|
222
|
AUDIO_IO_DeInit();
|
|
Jerome Coutant
1:917af0ca86df
|
223
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
224
|
|
|
Jerome Coutant
1:917af0ca86df
|
225
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
226
|
* @brief Get the CS43L22 ID.
|
|
Jerome Coutant
1:917af0ca86df
|
227
|
* @param DeviceAddr: Device address on communication Bus.
|
|
Jerome Coutant
1:917af0ca86df
|
228
|
* @retval The CS43L22 ID
|
|
Jerome Coutant
1:917af0ca86df
|
229
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
230
|
uint32_t cs43l22_ReadID(uint16_t DeviceAddr)
|
|
Jerome Coutant
1:917af0ca86df
|
231
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
232
|
uint8_t Value;
|
|
Jerome Coutant
1:917af0ca86df
|
233
|
/* Initialize the Control interface of the Audio Codec */
|
|
Jerome Coutant
1:917af0ca86df
|
234
|
AUDIO_IO_Init();
|
|
Jerome Coutant
1:917af0ca86df
|
235
|
|
|
Jerome Coutant
1:917af0ca86df
|
236
|
Value = AUDIO_IO_Read(DeviceAddr, CS43L22_CHIPID_ADDR);
|
|
Jerome Coutant
1:917af0ca86df
|
237
|
Value = (Value & CS43L22_ID_MASK);
|
|
Jerome Coutant
1:917af0ca86df
|
238
|
|
|
Jerome Coutant
1:917af0ca86df
|
239
|
return((uint32_t) Value);
|
|
Jerome Coutant
1:917af0ca86df
|
240
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
241
|
|
|
Jerome Coutant
1:917af0ca86df
|
242
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
243
|
* @brief Start the audio Codec play feature.
|
|
Jerome Coutant
1:917af0ca86df
|
244
|
* @note For this codec no Play options are required.
|
|
Jerome Coutant
1:917af0ca86df
|
245
|
* @param DeviceAddr: Device address on communication Bus.
|
|
Jerome Coutant
1:917af0ca86df
|
246
|
* @retval 0 if correct communication, else wrong communication
|
|
Jerome Coutant
1:917af0ca86df
|
247
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
248
|
uint32_t cs43l22_Play(uint16_t DeviceAddr, uint16_t* pBuffer, uint16_t Size)
|
|
Jerome Coutant
1:917af0ca86df
|
249
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
250
|
uint32_t counter = 0;
|
|
Jerome Coutant
1:917af0ca86df
|
251
|
|
|
Jerome Coutant
1:917af0ca86df
|
252
|
if(Is_cs43l22_Stop == 1)
|
|
Jerome Coutant
1:917af0ca86df
|
253
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
254
|
/* Enable the digital soft ramp */
|
|
Jerome Coutant
1:917af0ca86df
|
255
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x06);
|
|
Jerome Coutant
1:917af0ca86df
|
256
|
|
|
Jerome Coutant
1:917af0ca86df
|
257
|
/* Enable Output device */
|
|
Jerome Coutant
1:917af0ca86df
|
258
|
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_OFF);
|
|
Jerome Coutant
1:917af0ca86df
|
259
|
|
|
Jerome Coutant
1:917af0ca86df
|
260
|
/* Power on the Codec */
|
|
Jerome Coutant
1:917af0ca86df
|
261
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9E);
|
|
Jerome Coutant
1:917af0ca86df
|
262
|
Is_cs43l22_Stop = 0;
|
|
Jerome Coutant
1:917af0ca86df
|
263
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
264
|
|
|
Jerome Coutant
1:917af0ca86df
|
265
|
/* Return communication control value */
|
|
Jerome Coutant
1:917af0ca86df
|
266
|
return counter;
|
|
Jerome Coutant
1:917af0ca86df
|
267
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
268
|
|
|
Jerome Coutant
1:917af0ca86df
|
269
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
270
|
* @brief Pauses playing on the audio codec.
|
|
Jerome Coutant
1:917af0ca86df
|
271
|
* @param DeviceAddr: Device address on communication Bus.
|
|
Jerome Coutant
1:917af0ca86df
|
272
|
* @retval 0 if correct communication, else wrong communication
|
|
Jerome Coutant
1:917af0ca86df
|
273
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
274
|
uint32_t cs43l22_Pause(uint16_t DeviceAddr)
|
|
Jerome Coutant
1:917af0ca86df
|
275
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
276
|
uint32_t counter = 0;
|
|
Jerome Coutant
1:917af0ca86df
|
277
|
|
|
Jerome Coutant
1:917af0ca86df
|
278
|
/* Pause the audio file playing */
|
|
Jerome Coutant
1:917af0ca86df
|
279
|
/* Mute the output first */
|
|
Jerome Coutant
1:917af0ca86df
|
280
|
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_ON);
|
|
Jerome Coutant
1:917af0ca86df
|
281
|
|
|
Jerome Coutant
1:917af0ca86df
|
282
|
/* Put the Codec in Power save mode */
|
|
Jerome Coutant
1:917af0ca86df
|
283
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x01);
|
|
Jerome Coutant
1:917af0ca86df
|
284
|
|
|
Jerome Coutant
1:917af0ca86df
|
285
|
return counter;
|
|
Jerome Coutant
1:917af0ca86df
|
286
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
287
|
|
|
Jerome Coutant
1:917af0ca86df
|
288
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
289
|
* @brief Resumes playing on the audio codec.
|
|
Jerome Coutant
1:917af0ca86df
|
290
|
* @param DeviceAddr: Device address on communication Bus.
|
|
Jerome Coutant
1:917af0ca86df
|
291
|
* @retval 0 if correct communication, else wrong communication
|
|
Jerome Coutant
1:917af0ca86df
|
292
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
293
|
uint32_t cs43l22_Resume(uint16_t DeviceAddr)
|
|
Jerome Coutant
1:917af0ca86df
|
294
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
295
|
uint32_t counter = 0;
|
|
Jerome Coutant
1:917af0ca86df
|
296
|
volatile uint32_t index = 0x00;
|
|
Jerome Coutant
1:917af0ca86df
|
297
|
/* Resumes the audio file playing */
|
|
Jerome Coutant
1:917af0ca86df
|
298
|
/* Unmute the output first */
|
|
Jerome Coutant
1:917af0ca86df
|
299
|
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_OFF);
|
|
Jerome Coutant
1:917af0ca86df
|
300
|
|
|
Jerome Coutant
1:917af0ca86df
|
301
|
for(index = 0x00; index < 0xFF; index++);
|
|
Jerome Coutant
1:917af0ca86df
|
302
|
|
|
Jerome Coutant
1:917af0ca86df
|
303
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev);
|
|
Jerome Coutant
1:917af0ca86df
|
304
|
|
|
Jerome Coutant
1:917af0ca86df
|
305
|
/* Exit the Power save mode */
|
|
Jerome Coutant
1:917af0ca86df
|
306
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9E);
|
|
Jerome Coutant
1:917af0ca86df
|
307
|
|
|
Jerome Coutant
1:917af0ca86df
|
308
|
return counter;
|
|
Jerome Coutant
1:917af0ca86df
|
309
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
310
|
|
|
Jerome Coutant
1:917af0ca86df
|
311
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
312
|
* @brief Stops audio Codec playing. It powers down the codec.
|
|
Jerome Coutant
1:917af0ca86df
|
313
|
* @param DeviceAddr: Device address on communication Bus.
|
|
Jerome Coutant
1:917af0ca86df
|
314
|
* @param CodecPdwnMode: selects the power down mode.
|
|
Jerome Coutant
1:917af0ca86df
|
315
|
* - CODEC_PDWN_HW: Physically power down the codec. When resuming from this
|
|
Jerome Coutant
1:917af0ca86df
|
316
|
* mode, the codec is set to default configuration
|
|
Jerome Coutant
1:917af0ca86df
|
317
|
* (user should re-Initialize the codec in order to
|
|
Jerome Coutant
1:917af0ca86df
|
318
|
* play again the audio stream).
|
|
Jerome Coutant
1:917af0ca86df
|
319
|
* @retval 0 if correct communication, else wrong communication
|
|
Jerome Coutant
1:917af0ca86df
|
320
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
321
|
uint32_t cs43l22_Stop(uint16_t DeviceAddr, uint32_t CodecPdwnMode)
|
|
Jerome Coutant
1:917af0ca86df
|
322
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
323
|
uint32_t counter = 0;
|
|
Jerome Coutant
1:917af0ca86df
|
324
|
|
|
Jerome Coutant
1:917af0ca86df
|
325
|
/* Mute the output first */
|
|
Jerome Coutant
1:917af0ca86df
|
326
|
counter += cs43l22_SetMute(DeviceAddr, AUDIO_MUTE_ON);
|
|
Jerome Coutant
1:917af0ca86df
|
327
|
|
|
Jerome Coutant
1:917af0ca86df
|
328
|
/* Disable the digital soft ramp */
|
|
Jerome Coutant
1:917af0ca86df
|
329
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MISC_CTL, 0x04);
|
|
Jerome Coutant
1:917af0ca86df
|
330
|
|
|
Jerome Coutant
1:917af0ca86df
|
331
|
/* Power down the DAC and the speaker (PMDAC and PMSPK bits)*/
|
|
Jerome Coutant
1:917af0ca86df
|
332
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL1, 0x9F);
|
|
Jerome Coutant
1:917af0ca86df
|
333
|
|
|
Jerome Coutant
1:917af0ca86df
|
334
|
Is_cs43l22_Stop = 1;
|
|
Jerome Coutant
1:917af0ca86df
|
335
|
return counter;
|
|
Jerome Coutant
1:917af0ca86df
|
336
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
337
|
|
|
Jerome Coutant
1:917af0ca86df
|
338
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
339
|
* @brief Sets higher or lower the codec volume level.
|
|
Jerome Coutant
1:917af0ca86df
|
340
|
* @param DeviceAddr: Device address on communication Bus.
|
|
Jerome Coutant
1:917af0ca86df
|
341
|
* @param Volume: a byte value from 0 to 255 (refer to codec registers
|
|
Jerome Coutant
1:917af0ca86df
|
342
|
* description for more details).
|
|
Jerome Coutant
1:917af0ca86df
|
343
|
* @retval 0 if correct communication, else wrong communication
|
|
Jerome Coutant
1:917af0ca86df
|
344
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
345
|
uint32_t cs43l22_SetVolume(uint16_t DeviceAddr, uint8_t Volume)
|
|
Jerome Coutant
1:917af0ca86df
|
346
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
347
|
uint32_t counter = 0;
|
|
Jerome Coutant
1:917af0ca86df
|
348
|
uint8_t convertedvol = VOLUME_CONVERT(Volume);
|
|
Jerome Coutant
1:917af0ca86df
|
349
|
|
|
Jerome Coutant
1:917af0ca86df
|
350
|
if(Volume > 0xE6)
|
|
Jerome Coutant
1:917af0ca86df
|
351
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
352
|
/* Set the Master volume */
|
|
Jerome Coutant
1:917af0ca86df
|
353
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_A_VOL, convertedvol - 0xE7);
|
|
Jerome Coutant
1:917af0ca86df
|
354
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_B_VOL, convertedvol - 0xE7);
|
|
Jerome Coutant
1:917af0ca86df
|
355
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
356
|
else
|
|
Jerome Coutant
1:917af0ca86df
|
357
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
358
|
/* Set the Master volume */
|
|
Jerome Coutant
1:917af0ca86df
|
359
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_A_VOL, convertedvol + 0x19);
|
|
Jerome Coutant
1:917af0ca86df
|
360
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_MASTER_B_VOL, convertedvol + 0x19);
|
|
Jerome Coutant
1:917af0ca86df
|
361
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
362
|
|
|
Jerome Coutant
1:917af0ca86df
|
363
|
return counter;
|
|
Jerome Coutant
1:917af0ca86df
|
364
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
365
|
|
|
Jerome Coutant
1:917af0ca86df
|
366
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
367
|
* @brief Sets new frequency.
|
|
Jerome Coutant
1:917af0ca86df
|
368
|
* @param DeviceAddr: Device address on communication Bus.
|
|
Jerome Coutant
1:917af0ca86df
|
369
|
* @param AudioFreq: Audio frequency used to play the audio stream.
|
|
Jerome Coutant
1:917af0ca86df
|
370
|
* @retval 0 if correct communication, else wrong communication
|
|
Jerome Coutant
1:917af0ca86df
|
371
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
372
|
uint32_t cs43l22_SetFrequency(uint16_t DeviceAddr, uint32_t AudioFreq)
|
|
Jerome Coutant
1:917af0ca86df
|
373
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
374
|
return 0;
|
|
Jerome Coutant
1:917af0ca86df
|
375
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
376
|
|
|
Jerome Coutant
1:917af0ca86df
|
377
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
378
|
* @brief Enables or disables the mute feature on the audio codec.
|
|
Jerome Coutant
1:917af0ca86df
|
379
|
* @param DeviceAddr: Device address on communication Bus.
|
|
Jerome Coutant
1:917af0ca86df
|
380
|
* @param Cmd: AUDIO_MUTE_ON to enable the mute or AUDIO_MUTE_OFF to disable the
|
|
Jerome Coutant
1:917af0ca86df
|
381
|
* mute mode.
|
|
Jerome Coutant
1:917af0ca86df
|
382
|
* @retval 0 if correct communication, else wrong communication
|
|
Jerome Coutant
1:917af0ca86df
|
383
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
384
|
uint32_t cs43l22_SetMute(uint16_t DeviceAddr, uint32_t Cmd)
|
|
Jerome Coutant
1:917af0ca86df
|
385
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
386
|
uint32_t counter = 0;
|
|
Jerome Coutant
1:917af0ca86df
|
387
|
|
|
Jerome Coutant
1:917af0ca86df
|
388
|
/* Set the Mute mode */
|
|
Jerome Coutant
1:917af0ca86df
|
389
|
if(Cmd == AUDIO_MUTE_ON)
|
|
Jerome Coutant
1:917af0ca86df
|
390
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
391
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xFF);
|
|
Jerome Coutant
1:917af0ca86df
|
392
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_A_VOL, 0x01);
|
|
Jerome Coutant
1:917af0ca86df
|
393
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_B_VOL, 0x01);
|
|
Jerome Coutant
1:917af0ca86df
|
394
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
395
|
else /* AUDIO_MUTE_OFF Disable the Mute */
|
|
Jerome Coutant
1:917af0ca86df
|
396
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
397
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_A_VOL, 0x00);
|
|
Jerome Coutant
1:917af0ca86df
|
398
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_HEADPHONE_B_VOL, 0x00);
|
|
Jerome Coutant
1:917af0ca86df
|
399
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, OutputDev);
|
|
Jerome Coutant
1:917af0ca86df
|
400
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
401
|
return counter;
|
|
Jerome Coutant
1:917af0ca86df
|
402
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
403
|
|
|
Jerome Coutant
1:917af0ca86df
|
404
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
405
|
* @brief Switch dynamically (while audio file is played) the output target
|
|
Jerome Coutant
1:917af0ca86df
|
406
|
* (speaker or headphone).
|
|
Jerome Coutant
1:917af0ca86df
|
407
|
* @note This function modifies a global variable of the audio codec driver: OutputDev.
|
|
Jerome Coutant
1:917af0ca86df
|
408
|
* @param DeviceAddr: Device address on communication Bus.
|
|
Jerome Coutant
1:917af0ca86df
|
409
|
* @param Output: specifies the audio output target: OUTPUT_DEVICE_SPEAKER,
|
|
Jerome Coutant
1:917af0ca86df
|
410
|
* OUTPUT_DEVICE_HEADPHONE, OUTPUT_DEVICE_BOTH or OUTPUT_DEVICE_AUTO
|
|
Jerome Coutant
1:917af0ca86df
|
411
|
* @retval 0 if correct communication, else wrong communication
|
|
Jerome Coutant
1:917af0ca86df
|
412
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
413
|
uint32_t cs43l22_SetOutputMode(uint16_t DeviceAddr, uint8_t Output)
|
|
Jerome Coutant
1:917af0ca86df
|
414
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
415
|
uint32_t counter = 0;
|
|
Jerome Coutant
1:917af0ca86df
|
416
|
|
|
Jerome Coutant
1:917af0ca86df
|
417
|
switch (Output)
|
|
Jerome Coutant
1:917af0ca86df
|
418
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
419
|
case OUTPUT_DEVICE_SPEAKER:
|
|
Jerome Coutant
1:917af0ca86df
|
420
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xFA); /* SPK always ON & HP always OFF */
|
|
Jerome Coutant
1:917af0ca86df
|
421
|
OutputDev = 0xFA;
|
|
Jerome Coutant
1:917af0ca86df
|
422
|
break;
|
|
Jerome Coutant
1:917af0ca86df
|
423
|
|
|
Jerome Coutant
1:917af0ca86df
|
424
|
case OUTPUT_DEVICE_HEADPHONE:
|
|
Jerome Coutant
1:917af0ca86df
|
425
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xAF); /* SPK always OFF & HP always ON */
|
|
Jerome Coutant
1:917af0ca86df
|
426
|
OutputDev = 0xAF;
|
|
Jerome Coutant
1:917af0ca86df
|
427
|
break;
|
|
Jerome Coutant
1:917af0ca86df
|
428
|
|
|
Jerome Coutant
1:917af0ca86df
|
429
|
case OUTPUT_DEVICE_BOTH:
|
|
Jerome Coutant
1:917af0ca86df
|
430
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0xAA); /* SPK always ON & HP always ON */
|
|
Jerome Coutant
1:917af0ca86df
|
431
|
OutputDev = 0xAA;
|
|
Jerome Coutant
1:917af0ca86df
|
432
|
break;
|
|
Jerome Coutant
1:917af0ca86df
|
433
|
|
|
Jerome Coutant
1:917af0ca86df
|
434
|
case OUTPUT_DEVICE_AUTO:
|
|
Jerome Coutant
1:917af0ca86df
|
435
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0x05); /* Detect the HP or the SPK automatically */
|
|
Jerome Coutant
1:917af0ca86df
|
436
|
OutputDev = 0x05;
|
|
Jerome Coutant
1:917af0ca86df
|
437
|
break;
|
|
Jerome Coutant
1:917af0ca86df
|
438
|
|
|
Jerome Coutant
1:917af0ca86df
|
439
|
default:
|
|
Jerome Coutant
1:917af0ca86df
|
440
|
counter += CODEC_IO_Write(DeviceAddr, CS43L22_REG_POWER_CTL2, 0x05); /* Detect the HP or the SPK automatically */
|
|
Jerome Coutant
1:917af0ca86df
|
441
|
OutputDev = 0x05;
|
|
Jerome Coutant
1:917af0ca86df
|
442
|
break;
|
|
Jerome Coutant
1:917af0ca86df
|
443
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
444
|
return counter;
|
|
Jerome Coutant
1:917af0ca86df
|
445
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
446
|
|
|
Jerome Coutant
1:917af0ca86df
|
447
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
448
|
* @brief Resets cs43l22 registers.
|
|
Jerome Coutant
1:917af0ca86df
|
449
|
* @param DeviceAddr: Device address on communication Bus.
|
|
Jerome Coutant
1:917af0ca86df
|
450
|
* @retval 0 if correct communication, else wrong communication
|
|
Jerome Coutant
1:917af0ca86df
|
451
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
452
|
uint32_t cs43l22_Reset(uint16_t DeviceAddr)
|
|
Jerome Coutant
1:917af0ca86df
|
453
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
454
|
return 0;
|
|
Jerome Coutant
1:917af0ca86df
|
455
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
456
|
|
|
Jerome Coutant
1:917af0ca86df
|
457
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
458
|
* @brief Writes/Read a single data.
|
|
Jerome Coutant
1:917af0ca86df
|
459
|
* @param Addr: I2C address
|
|
Jerome Coutant
1:917af0ca86df
|
460
|
* @param Reg: Reg address
|
|
Jerome Coutant
1:917af0ca86df
|
461
|
* @param Value: Data to be written
|
|
Jerome Coutant
1:917af0ca86df
|
462
|
* @retval None
|
|
Jerome Coutant
1:917af0ca86df
|
463
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
464
|
static uint8_t CODEC_IO_Write(uint8_t Addr, uint8_t Reg, uint8_t Value)
|
|
Jerome Coutant
1:917af0ca86df
|
465
|
{
|
|
Jerome Coutant
1:917af0ca86df
|
466
|
uint32_t result = 0;
|
|
Jerome Coutant
1:917af0ca86df
|
467
|
|
|
Jerome Coutant
1:917af0ca86df
|
468
|
AUDIO_IO_Write(Addr, Reg, Value);
|
|
Jerome Coutant
1:917af0ca86df
|
469
|
|
|
Jerome Coutant
1:917af0ca86df
|
470
|
#ifdef VERIFY_WRITTENDATA
|
|
Jerome Coutant
1:917af0ca86df
|
471
|
/* Verify that the data has been correctly written */
|
|
Jerome Coutant
1:917af0ca86df
|
472
|
result = (AUDIO_IO_Read(Addr, Reg) == Value)? 0:1;
|
|
Jerome Coutant
1:917af0ca86df
|
473
|
#endif /* VERIFY_WRITTENDATA */
|
|
Jerome Coutant
1:917af0ca86df
|
474
|
|
|
Jerome Coutant
1:917af0ca86df
|
475
|
return result;
|
|
Jerome Coutant
1:917af0ca86df
|
476
|
}
|
|
Jerome Coutant
1:917af0ca86df
|
477
|
|
|
Jerome Coutant
1:917af0ca86df
|
478
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
479
|
* @}
|
|
Jerome Coutant
1:917af0ca86df
|
480
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
481
|
|
|
Jerome Coutant
1:917af0ca86df
|
482
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
483
|
* @}
|
|
Jerome Coutant
1:917af0ca86df
|
484
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
485
|
|
|
Jerome Coutant
1:917af0ca86df
|
486
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
487
|
* @}
|
|
Jerome Coutant
1:917af0ca86df
|
488
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
489
|
|
|
Jerome Coutant
1:917af0ca86df
|
490
|
/**
|
|
Jerome Coutant
1:917af0ca86df
|
491
|
* @}
|
|
Jerome Coutant
1:917af0ca86df
|
492
|
*/
|
|
Jerome Coutant
1:917af0ca86df
|
493
|
|
|
Jerome Coutant
1:917af0ca86df
|
494
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
|