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